When the OI is switched into autonomous mode it no longer reads input from the joystick ports. All input values get zeroed (127 for analogs) until it is placed back into standard operating mode. What you’ll want to do is read the input value only when the robot is not in auto mode, then evaluate it when the robot is. Otherwise it will always read 127 as the selector input, no matter what position it’s in. Remember that the OI can receive input from the ports when the robot is disabled, which means that you will be able to set the autonomous mode selector at any point before the match begins.
Also, use “extern int newautoselect;” in the header,
and use “int newautoselect = 0;”, outside of any routine,
in one of the files that the header is included in. If you
use “static int newautoselect;” in the header a different
instance of newautoselect is what you will get in each file the
header is included in and desired communication will not occur.
You need to save the value of the OI reading the last cycle before you enter autonomous.
I recommend creating a char to hold the state of the OI input and updating it in Process_Data_From_Master_uP() as long as the autonomous_mode flag is not set.
unsigned char currentauto = 0; //Set outside function to make it global
currentauto = p2_wheel;
// Remainder of function
Then in user_routines_fast you’ll need:
extern unsigned char currentauto;
to access it.
The only thing, I’m not sure if the name of the flag (autonomous_mode) is right, I don’t have code to reference at the moment.
I second that. Also, if you are meaning to do a logical OR, you need to be using a double pipe (i.e ||) not a single (i.e. |). The single pipe represents a bitwise OR, which can give you drastically different results. If you switch over to the AND, make sure that you use a double ampersand (i.e. &&) for the same reason.
You can find more information about bitwise operations here
You have a type miss-match between your extern declarations
and the definitions in user_routines.c You need them to be
consistent. If you put the extern declarations in a common header
file that is also included in user_routines.c the compiler will catch
this sort of error for you.