What our team is trying to do this year is to select our Autonomous mode by using the joystick buttons or some other type of button mounted on our control box. While searching Chief Delphi forums for possible solutions we have stumbled upon this code:
Quote:
It's written by Kevin Watson. We used a slightly modified version of it.
Quote:
void auton_selector(void)
{
static char last_sw1;
static char last_sw2;
if(AUTON_UP == 1 && AUTON_UP != last_sw1)
{
if(auton_select < MAXAUTONROUTINES)
auton_select++;
else
auton_select=99;
}
if(AUTON_DN == 1 && AUTON_DN != last_sw2 && auton_select > 0)
{
if (auton_select == 94)
auton_select=MAXAUTONROUTINES;
else
auton_select--;
}
last_sw1 = AUTON_UP; //oneshot the trigger and top buttons
last_sw2 = AUTON_DN;
User_Mode_Byte = auton_select;
}
User_Mode_Byte is the user display on the OI. Use that little button to change to it.
AUTON_UP/DOWN are the defines to which a joystick button or something similar.
|
Now we are stumped as we are unable to make this code work for us. First of all we are unsure in which of the program files should we put this function into. Second of all when we tried simply pasting this code into our user_routines.c or user_routines_fast.c functions the compiler came out with a bunch of errors. Can anyone take a look and maybe guide us to a solution if possible. Thanks in advance!