Go to Post I always thought a trained bio mechanical monkey wrapped in aluminum foil would be the best robot, but every year my team says "No Pete, go sit down." - BuddyB309 [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

 
Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 19-02-2011, 14:50
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 :)

Quote:
Originally Posted by robotic321 View Post
Ty for your help, maybe i will, but after bagging.
I wrote up a custom object that lets you track variables and output more easily on the lcd in the bottom right. If you'd like, I can post it.
__________________
PETA wants your help finding Schrödinger.
Reply With Quote
  #2   Spotlight this post!  
Unread 19-02-2011, 15:02
robotic321's Avatar
robotic321 robotic321 is offline
Registered User
FRC #1793
 
Join Date: Jan 2010
Location: Norfolk, VA
Posts: 24
robotic321 is an unknown quantity at this point
Re: Dashboard Tutorial fro Java Pls :)

That would be cool, especially since i want to track the state of some switches we have..
__________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=


1793 FTW
=-=-=-=-=-=-=-=-=-=-=-=-=-=
Reply With Quote
  #3   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
  #4   Spotlight this post!  
Unread 21-02-2011, 07:16
java4first java4first is offline
(Java) Programming Mentor
AKA: Stu
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 2011
Location: Goffstown, NH
Posts: 56
java4first is an unknown quantity at this point
Re: Dashboard Tutorial fro Java Pls :)

We started with the approach of using the LCD on the Driver Station by doing something similar, because we thought that was the best we were going to be able to accomplish.

But, if you look at my post to bascially the same question on "Info to Dashboard" started by sand500 (sorry, I don't know how to link here), then you'll see the information you need to get you into the 'real' Dashboard with LabView.

I know lots about Java programming, but our team had zero LabView experience, and we managed to make this work - so I'm sure you can too.

Good luck!
Reply With Quote
Reply


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 10:58.

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