Helm: Pseudocode | ||
|
Home
The Game Water Craft Helm Software Electronics Communications Gems of Wisdom Media |
· Initialize ports · Configure communication to xBee UART o 9600 baud · Loop until iButton is detected o Check for PING from admiral § Respond to admiral if pinged o Check for iButton · Read iButton · Loop until MATCHED command received from craft o Broadcast IBUTTON command with iButton ID number every 0.2 seconds o Check for PING from admiral § Respond to admiral if pinged o Check for MATCHED message from craft · Store address of craft sending MATCHED command · Check look up table for Craft number associated with address of paired craft · Display team affiliation (red for odd iButton #, blue for even) · Display number of paired craft · Loop until admirals broadcast START_OF_GAME command o Send NO_ACTION to paired craft o Check for PING from admiral § Respond to admiral if pinged o Listen for START_OF_GAME command · Acknowledge START_OF_GAME to admirals · Loop until admirals broadcast END_OF_GAME command o Check for messages § If a Craft message (byte 0 = 0x08) · If STAND_DOWN received from correct craft o Activate stand down indicator o Start 10 second countdown timer § Loop until timer expires · Send NO_ACTION commands to craft every 0.2 seconds o Turn off stand down indicator § If admiral message (byte 0 = 0x04) · If RED_GOAL message o Turn off blue goal active indicator o Turn on red goal active indicator · If BLUE_GOAL message o Turn off red goal active indicator o Turn on blue goal active indicator · If PING o Respond to admiral with ping response · If HARD_RESET o Unpair from craft § Reset address of craft transmitting to § Reset serial number read from iButton o Return to initial checking for iButton state o Every 0.2 seconds § Read control inputs § ME218 byte 0 = 0x02 § Assemble ME218 byte 1 § Assemble ME218 byte 2 § Send commands to helm · Acknowledge END_OF_GAME to admiral · Send command to turn off all water and special functions · Loop until HARD_RESET received o Every 0.2 seconds § Read control inputs § Assemble ME218 byte 1 § ME218 byte 2 is always 0 § Send commands to helm · Unpair from craft o Reset address of craft transmitting to o Reset serial number read from iButton · Return to initial checking for iButton state
| |