Capacitive Touch Service
This service is responsible for detecting if the capacitive touch switch is triggered. If it is pressed during the Begin state, the motors start rotating. If it is pressed again, the motors stop rotating.
Constants and Module Variables
Module Defines
Static int LastButtonState, Read_Btn_PIN as PORTAbits.RA3
Service Initialization
InitButtonStatus
Inputs: void
Set LastButtonState to Read_Btn_PIN
Module Functions
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