From 44687da028ac974dcca208457fee239b27327603 Mon Sep 17 00:00:00 2001 From: reaw Date: Fri, 16 Feb 2024 13:46:02 +0700 Subject: [PATCH] fix standby picture not toggling --- src/ise_display.cpp | 131 +++++++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 57 deletions(-) diff --git a/src/ise_display.cpp b/src/ise_display.cpp index 646c329..fb762fc 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -782,38 +782,39 @@ void ISEDisplay::updateAirPurifierStateStandby() void ISEDisplay::updateAirPurifierState() { //check for page - if(currentPage != 2){ + if(currentPage != 1){ + // Get the state + bool state = strcmp(pm_switch->getValue(), "on") == 0; + ESP_LOGI("ISEDisplay", "Updating air purifier state to: %d", state); + pm_fan_speed = (int) atof(remote_pm_fan_speed->getValue()); + // Send the state to the display + this->takeSerialMutex(); + + this->displayAdapter->print("pm_sw.pic="); + this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON : COMPONENT_PM_TOGGLE_PIC_OFF); + this->sendStopBytes(); + + this->displayAdapter->print("pm_sw.pic2="); + this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.val="); + this->displayAdapter->print(pm_fan_speed); + // this->displayAdapter->print("\""); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pco="); + this->displayAdapter->print(state ? 34486 : 33841); + this->sendStopBytes(); + + this->giveSerialMutex(); return; } - else if(currentPage ==1){ + + else if(currentPage == 1){ updateAirPurifierStateStandby(); return; } - // Get the state - bool state = strcmp(pm_switch->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Updating air purifier state to: %d", state); - pm_fan_speed = (int) atof(remote_pm_fan_speed->getValue()); - // Send the state to the display - this->takeSerialMutex(); - - this->displayAdapter->print("pm_sw.pic="); - this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON : COMPONENT_PM_TOGGLE_PIC_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("pm_sw.pic2="); - this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.val="); - this->displayAdapter->print(pm_fan_speed); - // this->displayAdapter->print("\""); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pco="); - this->displayAdapter->print(state ? 34486 : 33841); - this->sendStopBytes(); - - this->giveSerialMutex(); } void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature) { @@ -898,48 +899,64 @@ void ISEDisplay::updateACState() // Get the state uint8_t mode = this->climateCard->getMode(); uint8_t temperature = this->climateCard->getTemperature(); + if(currentPage != 1){ + this->takeSerialMutex(); - this->takeSerialMutex(); + // Send the state to the display + if (mode == 0) + { + this->displayAdapter->print("ac_temp.pco="); + this->displayAdapter->print(33841); + this->sendStopBytes(); - // Send the state to the display - if (mode == 0) - { - this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(33841); + this->displayAdapter->print("ac_temp.pic="); + this->displayAdapter->print(COMPONENT_AC_STATUS_OFF); + this->sendStopBytes(); + } + else + { + this->displayAdapter->print("ac_temp.pco="); + this->displayAdapter->print(34486); + this->sendStopBytes(); + + this->displayAdapter->print("ac_temp.pic="); + this->displayAdapter->print(COMPONENT_AC_STATUS_ON); + this->sendStopBytes(); + + user_mode = mode; + } + this->displayAdapter->print("ac_sw.pic="); + this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON : COMPONENT_AC_TOGGLE_PIC_OFF); + this->sendStopBytes(); + this->displayAdapter->print("ac_sw.pic2="); + this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON_PRESSED : COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED); this->sendStopBytes(); - this->displayAdapter->print("ac_temp.pic="); - this->displayAdapter->print(COMPONENT_AC_STATUS_OFF); + updateuserACmode(); + + updateACfanSpeed(); + + this->displayAdapter->print("ac_temp.val="); + this->displayAdapter->print(temperature); + // this->displayAdapter->print("\""); this->sendStopBytes(); + this->giveSerialMutex(); } - else + else if (currentPage == 1) { - this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(34486); + this->takeSerialMutex(); + + this->displayAdapter->print("s_ac_toggle.pic="); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON : COMPONENT_STANDBY_AC_PIC_OFF); this->sendStopBytes(); - this->displayAdapter->print("ac_temp.pic="); - this->displayAdapter->print(COMPONENT_AC_STATUS_ON); + this->displayAdapter->print("s_ac_toggle.pic2="); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON_PRESSED : COMPONENT_STANDBY_AC_PIC_OFF_PRESSED); this->sendStopBytes(); - user_mode = mode; + this->giveSerialMutex(); } - this->displayAdapter->print("ac_sw.pic="); - this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON : COMPONENT_AC_TOGGLE_PIC_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_sw.pic2="); - this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON_PRESSED : COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED); - this->sendStopBytes(); + - updateuserACmode(); - - updateACfanSpeed(); - - this->displayAdapter->print("ac_temp.val="); - this->displayAdapter->print(temperature); - // this->displayAdapter->print("\""); - this->sendStopBytes(); - - this->giveSerialMutex(); ESP_LOGI("ISEDisplay", "display AC state updated"); }