I need to merge several of my test code projects for my robot into a lcd menu, I want to be able to start a driver control with my battery voltages, and also have it start on that button press(it also needs to work in competition). Any help would be appreciated.
Driver:
#pragma config(Motor, port2, lfwMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, iMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, , tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, rfwMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, rwMotor, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, lwMotor, tmotorVex393_MC29, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include "Vex_Competition_Includes.c" //Main competition background code...do not modify!
/////////////////////////////////////////////////////////////////////////////////////////
//
// Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////
void pre_auton()
{
bLCDBacklight = true;
repeat(5)
{
displayLCDString(1,0,"Loading 8686K");
wait1Msec(500);
displayLCDString(1,0,"Loading 8686K.");
wait1Msec(500);
displayLCDString(1,0,"Loading 8686K..");
wait1Msec(500);
displayLCDString(1,0,"Loading 8686K...");
wait1Msec(500);
clearLCDLine(1);
}
// 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;
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// 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()
{
// .....................................................................................
// Insert user code here.
// .....................................................................................
AutonomousCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
}
/////////////////////////////////////////////////////////////////////////////////////////
//
// User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////
task usercontrol()
{
// User control code here, inside the loop
while (true)
{
bLCDBacklight = true;
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, "Avg: ");
sprintf(backupBattery, "%1.2f%c", nAvgBatteryLevel/1000.0, 'V'); //Build the value to be displayed
displayNextLCDString(backupBattery);
{
//Short delay for the LCD refresh rate
motor[lwMotor] = vexRT[Ch3] / 2;
motor[rwMotor] = vexRT[Ch2] / 2;
if(vexRT[Btn6U] == 1)
{
motor[iMotor] = 127;
}
else if(vexRT[Btn6D] == 1)
{
motor[iMotor] = -127;
}
else
{
motor[iMotor] = 0;
}
if(vexRT[Btn5U] == 1)
{
motor[lfwMotor] = 0;
motor[rfwMotor] = 0;
}
else if(vexRT[Btn5U] == 1)
{
motor[lfwMotor] = 0;
motor[rfwMotor] = 0;
}
else
{
motor[lfwMotor] = 83;
motor[rfwMotor] = 83;
}}
// This is the main execution loop for the user control program. Each time through the loop
// your program should update motor + servo values based on feedback from the joysticks.
// .....................................................................................
// Insert user code here. This is where you use the joystick values to update your motors, etc.
// .....................................................................................
}}}