IterativeRobot will call the DisabledContinuous and DisabledPeriodic functions whenever the robot is in a disabled state, regardless whether it is in Autonomous or Teleop. The others are called only when the robot is Enabled. You should read your switches in one of the Disabled routines, as they will not be available to read in Autonomous/Enabled.
Our robot has a six position switch on a DriverStation analog input, configured to read out 0V, 1V, 2V, 3V, 4V or 5V. I think this will work, can’t test it until the regional:
static int auto_v = 0;
static int autonomousmode = 0;
void DisabledPeriodic(void) {
int auto_v_now;
auto_v_now = ((int)((m_ds->GetAnalogIn(1))+0.5)) + 1;
if(auto_v_now == auto_v)
{
autonomousmode = auto_v; // only shift when equal (stable voltage)
}
auto_v = auto_v_now; // always update current state
}
I know that GetAnalogIn() does not return a “float” voltage like GetVoltage() does, so auto_v_now will need scaling. The robot will use autonomousmode to select one of six modes during the autonomous period.
Yes. It’s a single (12 way?) rotary switch and we’re using 6 positions. Originally the switch was wired to six digital inputs but we later needed those for other functions and reworked the switch to read out 6 different analog voltages. It will be tested tomorrow at Rochester NY. I’ve read here that on the last pass through the Disabled code it can report bad data on the DriverStation inputs, hence the slightly more complicated code.