PHP Code:
package edu.wpi.first.wpilibj.defaultCode;
import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.DriverStationLCD.Line;
/**
* Let me know if you use this code! I'd like to hear
* whether it worked or not, and that there are teams that use it.
* @author ArchVince
* team 1290
*/
public class SimpleLCD {
String print[];
String over, overflow;
Object moniAr[];
Line lines[];
int watching;
public SimpleLCD(){
watching = 0;
moniAr = new Object[6];
lines = new Line[6];
lines[0] = Line.kMain6;
lines[1] = Line.kUser2;
lines[2] = Line.kUser3;
lines[3] = Line.kUser4;
lines[4] = Line.kUser5;
lines[5] = Line.kUser6;
over = " ";
for(int y = 1; y < DriverStationLCD.kLineLength; y++) over += " ";
print = new String[6];
for(int x = 0; x < print.length; x++) print[x] = " ";
for(int x = 0; x < print.length; x++) for(int y = 1; y < DriverStationLCD.kLineLength; y++) print[x] += " ";
}
public void upd(){
int curr = 0;
for(int x = 0; x < 5; x++){
if(moniAr[x]!=null){
DriverStationLCD.getInstance().println(lines[curr], 1, over);
DriverStationLCD.getInstance().println(lines[curr], 1, moniAr[x].toString());
DriverStationLCD.getInstance().updateLCD();
curr++;
}
}
}
public boolean stopMonitor(int test){
boolean found = true;
if(moniAr[test] == null) found = false;
moniAr[test] = null;
if(found)watching--;
return found;
}
public boolean monitor(Object watch, int test){
if(watching == lines.length && moniAr[test] == null) return false;
else{
if(moniAr[test] == null) watching++;
moniAr[test] = watch;
return true;
}
}
public void output(String out){
overflow = "";
if(out.length()>DriverStationLCD.kLineLength)out.substring(DriverStationLCD.kLineLength);
for(int x = watching; x < 5; x++) print[x] = print[x+1];
print[5] = out;
cls();
for(int x = watching; x < 5; x++) DriverStationLCD.getInstance().println(lines[x], 1, print[x]);
DriverStationLCD.getInstance().updateLCD();
if(!overflow.equals("")) output(overflow);
}
public void cls(){
for(int x = watching; x < 5; x++) DriverStationLCD.getInstance().println(lines[x], 1, over);
DriverStationLCD.getInstance().updateLCD();
}
}
That's SimpleLCD.java.
I don't have any documentation for it, but I'll summarize how to use it. Make a simpleLcd object with:
PHP Code:
SimpleLCD lcd = new SimpleLCD();
lcd.output is a method that takes in a string and prints it to the screen. It should automagically wrap it handle which line ot put it on; if you have any problems PM me.
To monitor a variable:
lcd.monitor needs two arguments. First is the variable itself. It needs to be in object format, but it should be able to automatically do get the object from a string or the like. You may need to wrap primitive data types, such as ints. The second is the number. If it's the first one, just pass 1. Second, pass 2, etc.TO do so:
PHP Code:
String woo = "yay";
//Put these next lines inside a function that is called repeatedly. In our case, we have inside teleopPeriodic()
lcd.monitor(woo, 1);
lcd.upd();
lcd.upd() MUST be called at the end of the periodic loop for it to work. I'm not to great at explaining how to use it, so please ask questions. Oh, and you can call lcd.cls() to clear the lcd screen.