Quote:
Originally Posted by kamocat
I'm making a CAN startup test, and want to send the results back to the driver. However, I'd rather not make anyone who uses this startup test have to fit this into their dashboard. I only plan to send the message once at the start of Autonomous Enabled.
|
If its your own message, then why can't you make it fit within the length of the box?
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
}
}
(note, this is character wrapping. Your message can and will be chopped off to a new line)
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]