I would suggest making a two dimentional array.
Code:
Example commands.h file:
#define AUTO_MODE 1
struct commands command_list[][] =
{
{Set 0 of autonomous commands;}
},
{
{set 1 of autonomous commands;}
},
{
{set 2 of autonomous commands;}
}
Code:
Example robot.c code:
switch (command_list[AUTO_MODE][current_command].command)
{
case NULL:
{
rc = 0; // We don't want to increment to the next command
break;
}
case CMD_SHOW_STATE:
{
rc = cmd_show_state();
break;
}
...so on and so forth
Anyways, this allows for multiple programs that change with one macro definition. If you're worried about space, just have multiple codes in you commands.h file, and comment them all out except for the one you want.
This array decliration can also be used if you have multiple programs and want to change between them with a switch on the robot without recompiling and downloading. Just replace the macro definition with the input source.
-Tony K