Go to Post "You have not lived until you have done something for someone who can never repay you." - unknown - rufu5 [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 23-02-2013, 12:36
Fifthparallel Fifthparallel is offline
Registered User
AKA: Sam Chen
FRC #1410
 
Join Date: Dec 2012
Rookie Year: 2011
Location: Denver, CO
Posts: 65
Fifthparallel is an unknown quantity at this point
Re: Command-Based robot button toggle question

Are the two commands related in any way? (i.e., could you use one command for both actions?). If so, you may want to consider refactoring either your subsystem or command code so that you have this functionality.

OR, you could put them all inside a command group with a bool that holds state, and based on that run either of two commands. Just make sure your "state" variable inside of whatever subsystem is actually being toggled back to whatever is needs to be.

Code:
//In the CommandGroup foo, you could either have a state that is toggled from within one of your subsystems,
//ala GetterSetter pattern and use this state to make a decision.

//OI code
JoystickButton *xyz = new JoystickButton(stick1, 11);
xyz->WhenPressed(new foo());

//CommandGroup 'foo' code

subsystemOne.ChangeStateOfFooBar();
if(subsystemOne.GetStateOfFooBar())
{
     AddSequential(new bar());
}
else
{
     AddSequential(new baz());
}
__________________
sudo chmod u+x helloworld.sh
gotta start somewhere.

Last edited by Fifthparallel : 23-02-2013 at 14:11.
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 18:21.

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