Auton Selection not working with a field controller but with a comp switch

Recently went to a scrimmage and my auton selection code that works with our comp switch didn’t work. This function is called during perauton. When plugged into a field controller the function does run as it prints. I don’t think that the while loop is ever entered but I haven’t actually checked that yet. Any ideas why this works on a comp switch but not on a field?

  autonSelect selectAuton;
  int selectedAuton = selectAuton.getSelectedAuton();
  int switchAuton = selectedAuton;

  // print once. 
  std::string autonToRun = selectAuton.getAutonToRun();
  Brain.Screen.setCursor(2,1);
  Brain.Screen.print("Curent Selection: ");
  Brain.Screen.print(autonToRun.c_str());
  Controller1.Screen.setCursor(1,1);
  Controller1.Screen.clearScreen();
  Controller1.Screen.print("Curent Selection: ");
  Controller1.Screen.setCursor(2,1);
  Controller1.Screen.print(autonToRun.c_str());

  std::cout << autonToRun;

  while ((!Competition.isEnabled() && Competition.isCompetitionSwitch()) && !confirmAuton) { // while pluged into a comp switch and comp off and confirm not true 
    switchAuton = buttonA.incrementValButton(LimitSwitchA.pressing(), switchAuton);
    confirmAuton = buttonB.toggleButton(LimitSwitchB.pressing(),confirmAuton);
    LimitSwitchB.released(autonConfirm);
 

    if (switchAuton >= 6) { // 6 is the current number of autons in the list rn need to make this more universal. 
      switchAuton = 0; // if it gets to the end of the list loop back to the start
    }

    if (selectedAuton != switchAuton) {
      selectedAuton = selectAuton.setSelectedAuton(switchAuton);

      autonToRun = selectAuton.getAutonToRun();
      Brain.Screen.setCursor(2,1);
      Brain.Screen.clearLine();
      Brain.Screen.print("Curent Selection: ");
      Brain.Screen.print(autonToRun.c_str());
      Controller1.Screen.setCursor(1,1);
      Controller1.Screen.clearScreen();
      Controller1.Screen.print("Curent Selection: ");
      Controller1.Screen.setCursor(2,1);
      Controller1.Screen.print(autonToRun.c_str());
    }
    wait(10,msec);
  }

  Controller1.Screen.setCursor(3,0);
  Controller1.Screen.print(selectedAuton);
  selectedAutonomous = selectedAuton;
  return selectedAuton;
} ```


Thanks

This part only checks for a competition switch. To make it also work with field control, you need to add Competition.isFieldControl() to the while loop’s conditional statement.

2 Likes

(!Competition.isEnabled() && (Competition.isCompetitionSwitch()) || Competition.isFieldControl())

So something like this. For future reference where can I find this info. The api? (I can’t really navigate that api at all)

You should probably group it together with the competition switch using an or. Something like this

(!Competition.isEnabled() && (Competition.isCompetitionSwitch() || Competition.isFieldControl()))

And you can find all of this info on the api. I just typed in competition in the search bar and came to this page. The isFieldControl() method is listed at the bottom of the page.
https://api.vexcode.cloud/v5/class/classvex_1_1competition

2 Likes