Urbanite: Parking aid system
|
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_t * | fsm_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... | |
Header for fsm_display.c file.
#define DANGER_MIN_CM |
Minimum distance in cm to show the DANGER status
#define INFO_MIN_CM |
Minimum distance in cm to show the INFO status
#define NO_PROBLEM_MIN_CM |
Minimum distance in cm to show the NO_PROBLEM status
#define OK_MAX_CM |
Maximum distance in cm to show the OK status
#define OK_MIN_CM |
Minimum distance in cm to show the OK status
#define WARNING_MIN_CM |
Minimum distance in cm to show the WARNING status
enum 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 |
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, returnfalse
.
p_fsm | Pointer to an fsm_display_t struct. |
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.
p_fsm | Pointer to an fsm_display_t struct. |
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 thefsm_t
struct.
p_fsm | Pointer to an fsm_display_t struct. |
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.
p_fsm | Pointer to an fsm_display_t struct. |
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 (fieldf
of the struct).
p_fsm | Pointer to an fsm_display_t struct. |
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
.
p_fsm | Pointer to an fsm_display_t struct. |
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.
display_id | Display ID. Must be unique. |
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 thenew_color
field accordingly to indicate that a new color has to be set.
p_fsm | Pointer to an fsm_display_t struct. |
distance_cm | Distance in cm to show in the display system. |
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.
p_fsm | Pointer to an fsm_display_t struct. |
state | New state of the display FSM. |
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
p_fsm | Pointer to an fsm_display_t struct. |
pause | Status of the display system. true if the display system is paused, false if the display system is active. |