View Single Post
  #2   Spotlight this post!  
Unread 02-02-2012, 00:37
davidthefat davidthefat is offline
Alumni
AKA: David Yoon
FRC #0589 (Falkons)
Team Role: Alumni
 
Join Date: Jan 2011
Rookie Year: 2010
Location: California
Posts: 792
davidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud ofdavidthefat has much to be proud of
Re: A few syntax type questions

Quote:
Originally Posted by nickpeq View Post
1) I would probably have to see the involved code. You might simply have a scope issue.

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;
Of course, you should initialize alreadyPressed in robotInit() and make pressed and alreadyPressed global variables.
Also, if you want this to be used more than once, I suggest adding a timer to have a "buffer zone" between clicks. Since the crio is running fast, you probably will trigger it more than once and end up with the same state you started with (yes, I've run into this problem). Just check if the time since the last click has exceeded before changing the pressed state.
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
Reply With Quote