HELM
PSEUDO-CODE
STATE-BY-STATE
WAIT_FOR_iBUTTON:
Turn off all Status LEDs
Check for iButton
If No iButton return to WAIT_FOR_iBUTTON
If Yes read and go to BROADCAST_iBUTTON
*If
BROADCAST_iBUTTON
Turn on iBUTTON Read LED
Display Team association from last bit of iButton
Broadcast iBUTTON number
Cycle until response (MATCHED) received
Save received from address
Display Boat Number being controlled
*If
*If HARD_RESET received, return to WAIT_FOR_iBUTTON
WAIT_FOR_START_GAME
Turn on iBUTTON Matched LED
*If
Send NO_ACTION every .2 sec
If START_GAME command received, send ACK, go to PLAY_GAME
*If HARD_RESET received, return to WAIT_FOR_iBUTTON
PLAY_GAME
Turn on Playing Game LED
*If
*If HARD_RESET received, return to WAIT_FOR_iBUTTON
Read sensors and send commands every .2 sec
*If BLUE_GOAL received, change LEDs to show blue
*If RED_GOAL received, change LEDs to show red
*If END_GAME received, go to GAME_OVER
*If STAND_DOWN_RECEIVED from WC, go to STANDING_DOWN
STAND_DOWN
Turn on Playing Game LED
*If
*If HARD_RESET received, return to WAIT_FOR_iBUTTON
*If BLUE_GOAL received, change LEDs to show blue
*If RED_GOAL received, change LEDs to show red
*If END_GAME received, go to GAME_OVER
*If STAND_DOWN_RECEIVED from WC, go to STANDING_DOWN
Send ACK
Set counter to zero
Send NO_ACTION every .2 sec
After counter has reached ticks = 10 sec, go to PLAY_GAME, Turn off Stand Down LED
GAME_OVER
Send ACK to Admiral
Turn off Playing Game LED
Send Navigation Byte and Cleared Special Byte every .2 sec
*If
*If HARD_RESET received, return to WAIT_FOR_iBUTTON