So I just did a code chooser (thank you sample programs), but it seems that in order for it to actually run, you have to press the button while in autonomous, which is not allowed. I am only using the built-in competition switch for robotC and my cortex with an LCD at the moment, as the robot is at my school, but this will be an issue in competition. This is my code;
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
//---Reset Encoder Values
nMotorEncoder[backLeft] = 0;
nMotorEncoder[backRight] = 0;
//---LCD Code Selector---
while(bIfiRobotDisabled == true) //While the robot is disabled
{
//------------- Beginning of User Interface Code ---------------
//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, "RIGHT CUBE");
displayLCDCenteredString(1, "< ENTER >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count = 3;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count++;
}
break;
case 1:
//Display second choice
displayLCDCenteredString(0, "LEFT CUBE");
displayLCDCenteredString(1, "< ENTER >");
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, "LEFT FENCE");
displayLCDCenteredString(1, "< ENTER >");
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, "RIGHT FENCE");
displayLCDCenteredString(1, "< Enter >");
waitForPress();
//Increment or decrement "count" based on button press
if(nLCDButtons == leftButton)
{
waitForRelease();
count--;
}
else if(nLCDButtons == rightButton)
{
waitForRelease();
count = 0;
}
break;
default:
count = 0;
break;
}
}
//------------- End of User Interface Code ---------------------
}
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task autonomous()
{
//------------- Beginning of Autonomous Code ---------------
//Clear LCD
clearLCDLine(0);
clearLCDLine(1);
//Switch Case that actually runs the user choice
switch(count){
case 0:
//If count = 0, run the code correspoinding with choice 1
displayLCDCenteredString(0, "RIGHT CUBE");
displayLCDCenteredString(1, "3116C");
rightCube();
break;
case 1:
//If count = 1, run the code correspoinding with choice 2
displayLCDCenteredString(0, "LEFT CUBE");
displayLCDCenteredString(1, "3116C");
leftCube();
break;
case 2:
//If count = 2, run the code correspoinding with choice 3
displayLCDCenteredString(0, "LEFT FENCE");
displayLCDCenteredString(1, "3116C");
leftFence();
break;
case 3:
//If count = 3, run the code correspoinding with choice 4
displayLCDCenteredString(0, "RIGHT FENCE");
displayLCDCenteredString(1, "3116C");
rightFence();
break;
default:
displayLCDCenteredString(0, "No valid choice");
displayLCDCenteredString(1, "was made!");
break;
}
//------------- End of Autonomous Code -----------------------
AutonomousCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
}
We have a competition on Saturday so we need this to be done