We use a selector switch on the OI to choose from 8 different modes (2^3).
Because the OI button states arent gotten until AFTER the initialization, we could not populate our autonomous queueing system with different modes.
I solved that problem by going into main.c (the file you should never have to touch) and after the Process_Data_From_Master_uP(); call, inserting this code below:
Code:
...
Process_Data_From_Master_uP(); /* You edit this in user_routines.c */
if(flag)
{
//printf("AUTO FLAG");
tcr_autonomous_fill_queue();
flag = 0;
}
if(autonomous_mode)
{
...
The variable flag is an int that is declared and initialized to 1 at the start.
The flag = 0; means it will only run once.
I believe the same code could be inserted into Process_Data_From_Master_uP however, I did not try it and cannot verify that it works.
The best implementation of that in my mind would be to have a function called in that if statement that reads which mode it is from OI buttons and stores it into memory. Extern that variable over to user_routines_fast and use it with your current code. A switch statement or if statements?
Our autonomous code is a scripting / queue style so the only thing that ever changes is the list of commands in the queue as governed by tcr_autonomous_fill_queue(), enabling us to never have to touch our user_routines_fast.