View Single Post
  #4   Spotlight this post!  
Unread 01-08-2010, 23:42
biojae's Avatar
biojae biojae is offline
Likes Omni drives :)
AKA: Justin Stocking
FTC #5011 (BOT SQUAD) && FTC#72(Garage bots)&& FRC#0399 (Eagle Robotics)
Team Role: College Student
 
Join Date: Oct 2008
Rookie Year: 2008
Location: Lancaster
Posts: 276
biojae is a jewel in the roughbiojae is a jewel in the roughbiojae is a jewel in the rough
Re: DS "User Message"

Quote:
Originally Posted by kamocat View Post
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]
__________________
FTC Team 72 - No site
FRC Team 399 - http://www.team399.org
2010 Rockwell Collins Innovation in Control Award - (Use of the CAN bus, among other reasons) Phoenix, Arizona!

Last edited by biojae : 02-08-2010 at 02:11.