Urbanite: Parking aid system
fsm_display.h File Reference

Header for fsm_display.c file. More...

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

Macros

#define DANGER_MIN_CM
 
#define WARNING_MIN_CM
 
#define NO_PROBLEM_MIN_CM
 
#define INFO_MIN_CM
 
#define OK_MIN_CM
 
#define OK_MAX_CM
 

Typedefs

typedef struct fsm_display_t fsm_display_t
 Structure to define the FSM of the display system.
 

Enumerations

enum  FSM_DISPLAY_SYSTEM {
  WAIT_DISPLAY = 0,
  SET_DISPLAY
}
 Enumerator for the display system finite state machine. More...
 

Functions

fsm_display_tfsm_display_new (uint32_t display_id)
 Create a new display FSM. More...
 
void fsm_display_destroy (fsm_display_t *p_fsm)
 Destroy a display FSM. More...
 
void fsm_display_set_distance (fsm_display_t *p_fsm, uint32_t distance_cm)
 Set the display system to show the distance in cm. More...
 
void fsm_display_fire (fsm_display_t *p_fsm)
 Fire the display FSM. More...
 
bool fsm_display_get_status (fsm_display_t *p_fsm)
 Get the status of the display FSM. More...
 
void fsm_display_set_status (fsm_display_t *p_fsm, bool pause)
 Set the status of the display FSM. More...
 
bool fsm_display_check_activity (fsm_display_t *p_fsm)
 Check if the display system is active. More...
 
fsm_t * fsm_display_get_inner_fsm (fsm_display_t *p_fsm)
 Get the inner FSM of the display. More...
 
uint32_t fsm_display_get_state (fsm_display_t *p_fsm)
 Get the state of the display FSM. More...
 
void fsm_display_set_state (fsm_display_t *p_fsm, int8_t state)
 Set the state of the display FSM. More...
 

Detailed Description

Header for fsm_display.c file.

Author
Sistemas Digitales II
Date
2025-01-01

Macro Definition Documentation

◆ DANGER_MIN_CM

#define DANGER_MIN_CM

Minimum distance in cm to show the DANGER status

◆ INFO_MIN_CM

#define INFO_MIN_CM

Minimum distance in cm to show the INFO status

◆ NO_PROBLEM_MIN_CM

#define NO_PROBLEM_MIN_CM

Minimum distance in cm to show the NO_PROBLEM status

◆ OK_MAX_CM

#define OK_MAX_CM

Maximum distance in cm to show the OK status

◆ OK_MIN_CM

#define OK_MIN_CM

Minimum distance in cm to show the OK status

◆ WARNING_MIN_CM

#define WARNING_MIN_CM

Minimum distance in cm to show the WARNING status

Enumeration Type Documentation

◆ FSM_DISPLAY_SYSTEM

Enumerator for the display system finite state machine.

This enumerator defines the different states that the display system finite state machine can be in. Each state represents a specific condition of the display system: waiting for a status of display, or showing the status of the display.

Enumerator
WAIT_DISPLAY 

Starting state. Also comes here when there is no status of display, i.e. the display system is inactive

SET_DISPLAY 

State to show the status of the display system

Function Documentation

◆ fsm_display_check_activity()

bool fsm_display_check_activity ( fsm_display_t p_fsm)

Check if the display system is active.

This function checks if the display system is active.

TODO alumnos

✅ 1. Return true if the display system is active and it is not idle. Otherwise, return false.

Parameters
p_fsmPointer to an fsm_display_t struct.
Returns
true If the display system is active.
false If the display system is inactive.

◆ fsm_display_destroy()

void fsm_display_destroy ( fsm_display_t p_fsm)

Destroy a display FSM.

This function destroys a display FSM and frees the memory.

TODO alumnos:

✅ 1. Implement this function analogously to the fsm_display_destroy() function.

Parameters
p_fsmPointer to an fsm_display_t struct.

◆ fsm_display_fire()

void fsm_display_fire ( fsm_display_t p_fsm)

Fire the display FSM.

This function is used to fire the display FSM. It is used to check the transitions and execute the actions of the display FSM.

TODO alumnos:

✅ 1. Call the fsm_fire() function. Pass the address of the fsm_t struct.

Parameters
p_fsmPointer to an fsm_display_t struct.

◆ fsm_display_get_inner_fsm()

fsm_t* fsm_display_get_inner_fsm ( fsm_display_t p_fsm)

Get the inner FSM of the display.

This function returns the inner FSM of the display.

    💡 This function is important because the struct is private and external functions such as those of the unit tests cannot access the inner FSM directly.

TODO alumnos:

✅ 1. Return the address of the f field of the struct.

Parameters
p_fsmPointer to an fsm_display_t struct.
Returns
fsm_t* Pointer to the inner FSM.

◆ fsm_display_get_state()

uint32_t fsm_display_get_state ( fsm_display_t p_fsm)

Get the state of the display FSM.

This function returns the current state of the display FSM.

    💡 This function is important because the struct is private and external functions such as those of the unit tests cannot access the state of the FSM directly.

TODO alumnos:

✅ 1. Retrieve and return the field current_state of the FSM (field f of the struct).

Parameters
p_fsmPointer to an fsm_display_t struct.
Returns
uint32_t Current state of the display FSM.

◆ fsm_display_get_status()

bool fsm_display_get_status ( fsm_display_t p_fsm)

Get the status of the display FSM.

This function returns the status of the display 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_display_t struct.
Returns
true If the display system has been indicated to be active.
false If the display system has been indicated to be paused.

◆ fsm_display_new()

fsm_display_t* fsm_display_new ( uint32_t  display_id)

Create a new display FSM.

This function creates a new display FSM with the given display ID.

Parameters
display_idDisplay ID. Must be unique.
Returns
fsm_display_t* Pointer to the display FSM.

◆ fsm_display_set_distance()

void fsm_display_set_distance ( fsm_display_t p_fsm,
uint32_t  distance_cm 
)

Set the display system to show the distance in cm.

This function is used to set the display system to show the distance in cm.

TODO alumnos:

✅ 1. Set the distance in cm in the display 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_display_t struct.
distance_cmDistance in cm to show in the display system.

◆ fsm_display_set_state()

void fsm_display_set_state ( fsm_display_t p_fsm,
int8_t  state 
)

Set the state of the display FSM.

This function sets the current state of the display FSM.

    💡 This function is important because the struct is private and external functions such as those of the unit tests cannot access the state of the FSM directly.

Parameters
p_fsmPointer to an fsm_display_t struct.
stateNew state of the display FSM.

◆ fsm_display_set_status()

void fsm_display_set_status ( fsm_display_t p_fsm,
bool  pause 
)

Set the status of the display FSM.

This function is used to set the status of the display system. Indicating if the display system is active or paused.

TODO alumnos:

✅ 1. Update the field status with the received value

Parameters
p_fsmPointer to an fsm_display_t struct.
pauseStatus of the display system. true if the display system is paused, false if the display system is active.