0% found this document useful (0 votes)
90 views2 pages

Led Service Pseudocode

This document contains module code for controlling an LED display. It defines functions and data for initializing the LED service, updating the display, and running a state machine to handle different display states and events. The RunLEDService function implements a state machine with states for initializing, waiting for events, and writing updates to control the display based on events like score updates, timeouts, or column updates for a progress bar.

Uploaded by

api-581249153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views2 pages

Led Service Pseudocode

This document contains module code for controlling an LED display. It defines functions and data for initializing the LED service, updating the display, and running a state machine to handle different display states and events. The RunLEDService function implements a state machine with states for initializing, waiting for events, and writing updates to control the display based on events like score updates, timeouts, or column updates for a progress bar.

Uploaded by

api-581249153
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Functions in this module: InitializeLEDService, PostLEDService, RunLEDService

Data private to module: static uint32_t data, static uint32_t pattern, static uint32_t bullet[8], static
char endMessage[8], static uint8_t score, static char scoreChar[3], uint8_t messageIndex

RunLEDService

Switch for CurrentState


CurrentState is InitLEDState
If Event Type is ES_INIT
Initialize display
Set CurrentState to Waiting
Endif
End InitLEDState block

CurrentState is Waiting
Switch for Event Type
Event is ES_UPDATE_COL
Bit shift data to left by 1 and add a 1 on the right end (this makes
data a right to left progress bar)
For each row
Set current row of shift variable to bits matching data and
current row of bullet pattern, then bitshift by 31-column
End for loop
Put all rows of shift data into display buffer
Set CurrentState to Writing
Post to this service ES_SEND event
End ES_UPDATE_COL block

Event is ES_BEGIN
Clear all rows of display buffer
Disable Scroll Timer to stop scroll message
End ES_BEGIN block

Event is ES_ACTIVITY_TIMEOUT
Reset data to 0
Reset Scroll Timer
Reset messageIndex to 0
Convert score to char array
Combine endMessage and scoreChar
End ES_ACTIVITY_TIMEOUT block

Event is ES_ADD_SCORE
Add event parameter to score
End ES_ADD_SCORE block

Event is ES_SCROLL_TIMEOUT
If messageIndex is less than length of endMessage
Scroll display buffer by char length
Add next character from endMessage to display buffer
Post ES_SEND to this service
Increment messageIndex
Reset Scroll Timer
Set CurrentState to Writing
Endif
End ES_SCROLL_TIMEOUT block
End switch
End Waiting block

CurrentState is Writing
Switch for Event Type
Event is ES_SEND
If (false == DM_TakeDisplayUpdateStep)
Repost ThisEvent
Else
Set CurrentState to Waiting
Recall any deferred events
Endif
End ES_SEND block

Event is ES_UPDATE_COL
Defer the event
End ES_UPDATE_COL block
End switch
End Writing block
End switch

You might also like