Is it possible to program custom control schemes in robotC? For example, we have two drivers and both of them prefer to have a different button layout. Could you use the LCD to switch between the two?
It is possible.
You can use the LCD (or something simpler like a jumper in a digital port) that will select between two or more different control schemes. Here is a simple example.
#pragma config(Sensor, dgtl1, jumper, sensorDigitalIn)
#pragma config(Motor, port1, motorL, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port10, motorR, tmotorVex393HighSpeed_HBridge, openLoop, reversed)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
// Simple example to use a jumper in digital port1
// to select between left and right joystick controlling
// the robot drive.
task main()
{
int controlScheme = 0;
int forward, turn;
// Switch to alternate control if the jumper is installed
if( SensorValue jumper ] == 0 )
controlScheme = 1;
while(1) {
// Use different joysticks depending on the
// selected control scheme.
if( controlScheme == 1 ){
forward = vexRT Ch3 ];
turn = vexRT Ch4 ];
}
else {
forward = vexRT Ch2 ];
turn = vexRT Ch1 ];
}
// Limit when stick is near center
if( abs(forward) < 10 ) forward = 0;
if( abs(turn) < 10 ) turn = 0;
// Set motors, arcade drive
motor motorL ] = forward + turn;
motor motorR ] = forward - turn;
// Don't hog the cpu :)
wait1Msec(25);
}
}