FSM thermostat
fsm_thermostat.h File Reference

Header file for the thermostat FSM. More...

#include <stdint.h>
#include <fsm.h>
#include "port_led.h"
#include "port_temp_sensor.h"

Go to the source code of this file.

Data Structures

struct  fsm_thermostat_t
 Structure to define the thermostat FSM. More...
 

Macros

#define THERMOSTAT_TIMEOUT_SEC   1
 
#define THERMOSTAT_HISTORY   10
 
#define THERMOSTAT_DEFAULT_THRESHOLD   25
 

Enumerations

enum  FSM_THERMOSTAT_STATES {
  THERMOSTAT_OFF = 0,
  THERMOSTAT_ON
}
 Enumerates the states of the thermostat FSM. More...
 
enum  THERMOSTAT_EVENTS {
  UNKNOWN = -1,
  ACTIVATION = 0,
  DEACTIVATION
}
 Enumerates the events of the thermostat FSM. More...
 

Functions

fsm_t * fsm_thermostat_new (port_led_hw_t *p_led_heat, port_led_hw_t *p_led_comfort, port_temp_hw_t *p_temp)
 Creates a new thermostat FSM. More...
 
uint32_t fsm_thermostat_get_last_time_event (fsm_t *p_this, uint8_t event)
 Gets the last time there was an event in the thermostat. If the event is not found, it returns 0. More...
 
uint8_t fsm_thermostat_get_status (fsm_t *p_this)
 Gets the thermostat status. More...
 

Detailed Description

Header file for the thermostat FSM.

Author
Josué Pagán (j.pag.nosp@m.an@u.nosp@m.pm.es)
Date
2024-05-01

Definition in file fsm_thermostat.h.

Macro Definition Documentation

◆ THERMOSTAT_DEFAULT_THRESHOLD

#define THERMOSTAT_DEFAULT_THRESHOLD   25

Threshold temperature to activate the thermostat

Definition at line 25 of file fsm_thermostat.h.

◆ THERMOSTAT_HISTORY

#define THERMOSTAT_HISTORY   10

Number of events to store in the thermostat

Definition at line 24 of file fsm_thermostat.h.

◆ THERMOSTAT_TIMEOUT_SEC

#define THERMOSTAT_TIMEOUT_SEC   1

Timeout for the thermostat to be activated

Definition at line 23 of file fsm_thermostat.h.

Enumeration Type Documentation

◆ FSM_THERMOSTAT_STATES

Enumerates the states of the thermostat FSM.

Enumerator
THERMOSTAT_OFF 

Thermostat is off

THERMOSTAT_ON 

Thermostat is on

Definition at line 32 of file fsm_thermostat.h.

◆ THERMOSTAT_EVENTS

Enumerates the events of the thermostat FSM.

Enumerator
UNKNOWN 

Unknown event

ACTIVATION 

Thermostat activated

DEACTIVATION 

Thermostat deactivated

Definition at line 42 of file fsm_thermostat.h.

Function Documentation

◆ fsm_thermostat_get_last_time_event()

uint32_t fsm_thermostat_get_last_time_event ( fsm_t *  p_this,
uint8_t  event 
)

Gets the last time there was an event in the thermostat. If the event is not found, it returns 0.

Parameters
p_thisPointer to the thermostat FSM structure.
eventEvent to check. It can be any of the events in the THERMOSTAT_EVENTS enum.

Definition at line 108 of file fsm_thermostat.c.

◆ fsm_thermostat_get_status()

uint8_t fsm_thermostat_get_status ( fsm_t *  p_this)

Gets the thermostat status.

Parameters
p_thisPointer to the thermostat FSM structure.

Definition at line 123 of file fsm_thermostat.c.

◆ fsm_thermostat_new()

fsm_t* fsm_thermostat_new ( port_led_hw_t p_led_heat,
port_led_hw_t p_led_comfort,
port_temp_hw_t p_temp 
)

Creates a new thermostat FSM.

Parameters
p_led_heatPointer to the LED of the thermostat.
p_led_comfortPointer to the comfort LED of the thermostat.
p_tempPointer to the temperature sensor of the thermostat.
Returns
fsm_thermostat_t* Pointer to the new thermostat FSM.

Definition at line 174 of file fsm_thermostat.c.