Quote:
|
Originally Posted by TubaMorg
I was thinking that, too, which will certainly get you out of Initialize(). The only problem with that, though, is that the mode counter increments 1 more, taking you off the program you set. I'm thinking my original sample is the answer, although if you like the %= (which is pretty slick) you could substitute that for my way of counting.
|
Yea...you are probably right on this one, i'll give you that.
But for the sake of argument (and because I like the way Brad's code is layed out more[no offense]), I think this might work...
Code:
// code sample from EasyC (or WPILib)
void Initialize ( void )
{
unsigned char mode = 0;
while ( !IsEnabled() )
{
while ( GetOIDInput(1,1) == 0 && !IsEnabled() )
// wait for the trigger, but only if the field is disabled.
{
}
if ( !IsEnabled() )
{
mode++; // increment mode
}
while ( GetOIDInput(1,1) == 1 ) // wait for trigger release
{
}
mode %= 5 ; // make sure mode < 5
SetUserDisplay ( mode ) ; // put mode in LED for feedback
}
}