View Single Post
  #1   Spotlight this post!  
Unread 23-02-2013, 11:14
ssong1995 ssong1995 is offline
Registered User
FRC #1403
 
Join Date: Oct 2011
Location: Belle Mead
Posts: 12
ssong1995 is an unknown quantity at this point
Command-Based robot button toggle question

We are having a problem regarding making a toggle method for the button class. In the OI file, we plan to code certain buttons such that the first time its pressed one command would execute, the next time a different command would, and it would alternate between (thus toggling between these two states).

One of the powerpoints we came across described going into the Button source code file and adding a new method, so we wrote a new one that accepts two commands as the parameters and have worked out the logic for the toggle. It doesn't seem to be working, so could someone explain the proper way to code it? Thank you very much.

state is set to false in the beginning, and:

void Button::WhenToggled(Command *command1, Command *command2){

if(state){
WhenActive(command2);
state = false;
} else {
WhenActive(command1);
state = true;
}
}
Reply With Quote