Spice Sensor Service

This service is responsible for detecting if there has been a new spice detected during the rotation of the ferris wheel. If a new spice is detected, trigger a display indication to the LED matrix.

Constants and Module Variables

Module Defines

Static int LastSpiceState, Read_Spice_PIN as PORTBbits.RB11, SetMode_Spice_PIN as TRISBbits.TRISB11

Module Functions

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


PostSpiceSensorService

Input: ES_Event_t

Post to service(priority, event)

Service Initialization

InitSpiceSensorService

Input: priority

ES_Event_t ThisEvent

Set SetMode_Spice_PIN  to 1 

Set LastSpiceState to Read_Spice_PIN 

Post Initial event ES_INIT