Ajout stockage EEPROM
This commit is contained in:
@@ -1,27 +1,42 @@
|
||||
#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_CONFORT] = 20.0;
|
||||
presetTemps[MODE_ECO] = 17.0;
|
||||
presetTemps[MODE_BOOST] = 22.0;
|
||||
presetTemps[MODE_HORS_GEL] = 7.0;
|
||||
presetTemps[MODE_OFF] = 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the thermostat mode. This will automatically update the target temperature to the preset for that mode.
|
||||
*/
|
||||
void Thermostat::setMode(ThermostatMode m) {
|
||||
mode = m;
|
||||
targetTemp = presetTemps[mode];
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually set the target temperature. This does not change the mode or presets, but will override the preset for the
|
||||
* current mode until the mode is changed again.
|
||||
*/
|
||||
void Thermostat::setTemperature(float temp) {
|
||||
targetTemp = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the preset temperature for a specific mode. If the current mode is the one being updated, also update the
|
||||
* target temperature.
|
||||
*/
|
||||
void Thermostat::setPresetTemp(ThermostatMode m, float temp) {
|
||||
presetTemps[m] = temp;
|
||||
if (mode == m) targetTemp = temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the heating state based on the current temperature and target temperature.
|
||||
* this is real simple logic: if current temp is below target, turn on heating, otherwise turn it off. In a real system, you would want to add some hysteresis to prevent rapid on/off cycling.
|
||||
*/
|
||||
void Thermostat::update(float currentTemp) {
|
||||
if (mode == MODE_OFF) {
|
||||
heating = false;
|
||||
|
||||
Reference in New Issue
Block a user