LEDMap Module

This software module

  1) Controls the 15LED Map which is driven by a decoder

  2) Keeps track of the guards position as he approaches the computer room

 

Public Functions:

initLEDMap

  Set output to decoder to zero (which corresponds to an output on the decoder that is NOT

  connected to an LED)

  Set wait times (for blinking and advancing the guard's position) to the calibrated values

  Initialize internal state to LEDMap_OFF

 

LEDMapGuardAlerted

  Update all the wait times to be a fraction of the calibrated values (this will speed up the

  guard's progress and speed up the LED blinking)

 

checkLEDMapEvents

  State machine using internal state

  Case LEDMAP_OFF:

     Do nothing

 

  Case LEDMAP_RUNNING:

     If enough time has passed

       Update which LED is active

     If guard has reached end of the map

       Return LEDMAP_GUARD_ARRIVED

     Else

       Return LEDMAP_GUARD_RUNNING

 

  Case LEDMap_GUARD_ARRIVED:

     Do nothing

  Regardless of what the internal state is, call updateOutputs() to handle blinking of LED

 

startLEDMap

  Set internal state to LEDMAP_RUNNING

  Turn on the first LED of the map

  Set the blink state to be on initially

  Update timing variables to the current time

  Call updateOutputs

 

Module Functions:

updateOutputs

  If enough time has passed for the current LED to be “blinked”

     If current LED is currently on

       Turn it off by setting decoder output to zero

     Else

       Turn it on by setting decoder output to the LED corresponding to the guard's position