I am scratching my head at the pre_auton method. As far as I can tell it is called once at the beginning of main(), and never again. Yet, it seems to be running in the background while usercontrol and autonomous are running. I can tell because graphics I use in the pre_auton stage are still being printed despite the fact they should be cleared from the screen. Help?
I am using Vexcode V5 C++, on the competition template
I believe that it’s because the code for the pre-auton never technically stops. There might not be a bracket or a line that tells it to end, so the screen doesn’t get cleared even though the code is making the robot do a different action, since the screen isn’t directly told to clear. Maybe try to program a different graphic for the screen for the regular user control and autonomous.
pre_auton() is just a standard function that main calls. If the function blocks (ie. has some sort of while(1) loop) then it will never exit, why would it ?
My autonomous selection contains a while(1) loop. I have tried to program it so that it exits when the competition switch is in user control or autonomous mode but I can’t seem to get that to work either.
I am curious if you need to be hooked up to a field switch to detect the status.
@jpearman is Competition utilized when a team uses the controller to simulate timers or does it need to be connected to a field control? Looking at the reference I would assume the latter.
Brain.Screen.clearLine();
// check what method of match control if any is being used
if (Competition.isCompetitionSwitch()) {
// connected to a competition switch
Brain.Screen.print("Connected to a competition switch");
} else if (Competition.isFieldControl()) {
// connected to a field control system
Brain.Screen.print("Connected to a field control system");
} else {
// not connected to any control system
Brain.Screen.print("not connected to a control system");
}
Brain.Screen.setCursor(2, 1);