|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
A few syntax type questions
As I am going through the state of my teams code, I have a few questions I wanted to ask.
Also I am using iterativeRobot() 1) When I send a line to the driverstation using driverStationLCD(probably not the right syntax, but you know what I want), It displays the text, but does not update the values ever if they are changed in teleop(). I tried putting myLCD.updateLCD() at the bottom of my teleopPeriodic() function, but when I do netbeans says the myLCD variable is not created, even though I create it earlier where the output lines to the ds are. also to be clear, I have verified that the values are actually changing by using the Netconsole+System.out.println(). 2) We are able to use the Microsoft Kinect to control the robot, and while we don't know if it will be used during competition, it will be a great way to demonstrate the robot. What I have done is split the teleoperated section of the code into two sections using an if statement like this: if (isKinect == 1) { // kinect enabled version of the code goes here } else { //normal code goes here } Right now all of my code is in 1 class file, although I would like to split it up into multiple files, to make it easier to read. it would then theoretically look like this: if (isKinect == 1) { run kinectcode.java; } else{ run normalcode.java; } However I have never worked with multiple files together, and so I am not sure how to do this. 3)right now I have shAUTOFIRE (one of my buttons) written using the .get() function (I believe it's a function), but I only want it run once, not for as long as it's held down. I know that I could do this using a keyboard: public void keyPressed(KeyEvent e) { keyCode = e.getKeyCode(); swith (keyCode) { case KeyEvent.VK_SPACEBAR: //do autofire stuff break; } however, I am at a loss as to what to do with the buttons. I looked at the API documentation and found the whenPressed() method, which seems like It should be similar as to what I do with the keyboard, but I don't know what to do. Thank you for any and all help. |
|
#2
|
|||
|
|||
|
Re: A few syntax type questions
Quote:
2) Java doesn't work quite that way. You can create seperate files for separate classes, and call methods from those classes, but you don't "run" any files except the main one. I would probably either make a new project for the Kinect-enabled version, or leave the code as it is on one java file. If it makes things more managable, move the kinect code into its own method elsewhere in the .java 3) If you mean you want something to run only once per button-press, do something this: Code:
pressed = controller.getRawButton(buttonID);
if(pressed && !alreadyPressed)
doStuffHere()
alreadyPressed = pressed;
Last edited by nickpeq : 02-01-2012 at 09:54 PM. |
|
#3
|
|||
|
|||
|
Re: A few syntax type questions
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|