View Single Post
  #7   Spotlight this post!  
Unread 20-01-2005, 01:28
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Re: Multiple command_lists

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
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year