|
|
|
//
|
|
|
|
// Created by MightyPork on 2022/08/20.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef FANCTL_FANCONTROL_H
|
|
|
|
#define FANCTL_FANCONTROL_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "actuators.h"
|
|
|
|
|
|
|
|
void fancontrol_init();
|
|
|
|
|
|
|
|
enum ventilation_mode {
|
|
|
|
VENT_MODE_OFF = 0,
|
|
|
|
VENT_MODE_FREE = 1,
|
|
|
|
VENT_MODE_OUT = 3,
|
|
|
|
VENT_MODE_IN = 5,
|
|
|
|
VENT_MODE_RECUP = 7,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum recup_mode {
|
|
|
|
/** stricly time based recuperation switching */
|
|
|
|
RECUP_MODE_TIME = 0,
|
|
|
|
/** Temperature-based recuperation switching
|
|
|
|
* (switch direction when further blowing won't save energy) */
|
|
|
|
RECUP_MODE_TEMP = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct FanControlState {
|
|
|
|
/**
|
|
|
|
* Power requested trough register or as the default value.
|
|
|
|
* This value stays unchanged even if stopped, unlike gAct.power which reflects the actual output.
|
|
|
|
*/
|
|
|
|
uint16_t set_power;
|
|
|
|
/**
|
|
|
|
* rezim ventilace. Use fan_set_vent_mode() to change it!
|
|
|
|
*/
|
|
|
|
enum ventilation_mode set_vent_mode;
|
|
|
|
/** Status for the register */
|
|
|
|
enum ventilation_mode instantaneous_vent_mode;
|
|
|
|
|
|
|
|
/* sensors */
|
|
|
|
bool valid_t_indoor;
|
|
|
|
bool valid_t_outdoor;
|
|
|
|
bool valid_t_inflow;
|
|
|
|
bool valid_t_exhaust;
|
|
|
|
bool valid_t_actual_1;
|
|
|
|
bool valid_t_actual_2;
|
|
|
|
|
|
|
|
int16_t t_indoor;
|
|
|
|
int16_t t_outdoor;
|
|
|
|
int16_t t_inflow;
|
|
|
|
int16_t t_exhaust;
|
|
|
|
|
|
|
|
int16_t t_actual_1;
|
|
|
|
int16_t t_actual_2;
|
|
|
|
|
|
|
|
// Private
|
|
|
|
/**
|
|
|
|
* like vent_mode, but if power is 0, becomes OFF
|
|
|
|
*/
|
|
|
|
enum ventilation_mode effective_vent_mode;
|
|
|
|
/**
|
|
|
|
* skutecny aktualni pohyb motoru (zustava stejny, dokud ramp time nedosahne nuly)
|
|
|
|
*/
|
|
|
|
enum motor_direction real_direction;
|
|
|
|
/**
|
|
|
|
* Poloha roletky, 0<->blind_time, inkrement/dekrement 1 za sekundu.
|
|
|
|
* Pri zmene blind_time se musi hodnota aktualizovat, pokud je na doraze nebo za.
|
|
|
|
*/
|
|
|
|
uint16_t blind_position;
|
|
|
|
/**
|
|
|
|
* Cas chodu motoru v aktualnim smeru, inkrement 1 za sekundu.
|
|
|
|
*/
|
|
|
|
uint16_t run_time;
|
|
|
|
/**
|
|
|
|
* "stav chodu motoru". 0=stop, ramp_time = jede.
|
|
|
|
*/
|
|
|
|
uint16_t ramp;
|
|
|
|
int32_t t1_aggr;
|
|
|
|
int32_t t2_aggr;
|
|
|
|
uint32_t t_aggr_cnt;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct FanControlState gState;
|
|
|
|
|
|
|
|
void fan_set_vent_mode(enum ventilation_mode mode);
|
|
|
|
void fan_set_power(uint16_t power);
|
|
|
|
|
|
|
|
#endif //FANCTL_FANCONTROL_H
|