bool check_comfort(fsm_t *p_this)
Check if the temperature is hot enough to deactivate the thermostat.
void do_thermostat_on(fsm_t *p_this)
Turn off the thermostat.
port_temp_hw_t * p_temp_sensor
uint8_t fsm_thermostat_get_status(fsm_t *p_this)
Gets the thermostat status.
double port_temp_sensor_get_temperature(port_temp_hw_t *pir_sensor)
Gets the temperature in Celsius of the temperature sensor.
void port_led_init(port_led_hw_t *p_led)
Initializes the LED.
#define THERMOSTAT_DEFAULT_THRESHOLD
Structure to define the HW dependencies of a LED.
Structure to define the thermostat FSM.
double threshold_temp_celsius
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.
bool last_events[THERMOSTAT_HISTORY]
Header file for the thermostat FSM.
void port_led_off(port_led_hw_t *p_led)
Turn off the LED.
void port_temp_sensor_init(port_temp_hw_t *pir_sensor)
Initializes the temperature sensor.
Header file for the temperature sensor port layer.
Header file for the LED port layer.
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,...
void port_thermostat_timer_setup(fsm_thermostat_t *p_thermostat)
Initializes the timer of the thermostat.
#define THERMOSTAT_TIMEOUT_SEC
uint32_t port_system_get_millis(void)
Get the count of the System tick in milliseconds.
void do_thermostat_off(fsm_t *p_this)
Turn on the thermostat.
uint32_t timer_period_sec
Structure to define the HW dependencies of a temperature sensor.
port_led_hw_t * p_led_comfort
Header file for the thermostat system port layer.
fsm_trans_t fsm_trans_thermostat[]
Transitions table for the thermostat.
void fsm_thermostat_init(fsm_t *p_this, port_led_hw_t *p_led_heat, port_led_hw_t *p_led_comfort, port_temp_hw_t *p_temp)
Initialize the thermostat FSM.
#define THERMOSTAT_HISTORY
uint32_t last_time_events[THERMOSTAT_HISTORY]
void port_led_on(port_led_hw_t *p_led)
Turn on the LED.
port_led_hw_t * p_led_heat
bool check_heat(fsm_t *p_this)
Check if the temperature is cold enough to activate the thermostat.