Ok, so yesterday I was programming a new code for our robot to basically act as a start up menu, in pair with the LCD display. When I came to school today and testes it out it only got to the first brace, any clues to what’s causing this?
Code:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1, gyroscopicSensor, sensorGyro)
#pragma config(Sensor, I2C_1, Encoder1, sensorQuadEncoderOnI2CPort, , AutoAssign)
#pragma config(Motor, port2, ldwMotor, tmotorVex393HighSpeed_MC29, PIDControl, driveLeft, encoderPort, I2C_1)
#pragma config(Motor, port3, rdwMotor, tmotorVex393HighSpeed_MC29, openLoop, driveRight)
#pragma config(Motor, port5, lfwMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, rfwMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port8, intakeMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, intake1Motor, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
void pre_auton()
{
bLCDBacklight = true;
displayLCDString(1, 7, " .");
wait1Msec(750);
displayLCDString(1, 7, " ..");
wait1Msec(750);
displayLCDString(1, 7, "...");
wait1Msec(750);
displayLCDString(1, 7, " 8686K");
displayLCDString(2, 7, " Zeus");
wait1Msec(5000);
clearLCDLine(1);
clearLCDLine(1);
}
int count = 0;
const short leftButton = 1;
const short centerButton = 2;
const short rightButton = 4;
//Wait for Press--------------------------------------------------
void waitForPress()
{
while(nLCDButtons == 0){}
wait1Msec(5);
}
//----------------------------------------------------------------
//Wait for Release------------------------------------------------
void waitForRelease()
{
while(nLCDButtons != 0){}
wait1Msec(5);
{
//Declare count variable to keep track of our choice
//------------- 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, "usercontrol");
displayLCDCenteredString(1, "< select >");
waitForPress();
startTask(usercontrol);
//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, "autonomous");
displayLCDCenteredString(1, "< select >");
waitForPress();
startTask(autonomous);
//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, "programskills");
displayLCDCenteredString(1, "< select >");
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, "battery");
displayLCDCenteredString(1, "< select >");
waitForPress();
startTask(autonomous);
//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;
}
}
}
//----------------------------------------------------------------
}
task autonomous()
{
//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, "usercontrol");
displayLCDCenteredString(1, "is running!");
displayLCDCenteredString(2, "End Task");
startTask(usercontrol);
if(nLCDButtons == centerButton)
{
stopTask(usercontrol);
clearLCDLine(0);
clearLCDLine(1);
clearLCDLine(2);
}
break;
case 1:
//If count = 1, run the code correspoinding with choice 2
displayLCDCenteredString(0, "autonomous");
displayLCDCenteredString(1, "is running!");
displayLCDCenteredString(2, "End Task");
startTask(autonomous);
// Motors on ports 3, 4 & 5 will follow the motor on port 2
slaveMotor(port3, port2);
//Auton testing here
if(nLCDButtons == centerButton)
{
stopTask(autonomous);
clearLCDLine(0);
clearLCDLine(1);
clearLCDLine(2);
}
break;
case 2:
//If count = 2, run the code correspoinding with choice 3
displayLCDCenteredString(0, "programskills");
displayLCDCenteredString(1, "is running!");
displayLCDCenteredString(2, "End Task");
// Motors on ports 3, 4 & 5 will follow the motor on port 2
slaveMotor(port3, port2);
//programmingskills code goes here
if(nLCDButtons == centerButton)
{
stopTask(autonomous);
clearLCDLine(0);
clearLCDLine(1);
clearLCDLine(2);
}
break;
case 3:
//If count = 3, run the code correspoinding with choice 4
displayLCDCenteredString(2, "End Task");
string mainBattery, backupBattery;
while(true) // An infinite loop to keep the program running until you terminate it
{
clearLCDLine(0); // Clear line 1 (0) of the LCD
clearLCDLine(1); // Clear line 2 (1) of the LCD
//Display the Primary Robot battery voltage
displayLCDString(0, 0, "Primary: ");
sprintf(mainBattery, "%1.2f%c", nImmediateBatteryLevel/1000.0,'V'); //Build the value to be displayed
displayNextLCDString(mainBattery);
//Display the Backup battery voltage
displayLCDString(1, 0, "Backup: ");
sprintf(backupBattery, "%1.2f%c", BackupBatteryLevel/1000.0, 'V'); //Build the value to be displayed
displayNextLCDString(backupBattery);
//Short delay for the LCD refresh rate
wait1Msec(100);
if(nLCDButtons == centerButton)
{
stopTask(autonomous);
clearLCDLine(0);
clearLCDLine(1);
clearLCDLine(2);
}
}
break;
default:
displayLCDCenteredString(0, "competition");
displayLCDCenteredString(1, "< selected >");
break;
//------------- End of Robot Movement Code -----------------------
}
AutonomousCodePlaceholderForTesting();
}
task usercontrol()
{
while (true)
{
//////////////////////////////////////////////////
//////////////////////////////////////////////////
motor[ldwMotor] = vexRT[Ch3] / 2;
motor[rdwMotor] = vexRT[Ch2] / 2;
//////////////////////////////////////////////////
//////////////////////////////////////////////////
if(vexRT[Btn6U] == 1)
{
motor[lfwMotor] = 127;
motor[rfwMotor] = -127;
}
else if(vexRT[Btn6D] == 1)
{
motor[lfwMotor] = 0;
motor[rfwMotor] = 0;
}
else
{
motor[lfwMotor] = 127;
motor[rfwMotor] = -127;
}
//////////////////////////////////////////////////
//////////////////////////////////////////////////
if(vexRT[Btn5U] == 1)
{
motor[intakeMotor] = 127;
}
else if(vexRT[Btn5D] == 1)
{
motor[intakeMotor] = -127;
}
else
{
motor[intakeMotor] = 0;
}
UserControlCodePlaceholderForTesting();
}
}