From 20e9544ca4aa082542767eb2d1d5b043f268ac87 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sun, 24 Mar 2024 01:11:43 +0700 Subject: [PATCH] add room temperature display --- src/display.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/display.cpp b/src/display.cpp index a40ed8c..31cfa0f 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -640,7 +640,23 @@ void CUDDisplay::handle_ac_change(uint8_t mode, uint8_t fan_speed, uint8_t tempe void CUDDisplay::handle_ac_sensor(float temperature, float humidity) { - // Not needed for now + // Is the temperature valid? + // A temperature of -999.0 means the sensor is not connected + ESP_LOGV("CUD Display", "AC Sensor Temperature: %f", temperature); + if (temperature == -999.0) + { + // If the temperature is not valid, Send NA to the display + this->takeSerialMutex(); + this->displayAdapter->printf("%s.txt=\"NA\"", LCD_DASHBOARD_ELEMENT_NAME_ROOM_TEMPERATURE); + this->sendStopBytes(); + this->giveSerialMutex(); + return; + } + // Temperature is valid, send it to the display + this->takeSerialMutex(); + this->displayAdapter->printf("%s.txt=\"%d\"", LCD_DASHBOARD_ELEMENT_NAME_ROOM_TEMPERATURE, (int)temperature); + this->sendStopBytes(); + this->giveSerialMutex(); } void CUDDisplay::handle_mqtt_connected()