From 733ed54f9bee7a91926bf64d142c8811f6b80a53 Mon Sep 17 00:00:00 2001 From: reaw Date: Fri, 9 Feb 2024 10:11:44 +0700 Subject: [PATCH] fix pm fan speed --- ise-display/ise-display-prod.HMI | Bin 37446253 -> 37446253 bytes src/ise_display.cpp | 67 ++++++++++++++++++++----------- src/ise_display.hpp | 8 ++++ 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/ise-display/ise-display-prod.HMI b/ise-display/ise-display-prod.HMI index ac9122b18c4b822521fe31a0bc3197eaa5f9fe6f..c39453341d45eb75fceb68fe20eb5e4d35e0d026 100644 GIT binary patch delta 1797 zcmd7R=f4+nAII_Y`nFI~)~QZp9Gl2&7(cs^?7bRBD243Zn+{&)vG>jv2N@xhy&^jl ziRf@5dtJZB^|)?be}T{A@w)Z-+<4ykG*4;n++1x!m(sOn@bHm6`wtvY^S_zicT`QM zwly_0^(wWc`-uNrw~QbC-*rvPm^MwrTHB6Zjq}^rwyK#tsIh&Asnj%1>re|#b363t z*m~&9S@RlOx^)>_UpKD4j%uY^t7@&QwW-#2Vtrk^1#|uliW#%VR_ex8s?182S*bEB zRc58itW=qmx^|QQ6$ed~x=KTOr%(E(UpCGr*)*G_lFhS4w#-)9I@@I1^v{57m+iAd z24=?$%1+riyJXkwmff>Q_RL<{JNsnc?3ev>Kn~178Jr;*nqfIOhvd*4mf<-(N94$i z$jBU(Q5l`1b4-rSm>iemb3#tcNjW*EwYhtiaX^GF`e#5|VA^F*G^q&$_U^Gqh^**ur$GbK~=LSD>Ec{#7-)x4J1^G4px zTbY)(^G>Gc-Mp9g^Fcn$NBKB2@<~3;XPKE<`8;1_cD~G=H{ayj%u92=%lB!? z{QQs~vmig^=lqgi^ILw;ANezX$6*7Wi|66_ zC|-aU;zf8dUV@imBVLA=;}v)%UWHfVHFzyvhu7l`cq86~H{&gME8d2;;~h92@5H62_QejxMT;GaixoQ+I~Nx(E>T>vxKwfJVr{WYv1_qgv98#?xJ+@` zVvpi-#pR1D6jvcusR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Kt;bU&m?q2EK{Y@hyBC-@$kBJ$xTOz!~@<62&Epb;ZubF2%0J`eL`@QpKf< z-HXc|N|r>{}-EE5io=4;So<<^TWy diff --git a/src/ise_display.cpp b/src/ise_display.cpp index 95e443f..1006f8d 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -17,18 +17,35 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange); this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange); this->user_mode = 1; // initialized to cool by default + this->pm_fan_speed = 10; + this->ac_fan_speed = 0; + this->ac_mode = 0; + this->ac_temperature = 25; + this->lightLevelRow1 = 0; + this->lightLevelRow2 = 0; + this->lightLevelRow3 = 0; + this->lightLevelRow4 = 0; this->time_since_last_screen_update = 0; this->registerTouchCallback(bindedHandleTouch); this->reset(); delay(1000); // TODO : Will the light be on or off when the system is started?, You need to jump to its respective page // first jump to main then if no activity jump to standby - this->jumpToPage(1); // change this back later to 2 + this->jumpToPage(2); // change this back later to 2 delay(100); this->updateAirPurifierState(); this->updateACState(); this->updateLightGroupStatePageDashboard(); this->updateLightGroupStatePageStandby(); + this->outputCard->setValue(6,pm_fan_speed); + this->outputCard->setValue(5,0); + this->outputCard->setValue(1,0); + this->outputCard->setValue(2,0); + this->outputCard->setValue(3,0); + this->outputCard->setValue(4,0); + // this->climateCard->setTemperature(ac_temperature); + // this->climateCard->setFanSpeed(ac_fan_speed); + // this->climateCard->setMode(ac_mode); } void ISEDisplay::loop() { @@ -43,13 +60,18 @@ void ISEDisplay::loop() if (current_time - this->time_since_last_screen_update > 120000) { // jump to standby page if there is no activity for 2 minutes - this->jumpToPage(1); + if(this->currentPage != 1){ + this->jumpToPage(1); + ESP_LOGI("ISEDisplay", "Jumping to standby page"); + } + ESP_LOGI("ISEDisplay", "No activity for 2 minutes & currently at standby page"); } } void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type) { ESP_LOGD("ISEDisplay", "Touch detected on page %d, component %d, touch type %d", page, component, touch_type); + time_since_last_screen_update = millis(); // update time since last activity if (page == PAGE_STANDBY) { switch (component) @@ -81,7 +103,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type case COMPONENT_STANDBY_PM_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - togglePM(); + togglePMStandby(); break; default: break; @@ -90,12 +112,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type else if (page == PAGE_DASHBOARD) { - u_int8_t pm_fan_speed = 0; - u_int8_t fan_speed = 0; - u_int8_t lightLevelRow1 = 0; - u_int8_t lightLevelRow2 = 0; - u_int8_t lightLevelRow3 = 0; - u_int8_t lightLevelRow4 = 0; + switch (component) { @@ -188,10 +205,10 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type case COMPONENT_AC_FAN_SPEED: if (touch_type != TOUCH_TYPE_RELEASE) break; - fan_speed = this->climateCard->getFanSpeed(); + ac_fan_speed = this->climateCard->getFanSpeed(); // We have auto, low, mid, high right?, that's 0,1,2,3 a modulo operation of 3 only gives 0,1,2 // mod 4 should fixed it - this->climateCard->setFanSpeed((fan_speed + 1) % 4); + this->climateCard->setFanSpeed((ac_fan_speed + 1) % 4); updateACState(); break; case COMPONENT_AC_TEMP_DOWN_BUTTON: @@ -215,16 +232,20 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; pm_fan_speed = this->outputCard->getValue(6); - if (pm_fan_speed >= 0 && pm_fan_speed <= 20) - this->outputCard->setValue(5, (pm_fan_speed - 1)); + ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed); + if (pm_fan_speed >=1 && pm_fan_speed <= 20) + this->outputCard->setValue(6, (pm_fan_speed - 1)); + ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed); updateAirPurifierState(); break; case COMPONENT_PM_FAN_SPEED_INCREASE: if (touch_type != TOUCH_TYPE_RELEASE) break; pm_fan_speed = this->outputCard->getValue(6); - if (pm_fan_speed >= 0 && pm_fan_speed <= 20) - this->outputCard->setValue(5, (pm_fan_speed + 1)); + ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed); + if (pm_fan_speed >= 0 && pm_fan_speed <= 19) + this->outputCard->setValue(6, (pm_fan_speed + 1)); + ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed); updateAirPurifierState(); break; default: @@ -368,14 +389,14 @@ void ISEDisplay::updateTempOutside(float temp_outside) // change temp_outside to int then display u_int8_t temp_outside_int = (u_int8_t)temp_outside; this->takeSerialMutex(); - this->displayAdapter->printf("temp_outside.txt=\"%d\"", temp_outside_int); + this->displayAdapter->printf("temp_outside.txt=%d", temp_outside_int); this->sendStopBytes(); this->giveSerialMutex(); } void ISEDisplay::updatePMoutside(u_int16_t pm25_outside) { this->takeSerialMutex(); - this->displayAdapter->printf("pm_outside.txt=\"%d\"", pm25_outside); + this->displayAdapter->printf("pm_outside.txt=%d", pm25_outside); this->sendStopBytes(); this->giveSerialMutex(); // TODO : use remotevar to get PM2.5 data from appdaemon and update the display @@ -652,7 +673,7 @@ void ISEDisplay::updateAirPurifierState() { // Get the state bool state = this->outputCard->getState(5); - uint8_t fan_speed = this->outputCard->getState(6); + pm_fan_speed = this->outputCard->getValue(6); // Send the state to the display this->takeSerialMutex(); @@ -664,9 +685,9 @@ void ISEDisplay::updateAirPurifierState() this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED); this->sendStopBytes(); - this->displayAdapter->print("pm_speed.txt=\""); - this->displayAdapter->print(fan_speed); - this->displayAdapter->print("\""); + this->displayAdapter->print("pm_speed.val="); + this->displayAdapter->print(pm_fan_speed); + //this->displayAdapter->print("\""); this->sendStopBytes(); this->displayAdapter->print("pm_speed.pco="); @@ -788,9 +809,9 @@ void ISEDisplay::updateACState() updateACfanSpeed(); - this->displayAdapter->print("ac_temp.txt=\""); + this->displayAdapter->print("ac_temp.val="); this->displayAdapter->print(temperature); - this->displayAdapter->print("\""); + //this->displayAdapter->print("\""); this->sendStopBytes(); this->giveSerialMutex(); diff --git a/src/ise_display.hpp b/src/ise_display.hpp index 353efac..8727675 100644 --- a/src/ise_display.hpp +++ b/src/ise_display.hpp @@ -45,7 +45,15 @@ class ISEDisplay : public ESPMegaDisplay { uint8_t outputCallbackHandle; uint8_t climateCallbackHandle; uint8_t user_mode; + uint8_t ac_mode; + uint8_t ac_fan_speed; + uint8_t ac_temperature; + uint8_t pm_fan_speed; uint8_t time_since_last_screen_update; + u_int8_t lightLevelRow1; + u_int8_t lightLevelRow2; + u_int8_t lightLevelRow3; + u_int8_t lightLevelRow4; void updateuserACmode();