Quote:
Originally Posted by Sparkyshires
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.