|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#4
|
|
|
Re: DS "User Message"
Quote:
You could use multiple lines. [edit] Or, you could use this: Code:
public class DriverStationLCDwWrap {
private static DriverStationLCD lcd = null;
private static DriverStationLCDwWrap LCDw = null;//keep the singleton pattern going
private DriverStationLCD.Line[] lcdLines =
{DriverStationLCD.Line.kMain6, DriverStationLCD.Line.kUser2,
DriverStationLCD.Line.kUser3, DriverStationLCD.Line.kUser4,
DriverStationLCD.Line.kUser5, DriverStationLCD.Line.kUser6};
private DriverStationLCDwWrap()
{
lcd = DriverStationLCD.getInstance();
}
public static DriverStationLCDwWrap getInstance()
{
if(LCDw == null)
LCDw = new DriverStationLCDwWrap();
return LCDw;
}
public void updateLCD()
{
lcd.updateLCD();
}
public void println(String text)
{
int length = text.length();
int lines = length / lcd.kLineLength;
String blank = " "; // 21 spaces, clears the line.
for(int i = 0; i < i < lcdLines.length; i++)
{
lcd.println(lcdLines[i], 1, blank); // Clear the all lines of previous text
}
for(int i = 0; i < (lines + 1) && i < lcdLines.length; i++)
{
int start = lcd.kLineLength*i;
int end = (start+lcd.kLineLength >= length)? length : start+lcd.kLineLength;
lcd.println(lcdLines[i], 1, text.substring(start, end));
}
updateLCD(); // call it since the the string has replaced the entire DS LCD buffer
}
}
For example: println("This is a very long message that will be split into several pieces"); becomes: This is a very long m essage that will be s plit into several pie ces [/edit] Last edited by biojae : 02-08-2010 at 02:11. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "Emergency Stopped" message won't go away | Lakedaimon | General Forum | 25 | 13-08-2012 22:14 |
| "Demo Stamp not found" error message | Gatto | Programming | 1 | 07-02-2007 23:17 |
| "The Power of a Positive Team" Message | Joe Matt | General Forum | 2 | 04-04-2005 09:48 |
| Why would I "subscribe" to a message thread or a forum? | Joe Johnson | CD Forum Support | 4 | 07-06-2001 22:07 |