START OF DebounceService
/******************************************************************************/
DEBOUNCE SERVICE MODULE PSEUDO-CODE
InitializeDebounceService
Takes a priority number, returns True
Initialize the MyPriority variable with the passed in parameter
Initialize DebounceTimer
Set CurrentState to be InitDebounceService
post Event ES_INIT to InitDebounceService (this service)
Initialize a pad state variable
Initialize steppedOffCounter
Initialize a pinch state variable
Initialize a card state variable
Create a return event
Assume no errors
End
RunDebounceService
IF event is ES_TIMEOUT & event parameter is for DebounceTimer
set the DebounceTimer to 20ms
start the time again
check the pad state using a mask
check the pinch sensor, save it to pinch state variable (use A/D)
check the tape sensors, save to two tape sensor state variables
END
//Check for rising edges on the stop pad to see when players lift their feet
The service works by checking the state of the pad evey 20 ms or so and then
sees if it is low and changed states from the last check.//
IF the pad is HIGH
IF different from the last pad state
//pad step off detected, POST AN EVENT
Create a new event
set new event to ES_STOMPRISE
Post the event to the GameSM
reset steppedOffCounter = 0
END IF
ELSE
up steppedOffCounter
ENDIF
IF steppedOffCounter is 250
post ES_RESET
ENDIF
//Check for the voltage of the FSR circuit to rise above a certain threshold//
IF the value of the pinch sensor is above the PINCH_THRESHOLD
//Pinch detected, post an event
Create a new event
set new event to ES_FSRPINCH
Post event to Game Module State Machine
ENDIF
//Check if the card is in the machine by seeing if the two tape sensors are
opposite of each other//
IF both tape sensors detect black (LOW)
Card detected, post an event
Create a new event
set new event to ES_CARDREAD
Post event to Game Module State Machine
ELSEIF either tape sensor detects white (high)
Card has been removed
Create a new event
set new event to ES_RESET
Post event to all state machines
ENDIF
ENDIF