Urbanite: Parking aid system
fsm_urbanite.h File Reference

Header for fsm_urbanite.c file. More...

#include <stdint.h>
#include "fsm_button.h"
#include "fsm_display.h"
#include "fsm_ultrasound.h"

Typedefs

typedef struct fsm_urbanite_t fsm_urbanite_t
 Structure that contains the information of the Urbanite FSM. More...
 

Enumerations

enum  FSM_URBANITE {
  OFF = 0,
  MEASURE,
  SLEEP_WHILE_OFF,
  SLEEP_WHILE_ON
}
 Enumerator for the Urbanite finite state machine. More...
 

Functions

fsm_urbanite_tfsm_urbanite_new (fsm_button_t *p_fsm_button, uint32_t on_off_press_time_ms, uint32_t pause_display_time_ms, fsm_ultrasound_t *p_fsm_ultrasound_rear, fsm_display_t *p_fsm_display_rear)
 Create a new Urbanite FSM. More...
 
void fsm_urbanite_fire (fsm_urbanite_t *p_fsm)
 Fire the Urbanite FSM. More...
 
void fsm_urbanite_destroy (fsm_urbanite_t *p_fsm)
 Destroy an Urbanite FSM. More...
 

Detailed Description

Header for fsm_urbanite.c file.

Author
Sistemas Digitales II
Date
2025-01-01

Typedef Documentation

◆ fsm_urbanite_t

Structure that contains the information of the Urbanite FSM.

Enumeration Type Documentation

◆ FSM_URBANITE

Enumerator for the Urbanite finite state machine.

This enumerator defines the different states that the Urbanite finite state machine can be in. Each state represents a specific condition or step in the process of showing the distance to the nearest obstacle.

Enumerator
OFF 

Starting state. Also comes here when the button has been pressed for the required time to turn OFF the Urbanite

MEASURE 

State to measure the distance to the obstacles

SLEEP_WHILE_OFF 

State to start the low power mode while the Urbanite is OFF

SLEEP_WHILE_ON 

State to start the low power mode while the Urbanite is ON

Function Documentation

◆ fsm_urbanite_destroy()

void fsm_urbanite_destroy ( fsm_urbanite_t p_fsm)

Destroy an Urbanite FSM.

This function destroys an Urbanite FSM and frees the memory.

TODO alumnos:

✅ 1. Implement this function analogously to the fsm_button_destroy(), fsm_ultrasound_destroy() and fsm_display_destroy() functions.

Parameters
p_fsmPointer to an fsm_urbanite_t struct.

◆ fsm_urbanite_fire()

void fsm_urbanite_fire ( fsm_urbanite_t p_fsm)

Fire the Urbanite FSM.

This function is used to check the transitions and execute the actions of the Urbanite FSM.

TODO alumnos:

✅ 1. Call function fsm_fire() with the received pointer to fsm_t

Parameters
p_fsmPointer to the fsm_urbanite_t struct.

◆ fsm_urbanite_new()

fsm_urbanite_t* fsm_urbanite_new ( fsm_button_t p_fsm_button,
uint32_t  on_off_press_time_ms,
uint32_t  pause_display_time_ms,
fsm_ultrasound_t p_fsm_ultrasound_rear,
fsm_display_t p_fsm_display_rear 
)

Create a new Urbanite FSM.

This function creates a new Urbanite FSM with the given button, ultrasound, display FSMs and the required times for configuration.

TODO alumnos:

✅ 1. Allocate memory for the fsm_urbanite_t struct in the same way as the fsm_button_new(), fsm_ultrasound_new() and fsm_display_new() functions.
✅ 2. Initialize the fsm_t struct of the Urbanite FSM by calling the fsm_urbanite_init() function.
✅ 3. Return the pointer to the Urbanite FSM once it has been created and initialized.

Parameters
p_fsm_buttonPointer to the button FSM to interact with the Urbanite.
on_off_press_time_msTime in ms to consider ON/OFF of the Urbanite parking aid system.
pause_display_time_msTime in ms to pause the display system.
p_fsm_ultrasound_rearPointer to the rear ultrasound FSM.
p_fsm_display_rearPointer to the rear display FSM.
Returns
fsm_urbanite_t* Pointer to the Urbanite FSM.