display climate implementation

This commit is contained in:
Siwat Sirichai 2023-12-31 00:37:50 +07:00
parent ea2c2e076b
commit 19aae95252
4 changed files with 21 additions and 17 deletions

View file

@ -92,6 +92,18 @@ void ClimateCard::saveStateToFRAM()
void ClimateCard::loadStateFromFRAM()
{
fram->readObject(fram_address, this->state);
// If temperature is out of range, set to its respective maximum or minimum
if (state.ac_temperature > ac.max_temperature)
state.ac_temperature = ac.max_temperature;
else if (state.ac_temperature < ac.min_temperature)
state.ac_temperature = ac.min_temperature;
// If mode is out of range, set to 0
if (state.ac_mode > ac.modes)
state.ac_mode = 0;
// If fan speed is out of range, set to 0
if (state.ac_fan_speed > ac.fan_speeds)
state.ac_fan_speed = 0;
updateAirConditioner();
}
void ClimateCard::setTemperature(uint8_t temperature)