PrizeLED Module

Description

Provides the functions for initializing, resetting, and writing patterns to the Prize LED hardware

PrizeLEDInit()

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

PrizeLEDReset()

Light the default pattern (2 winning slots at the right end)

PrizeLEDShiftLeft()

Take no argument and shift the prize slots to the left

PrizeLEDShiftRight()

Take no argument and shift the prize slots to the right

PrizeLEDGetPattern()

Take no argument and return the current prize pattern

e.g if winning slot is slot 2 and slot 3, return BIT3HI | BIT2HI or 1100

LightLEDpattern()

Take a number of type unsigned int and light the corresponding pattern. When bit i-1 of this number is 1, light the prize LED at slot i.

e.g if pattern=BIT5HI | BIT3HI | BIT8HI then LightLEDPattern(pattern) will light up slot 6,4 and 9

Implementation

Module static variables

static OutputT Clock,Data

            Clock and Data hold output configuration data for the clock and data pins.

static unsigned int PrizePattern

            PrizePattern is used to store the current LED pattern

PrizeLEDInit()

Pass the argument of PrizeLEDInit (two InputT) to the module static variables Clock and Data

Initialize the shift register corresponding to Clock and Data

LightLEDpattern(0) (turn off all the LEDs)

PrizeLEDShiftLeft()

Record the current LED pattern to prizePos

Shfit this number to the left, record to to prizePosNew

If bit 8 of the initial prizePos is 1, then bit 0 of the prizePosNew is 1

LightLEDpattern(prizePosNew)

PrizeLEDShiftRight()

Record the current LED pattern to prizePos

Shfit this number to the right, record to to prizePosNew

If bit 0 of prizePos is 1, then bit 8 of the prizePosNew is 1

LightLEDpattern(prizePosNew)

PrizeLEDGetPattern()

Return the value of static variable PrizePattern

PrizeLEDReset()

LightLEDpattern(3) (3=BIT0HI | BIT1HI: => light the two slots at the right end)

LightLEDpattern(patttern)

Repeat 9 times

            If bit 0 of pattern is 1

                        Use LightNext(Clock,Data) to shift 1 in

            Else use DontLightNext(Clock,Data) to shift 0 in

            Shift pattern right (pattern >>=1)