Main Pseudocode
Main Module Function: Main Start Master State Machine and initialize submodules Start TMRS12 timer Enable interrupts Loop forever: Get Event from Event Checker Run Master State Machine on Event Run Debugging Output Event Checker Module Function: CheckEvents Check Debugger for manual event Check for the following events: New response from the Field New SPI read OC timer expired, or OC timeout New command ready for OC State transition for Drivetrain SM Drivetrain timer expired Beacon found during alignment Beacon lost during tracking Robot aimed at target Bump sensor hit Front tape sensors all recently set off Back tape sensors all recently set off Game Running response received while paused Game Paused response received while running If the game is running: If the game is almost over: We aren't near our hoop If the game is not almost over: The dispenser we are at is empty We have timed out at, or in route to, a dispenser We have arrived at a dispenser There is a ball ready to be shot The Shooter transition timer has expired A Request Ball state has timed out Debugging Module Function: DebugEvent Returns: New Event If there has been a keypress Interpret the key, return the corresponding event Function: DebugPrint Print to terminal desired debugging information: - Most recent event - OC responses - Current machine states - Sensor values