View Single Post
  #2   Spotlight this post!  
Unread 03-02-2014, 13:14
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,715
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Toggle When Pressed Option

Quote:
Originally Posted by vandle879 View Post
First year doing Java and I don't have a robot yet to test on so I was wondering about the toggleWhenPressed option.

Does it simply just switch between the execute and end in whatever command its mapped to each time the same button is pressed?

Ex. Is this the correct usage?

OI

joystickButton1.toggleWhenPressed(new FireSolenoid());


FireSolenoid

...
protected void execute() {
Robot.shooter.pistonUp();
}
...
protected void end() {
Robot.shooter.pistonDown();
}



Will this just switch between pistonUp and pistonDown each time I press button 1?
I'm assuming it doesn't use the end() but the interrupted() method. The whileHeld() method cancels the command that was running, so I'd assume the toggle would do the same thing.

Do you at least have a crio you could plug into and run the code. If you do you could put print statements into those methods to verify that they are being called the way you think they are.
Reply With Quote