|
Simone: a game of visual memory and speed
|
Header for fsm_rgb_light.c file. More...
Data Structures | |
| struct | fsm_rgb_light_t |
| Structure to define the FSM of the RGB light system. More... | |
Macros | |
| #define | MAX_LEVEL_INTENSITY |
Enumerations | |
| enum | FSM_RGB_LIGHT_SYSTEM { IDLE_RGB = 0, SET_COLOR } |
| Enumerator for the RGB light system finite state machine. More... | |
Functions | |
| fsm_rgb_light_t * | fsm_rgb_light_new (uint8_t rgb_light_id) |
| Create a new RGB light FSM. More... | |
| void | fsm_rgb_light_destroy (fsm_rgb_light_t *p_fsm) |
| Destroy an RGB light FSM. More... | |
| void | fsm_rgb_light_set_color_intensity (fsm_rgb_light_t *p_fsm, rgb_color_t color, uint8_t intensity_perc) |
| Set the color and intensity of the RGB light. More... | |
| void | fsm_rgb_light_fire (fsm_rgb_light_t *p_fsm) |
| Fire the RGB light FSM. More... | |
| bool | fsm_rgb_light_get_status (fsm_rgb_light_t *p_fsm) |
| Get the status of the RGB light FSM. More... | |
| void | fsm_rgb_light_set_status (fsm_rgb_light_t *p_fsm, bool pause) |
| Set the status of the RGB light FSM. More... | |
| bool | fsm_rgb_light_check_activity (fsm_rgb_light_t *p_fsm) |
| Check if the RGB light system is active. More... | |
Header for fsm_rgb_light.c file.
| #define MAX_LEVEL_INTENSITY |
Maximum level of intensity in percentage
| enum FSM_RGB_LIGHT_SYSTEM |
Enumerator for the RGB light system finite state machine.
This enumerator defines the different states that the RGB light system finite state machine can be in. Each state represents a specific condition of the RGB light system: waiting for a status of RGB light, or showing the status of the RGB light.
| Enumerator | |
|---|---|
| IDLE_RGB | Starting state. Also comes here when there is no status of RGB light, i.e. the RGB light system is inactive |
| SET_COLOR | State to show the status of the RGB light system |
| bool fsm_rgb_light_check_activity | ( | fsm_rgb_light_t * | p_fsm | ) |
Check if the RGB light system is active.
This function checks if the RGB light system is active.
TODO alumnos
✅ 1. Return
trueif the RGB light system is active and it is not idle. Otherwise, returnfalse.
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| void fsm_rgb_light_destroy | ( | fsm_rgb_light_t * | p_fsm | ) |
Destroy an RGB light FSM.
This function destroys an RGB light FSM and frees the memory.
TODO alumnos:
✅ 1. Implement this function analogously to the
fsm_rgb_light_destroy()function.
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| void fsm_rgb_light_fire | ( | fsm_rgb_light_t * | p_fsm | ) |
Fire the RGB light FSM.
This function is used to fire the RGB light FSM. It is used to check the transitions and execute the actions of the RGB light FSM.
TODO alumnos:
✅ 1. Call the
fsm_fire()function. Pass the address of thefsm_tstruct.
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| bool fsm_rgb_light_get_status | ( | fsm_rgb_light_t * | p_fsm | ) |
Get the status of the RGB light FSM.
This function returns the status of the RGB light system. This function might be used for testing and debugging purposes.
TODO alumnos:
✅ 1. Retrieve and return the field
status.
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| fsm_rgb_light_t* fsm_rgb_light_new | ( | uint8_t | rgb_light_id | ) |
Create a new RGB light FSM.
This function creates a new RGB light FSM with the given RGB light ID.
| rgb_light_id | RGB light ID. Must be unique. |
| void fsm_rgb_light_set_color_intensity | ( | fsm_rgb_light_t * | p_fsm, |
| rgb_color_t | color, | ||
| uint8_t | intensity_perc | ||
| ) |
Set the color and intensity of the RGB light.
This function sets the color and intensity of the RGB light.
TODO alumnos: ✅ 1. Set the
colorandintensity_percfields of the RGB light system FSM.
✅ 2. Set thenew_colorfield accordingly to indicate that a new color has to be set.
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| color | RGB color to set. |
| intensity_perc | Intensity in percentage to set. |
| void fsm_rgb_light_set_status | ( | fsm_rgb_light_t * | p_fsm, |
| bool | pause | ||
| ) |
Set the status of the RGB light FSM.
This function is used to set the status of the RGB light system. Indicating if the RGB light system is active or paused.
TODO alumnos:
✅ 1. Update the field
statuswith the received value
| p_fsm | Pointer to an fsm_rgb_light_t struct. |
| pause | Status of the RGB light system. true if the RGB light system is paused, false if the RGB light system is active. |