We had the following code to use 2 pots on the OI to set the aunonomous mode.
Basically, we had 6 varieties of Auton (0-5). We had up to 15 steps per auton program (0-15). We could set the max number of steps as well as set the particular program.
The way it works is that your robot has to be not in AUTONOMOUS MODE, DISABLED and the OI has to be in USER MODE.
After that, you either are looking at the codes or you are setting the codes.
For our OI, we had two software disable switches in addition to the disable from the competition port (OIW_Enable_Sw and OIA_Enable_Sw). We used these switches to decide if we were in the “view autonomous” mode or the “set autonomous” mode. If both of these switches are in the “enabled” state, the program is in the “viewing” mode. If one or both switch is disabled, then the program is in the “setting” mode.
One pot sets the program number (OIW_RHW_Pot), the other sets the number of steps (OIA_Extra_Pot).
The display is as follows XXY where XX is the number of steps the particular program will run and Y is the auton program number – I use this format because the number of steps is greater then 10 and the number of auton programs is not AND I need to have the entire number (XXY) be less than 255 or it would not display properly on the 3 digit display on the OI.
It is harder to explain than to use.
Below is the code fragment of where we set the codes we use in autonomous mode to select which program runs and how far it runs.
Finally, we also set these numbers to a safe condition upon reset so that we could simply cancel autonomous mode by simply hitting robot reset.
Joe J.
if (!Enabled && user_display_mode && !autonomous_mode)
{
if (OIW_Enable_Sw == 0 || OIA_Enable_Sw == 0)
{
[indent]if ((OIA_Extra_Pot >> 4) < 16) auton_stop_cnt = OIA_Extra_Pot >> 4 ;
else auton_stop_cnt = 15 ;
if ((OIW_RHW_Pot >> 5) < 6) auton_prog_no = OIW_RHW_Pot >> 5 ;
else auton_prog_no = 5 ;
}
User_Mode_byte = (auton_stop_cnt *10) + auton_prog_no;
[/indent]}