|
FreeRTOS Tetris
|
State Machine handling changes between tasks. More...

Functions | |
| int | iCheckStateInput (player_mode_t playerMode, bool isConnected, rotation_t rotationMode, bool gameOver) |
| Function that checks if the player switched to a different state, depending on different parameters. More... | |
| int | iStateMachineInit () |
| Initialize the state machine. More... | |
| static void | changeState (volatile uint8_t *state, uint8_t forwards) |
| Change the state, either forwards of backwards. More... | |
| static void | stateMachine () |
| Basic state machine with sequential states. More... | |
Variables | |
| const uint8_t | nextStateSignal = NEXT_TASK |
| Signal to change to the next state. | |
| const uint8_t | prevStateSignal = PREV_TASK |
| Signal to change to the previous state. | |
| static TaskHandle_t | StateMachine = NULL |
| Task for the State Machine | |
| QueueHandle_t | StateQueue = NULL |
| Queue for the different states | |
State Machine Definitions | |
| #define | STATE_QUEUE_LENGTH 1 |
| Length of the state queue. | |
| #define | STATE_COUNT 3 |
| Total number of states. | |
| #define | STATE_ONE 0 |
| State 1. | |
| #define | STATE_TWO 1 |
| State 2. | |
| #define | STATE_THREE 2 |
| State 3. | |
| #define | NEXT_TASK 0 |
| Next task. | |
| #define | PREV_TASK 1 |
| Previous task. | |
| #define | STARTING_STATE STATE_ONE |
| Initial state. | |
| #define | STATE_DEBOUNCE_DELAY 300 |
| Delay between state changes. | |
State Machine handling changes between tasks.
This module contains a state machine task. This task is responsible for switching from one state (task) to another.
|
static |
#include <stateMachine.c>
Change the state, either forwards of backwards.
| [in,out] | state | (uint8_t*): Current state, to be changed. |
| [in] | forwards | (uint8_t): Whether to change to the next or previous state. |
| int iCheckStateInput | ( | player_mode_t | playerMode, |
| bool | isConnected, | ||
| rotation_t | rotationMode, | ||
| bool | gameOver | ||
| ) |
#include <stateMachine.h>
Function that checks if the player switched to a different state, depending on different parameters.
| [in] | playerMode | ( player_mode_t): The current player mode. |
| [in] | isConnected | (bool): The current connection status. |
| [in] | rotationMode | ( rotation_t): The current rotation mode. |
| [in] | gameOver | (bool): Whether the game is over. |
| int iStateMachineInit | ( | ) |
#include <stateMachine.h>
Initialize the state machine.
|
static |
#include <stateMachine.c>
Basic state machine with sequential states.
1.8.17