Our software was implemented primarily via two concurrent hierarchical state machines. The first (SushiMaster) governed all gameplay logic, while the second governed communication with the LOC.
Sushi master state machine
The SushiMaster state machine contained all possible states of gameplay: idle, constructing, and free-for-all.
constructiNG STATE MACHINE
ConstructingSM contained the majority of all gameplay software. It contained lower-level state machines for traveling between stages (Going2Stage), shooting, checking in, and loading. This state machine was run when SushiMaster was in the constructing state.
Communication state machine
CommunicationSM contained logic for communicating with the LOC via SPI. The LOC was queried when a SEND_CMD event was received, and COMM_ARRAY_READY was posted to SushiMaster when the result was available. A custom library of SPI functions was used to send and read data.
Hall effect sensor service
Hall Effect Service was a helper service that ran continuously in the background checking for signals from the Hall effect sensor. An input capture ISR was used to calculate the frequency a found signal and post the frequency to SushiMaster.