Pseudo-code for Timer Servo ************************************************************************************* InitializeTimerServo Takes a priority number, returns True. Initialize MyPriority variable with the passed in parameter. Initialize TimeCounter variable as its maximum value of 60. Set CurrentPW of timer servo to correspond to leftmost position. Set pulse width of TimerServoChannel to CurrentPW to move servo to that position. Generate and post event ES_INIT to TimerServo queue. End of InitializeTimerServo PostTimerServo Post passed in parameter (ThisEvent) to TimerServo queue. End of PostTimerServo RunTimerServo Takes parameter ThisEvent with ThisEvent.EventType being one of : ES_TIMEOUT or GAME_OVER Returns ES_NO_EVENT Based on the EventType of event posted to service, choose one of the following blocks of code: EventType is ES_TIMEOUT: Based on the EventParam of event posted to service, choose one of the following blocks of code: EventParam is FUN_TIMER: Statically initialize parameter HPFunCounter with initial value of 1. if HPFunCounter is 4 Send timer servo to leftmost position. else if HPFunCounter is 7 Send timer servo to rightmost position. Reset HPFunCounter to 0. endif Increment HPFunCounter. End FUN_TIMER block EventParam is WAIT_TOT_TIMER: Initialize GAME_TIMER, 1s. Set TimeCounter variable to its maximum value of 60. Send timer servo to leftmost position. End WAIT_TOT_TIMER block EventParam is GAME_TIMER: if TimeCounter <= 0 Post Event GAME_OVER with EventParam LOSE_VALUE to HPServo and Gameplay modules. else Initialize GAME_TIMER, 1s. Move timer servo a tick to the right by modifying PWM pulsewidth by PW_Delta. Decrement TimeCounter endif End GAME_TIMER block EventParam is AUDIO_TIMER: Send timer servo to leftmost position. End AUDIO_TIMER block EventParam is anything else: Do nothing. End default block End ES_TIMEOUT block EventType is GAME_OVER: Stop GAME_TIMER. Set TimeCounter to 0. End GAME_OVER block EventType is anything else: Do nothing. End default block Return ES_NO_EVENT. End of RunTimerServo