Quote:
|
Originally Posted by Dave Scheck
I think that would work as long as check_switch_box can see current_command. Depending on where it is defined you may need an extern.
It may be a little cleaner to do it in two steps
Code:
new_cmd = check_switch_box();
switch(new_cmd)
That way you have a chance to sneak in and add debug for the return value of your function.
An even cleaner way to do it would be to get your program number up front and then use pass that in to your function.
Code:
//Outside of autonomous loop....
if(rc_dig_in01==1)
{
g_prog_num = 1;
}
else if(rc_dig_in02==1)
{
g_prog_num = 2;
}
...
//Inside autonomous loop....
//Assuming that the function can see current_command
new_cmd = get_auton_command(g_prog_num);
switch(new_cmd)
{
.....
}
...
// Using unsigned ints for the sake of argument
unsigned int get_auton_command(unsigned int prog_num)
{
unsigned int command = DO_NOTHING;
if(prog_num == 1)
{
command = command_list_prog1[current_command].command
}
else if(prog_num == 2)
{
command = command_list_prog2[current_command].command
}
return command;
}
|
Thanks Dave. The function robot_command() is in robot.c. That is the function that is called from user_routines_fast. Due to that fact, I am putting check_switch_box() in robot.c, so since current_command is a global declared in robot.c, check_switch_box should be able to see it, correct?
Thanks again,