Ajout Thermostat
This commit is contained in:
35
Thermostat/src/thermostat.cpp
Normal file
35
Thermostat/src/thermostat.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "thermostat.h"
|
||||
|
||||
Thermostat::Thermostat() : mode(MODE_OFF), targetTemp(0), heating(false) {
|
||||
presetTemps[MODE_CONFORT] = 21.0;
|
||||
presetTemps[MODE_ECO] = 18.0;
|
||||
presetTemps[MODE_BOOST] = 23.0;
|
||||
presetTemps[MODE_HORS_GEL] = 7.0;
|
||||
presetTemps[MODE_OFF] = 0.0;
|
||||
}
|
||||
|
||||
void Thermostat::setMode(ThermostatMode m) {
|
||||
mode = m;
|
||||
targetTemp = presetTemps[mode];
|
||||
}
|
||||
|
||||
void Thermostat::setTemperature(float temp) {
|
||||
targetTemp = temp;
|
||||
}
|
||||
|
||||
void Thermostat::setPresetTemp(ThermostatMode m, float temp) {
|
||||
presetTemps[m] = temp;
|
||||
if (mode == m) targetTemp = temp;
|
||||
}
|
||||
|
||||
void Thermostat::update(float currentTemp) {
|
||||
if (mode == MODE_OFF) {
|
||||
heating = false;
|
||||
} else {
|
||||
heating = (currentTemp < targetTemp);
|
||||
}
|
||||
}
|
||||
|
||||
bool Thermostat::isHeating() const { return heating; }
|
||||
ThermostatMode Thermostat::getMode() const { return mode; }
|
||||
float Thermostat::getTargetTemp() const { return targetTemp; }
|
||||
Reference in New Issue
Block a user