Debounce Pseudo Code
The Debounce Service checks for Ready Button, Balance Switch, and Access Card events.
InitDebounce Set the last button value
Set the last access card value
Set the last balance value
RunDebounce
Get the current button value
Get the current access card value
Get the current balance value
switch ( ThisEvent)
case ES_INIT:
Do Nothing
case ES_TIMEOUT:
if currentButtonValue is different than the lastButtonValue
if the button is down
Post Button Down Event
if currentBalanceValue is different than the lastBalanceValue
if balance switch is down
Post an off balance event
else
Post a rebalanced event
if currentAccessCardValue is different than the lastAccessCardValue
if a card is detected
Post an Access Card detected event
else
Post an Access Card Removed event
Restart the timer
set last values to current values
Set the last access card value
Set the last balance value
RunDebounce
Get the current button value
Get the current access card value
Get the current balance value
switch ( ThisEvent)
case ES_INIT:
Do Nothing
case ES_TIMEOUT:
if currentButtonValue is different than the lastButtonValue
if the button is down
Post Button Down Event
if currentBalanceValue is different than the lastBalanceValue
if balance switch is down
Post an off balance event
else
Post a rebalanced event
if currentAccessCardValue is different than the lastAccessCardValue
if a card is detected
Post an Access Card detected event
else
Post an Access Card Removed event
Restart the timer
set last values to current values