IR Sensor Service
This service is responsible for detecting if the IR sensor is triggered. If there is a gesture during the Begin state, the motors start rotating. If there is a gesture again, the motors stop rotating.
Constants and Module Variables
Constants and Module Variables
Module Defines
Static int LastOptoState, Read_Opto_PIN as PORTBbits.RB13, SetMode_Opto_PIN as TRISBbits.TRISB13
Module Functions
Module Functions
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
Service Initialization
Service Initialization
Init_Opto_Status
no input
Set LastOptoState to Read_Opto_PINÂ