Quote:
|
Originally Posted by TubaMorg
Uh...hate to be a wet blanket, but for others that are looking at this I just thought of another problem with your snippet. Won't the INNER while loops also cause the program to stick in Initialize()? Say the operator sets the auto program he wants then backs away, then the code sits here in:
while ( GetOIDInput(1,1) == 0 ) // wait for the trigger
{
}
Right? The only way to escape to the outside loop is to press the trigger again after the field is enabled (not allowed).
|
Would this work (changes in red)? If I am not mistaken, this will break you out of the inner loop as soon as the field is enabled, eliminating the infinite loop type issue.
Quote:
// 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
{
}
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
}
}
|