fix standby picture not toggling

This commit is contained in:
reaw 2024-02-16 13:46:02 +07:00
parent b537d3921e
commit 44687da028

View file

@ -782,38 +782,39 @@ void ISEDisplay::updateAirPurifierStateStandby()
void ISEDisplay::updateAirPurifierState() void ISEDisplay::updateAirPurifierState()
{ {
//check for page //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; return;
} }
else if(currentPage ==1){
else if(currentPage == 1){
updateAirPurifierStateStandby(); updateAirPurifierStateStandby();
return; 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) void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature)
{ {
@ -898,48 +899,64 @@ void ISEDisplay::updateACState()
// Get the state // Get the state
uint8_t mode = this->climateCard->getMode(); uint8_t mode = this->climateCard->getMode();
uint8_t temperature = this->climateCard->getTemperature(); 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 this->displayAdapter->print("ac_temp.pic=");
if (mode == 0) this->displayAdapter->print(COMPONENT_AC_STATUS_OFF);
{ this->sendStopBytes();
this->displayAdapter->print("ac_temp.pco="); }
this->displayAdapter->print(33841); 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->sendStopBytes();
this->displayAdapter->print("ac_temp.pic="); updateuserACmode();
this->displayAdapter->print(COMPONENT_AC_STATUS_OFF);
updateACfanSpeed();
this->displayAdapter->print("ac_temp.val=");
this->displayAdapter->print(temperature);
// this->displayAdapter->print("\"");
this->sendStopBytes(); this->sendStopBytes();
this->giveSerialMutex();
} }
else else if (currentPage == 1)
{ {
this->displayAdapter->print("ac_temp.pco="); this->takeSerialMutex();
this->displayAdapter->print(34486);
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->sendStopBytes();
this->displayAdapter->print("ac_temp.pic="); this->displayAdapter->print("s_ac_toggle.pic2=");
this->displayAdapter->print(COMPONENT_AC_STATUS_ON); this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON_PRESSED : COMPONENT_STANDBY_AC_PIC_OFF_PRESSED);
this->sendStopBytes(); 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"); ESP_LOGI("ISEDisplay", "display AC state updated");
} }