Ok, so I am away from my team at the moment but am still tasked with getting some codes for them to test. I have been attempting to create an auton selector code and past versions have had trouble, so before they are able to test it as they are not with a brain right now I wanted to ask for help if anyone can see an obvious error in the code. (Note: I am sorry if the is another topic on this, I didn’t see one that seemed to fit directly to this to use.)
void pre_auton(void) {
vexcodeInit();
int loop = 1;
if(loop == 1){
while(loop == 1) {
Brain.Screen.setFillColor(color::blue);
Brain.Screen.drawRectangle(24,16,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(24,128,96,96);
Brain.Screen.setFillColor(color::cyan);
Brain.Screen.drawRectangle(136,16,96,96);
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::orange);
Brain.Screen.drawRectangle(248,16,96,96);
Brain.Screen.setFillColor(color::purple);
Brain.Screen.drawRectangle(248,128,96,96);
while(true){
if(Brain.Screen.pressing()){
int XPos = Brain.Screen.xPosition();
int YPos = Brain.Screen.yPosition();
if(XPos>24 && XPos<120 && YPos>16 && YPos<112){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (Launcher Spin Forward) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 1;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
if(XPos>24 && XPos<120 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (Laucher Spin in Reverse) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 2;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
if(XPos>136 && XPos<232 && YPos>16 && YPos<112){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (example Auton Name) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 3;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (example Auton Name) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 4;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
if(XPos>248 && XPos<344 && YPos>16 && YPos<112){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (example Auton Name) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 5;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("You Have Selected (example Auton Name) is this the code you would like to run?");
Brain.Screen.setFillColor(color::green);
Brain.Screen.drawRectangle(136,128,96,96);
Brain.Screen.setFillColor(color::red);
Brain.Screen.drawRectangle(248,128,96,96);
while(true) {
if(XPos>136 && XPos<232 && YPos>128 && YPos<224){
Brain.Screen.clearScreen();
Brain.Screen.setCursor(3,4);
Brain.Screen.setFont(vex::fontType::mono60);
Brain.Screen.print("Comleted");
Auton = 6;
}
if(XPos>248 && XPos<344 && YPos>128 && YPos<224){
loop = 2;
}
}
}
wait(1,seconds);
}
}
}
wait(20,msec);
} else{
Brain.Screen.clearScreen();
wait(20,msec);
loop = 1;
}
}
//Auton
void autonomous(void) {
Brain.Screen.clearScreen();
Brain.Screen.drawImageFromFile("Logo.png",0,0);
if(Auton == 1) {
MotorLaunch.spin(forward);
wait(5,sec);
MotorLaunch.stop();
}
if(Auton == 2) {
MotorLaunch.spin(reverse);
wait(5,sec);
MotorLaunch.stop();
}
if(Auton == 3) {
Drivetrain.turnFor(-90,degrees);
Drivetrain.driveFor(forward, 500, mm);
}
if(Auton == 4) {
Drivetrain.driveFor(forward, -500, mm);
}
if(Auton == 5) {
Drivetrain.driveFor(forward, 150, mm);
Drivetrain.turnFor(23, degrees);
Drivetrain.turnFor(720, degrees);
}
if(Auton == 6) {
Drivetrain.driveFor(forward, 150, mm);
Drivetrain.turnFor(-23, degrees);
Drivetrain.turnFor(-720, degrees);
}
}