GameTimerLED Module

Description

Provides the functions for initializing, resetting, and counting on the Game Timer LED hardware.

GameTimerInit()

Take 2 arguments of type OutputT (clock and data) and return nothing. When main calls this function it tells the GameTimerLED Module which ports are used for the corresponding shift register, initializes these ports and turns off all the LEDs.

GameTimerReset()

Take no argument turn all the LEDs on

GameTimerCountDown()

Take no argument, count down the LED by 1

LightN(n)

Take a number between 0 and 8, light the number of LEDs corresonding

Implementation

Module static variables

static OutputT Clock,Data
static char TimerPattern

            this number is used to keep track of the current LED pattern.

            e.g TimerPattern=8: 8 LEDs are on, =1, only 1 LED left

GameTimerInit()

Pass the argument of GameTimerInit to the module static variable Clock and Data, initialize the shift register corresponding to Clock and Data

LightN (n)

If n<=0 do nothing

Repeat n times

            LightNext(Clock,Data) (function defined in ShiftRegister)

Repeat 8-n times

            DontLightNext(Clock,Data)

Set TimerPatter=n

GameTimerReset()

LightN(8)

GameTimerCountDown()

LightN(TimerPattern-1)