Simone: a game of visual memory and speed
fsm_rgb_light.h File Reference

Header for fsm_rgb_light.c file. More...

#include <stdint.h>
#include <stdbool.h>
#include "fsm.h"
#include "rgb_colors.h"

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_tfsm_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...
 

Detailed Description

Header for fsm_rgb_light.c file.

Author
Sistemas Digitales II
Date
2026-01-01

Macro Definition Documentation

◆ MAX_LEVEL_INTENSITY

#define MAX_LEVEL_INTENSITY

Maximum level of intensity in percentage

Enumeration Type Documentation

◆ 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

Function Documentation

◆ fsm_rgb_light_check_activity()

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 true if the RGB light system is active and it is not idle. Otherwise, return false.

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.
Returns
true If the RGB light system is active.
false If the RGB light system is inactive.

◆ fsm_rgb_light_destroy()

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.

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.

◆ fsm_rgb_light_fire()

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 the fsm_t struct.

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.

◆ fsm_rgb_light_get_status()

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.

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.
Returns
true If the RGB light system has been indicated to be active.
false If the RGB light system has been indicated to be paused.

◆ fsm_rgb_light_new()

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.

Parameters
rgb_light_idRGB light ID. Must be unique.
Returns
fsm_rgb_light_t* Pointer to the RGB light FSM.

◆ fsm_rgb_light_set_color_intensity()

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 color and intensity_perc fields of the RGB light system FSM.
✅ 2. Set the new_color field accordingly to indicate that a new color has to be set.

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.
colorRGB color to set.
intensity_percIntensity in percentage to set.

◆ fsm_rgb_light_set_status()

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 status with the received value

Parameters
p_fsmPointer to an fsm_rgb_light_t struct.
pauseStatus of the RGB light system. true if the RGB light system is paused, false if the RGB light system is active.