/****************************************************************************** * RCX transmitter * 20APR04 JRH Finalized Version 1.0 of RCX Communication software.. * Questions can be directed to Joseph Hansen at * (760) 939-6999, or joseph.hansen@navy.mil *******************************************************************************/ #define BUTTON SENSOR_1 #define TIMEOUT 3 #define NUMBER_OF_COMMANDS 20 #define NUMBER_OF_TEAMS 10 int count = 0; int teamId = 0; task teamIdTask () { /* loop forever */ while (1) { /* wait for the first button press */ until (BUTTON == 1) ; /* wait for additional button presses */ ClearTimer (0); PlaySound (SOUND_CLICK); teamId = teamId % NUMBER_OF_TEAMS + 1;; SetUserDisplay (teamId, 0); /* wait for button to be lifted */ until (BUTTON == 0) ; } } /* teamIdTask */ void setTeamId () { int i; /* set the transmit power */ SetTxPower (TX_POWER_HI); /* initialize the button */ SetSensor (BUTTON, SENSOR_TOUCH); /* clean out the team ID */ teamId = 0; /* start counting */ start teamIdTask; /* wait until at least one press, and then a timeout */ until (teamId == 1) ; until (Timer (0) > TIMEOUT) ; /* no more counting */ stop teamIdTask; /* initialize the receiver */ SendMessage (teamId); /* clear the timer */ ClearTimer (0); PlaySound (SOUND_UP); PlaySound (SOUND_DOWN); } /* setTeamId */ task countTask () { /* loop forever */ while (1) { /* wait for the first button press */ until (BUTTON == 1) ; /* wait for additional button presses */ ClearTimer (0); PlaySound (SOUND_CLICK); count = count % NUMBER_OF_COMMANDS + 1; SetUserDisplay (count, 0); /* wait for button to be lifted */ until (BUTTON == 0) ; } } /* countTask */ void sendCmd () { /* clean out the count */ count = 0; /* start counting */ start countTask; /* wait until at least one press, and then a timeout */ until (count == 1) ; until (Timer (0) > TIMEOUT) ; /* no more counting */ stop countTask; /* send the command */ SendMessage (count + (teamId * NUMBER_OF_COMMANDS)); } /* sendCmd */