Pre-Auton Programming

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();
}
}

I am confused, you start task autonomous multiple times, then task autonomous starts user control, this means that you will have 3 things running, 2 of which are trying to use the LCD screen, this may be the source of the problems

also the last curly brace in the wait for release function is backwards, ill keep looking to see if I find more errors

also you have the “useControlCodePlaceholderForTesting();”
still in your code even though you have your own code, this should be removed

Here is some code, a main structure for a program. It includes the LCD code chooser.

// motor and sensor deff. are here

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(105)

#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!

const short leftButton = 1;
const short centerButton = 2;
const short rightButton = 4;

static int count = 0; // declare count variable to keep track of our choice

//Wait for Press--------------------------------------------------
void waitForPress()
{
	while(nLCDButtons == 0){}
	wait1Msec(5);
}
//----------------------------------------------------------------

//Wait for Release------------------------------------------------
void waitForRelease()
{
	while(nLCDButtons != 0){}
	wait1Msec(5);
}
//----------------------------------------------------------------

void WaitForPressAndRelease (int value = -1) {
	waitForPress();
	if(nLCDButtons == leftButton) {
		waitForRelease();
		if (value > 0) {
			count = value;
		}
		else {
			count--;
		}
	}
	else if(nLCDButtons == rightButton) {
		waitForRelease();
		if (value == 0) {
			count = 0;
		}
		else {
			count++;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                          Pre-Autonomous Functions
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
	bStopTasksBetweenModes = true;

	bLCDBacklight = true; // Turn on LCD Backlight

	// check if the robot is disabled or enabled
	if (nVexRCReceiveState & vrDisabled) {
		// Disabled
	}
	else {
		// Enabled
		return; // skip LCD selection
	}

	// Display the battery level
	string batteryString;
	sprintf(batteryString, "M: %1.2f B: %1.2f", (float)nImmediateBatteryLevel/1000.0, (float)BackupBatteryLevel/1000.0);
	displayLCDCenteredString(0, batteryString);

	// Code Chooser
	while(nLCDButtons != centerButton) {
		switch(count){

		case 0:
			displayLCDCenteredString(1, "<   Open 1  >");
			WaitForPressAndRelease(3); // go forward to 3 if left is pressed
			break;

		case 1:
			displayLCDCenteredString(1, "<  Open 2  >");
			WaitForPressAndRelease();
			break;

		case 2:
			displayLCDCenteredString(1, "< Open 3 >");
			WaitForPressAndRelease();
			break;

		case 3:
			displayLCDCenteredString(1, "< Open 4 >");
			WaitForPressAndRelease();
			break;

		case 4:
			displayLCDCenteredString(1, "<     Test     >");
			WaitForPressAndRelease(0); // go back to zero if right is pressed
			break;
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 Autonomous Tasks
//
/////////////////////////////////////////////////////////////////////////////////////////

void Open1 () // autonomus codes are in these slots
{

}

void Open2 ()
{

}

void Open3 ()
{

}
void Test ()
{

}

task autonomous()
{
	bLCDBacklight = true; // Turn on LCD Backlight
	displayLCDCenteredString(0, "Autonomous");
	switch(count){
	case 0:
		// No Autonomous
		displayLCDCenteredString(1, "No Autonomous");
		break;
	case 1:
		// Either Middle Zone
		displayLCDCenteredString(1, "Open 1");
		Open1();
		break;
	case 2:
		// Red Hanging Zone
		displayLCDCenteredString(1, "Open 2");
		Open2();
		break;
	case 3:
		// Blue Hanging Zone
		displayLCDCenteredString(1, "Open 3");
		Open3();
		break;
	case 4:
		// test
		displayLCDCenteredString(1, "Test");
		Test();
		break;
	}
}
/////////////////////////////////////////////////////////////////////////////////////////
//
//                             Coviniance Functions
//
/////////////////////////////////////////////////////////////////////////////////////////
void function1 ()
{

}
void function2 ()
{

}
void function3 ()
{

}
/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 User Control Task
//
/////////////////////////////////////////////////////////////////////////////////////////

task usercontrol()
{
	bLCDBacklight = true; // turn on LCD backlight
	while (true)
	{
		// driver control loops here
		wait1Msec(25);
	}
}

If you have any questions just ask.

There are many problems, it’s hard to know where to start. Here are a couple of things to sort first.

  1. The LCD only has two lines, all the calls to, for example, clearLCDLine(2) will cause problems.
  2. You should not be starting the autonomous or usercontrol tasks, let the competition template do that.

Then there are a bunch of syntax errors, fix this first.

//Wait for Release------------------------------------------------
void waitForRelease()
{
	while(nLCDButtons != 0){}
	wait1Msec(5);
{

Yeah, fix that one up and it should be good. I used one kind of like that last year, it worked great.