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