Pseudo-code for Hit Register (Beam Break) module ******************************************************************************* IRLed_Init //Takes no input, Returns nothing Initialize pin PE4 for the IR LED Output and set output to LO End of IRLed_Init SensingPins_Init //Takes no input, Returns nothing Set the direction of pins C5, C6, C7 to read the IR input End of SensingPins_Init InitializeBeamBreak //Takes a priority number, Returns True Call IRLed_Init to handle IR LED Output Call Sensing Pins_Init to handle reading the IR Input Set the left/middle/right states to the current input states Set WhichHit to 0 Post Event ES_Init to BeamBreak queue End of InitializeBeamBreak PostBeamBreak Takes an event and posts to service End of PostBeamBreak CheckBeamBreak //Takes no parameters, returns True if an event was posted Set ReturnVal to false Get current state of left IR sensor If current state is different that last state If current state is LO then start left timer Set ReturnVal to true Get current state of middle IR sensor If current state is different that last state If current state is LO then start middle timer Set ReturnVal to true Get current state of right IR sensor If current state is different that last state If current state is LO then start right timer Set ReturnVal to true Update last state of left, middle and right sensors to current states Return ReturnVal End of CheckBeamBreak RunBeamBreak //Takes an event, Returns a blank event if case is HIT_POST Set WhichHit equal to EventParam if case is ES_TIMEOUT If WhichHit is equal to EventParam Stop all timers Set EventType to HIT_SUCCESS Set EventParam to WhichHit Set WhichHit = 0 Else If WhichHit is not equal to 0 Stop all timers Set EventType to HIT_MISTAKE Set EventParam to WhichHit Set WhichHit = 0 Post event to Gameplay Post event to HP Servo Return ES_NO_EVENT End of RunBeamBreak