LCD - After making auton selection, display confirmation

I was wondering how to program my LCD Screen so that once I make my selection for autonomous, I receive a confirmation on the screen saying “Auton Selected”. I can’t quite figure out how to do this, and I don’t want to do anything that would mess up my code. Can someone please point me in the right direction? Thanks in advance.


#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1,    gyroscope,      sensorGyro)
#pragma config(Sensor, dgtl1,  skills,         sensorTouch)
#pragma config(Sensor, dgtl2,  auton1,         sensorTouch)
#pragma config(Sensor, dgtl3,  auton2,         sensorTouch)
#pragma config(Sensor, dgtl4,  auton3,         sensorTouch)
#pragma config(Sensor, I2C_1,  MotorLF,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_2,  MotorLB,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_3,  MotorRB,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_4,  MotorRF,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Motor,  port2,           MotorLF,       tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor,  port3,           MotorLB,       tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_4)
#pragma config(Motor,  port4,           RightLift,     tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port5,           LeftLift,      tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port6,           hang,          tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port7,           TopLift,       tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port8,           MotorRB,       tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, I2C_3)
#pragma config(Motor,  port9,           MotorRF,       tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, I2C_2)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#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!
int auton = 0;

//ADD all autonomous choices
void displayAuton(){
	switch(auton){
	case 4:
		displayLCDCenteredString(0, "Skills Auton");
		displayLCDCenteredString(1, "");
		break;
	case 3:
		displayLCDCenteredString(0, "Star Auton");
		displayLCDCenteredString(1, "Left");
		break;
	case 2:
		displayLCDCenteredString(0, "Star Auton");
		displayLCDCenteredString(1, "Right");
		break;
	case 1:
		displayLCDCenteredString(0, "Cube Auton");
		displayLCDCenteredString(1, "Left");
		break;
	case 0:
		displayLCDCenteredString(0, "Cube Auton");
		displayLCDCenteredString(1, "Right");
		break;
	default:
		displayLCDCenteredString(0, "No Auton");
		displayLCDCenteredString(1, "");
		break;
	}
}
//DO NOT MODIFY
task LCDControl()
{
	clearLCDLine(0);
	clearLCDLine(1);
	bool noButtonsPressed = true;
	displayAuton();
	while(true){
		if(noButtonsPressed){ // only update auton if a button is pressed AND wasn't pressed previously
			switch(nLCDButtons){
			case kButtonLeft:
				auton--;
				displayAuton();
				break;
			case kButtonCenter:
				stopTask(LCDControl);
				break;
			case kButtonRight:
				auton++;
				displayAuton();
				break;
			}
		}//if
		noButtonsPressed = !nLCDButtons; //update if there is a button currently pressed
		wait1Msec(20);
	}//while
}//task
////////////////////////////////////////////////////////////////////////////////////
//                          Pre-Autonomous Functions
// You may want to perform some actions before the competition starts. Do them in the
// following function.
////////////////////////////////////////////////////////////////////////////////////
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;
	bDisplayCompetitionStatusOnLcd = false;
	bLCDBacklight = true;// Turn on LCD Backlight
	startTask(LCDControl);
}

*Autonomous and Driver modes are excluded from this snippet of code

What if you use the middle button to confirm, and inside the loop on your task you check for it being pressed. If it is, you display that text on the LCD and end the task?

Yes, but I am not quite sure how to write the if statement as well as where to place it, as I am not that familiar with the LCD. Any help would be appreciated.

EDIT: I think I may have found out how to do it. Does this look right?


if(nLCDButtons == 2)//center button
{
displayLCDCenteredString(0, "Auton Selected");
}

Add it just before the line that says.
stopTask(LCDControl);

No need for an if statement, you are already detecting the center button in the while loop.

Thank you @jpearman
Would this be right then?


#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1,    gyroscope,      sensorGyro)
#pragma config(Sensor, dgtl1,  skills,         sensorTouch)
#pragma config(Sensor, dgtl2,  auton1,         sensorTouch)
#pragma config(Sensor, dgtl3,  auton2,         sensorTouch)
#pragma config(Sensor, dgtl4,  auton3,         sensorTouch)
#pragma config(Sensor, I2C_1,  MotorLF,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_2,  MotorLB,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_3,  MotorRB,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Sensor, I2C_4,  MotorRF,        sensorQuadEncoderOnI2CPort,    , AutoAssign )
#pragma config(Motor,  port2,           MotorLF,       tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_1)
#pragma config(Motor,  port3,           MotorLB,       tmotorVex393HighSpeed_MC29, openLoop, encoderPort, I2C_4)
#pragma config(Motor,  port4,           RightLift,     tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port5,           LeftLift,      tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port6,           hang,          tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor,  port7,           TopLift,       tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor,  port8,           MotorRB,       tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, I2C_3)
#pragma config(Motor,  port9,           MotorRF,       tmotorVex393HighSpeed_MC29, openLoop, reversed, encoderPort, I2C_2)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#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!
int auton = 0;

//ADD all autonomous choices
void displayAuton(){
	switch(auton){
	case 4:
		displayLCDCenteredString(0, "Skills Auton");
		displayLCDCenteredString(1, "");
		break;
	case 3:
		displayLCDCenteredString(0, "Star Auton");
		displayLCDCenteredString(1, "Left");
		break;
	case 2:
		displayLCDCenteredString(0, "Star Auton");
		displayLCDCenteredString(1, "Right");
		break;
	case 1:
		displayLCDCenteredString(0, "Cube Auton");
		displayLCDCenteredString(1, "Left");
		break;
	case 0:
		displayLCDCenteredString(0, "Cube Auton");
		displayLCDCenteredString(1, "Right");
		break;
	default:
		displayLCDCenteredString(0, "No Auton");
		displayLCDCenteredString(1, "");
		break;
	}
}
//DO NOT MODIFY
task LCDControl()
{
	clearLCDLine(0);
	clearLCDLine(1);
	bool noButtonsPressed = true;
	displayAuton();
	while(true){
		if(noButtonsPressed){ // only update auton if a button is pressed AND wasn't pressed previously
			switch(nLCDButtons){
			case kButtonLeft:
				auton--;
				displayAuton();
				break;
			case kButtonCenter:
				displayLCDCenteredString(0, "Auton Selected");
				stopTask(LCDControl);
				break;
			case kButtonRight:
				auton++;
				displayAuton();
				break;
			}
		}//if
		noButtonsPressed = !nLCDButtons; //update if there is a button currently pressed
		wait1Msec(20);
	}//while
}//task
////////////////////////////////////////////////////////////////////////////////////
//                          Pre-Autonomous Functions
// You may want to perform some actions before the competition starts. Do them in the
// following function.
////////////////////////////////////////////////////////////////////////////////////
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;
	bDisplayCompetitionStatusOnLcd = false;
	bLCDBacklight = true;// Turn on LCD Backlight
	startTask(LCDControl);
}

That should work.

Thank you very much!