View Single Post
  #6   Spotlight this post!  
Unread 25-03-2014, 13:09
jwakeman jwakeman is offline
Registered User
FRC #0063 (Red Barons)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: 16510
Posts: 182
jwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nicejwakeman is just really nice
Re: How to change command associated with button

Quote:
Originally Posted by DjScribbles View Post
@jwakeman: your issue appears to be that your alternate condition was causing a new command to be created every iteration
Thanks for taking a look at my code. The second if condition in the actually has a 'not operator' (!) on the throwSwitch1.get() so I don't think I was creating new command every iteration.

Code:
        if(throwSwitch1.get() && oi.current_interface == oi.CONFIG_FIELD_INTERFACE)
        {
            oi.setPitInterface();
        }
        
        if(!throwSwitch1.get() && oi.current_interface == oi.CONFIG_PIT_INTERFACE)
        {
            oi.setFieldInterface();
        }
My code would probably be more readable if I used throwSwitch1.get() == false, throwSwitch1.get() == true. I like your suggestion of switching back and forth between pre-made commands instead of creating new every time I switch. This still leaves the issue of being able to unmap a command, i.e. have a button go from doing something to doing nothing. I suppose you could create a null command which does nothing and switch between that and the do something command.
Reply With Quote