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:
Code:
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.