This page describes all of the event checkers that trigger posts of all the events in SpiceX. These checkers monitor changes detected in input pins.
CheckButtonEvents
No input
Declare int CurrentButtonState, ReturnVal to be false
Set CurrentButtonState to Read_Btn_PIN
If CurrentButtonState is different from LastButtonState
Set ReturnVal to true
If CurrentButtonState is 0
Post DBButtonDown event to SpiceRackFSM
Else
Post DBButtonUp event to SpiceRackFSM
Update LastButtonState to be CurrentButtonState
Return ReturnVal
CheckDoorState
No input
Declare int CurrentDoorState, ReturnVal to be false
Set CurrentDoorState to Read_Door_PIN
If CurrentDoorState is different from LastDoorState
Set ReturnVal to true
If CurrentDoorState is 0
Post ES_DOOR_OPEN event to SpiceRackFSM
Else
Post ES_DOOR_CLOSE event to SpiceRackFSM
Update LastDoorState to be CurrentDoorState
Return ReturnVal
Check_Opto_Events
No input
Declare int CurrentOptoState, ReturnVal to be false
Set CurrentOptoState to Read_Opto_PIN
If CurrentOptoState is different from LastOptoState
Set ReturnVal to true
If CurrentOptoState is 0
Post ES_DOOR_OptoDown event to SpiceRackFSM
Else
Post ES_OptoUp event to SpiceRackFSM
Update LastOptoState to be CurrentOptoState
Return ReturnVal
CheckSliderStatus
No input
Declare int p to (100*ConversionResults[0])/1023, ReturnVal to be false
Call ADC_MultiRead(ConversionResults)
Declare uint16_t CurrentPulseWidth to be p*50000/100
If CurrentPulseWidth is different from LastPulseWidth
Set ReturnVal to true
Create ES_Event_t newEvent, EventType as ES_NEW_POT_VAL, EventParam as CurrentPulseWidth
Post newEvent to PostMotorDriverService
Init Timer for TWENTY_SEC
Update LastPulseWidth to be CurrentPulseWidth
Return ReturnVal
CheckSpiceState
No input
Declare int CurrentSpiceState, ReturnVal to be false
Set CurrentSpiceState to Read_Spice_PIN
If CurrentSpiceState is different from LastSpiceState
If CurrentSpiceState is 1
Post ES_SPICE_HIGH event to SpiceRackFSM
Else
Post ES_SPICE_LOW event to SpiceRackFSM
Set ReturnVal to true
Update LastSpiceState to be CurrentSpiceState
Return ReturnVal