View Single Post
  #6   Spotlight this post!  
Unread 27-03-2013, 16:05
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: HELP - Dashboard Digital Inputs to Select Autonomous Modes

Quote:
Originally Posted by apm4242 View Post
Because more than one switch can be activated at a time, do I have to code something that will prevent selecting two autonomous modes simultaneously? If so, what would that look like?
There isn't any way for you to prevent more than one virtual digital input from being active at the same time. If you wish to use individual inputs to activate specific autonomous modes, you'll have to decide how to make one take precedence over others.

You could turn the boolean array into a number from 0-255 and make the cases something like (128..255), (64..127), (32..63), (16..31), (8..15), (4..7), (2..3), (1), and (0, Default). That will give you eight different modes to choose from, with the leftmost selected one having priority if multiple inputs are on. The Default case will be selected if none of the inputs are turned on, so you can leave it empty and have it be a "do nothing" mode.

If that sounds like a lot of work for the programmer, you could use a binary-coded number to select among modes, though that's not especially friendly for the person choosing it. Or you could use one of the virtual analog inputs, and make certain ranges of values choose certain modes.

Quote:
Also, is it possible to place a flat sequence structure inside a case block?
It's not only possible, it's probably the most common way teams implement multiple autonomous modes.
Reply With Quote