Go to Post If it were not about winning, it would not be called a competition - but FRC is much more than winning a competition. - JaneYoung [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 Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 28-03-2012, 15:23
Ginto8's Avatar
Ginto8 Ginto8 is offline
Programming Lead
AKA: Joe Doyle
FRC #2729 (Storm)
Team Role: Programmer
 
Join Date: Oct 2010
Rookie Year: 2010
Location: Marlton, NJ
Posts: 174
Ginto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of lightGinto8 is a glorious beacon of light
Re: Help !!!!

Both toggle and cycle buttons are based on a button "press" instead of just being held down. To detect when a button is pressed:
Code:
// outside the "checking" loop
boolean prevState = false;

// inside checking loop; can be within continuous or periodic
boolean currentState = joy.getRawButton(DESIRED_BUTTON);
if(currentState && !prevState) {
    // Button DESIRED_BUTTON is newly pressed
    // Do stuff here
}
prevState = currentState;
To do a toggle, have an extra boolean (e.g. tracking), then when the button is pressed:
Code:
tracking = !tracking;
To do a cycle, have an int (e.g. basketChoice) and do this on button pressed:
Code:
basketChoice = (basketChoice+1)%NUM_CHOICES;
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 10:05.

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