Go to Post Ken Patton rocks my socks off! - Josh Hambright [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #6   Spotlight this post!  
Unread 19-02-2011, 15:20
ArchVince's Avatar
ArchVince ArchVince is offline
Registered User
FRC #1290 (Si Se Puede)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Chandler High School
Posts: 26
ArchVince will become famous soon enough
Re: Dashboard Tutorial fro Java Pls :)

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 overoverflow;
    
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 1DriverStationLCD.kLineLengthy++) over += " ";
        print = new 
String[6];
        for(
int x 0< print.lengthx++) print[x] = " ";
        for(
int x 0< print.lengthx++) for(int y 1DriverStationLCD.kLineLengthy++) print[x] += " ";
    }
    public 
void upd(){
        
int curr 0;
        for(
int x 05x++){
            if(
moniAr[x]!=null){
                
DriverStationLCD.getInstance().println(lines[curr], 1over);
                
DriverStationLCD.getInstance().println(lines[curr], 1moniAr[x].toString());
                
DriverStationLCD.getInstance().updateLCD();
                
curr++;
            }
        }
    }
    public 
boolean stopMonitor(int test){
        
boolean found true;
        if(
moniAr[test] == nullfound false;
        
moniAr[test] = null;
        if(
found)watching--;
        return 
found;
    }
    public 
boolean monitor(Object watchint test){
        if(
watching == lines.length && moniAr[test] == null) return false;
        else{
            if(
moniAr[test] == nullwatching++;
            
moniAr[test] = watch;
            return 
true;
        }
    }
    public 
void output(String out){
        
overflow "";
        if(
out.length()>DriverStationLCD.kLineLength)out.substring(DriverStationLCD.kLineLength);
        for(
int x watching5x++) print[x] = print[x+1];
        print[
5] = out;
        
cls();
        for(
int x watching5x++) DriverStationLCD.getInstance().println(lines[x], 1, print[x]);
        
DriverStationLCD.getInstance().updateLCD();
        if(!
overflow.equals("")) output(overflow);
    }
    public 
void cls(){
        for(
int x watching5x++) DriverStationLCD.getInstance().println(lines[x], 1over);
        
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(woo1);
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.
__________________
PETA wants your help finding Schrödinger.
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi