Quote:
|
Originally Posted by Alan Anderson
Oh, my. There's certainly something odd going on:
Code:
case DR_BOTH_CENTER:
{
Navigator_State = AT_TARGET; // Both servos are within the target threshold
printf("AT_TARGET\n");
break;
}
}
}
else
{
// We are not locked on - Stop
// give the trackers a chance to catch up
left_drive_set = LSTOP;
right_drive_set = RSTOP;
drive_timer++ ;
if (drive_timer > LOST_TARGET_TIMEOUT)
{
Navigator_State = TURN_TO_TARGET;
printf("TURN_TO_TARGET\n"); // Done driving to center
left_servo_set = 127;
right_servo_set = 127;
}
}
break;
}
There are three }s in a row right before a naked else statement. This source code is apparently missing a few lines, including an if.
There is also a case statement commented out near the top of the big switch. That can't be doing what you want, can it? If you want to "skip" that state, as the comments suggest, I think you need to initialize your state variable to DRIVE_TO_CENTER instead of WAIT_TO_DRIVE in line 37.
|
I believe the three braces are OK. If you move your cursor in turn to each of those braces and type Ctrl-M, the editor will take you to their matching opening braces. They look fine to me.
As to the commented out case label, THAT does look strange, but I highly doubt that would cause the compile error in question. I don't know what the compiler will do with a chunk of code inside a switch statement without a case label. My guess is that it will simply be unreachable.