code icon to switch auton on v5 brain screen

I’ve been trying to code a icon on the screen that lets you cycle through four autonomous codes but I have no idea where to start. If someone can walk me through that would be very helpful. I need a square icon that is the color of the starting tile with the word “front” or “far” written on it depending on which autonomous it is currently. You should be able to press it and it will cycle through all four codes in this order: red far, red front, blue far, blue front. Here is my current code with all four autonomous programs and a driver control.

#include "robot-config.h"

int main(){
    
    pre_auton();

    auton = none
    Competition.autonomous(autonomous);
    Competition.drivercontrol(usercontrol);
}
void::competition

void autonomous(void){
    if(auton == none){
        vex::task::sleep(100);
    }
    if(auton == redfar){
        Catapult.rotateFor(3,rotationUnits::fwd);
        RightDrive.startRotateFor(10,rotationUnits::rev);
        LeftDrive.rotateFor(10,rotationUnits::rev);
        RightDrive.startRotateFor(13,rotationUnits::fwd);
        LeftDrive.rotateFor(13,rotationUnits::fwd);
        RightDrive.startRotateFor(4,rotationUnits::fwd);
        LeftDrive.rotateFor(4,rotationUnits::rev);
        RightDrive.startRotateFor(8,rotationUnits::fwd);
        LeftDrive.rotateFor(8,rotationUnits::fwd);
    }
    if(auton == redfront){
        Catapult.rotateFor(3,rotationUnits::fwd);
        RightDrive.startRotateFor(2,rotationUnits::fwd);
        LeftDrive.rotateFor(2,rotationUnits::rev);
        RightDrive.startRotateFor(8,rotationUnits::fwd);
        LeftDrive.rotateFor(8,rotationUnits::fwd);
        Lift.rotateFor(0.5,rotationUnits::fwd);
        LeftDrive.startRotateFor(4,rotationUnits::fwd);
        RightDrive.rotateFor(4,rotationUnits::rev);
        RightDrive.startRotateFor(4,rotationUnits::fwd);
        LeftDrive.rotateFor(4,rotationUnits::fwd);
        Lift.rotateFor(6,rotationUnits::fwd);
        LeftDrive.startRotateFor(2,rotationUnits::fwd);
        RightDrive.rotateFor(2,rotationUnits::fwd);
        Lift.rotateFor(1,rotationUnits::rev);
        LeftDrive.startRotateFor(2,rotationUnits::rev);
        RightDrive.rotateFor(2,rotationUnits::rev);
    }
    if(auton == bluefar){
        Catapult.rotateFor(3,rotationUnits::fwd);
        RightDrive.startRotateFor(10,rotationUnits::rev);
        LeftDrive.rotateFor(10,rotationUnits::rev);
        RightDrive.startRotateFor(13,rotationUnits::fwd);
        LeftDrive.rotateFor(13,rotationUnits::fwd);
        RightDrive.startRotateFor(4,rotationUnits::fwd);
        LeftDrive.rotateFor(4,rotationUnits::rev);
        RightDrive.startRotateFor(8,rotationUnits::rev);
        LeftDrive.rotateFor(8,rotationUnits::rev);
    }
    if(auton == bluefront){
        Catapult.rotateFor(3,rotationUnits::fwd);
        RightDrive.startRotateFor(2,rotationUnits::rev);
        LeftDrive.rotateFor(2,rotationUnits::fwd);
        RightDrive.startRotateFor(8,rotationUnits::fwd);
        LeftDrive.rotateFor(8,rotationUnits::fwd);
        Lift.rotateFor(0.5,rotationUnits::fwd);
        LeftDrive.startRotateFor(4,rotationUnits::rev);
        RightDrive.rotateFor(4,rotationUnits::fwd);
        Lift.rotateFor(6,rotationUnits::fwd);
        LeftDrive.startRotateFor(2,rotationUnits::fwd);
        RightDrive.rotateFor(2,rotationUnits::fwd);
        Lift.rotateFor(1,rotationUnits::rev);
        LeftDrive.startRotateFor(2,rotationUnits::rev);
        RightDrive.rotateFor(2,rotationUnits::rev);
    }
}

void usercontrol()void{
while (1){
RightDrive.spin(vex::directionType::fwd,Controller1.axis2.value()vex::velocityUnits::pct);
LeftDrive.spin(vex::directionType::fwd,Controller1,axis3.value()vex::velocityUnits::pct);

if(Controller1.ButtonL1.pressing()){
Lift.spin(directionType::fwd,200,vex::velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()){
Lift.spin(vex::directionType::rev,200,vex::velocityUnits::pct);
}
else{
Lift.stop(vex::brakeType::brake);
}
if(Controller1.ButtonUp.pressing()){
Spinner.spin(vex::directionType::fwd,200,vex::velocityUnits::pct);
}
else if(Controller1.ButtonDown.pressing()){
Spinner.spin(vex::directionType::fwd,200,vex::velocityUnits::pct);
}
else{
Spinner.stop(vex::brakeType::brake);
}
if(Controller1.ButtonR1.pressing()){
Catapult.spin(vex::directionType::fwd,200,vex::velocityUnits::pct);
}
else{
Catapult.stop(vex::brakeType::brake);
}
if(Controller1.ButtonX.pressing()){
BallIntake.spin(vex::directionType::fwd,200,vex::velocityUnits::pct);
}
else if(Controller1.ButtonB.pressing()){
BallIntake.spin(vex::directionType::rev,200,vex::velocityUnits::pct);
}
else{
BallIntake.stop(vex::brakeType::brake);
}
vex::task::sleep(20);
}
}

This has some useful info on how to make buttons on the Brain.

i wish it did but I don’t have that. ): “How to code a button on the v5 brain screen that switches autons” is a really long name.

The V5 brain can hold more than 1 code, so you can have 4 separate programs which have the same drive control but different autonomous programs.

@7517H The problem with that is you have to manually propagate changes to your drive code to each of the four programs and redownload four programs if you change the common code. Making buttons on the Brain’s LCD also lets you do things like tell it what team it’s on at the start of a match in addition to selecting autonomous programs. (This matters for things like vision sensors that will be searching for different colors depending on team.)