Right now my pre-autonomous code is set to allow my team to choose between five different autonomous modes (4 starting tiles and a disabled option). Yet there have been instances where the cortex has restarted mid-game and I can’t control the robot unless someone hits the enter button on the LCD. Is there any way I can make it not do this, or have the robot detect if it is already in driver-mode and circumvent the LCD from keeping it in the Pre-Auton loop?
Here is the current Pre-Auton Code:
void pre_auton()
{
//Clear LCD
clearLCDLine(0);
clearLCDLine(1);
//Loop while center button is not pressed
while(nLCDButtons != centerButton)
{
//Switch case that allows the user to choose from 4 different options
switch(count){
case 0:
//Display first choice
displayLCDCenteredString(0, "Red - Right");
displayLCDCenteredString(1, "< Enter >");
autonmode = 0;
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count = 4;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 1:
//Display second choice
displayLCDCenteredString(0, "Red - Left");
displayLCDCenteredString(1, "< Enter >");
autonmode = 1;
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 2:
//Display third choice
displayLCDCenteredString(0, "Blue - Right");
displayLCDCenteredString(1, "< Enter >");
autonmode = 2;
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 3:
//Display fourth choice
displayLCDCenteredString(0, "Blue - Left");
displayLCDCenteredString(1, "< Enter >");
autonmode = 3;
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 4:
//Display fifth choice
displayLCDCenteredString(0, "No Auton Mode");
displayLCDCenteredString(1, "< Enter >");
autonmode = 4;
waitForPress();
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count = 0;
}
break;
default:
count = 0;
break;
}
}