View Single Post
  #10   Spotlight this post!  
Unread 24-02-2014, 15:13
apalrd's Avatar
apalrd apalrd is offline
More Torque!
AKA: Andrew Palardy (Most people call me Palardy)
VRC #3333
Team Role: College Student
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Auburn Hills, MI
Posts: 1,347
apalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond reputeapalrd has a reputation beyond repute
Re: BCD switch programming

Quote:
Originally Posted by Sparkyshires View Post
Thats really neat! I'd never used enums before, I might use them next year The thing is that I would have used int's, but on the robot this year, almost every mechanism has boolean values, as we're using a fair amount of pneumatics. What it would have been helpful for is the shooter, as we're forced to put that in two variables, one for cocked and ready to shoot, and one for whether or not you have a ball.
Enums are awesome.

I have only used them in C and LV, I don't know about implementation other languages like Java. In both C and LV, they are represented as uint's, so you can do integer math and table lookups using it as well (e.g. we frequently have an array of setpoints, which we index by the state).

In the 'real world', I've seen people implement things with registers full of boolean bits, e.g. one program had things like GENFGA, GENFGB, GENFGC (gen flags A,B,C..Z and 1..9), each an 8 bit register full of bits relating to stuff, and the software is very bit-flag centric. IMHO, a numerical state machine is easier to understand.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor

"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack