You are on page 1of 3
Event Checker Pseudo-Code ButtonEventChecker Data private to module: LastButtonState, ButtonPin InitButtonstatus Returns true if button successfully initialized Initialize port line to receive digital inputs Set LastButtonState to ButtonPin Return true End of InitButtonstatus checkButton Returns true if ES_DBBUTTON_DOWN or ES BUTTON_UP event is posted Set local variable ReturaVal to false. Get current state of ButtonPin If the current state of ButtonPin is different than LastButtonPin: Post an ES_DBBUTTON_DOWN event if the button is currently pressed Post an ES_DBBUTTON_UP event if the button is currently unpressed Set ReturnVal to true Set LastButtonState to CurrentButtonstate Return Returnval End of CheckButton PotTurnedEventChecker Data private to the module: 22-bit integer array LastaD_Value[1] Initpotstatus Set up the corresponding pin to take in analog input call function to configure analog pin call function to read in a value from the pin and save it to LastAD_Value End of InitPotstatus checkPotTurned Set ReturnVal to false Declare new current val variable Call function to read in a value from the pin and save it to the current val variable Call function to find the difference between the last and current vals If the difference is greater than 50 Post a potentiometer turned event to ActiveSM with event parameter equal to the current val Set ReturnVal to true Update LastaD_Value[0] to equal the current val Endif Return ReturnVal End of CheckpotTurned absoluteDif£é Takes in two 32-bit integers and returns the absolute value of their difference If LastAD_Value is greater than CurrentAD_Value Return LastAD_Value - CurrentAD_Value Endif If CurrentaD_Value is greater than LastAD_Value Return CurrentAD Value - LastAD_Value Endif End of absoluteDiff HallEffectEventChecker Data private to module: LastHallstate, ticks, events, pinwheelComplete, MyPriority Define: HalleffectPin, Events Required, Ticks Per_Event InithallEffect Takes a priority number, returns True Initialize MyPriority variable with the passed in parameter Initialize port line to receive input data Set LastHallstate to current state of HalleffectPin Set ticks, events, and pinWheelComplete to zero Return true End of InitHallzffect checkHallEffect Takes no parameters, returns true if a ES_HALL EFFECT CHANGE event was posted. Set local variable ReturnVal to false Get current state of HallzffectPin If the current state of the HallzffectPin is different from LastHallstate: Increase ticks by one If ticks is greater than Ticks Per Event, post an ES_HALL_EFFECT CHANGE event, set ticks to zero, and set ReturnVal to true Increase number of events by one. Set LastHallstate to current state of HallEffectPin Return Returnval End of CheckHallgffect

You might also like