You are on page 1of 2

Functions in module: InitializeGear, PostGear, RunGear, Check4Shift

Check4Shift

Set returnVal to false


Read state of gear and initialize as CurrentGearState
If gear state changed
Post ES_GEAR_SHIFT event to this service
Endif

InitializeGearService
Set switch pin to input
Set Gear LED pin to output
Read switch pin and set as LastGearState
Set CurrentState to InitGear
Post Event ES_Init to this service
End of InitializeGearService

RunGear

Switch for CurrentState


CurrentState is InitializeGear
If ThisEvent is ES_INIT
Start with Gear LED off
Set CurrentState to GearWaiting2Begin
Endif
End InitializeGear block

CurrentState is GearWaiting2Begin
Switch for Event Type
Event is ES_BEGIN
Set Gear Timer
Set CurrentState to Waiting2Shift
Event is ES_GEAR_SHIFT
Post ES_BEGIN to all
End switch
End GearWaiting2Begin block

CurrentState is Waiting2Shift
Switch for Event Type
Event is ES_GEAR_TIMEOUT
Turn on Gear LED
Set CurrentState to Ready2Shift
Event is ES_ACTIVITY_TIMEOUT
Disable Gear Timer
Set CurrentState to GearWaiting2Begin
End switch
End Waiting2Shift block

CurrentState is Ready2Shift
Switch for Event Type
Event is ES_GEAR_SHIFT
Turn off Gear LED
Reset Gear Timer
Reset Activity Timer
Add 5 points to score
Set CurrentState to Waiting2Shift
Event is ES_ACTIVITY_TIMEOUT
Turn off Gear LED
Disable Gear Timer
Set CurrentState to GearWaiting2Begin
End switch
End Ready2Shift block
End switch block

You might also like