/**************************************************************************** Module: Angels_MapKeys.c Description: This service maps keystrokes to events for debugging the ME218B project. ****************************************************************************/ /**************************************************************************** Function InitMapKeys Saves away the priority, and does any other required initialization Takes uint8_t : the priority of this service Returns false if error in initialization, True otherwise ****************************************************************************/ Set MyPriority = Priority Initialize the display timer with Display_Update_Time Return True End of function /**************************************************************************** Function PostMapKeys Posts an event to this state machine's queue Takes an event ThisEvent to post to the queue Returns False if the Enqueue operation failed, True otherwise ****************************************************************************/ Call ES_PostToService( MyPriority, ThisEvent) and return what it returns /**************************************************************************** Function RunMapKeys Checks for key presses and posts events as appropriate Takes an event to process Returns ES_NO_EVENT if no error ES_ERROR otherwise ****************************************************************************/ Initialize an Event ReturnEvent Set ReturnEvent to ES_NO_EVENT (assuming no errors) If a key as been pressed: Depending on the key pressed, post a user-defined event: 'G' : Create Event GAME_START 'T' : Create Event TEAM_DETERMINED 'P' : Create Event PICKUP_TIMER_EXP 'R' : Create Event LOOKING_AT_BIN 'F' : Create Event LOST_BIN 'B' : Create Event ARRIVED_AT_BIN 'N' : Create Event ALIGNED_W_BIN 'H' : Create Event START_HOPPING 'J' : Create Event HOPPER_BOTTOM_LIMIT 'K' : Create Event HOPPER_MIDDLE_LIMIT 'L' : Create Event HOPPER_UPPER_LIMIT 'D' : Create Event TIME_TO_DUMP 'Q' : Create Event FIND_LEFT_SIGNAL 'A' : Create Event LOSE_LEFT_SIGNAL 'W' : Create Event FIND_RIGHT_SIGNAL 'S' : Create Event LOSE_RIGHT_SIGNAL '8' : Create Event BUMP_FRONT_LEFT '9' : Create Event BUMP_FRONT_RIGHT '5' : Create Event BUMP_BACK_LEFT '6' : Create Event BUMP_BACK_RIGHT '1' : Create Event NEW_GOAL_BEACON with parameter BEACON_1 '2' : Create Event NEW_GOAL_BEACON with parameter BEACON_2 '3' : Create Event NEW_GOAL_BEACON with parameter BEACON_3 '4' : Create Event NEW_GOAL_BEACON with parameter BEACON_4 If an event has been created Post it to the master State Machine If the display timer has run out Update the display with UpdateDisplay() reset the display timer for the next staff. return ReturnEvent End of function