|
Simone: a game of visual memory and speed
|
Header for fsm_keyboard.c file. More...
#include <stdint.h>#include <stdbool.h>#include "fsm.h"Data Structures | |
| struct | fsm_keyboard_t |
| Structure of the Keyboard FSM. More... | |
Enumerations | |
| enum | FSM_KEYBOARD { KEYBOARD_RELEASED_WAIT_ROW = 0, KEYBOARD_RELEASED_WAIT, KEYBOARD_PRESSED, KEYBOARD_PRESSED_WAIT } |
| Enumerator for the keyboard finite state machine. More... | |
Functions | |
| fsm_keyboard_t * | fsm_keyboard_new (uint32_t debounce_time_ms, uint8_t keyboard_id) |
| Create a new keyboard FSM. More... | |
| void | fsm_keyboard_destroy (fsm_keyboard_t *p_fsm) |
| Destroy a keyboard FSM. More... | |
| void | fsm_keyboard_fire (fsm_keyboard_t *p_fsm) |
| Fire the keyboard FSM. More... | |
| void | fsm_keyboard_start_scan (fsm_keyboard_t *p_fsm) |
| Start the keyboard scanning. More... | |
| void | fsm_keyboard_stop_scan (fsm_keyboard_t *p_fsm) |
| Stop the keyboard scanning. More... | |
| char | fsm_keyboard_get_key_value (fsm_keyboard_t *p_fsm) |
| Return the key pressed of the last keyboard press. More... | |
| bool | fsm_keyboard_get_is_valid_key (fsm_keyboard_t *p_fsm) |
| Check if the last key pressed is valid. More... | |
| void | fsm_keyboard_reset_key_value (fsm_keyboard_t *p_fsm) |
| Reset the key pressed of the last keyboard press. More... | |
| bool | fsm_keyboard_check_activity (fsm_keyboard_t *p_fsm) |
| Check if the keyboard FSM is active, or not. More... | |
Header for fsm_keyboard.c file.
| enum FSM_KEYBOARD |
Enumerator for the keyboard finite state machine.
This enumerator defines the different states that the keyboard finite state machine can be in. Each state represents a specific condition or step in the keyboard key identification process.
| bool fsm_keyboard_check_activity | ( | fsm_keyboard_t * | p_fsm | ) |
Check if the keyboard FSM is active, or not.
The keyboard is always inactive because it works with events.
TODO alumnos Version 4:
✅ 1. Return
falsealways.
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| void fsm_keyboard_destroy | ( | fsm_keyboard_t * | p_fsm | ) |
Destroy a keyboard FSM.
This function destroys a keyboard FSM and frees the memory.
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| void fsm_keyboard_fire | ( | fsm_keyboard_t * | p_fsm | ) |
Fire the keyboard FSM.
This function is used to fire the keyboard FSM. It is used to check the transitions and execute the actions of the keyboard FSM.
TODO alumnos:
✅ 1. Call the
fsm_fire()function. Pass the address of thefsm_tstruct.
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| bool fsm_keyboard_get_is_valid_key | ( | fsm_keyboard_t * | p_fsm | ) |
Check if the last key pressed is valid.
This function checks if the last key pressed is valid by comparing it with the invalid key value.
TODO alumnos:
✅ 1. Return true if the field
key_pressedis different frominvalid_key, otherwise return false.
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| char fsm_keyboard_get_key_value | ( | fsm_keyboard_t * | p_fsm | ) |
Return the key pressed of the last keyboard press.
TODO alumnos:
✅ 1. Retrieve and return the field
key_pressed
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| fsm_keyboard_t* fsm_keyboard_new | ( | uint32_t | debounce_time_ms, |
| uint8_t | keyboard_id | ||
| ) |
Create a new keyboard FSM.
This function creates a new keyboard FSM with the given debounce time for all keys and keyboard ID.
| debounce_time_ms | Debounce time in milliseconds for all keys. |
| keyboard_id | Keyboard ID. Must be unique. |
| void fsm_keyboard_reset_key_value | ( | fsm_keyboard_t * | p_fsm | ) |
Reset the key pressed of the last keyboard press.
TODO alumnos:
✅ 1. Set the field
key_valuetoinvalid_key
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| void fsm_keyboard_start_scan | ( | fsm_keyboard_t * | p_fsm | ) |
Start the keyboard scanning.
This function starts the keyboard scanning by calling the appropriate port function.
TODO alumnos:
✅ 1. Call the appropriate port function passing the keyboard ID
| p_fsm | Pointer to an fsm_keyboard_t struct. |
| void fsm_keyboard_stop_scan | ( | fsm_keyboard_t * | p_fsm | ) |
Stop the keyboard scanning.
This function stops the keyboard scanning by calling the appropriate port function.
TODO alumnos:
✅ 1. Call the appropriate port function passing the keyboard ID
| p_fsm | Pointer to an fsm_keyboard_t struct. |