Trying to make a Simple Auton Selector

I’m trying to make an auton selector using the program to make the buttons and the titles. Do you guys have any solutions how I can get the strings to be accessed in the other file and any other suggestions on how I can make an auton selector for the brain.

Code is below

Autons.cpp

char auton[] = " ";
//---------------------------------------------------------------------------//
//                                Neutral Goal                               //
void n(){
  
  sixDrive.driveFor(forward, 10, inches);
  wait(1, seconds);
  sixDrive.driveFor(reverse, 10, inches);
}

//---------------------------------------------------------------------------//
//                              Left Side Options                            //
void lw(){
  auton =+ "Left WP";
  sixDrive.driveFor(forward, 10, inches);
  wait(1, seconds);
  sixDrive.driveFor(reverse, 10, inches);
}

void lc(){
  auton =+ "Left C";
  n();
}

//---------------------------------------------------------------------------//
//                              Right Side Options                            //
void rw(){
  auton =+ "Right WP";
  sixDrive.driveFor(forward, 10, inches);
  wait(1, seconds);
  sixDrive.driveFor(reverse, 10, inches);
}

void rc(){
  auton =+ "Right C";
  n();
}

GUI.cpp

int x = Brain.Screen.xPosition(); // get the x position of last touch of the screen
int y = Brain.Screen.yPosition(); // get the y position of last touch of the screen

int bvx = 0; // Button Variable X & Y will be used for the buttons so every time that 
int bvy = 0; // the program draws a new button the X & Y values will be increased 

int bvx1 = 0; // Button Variable X & Y will be used for the buttons so every time that 
int bvy1 = 0; // the program draws a new button the X & Y values will be increased written a second time

//---------------------------------------------------------------------------//
//          * IMPORTANT * THE BRAIN RANGES ARE 480 x 272 PIXELS *            //
//---------------------------------------------------------------------------//


void drawButton(){
  Brain.Screen.printAt(0,0,"0");
  Brain.Screen.setFillColor( "#5dbede" );
  Brain.Screen.drawRectangle(bvx, bvy, 50, 50);
  wait(10, msec);
  Brain.Screen.printAt(0,0, " %d ", bvx);
}

void drawGUI() {
  bool lauton = false;
  bool rauton = false;
  Brain.Screen.printAt(190, 20, "Select Side"); // title for selecting the auton
  //Brain.Screen.printAt(1, 200, "Auton Selected =  %d   ", leftAutonSelect);
  
  //First Prints the Buttons for choosing the side
  
  bvx = 100; // changes the x
  bvy = 100; // and y for the position of the button
  
  drawButton();
  wait(10, msec);
  // change
  bvx1 = 280;
  bvy1 = 100;
  drawButton();
  wait(10, msec);
  
  if (x >= bvx && x <= bvx + 50 && y >= bvy && y <= bvy + 50){ // Checking to see where the brain screen was pressed
    lauton = true;
  }

  if (x >= bvx1 && x <= bvx1 + 50 && y >= bvy1 && y <= bvy1 + 50){
    rauton = true;
  }


  while(lauton == true){
   rauton = false;
   
  }
  
  while(rauton == true){
   lauton = false;
   drawButton();
   wait(10, msec);
  }

}
2 Likes

From turning point season, it imports into VEXcode project

there are others.

2 Likes

I remember reading that one team used a potentiometer as a manual dial. When the axle was rotated to one side, the program would carry out one string of code, and a different string for the opposite position. A locking mechanism for the axle could be created, and an indicator of what value could be printed on the screen to show which routine will be run.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.