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