diff --git a/ise-display/fonts/BaiJ-48-ascii.zi b/ise-display/fonts/BaiJ-48-ascii.zi new file mode 100644 index 0000000..4d572a4 Binary files /dev/null and b/ise-display/fonts/BaiJ-48-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-B-24-ascii.zi b/ise-display/fonts/BaiJ-B-24-ascii.zi new file mode 100644 index 0000000..c1d9392 Binary files /dev/null and b/ise-display/fonts/BaiJ-B-24-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-B-40.zi b/ise-display/fonts/BaiJ-B-40.zi new file mode 100644 index 0000000..3bd944c Binary files /dev/null and b/ise-display/fonts/BaiJ-B-40.zi differ diff --git a/ise-display/fonts/BaiJ-B-48-ascii.zi b/ise-display/fonts/BaiJ-B-48-ascii.zi new file mode 100644 index 0000000..81aabaa Binary files /dev/null and b/ise-display/fonts/BaiJ-B-48-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-24-ascii.zi b/ise-display/fonts/BaiJ-sb-24-ascii.zi new file mode 100644 index 0000000..1d0861a Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-24-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-72-ascii.zi b/ise-display/fonts/BaiJ-sb-72-ascii.zi new file mode 100644 index 0000000..16c1773 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-72-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-80-ascii.zi b/ise-display/fonts/BaiJ-sb-80-ascii.zi new file mode 100644 index 0000000..407cd64 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-80-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-86-ascii.zi b/ise-display/fonts/BaiJ-sb-86-ascii.zi new file mode 100644 index 0000000..6f27432 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-86-ascii.zi differ diff --git a/ise-display/fonts/baiJ-B-32-ascii.zi b/ise-display/fonts/baiJ-B-32-ascii.zi new file mode 100644 index 0000000..18a8e5c Binary files /dev/null and b/ise-display/fonts/baiJ-B-32-ascii.zi differ diff --git a/ise-display/fonts/baiJ-sb-32-ascii.zi b/ise-display/fonts/baiJ-sb-32-ascii.zi new file mode 100644 index 0000000..72dae21 Binary files /dev/null and b/ise-display/fonts/baiJ-sb-32-ascii.zi differ diff --git a/ise-display/ise-display-v2.tft b/ise-display/ise-display-v2.tft new file mode 100644 index 0000000..f64401e Binary files /dev/null and b/ise-display/ise-display-v2.tft differ diff --git a/src/ise_display.cpp b/src/ise_display.cpp index b685b7b..70275b5 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -26,7 +26,8 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar this->user_mode = 2; // initialized to cool by default this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; // initialized to get value this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; // initialized to get value - this->pm_fan_speed = 10; + this->pm_fan_speed = 18; + remote_pm_fan_speed->setIntValue(this->pm_fan_speed); // remote_pm_fan_speed->setValue(pm_fan_speed); this->ac_fan_speed = 0; this->ac_mode = 0; @@ -37,6 +38,8 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar this->lightLevelRow4 = 0; this->time_since_last_ac_change = 0; this->ac_press_pending = false; + this->time_since_ac_staggered_start_call = 0; + this->ac_staggered_start_call_pending = false; // this->time_since_last_screen_update = 0; this->registerTouchCallback(bindedHandleTouch); this->reset(); @@ -46,6 +49,7 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar delay(100); this->updateAirPurifierState(); this->updateSystemtoggle(); + this->updateAllStandbyToggle(); this->updateACState(); this->updateLightGroupStatePageDashboard(); @@ -62,7 +66,7 @@ void ISEDisplay::loop() recieveSerialCommand(); // Check if the AC state has been changed - if (ac_press_pending && (millis() - time_since_last_ac_change) > 5000) + if (ac_press_pending && (millis() - time_since_last_ac_change) > 500) { ESP_LOGI("ISEDisplay", "Sending AC IR code"); sendACIRcode(); @@ -70,6 +74,15 @@ void ISEDisplay::loop() ac_press_pending = false; ESP_LOGI("ISEDisplay", "AC press pending set to false"); } + // check for ac staggered start + if (ac_staggered_start_call_pending && (millis() - time_since_ac_staggered_start_call) > 3000) + { + ESP_LOGI("ISEDisplay", "Sending Staggered AC IR code (York)"); + sendACIRcode(); + ESP_LOGI("ISEDisplay", "AC Staggered AC IR code (York) sent"); + ac_staggered_start_call_pending = false; + ESP_LOGI("ISEDisplay", "AC staggered start call pending set to false"); + } // Check if the MQTT connection has been lost static uint32_t last_mqtt_connected_check = 0; @@ -136,10 +149,15 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type { switch (component) { + case COMPONENT_OBJ_STANDBY_LOGO: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + //this->jumpToPage(2); + break; case COMPONENT_OBJ_STANDBY_BTN_OPEN_ALL_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - allOn(); + //allToggleStandby(); this->jumpToPage(2); // the function of the button is to open the dashboard from standby break; @@ -151,7 +169,8 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type case COMPONENT_OBJ_STANDBY_BTN_AC_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - if (this->ac_lock_state == true){ + if (this->ac_lock_state == true) + { ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); break; } @@ -201,7 +220,8 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; // if ac_lock is true do nothing - if (this->ac_lock_state == true){ + if (this->ac_lock_state == true) + { ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); break; } @@ -217,7 +237,8 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; // if ac_lock is true do nothing - if (this->ac_lock_state == true){ + if (this->ac_lock_state == true) + { ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); break; } @@ -229,7 +250,8 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; // if ac_lock is true do nothing - if (this->ac_lock_state == true){ + if (this->ac_lock_state == true) + { ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); break; } @@ -241,7 +263,8 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; // if pm_lock is true do nothing - if (this->pm_lock_state == true){ + if (this->pm_lock_state == true) + { ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); break; } @@ -298,6 +321,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type if (touch_type != TOUCH_TYPE_RELEASE) break; // implement pm speed change + changePMfanspeed(); break; case COMPONENT_OBJ_DASHBOARD_BTN_PM_MODE: if (touch_type != TOUCH_TYPE_RELEASE) @@ -307,6 +331,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_MASTER_LIGHT: break; case COMPONENT_OBJ_DASHBOARD_LOGO: + jumpToPage(1); break; case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_PM_LOCK: if (touch_type != TOUCH_TYPE_RELEASE) @@ -426,6 +451,7 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) { // Light updateLightGroupStatePageStandby(); + updateAllStandbyToggle(); // time_since_last_screen_update = millis(); // update time since last activity } } @@ -435,6 +461,7 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) { // Light updateLightGroupStatePageDashboard(); + updateSystemtoggle(); // time_since_last_screen_update = millis(); // update time since last activity } } @@ -529,12 +556,13 @@ void ISEDisplay::setAClockstate(bool is_ac_lock_on) void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature) { + ESP_LOGI("ISEDisplay", "AC state before change is: fan speed: %d, mode: %d, temperature: %d", this->ac_fan_speed, this->ac_mode, this->ac_temperature); ESP_LOGI("ISEDisplay", "Setting AC state in memory to: = fan speed: %d, mode: %d, temperature: %d", ac_fan_speed, ac_mode, ac_temperature); this->ac_fan_speed = ac_fan_speed; this->ac_mode = ac_mode; this->ac_temperature = ac_temperature; - //check ac_temp is within bound of daikin + // check ac_temp is within bound of daikin if (this->ac_temperature < DAIKIN_MIN_TEMP) { this->ac_temperature = DAIKIN_MIN_TEMP; @@ -546,21 +574,30 @@ void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_te this->time_since_last_ac_change = millis(); this->ac_press_pending = true; updateACState(); + updateSystemtoggle(); + updateAllStandbyToggle(); } void ISEDisplay::sendACIRcode() { uint8_t cur_ac_fan_speed = this->ac_fan_speed; uint8_t cur_ac_mode = this->ac_mode; + uint8_t before_change_ac_mode = this->climateCard_daikin->getMode(); uint8_t cur_ac_temperature = this->ac_temperature; uint8_t york_temp = cur_ac_temperature; // this->climateCard->setFanSpeed(ac_fan_speed); ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", cur_ac_fan_speed); // this->climateCard->setMode(ac_mode); + ESP_LOGI("ISEDisplay", "AC mode before change is set to: %d", before_change_ac_mode); ESP_LOGI("ISEDisplay", "AC mode set to: %d", cur_ac_mode); // this->climateCard->setTemperature(ac_temperature); ESP_LOGI("ISEDisplay", "AC temperature set to: %d", cur_ac_temperature); // check if temp is within range of min and max for york if not set an min or max for only york - this->climateCard_daikin->setState(cur_ac_mode, cur_ac_fan_speed, cur_ac_temperature); + if (ac_staggered_start_call_pending == false) + { + ESP_LOGI("ISEDisplay", "AC Staggered start call pending is false"); + this->climateCard_daikin->setState(cur_ac_mode, cur_ac_fan_speed, cur_ac_temperature); + ESP_LOGI("ISEDisplay", "Daikin AC IR code sent"); + } if (cur_ac_temperature < YORK_MIN_TEMP) { york_temp = YORK_MIN_TEMP; @@ -569,16 +606,37 @@ void ISEDisplay::sendACIRcode() { york_temp = YORK_MAX_TEMP; } - if (ac_mode == 3) + if (cur_ac_mode == 3 && ac_staggered_start_call_pending == false) { + ESP_LOGI("ISEDisplay", "AC Staggered start call pending is false"); this->climateCard_york->setState(0, cur_ac_fan_speed, york_temp); + ESP_LOGI("ISEDisplay", "York AC IR code sent to off mode due to swtiching to dry on Daikin"); } else { - this->climateCard_york->setState(cur_ac_mode, cur_ac_fan_speed, york_temp); + // want to stagger start york ac when change state from off (mode 0) to on (mode 1,2,3) by 1 sec without delaying other code + if (before_change_ac_mode == 0 && ac_staggered_start_call_pending == false) + { + ESP_LOGI("ISEDisplay", "cur_ac_mode is 0 and ac_staggered_start_call_pending is false"); + this->time_since_ac_staggered_start_call = millis(); + this->ac_staggered_start_call_pending = true; + ESP_LOGI("ISEDisplay", "AC staggered start call pending set to true and call time set to current time"); + } + else + { + ESP_LOGI("ISEDisplay", "AC Staggered start call pending is true or cur_ac_mode is not 0"); + this->climateCard_york->setState(cur_ac_mode, cur_ac_fan_speed, york_temp); + ESP_LOGI("ISEDisplay", "York AC IR code sent"); + // wondering if there is a case where the ac_staggered_start_call_pending is not set to false after setState have been called + } } // get value of mode fanspeed and temp and print compare to store value ESP_LOGI("ISEDisplay", "AC IR code sent"); + ESP_LOGI("ISEDisplay", "NOTE: ac_staggered_start_call_pending is %d", ac_staggered_start_call_pending); + if (ac_staggered_start_call_pending == true) + { + ESP_LOGI("ISEDisplay", "thus the york ac will not be set to current mode if ac_staggered_start_call_pending is true will be trigger after 1 sec"); + } ESP_LOGI("ISEDisplay", "Daikin fan speed: %d, Daikin mode: %d, Daikin temperature: %d", cur_ac_fan_speed, cur_ac_mode, cur_ac_temperature); ESP_LOGI("ISEDisplay", "York fan speed: %d, York mode: %d, York temperature: %d", cur_ac_fan_speed, cur_ac_mode, york_temp); ESP_LOGI("ISEDisplay", "getting value of mode, fanspeed and temp from climate card"); @@ -596,6 +654,7 @@ void ISEDisplay::toggleLightGroupState() { setLightLevel(i, state ? 0 : 3); } + // for loop might slow it down maybe? idk } void ISEDisplay::setLightGroupState(uint8_t level) { @@ -622,12 +681,21 @@ void ISEDisplay::toggleLightGroupStateStandby() void ISEDisplay::togglePM() { // Get the current group state - bool state = strcmp(pm_switch->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Current PM state: %d", state); - // Toggle the state - pm_switch->setValue(state ? "off" : "on"); - ESP_LOGI("ISEDisplay", "New PM state: %d", state); - // updateAirPurifierState(); + bool ispmlock = this->pm_lock_state; + if (ispmlock) + { + ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); + return; + } + else + { + bool state = strcmp(pm_switch->getValue(), "on") == 0; + ESP_LOGI("ISEDisplay", "Current PM state: %d", state); + // Toggle the state + pm_switch->setValue(state ? "off" : "on"); + ESP_LOGI("ISEDisplay", "New PM state: %d", state); + // updateAirPurifierState(); + } } void ISEDisplay::toggleACLock() { @@ -699,23 +767,71 @@ void ISEDisplay::changeUserACmode() // uint8_t mode = this->climateCard_daikin->getMode(); ESP_LOGI("ISEDisplay", "Current actual AC mode: %d", mode); // Toggle the state - // user mode alternate between 1 and 2 + // user mode alternate between 1, 2, and 3 ESP_LOGI("ISEDisplay", "User mode BEFORE: %d", user_mode); - user_mode = (user_mode) % 2 + 1; + // user_mode = (user_mode) % 3 + 1; //loop from 1 to 2 to 3 then back to 1 + // Cycle user_mode from 2 to 1 to 3 + switch (user_mode) + { + case 2: // If current mode is cool (2), change to fan (1) + user_mode = 1; + break; + case 1: // If current mode is fan (1), change to dry (3) + user_mode = 3; + break; + case 3: // If current mode is dry (3), change to cool (2) + default: + user_mode = 2; + break; + } ESP_LOGI("ISEDisplay", "User mode AFTER: %d", user_mode); if (mode != 0) { // update mode to new mode mode = user_mode; ESP_LOGI("ISEDisplay", "change actual AC mode to user mode: %d", mode); + setACstate(this->ac_fan_speed, mode, this->ac_temperature); } else { // ie mode is off // do nothing as the state is keep in user_mode // the mode will change to user_mode when turn on by toggleAC() - ESP_LOGI("ISEDisplay", "do nothing; user mode: %d , actual mode: %d", user_mode, mode); + ESP_LOGI("ISEDisplay", "update just user mode display; user mode: %d , actual mode: %d", user_mode, mode); + updateuserACmode(); } - updateuserACmode(); // call to update mode part of the display seperately + + // updateuserACmode(); // call to update mode part of the display seperately +} +void ISEDisplay::changePMfanspeed() +{ + // Get the current group state + uint8_t fan_speed = this->pm_fan_speed; + uint8_t new_fan_speed = fan_speed; + // uint8_t fan_speed = this->climateCard_york->getFanSpeed(); + ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", fan_speed); + // Toggle the state + // fan_speed have 3 state high mid low switch between them + switch (fan_speed) + { + case PM_FAN_SPEED_LOW: + new_fan_speed = PM_FAN_SPEED_MID; + break; + case PM_FAN_SPEED_MID: + new_fan_speed = PM_FAN_SPEED_HIGH; + break; + case PM_FAN_SPEED_HIGH: + new_fan_speed = PM_FAN_SPEED_LOW; + break; + default: + new_fan_speed = PM_FAN_SPEED_HIGH; + break; + } + ESP_LOGI("ISEDisplay", "New PM fan speed: %d", new_fan_speed); + this->pm_fan_speed = new_fan_speed; + ESP_LOGI("ISEDisplay", "Setting PM fan speed in memory to: %d", this->pm_fan_speed); + remote_pm_fan_speed->setIntValue(this->pm_fan_speed); + ESP_LOGI("ISEDisplay", "Setting PM fan speed in remote var to: %d", remote_pm_fan_speed->getValueAsInt()); + updateAirPurifierState(); } void ISEDisplay::setLightLevel(uint8_t row, uint8_t level) { @@ -838,66 +954,12 @@ void ISEDisplay::updateLightGroupStatePageStandby() this->giveSerialMutex(); } void ISEDisplay::updateLightGroupStatePageDashboard() -{ - // Calculate the state - bool state = calculateLightGroupState(); - // Send the state to the display - if (!this->takeSerialMutex()) - return; - - this->displayAdapter->print("light_m_sw.pic="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("light_m_sw.pic2="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED); - this->sendStopBytes(); - - for (uint8_t i = 1; i <= 4; i++) - { - u_int8_t state = getLightLevel(i); - updateLightSwitch(); - switch (state) - { - case 0: - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_0); - this->sendStopBytes(); - break; - case 1: - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_1); - this->sendStopBytes(); - break; - case 2: - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_2); - this->sendStopBytes(); - break; - case 3: - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_3); - this->sendStopBytes(); - break; - default: - break; - } - } - - this->giveSerialMutex(); -} -void ISEDisplay::updateLightSwitch() { // Calculate the state bool state_master = calculateLightGroupState(); + uint8_t firstState = getLightLevel(1); + bool allMatch = true; + // Send the state to the display if (!this->takeSerialMutex()) return; @@ -910,16 +972,32 @@ void ISEDisplay::updateLightSwitch() this->displayAdapter->print(state_master ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED); this->sendStopBytes(); - this->giveSerialMutex(); + // this->displayAdapter->print("light_m_sw.pic="); + // this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF); + // this->sendStopBytes(); - // check state and set for each individual light row - // if state is 0 set to off and other(1,2,3) to on + // this->displayAdapter->print("light_m_sw.pic2="); + // this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED); + // this->sendStopBytes(); for (uint8_t i = 1; i <= 4; i++) { u_int8_t state = getLightLevel(i); - if (state == 0) + + if (i > 1 && state != firstState) { + allMatch = false; + } + + switch (state) + { + case 0: + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print(".pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_0); + this->sendStopBytes(); + this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print("_sw.pic="); @@ -931,9 +1009,14 @@ void ISEDisplay::updateLightSwitch() this->displayAdapter->print("_sw.pic2="); this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_OFF_PRESSED); this->sendStopBytes(); - } - else - { + break; + case 1: + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print(".pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_1); + this->sendStopBytes(); + this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print("_sw.pic="); @@ -945,8 +1028,100 @@ void ISEDisplay::updateLightSwitch() this->displayAdapter->print("_sw.pic="); this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); this->sendStopBytes(); + break; + case 2: + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print(".pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_2); + this->sendStopBytes(); + + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print("_sw.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON); + this->sendStopBytes(); + + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print("_sw.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); + this->sendStopBytes(); + break; + case 3: + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print(".pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_3); + this->sendStopBytes(); + + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print("_sw.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON); + this->sendStopBytes(); + + this->displayAdapter->print("light_row"); + this->displayAdapter->print(i); + this->displayAdapter->print("_sw.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); + this->sendStopBytes(); + break; + default: + break; } } + + if (allMatch) + { + // All states match, change the master light level which is the firststate + // use switch case + switch (firstState) + { + case 0: + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_0); + this->sendStopBytes(); + break; + case 1: + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_1); + this->sendStopBytes(); + break; + case 2: + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_2); + this->sendStopBytes(); + break; + case 3: + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_3); + this->sendStopBytes(); + break; + default: + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_D); + this->sendStopBytes(); + break; + } + } + else + { + this->displayAdapter->print("master_light.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_D); + this->sendStopBytes(); + } + + this->giveSerialMutex(); +} +void ISEDisplay::updateLightSwitch() +{ + // DEPRECATED + // Calculate the state + // not in use due to worse performance + + // check state and set for each individual light row + // if state is 0 set to off and other(1,2,3) to on } bool ISEDisplay::calculateLightGroupState() { @@ -996,13 +1171,50 @@ void ISEDisplay::toggleSystem() togglePM(); } } -void ISEDisplay::allOn() +void ISEDisplay::allToggleStandby() { - setLightGroupState(3); - setPMstate(true, pm_fan_speed); - setACstate(2, ac_fan_speed, ac_temperature); + bool lightState = calculateLightGroupState(); + bool pmState = strcmp(pm_switch->getValue(), "on") == 0; + if (ac_mode != 0) + { + setACstate(0, ac_fan_speed, ac_temperature); + } + else{ + setACstate(2, ac_fan_speed, ac_temperature); + } + if (lightState) + { + setLightGroupState(0); + } + else + { + setLightGroupState(3); + } + if (pmState) + { + setPMstate(false, pm_fan_speed); + } + else + { + setPMstate(true, pm_fan_speed); + } + } +void ISEDisplay::updateAllStandbyToggle() +{ + bool state = calculateAllState(); + if (!this->takeSerialMutex()) + return; + this->displayAdapter->print("s_open_all.pic="); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON : COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_OFF); + this->sendStopBytes(); + this->displayAdapter->print("s_open_all.pic2="); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_OFF_PRESSED); + this->sendStopBytes(); + + this->giveSerialMutex(); +} void ISEDisplay::toggleLightIndividual(uint8_t row) { // Get the current state @@ -1063,7 +1275,8 @@ void ISEDisplay::updateAirPurifierState() bool state = strcmp(pm_switch->getValue(), "on") == 0; this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; ESP_LOGI("ISEDisplay", "Updating air purifier state to: %d", state); - pm_fan_speed = (int)atof(remote_pm_fan_speed->getValue()); + pm_fan_speed = this->pm_fan_speed; + ESP_LOGI("ISEDisplay", "Updating air purifier fan speed to: %d", pm_fan_speed); // Send the state to the display if (!this->takeSerialMutex()) return; @@ -1080,6 +1293,86 @@ void ISEDisplay::updateAirPurifierState() this->displayAdapter->print(this->pm_lock_state ? COMPONENT_DASHBOARD_PIC_LOCK : COMPONENT_DASHBOARD_PIC_UNLOCK); this->sendStopBytes(); + this->displayAdapter->print("pm_mode.pic="); + this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON : COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF); + this->sendStopBytes(); + + this->displayAdapter->print("pm_mode.pic2="); + this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON_PRESSED : COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF_PRESSED); + this->sendStopBytes(); + + switch (pm_fan_speed) + { + case PM_FAN_SPEED_LOW: + if (state) + { // state is on + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON_PRESSED); + this->sendStopBytes(); + } + else + { // state is off + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF_PRESSED); + this->sendStopBytes(); + } + break; + case PM_FAN_SPEED_MID: + if (state) + { // state is on + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON_PRESSED); + this->sendStopBytes(); + } + else + { // state is off + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF_PRESSED); + this->sendStopBytes(); + } + break; + case PM_FAN_SPEED_HIGH: + if (state) + { // state is on + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON_PRESSED); + this->sendStopBytes(); + } + else + { // state is off + this->displayAdapter->print("pm_speed.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF); + this->sendStopBytes(); + + this->displayAdapter->print("pm_speed.pic2="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF_PRESSED); + this->sendStopBytes(); + } + break; + default: + break; + } + // this->displayAdapter->print("pm_speed.val="); // this->displayAdapter->print(pm_fan_speed); // // this->displayAdapter->print("\""); @@ -1102,6 +1395,8 @@ void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t tempera { ESP_LOGI("ISEDisplay", "AC state changed: mode: %d, fan speed: %d, temperature: %d", mode, fan_speed, temperature); updateACState(); + updateSystemtoggle(); + updateAllStandbyToggle(); } void ISEDisplay::updateuserACmode() { diff --git a/src/ise_display.hpp b/src/ise_display.hpp index e0bb516..9be7e1b 100644 --- a/src/ise_display.hpp +++ b/src/ise_display.hpp @@ -31,6 +31,7 @@ class ISEDisplay : public ESPMegaDisplay { void updateAirPurifierState(); void updateAirPurifierStateStandby(); void updateSystemtoggle(); + void updateAllStandbyToggle(); void updateDateTimeText(rtctime_t time); void updateWeather(char *weather_string); void updateTempOutside(float temp_outside); @@ -69,6 +70,8 @@ class ISEDisplay : public ESPMegaDisplay { uint8_t outputCallbackHandle; uint8_t climateCallbackHandle; uint32_t time_since_last_ac_change; + uint32_t time_since_ac_staggered_start_call; + bool ac_staggered_start_call_pending; uint8_t user_mode; uint8_t ac_lock_state; uint8_t pm_lock_state; @@ -95,7 +98,7 @@ class ISEDisplay : public ESPMegaDisplay { void setAClockstate(bool is_ac_lock_on); void toggleACLock(); void togglePMLock(); - void allOn(); + void allToggleStandby(); void toggleLightGroupState(); void toggleLightGroupStateStandby(); void toggleLightIndividual(uint8_t row); @@ -105,5 +108,6 @@ class ISEDisplay : public ESPMegaDisplay { void setLightGroupState(uint8_t level); void toggleACStandby(); void changeUserACmode(); + void changePMfanspeed(); }; diff --git a/src/ise_display_definitions.hpp b/src/ise_display_definitions.hpp index f277d47..b98e5c9 100644 --- a/src/ise_display_definitions.hpp +++ b/src/ise_display_definitions.hpp @@ -66,6 +66,10 @@ lights have 4 states #define MOTION_FRONT 8 #define MOTION_REAR 9 +//PM fanspeed setting +#define PM_FAN_SPEED_LOW 3 +#define PM_FAN_SPEED_MID 10 +#define PM_FAN_SPEED_HIGH 18 // #define DISPLAY_TIMEOUT 5*60*1000 // 5 minutes diff --git a/src/main.cpp b/src/main.cpp index e2b33c6..35f6bf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,20 +1,32 @@ #include - /*********************************************** * Begin Configuration * ***********************************************/ // Analog Card & Current Transformer Configuration -// bool analogCardAvailable = false; -// AnalogCard analogCard = AnalogCard(); -// float voltage = CT_RMS_VOLTAGE; -// CurrentTransformerCard ct1 = CurrentTransformerCard(&analogCard, 0, &voltage, &adc2current, 5000); -// CurrentTransformerCard ct2 = CurrentTransformerCard(&analogCard, 1, &voltage, &adc2current, 5000); -// CurrentTransformerCard ct3 = CurrentTransformerCard(&analogCard, 2, &voltage, &adc2current, 5000); -// CurrentTransformerCard ct4 = CurrentTransformerCard(&analogCard, 3, &voltage, &adc2current, 5000); -// CurrentTransformerCard ct5 = CurrentTransformerCard(&analogCard, 4, &voltage, &adc2current, 5000); -// CurrentTransformerCard ct6 = CurrentTransformerCard(&analogCard, 5, &voltage, &adc2current, 5000); +#ifdef ANALOG_ENABLE +bool analogCardAvailable = false; +AnalogCard analogCard = AnalogCard(); +float voltage = CT_RMS_VOLTAGE; +#define CT_INTERVAL 5000 +CurrentTransformerCard ct1 = CurrentTransformerCard(&analogCard, 0, &voltage, &adc2current, CT_INTERVAL); +CurrentTransformerCard ct2 = CurrentTransformerCard(&analogCard, 1, &voltage, &adc2current, CT_INTERVAL); +CurrentTransformerCard ct3 = CurrentTransformerCard(&analogCard, 2, &voltage, &adc2current, CT_INTERVAL); +CurrentTransformerCard ct4 = CurrentTransformerCard(&analogCard, 3, &voltage, &adc2current, CT_INTERVAL); +CurrentTransformerCard ct5 = CurrentTransformerCard(&analogCard, 6, &voltage, &adc2current, CT_INTERVAL); +CurrentTransformerCard ct6 = CurrentTransformerCard(&analogCard, 7, &voltage, &adc2current, CT_INTERVAL); +float adc2current(uint16_t adc_val) +{ + // float voltage = adc_val * 0.0007-0.1994; + float adc_voltage = adc_val * 0.0007; + // 0-10V Output with 30A Current Rating CT + float ct_current = adc_voltage / 10.0 * 30.0; + return ct_current; +} + +#endif + // Remote Variables RemoteVariable pm25_in = RemoteVariable(); @@ -26,11 +38,7 @@ RemoteVariable pm_fan_speed = RemoteVariable(); RemoteVariable pm_lock = RemoteVariable(); RemoteVariable ac_lock = RemoteVariable(); -float adc2current(uint16_t adc_val) { - return adc_val * 1.0; -} -#define CT_INTERVAL 5000 // Light Configuration uint8_t row = 4; @@ -42,8 +50,8 @@ const uint8_t light_array[4][2] = { {LIGHT_ROW4_COLUMN1, LIGHT_ROW4_COLUMN2}}; // Air Conditioner Configuration -const char *mode_names_daikin[] = {"off", "cool", "fan_only", "dry"}; -const char *mode_names_york[] = {"off", "cool", "fan_only"}; +const char *mode_names_daikin[] = {"off", "fan_only", "cool", "dry"}; +const char *mode_names_york[] = {"off", "fan_only", "cool"}; const char *fan_speed_names[] = {"auto", "high", "medium", "low"}; AirConditioner ac_daikin = { @@ -70,6 +78,9 @@ AirConditioner ac_york = { ESPMegaPRO espmega = ESPMegaPRO(); ISEDisplay iseDisplay = ISEDisplay(&iseDisplayAdapter, &light_array[0][0], row, column); +ESPMegaDisplayOTA iseDisplayOTA = ESPMegaDisplayOTA(); +ESPMegaDisplayOTA internalDisplayOTA = ESPMegaDisplayOTA(); + ClimateCard climateCard_daikin = ClimateCard(AIR_CONDITIONER_DAIKIN_IR_PIN, ac_daikin, AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN, AIR_CONDITIONER_RMT_CHANNEL0); @@ -118,11 +129,22 @@ void setup() // Disable factory reset for now espmega.inputs.loop(); - //set debounce time to 200 for pin 0-7 - for (uint16_t i = 0; i < 8; i++){ - espmega.inputs.setDebounceTime(i,200); + // set debounce time to 200 for pin 0-7 + for (uint16_t i = 0; i < 8; i++) + { + espmega.inputs.setDebounceTime(i, 200); } + // if (clear_fram) + // { + // Serial.print("boot_state.txt=\"Factory Resetting . . .\""); + // sendStopBytes(); + // for (uint16_t i = 0; i < 32768; i++) + // { + // espmega.fram.write8(i, 0); + // } + // esp_restart(); + // } // // ------------ End Factory Reset Routine ------------ @@ -158,36 +180,35 @@ void setup() } // ------------ End Inputs and Outputs Initialization Routine ------------ espmega.outputs.setState(12, true); - espmega.outputs.setValue(12,4095); + espmega.outputs.setValue(12, 4095); espmega.installCard(2, &climateCard_daikin); climateCard_daikin.bindFRAM(&espmega.fram, 5000); climateCard_daikin.loadStateFromFRAM(); climateCard_daikin.setFRAMAutoSave(true); espmega.display->bindClimateCard(&climateCard_daikin); - // // Current Transformers - // espmega.installCard(4, &analogCard); - - // espmega.installCard(5, &ct1); - // ct1.bindFRAM(&espmega.fram, 6000); - // espmega.iot->registerCard(5); - - // espmega.installCard(6, &ct2); - // ct2.bindFRAM(&espmega.fram, 6100); - // espmega.iot->registerCard(6); - - // espmega.installCard(7, &ct3); - // ct3.bindFRAM(&espmega.fram, 6200); - // espmega.iot->registerCard(7); - // espmega.installCard(8, &ct4); - // ct4.bindFRAM(&espmega.fram, 6300); - // espmega.iot->registerCard(8); - // espmega.installCard(9, &ct5); - // ct5.bindFRAM(&espmega.fram, 6400); - // espmega.iot->registerCard(9); - // espmega.installCard(10, &ct6); - // ct6.bindFRAM(&espmega.fram, 6500); - // espmega.iot->registerCard(10); +// Current Transformers +#ifdef ANALOG_ENABLE + espmega.installCard(4, &analogCard); + espmega.installCard(5, &ct1); + ct1.bindFRAM(&espmega.fram, 6000); + espmega.iot->registerCard(5); + espmega.installCard(6, &ct2); + ct2.bindFRAM(&espmega.fram, 6100); + espmega.iot->registerCard(6); + espmega.installCard(7, &ct3); + ct3.bindFRAM(&espmega.fram, 6200); + espmega.iot->registerCard(7); + espmega.installCard(8, &ct4); + ct4.bindFRAM(&espmega.fram, 6300); + espmega.iot->registerCard(8); + espmega.installCard(9, &ct5); + ct5.bindFRAM(&espmega.fram, 6400); + espmega.iot->registerCard(9); + espmega.installCard(10, &ct6); + ct6.bindFRAM(&espmega.fram, 6500); + espmega.iot->registerCard(10); +#endif // ------------ Climate Cards Initialization Routine ------------ ESP_LOGD("ISE OS", "Setting up climate cards"); @@ -203,47 +224,48 @@ void setup() // York Climate Card ESP_LOGD("ISE OS", "Installing york climate card"); - espmega.installCard(10, &climateCard_york); + espmega.installCard(3, &climateCard_york); climateCard_york.bindFRAM(&espmega.fram, 5005); climateCard_york.loadStateFromFRAM(); climateCard_york.setFRAMAutoSave(true); // ------------ End Climate Cards Initialization Routine ------------ // ------------ Current Transformer Cards Initialization Routine ------------ - //ESP_LOGD("ISE OS", "Installing current transformer cards"); + #ifdef ANALOG_ENABLE + ESP_LOGD("ISE OS", "Installing current transformer cards"); // First try to install the analog card - //analogCardAvailable = espmega.installCard(4, &analogCard); + analogCardAvailable = espmega.installCard(4, &analogCard); // If the analog card is available, install the current transformer cards // If the analog card is not available, current transformer cards will not be installed // Unless CT_FORCE_ENABLE is set to true // This is to prevent soft locking the device when the device tries to read from an ADC channel that does not exist - // if (analogCardAvailable || CT_FORCE_ENABLE) - // { - // ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards"); - // // espmega.installCard(5, &ct1); - // // ct1.bindFRAM(&espmega.fram, 5010); - // // espmega.installCard(6, &ct2); - // // ct2.bindFRAM(&espmega.fram, 5020); - // // espmega.installCard(7, &ct3); - // // ct3.bindFRAM(&espmega.fram, 5030); - // // espmega.installCard(8, &ct4); - // // ct4.bindFRAM(&espmega.fram, 5040); - // // espmega.installCard(9, &ct5); - // // ct5.bindFRAM(&espmega.fram, 5050); - // // espmega.installCard(10, &ct5); - // // ct6.bindFRAM(&espmega.fram, 5060); - // espmega.iot->registerCard(5); - // espmega.iot->registerCard(6); - // espmega.iot->registerCard(7); - // espmega.iot->registerCard(8); - // espmega.iot->registerCard(9); - // espmega.iot->registerCard(10); - // } - // else - // { - // ESP_LOGE("ISE OS", "Analog card not available, current transformer cards cannot and will not be installed."); - // } - //ESP_LOGD("ISE OS", "Registering Current Transformer Cards with IoT Module") + if (analogCardAvailable || CT_FORCE_ENABLE) + { + ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards"); + espmega.installCard(5, &ct1); + ct1.bindFRAM(&espmega.fram, 5010); + espmega.installCard(6, &ct2); + ct2.bindFRAM(&espmega.fram, 5020); + espmega.installCard(7, &ct3); + ct3.bindFRAM(&espmega.fram, 5030); + espmega.installCard(8, &ct4); + ct4.bindFRAM(&espmega.fram, 5040); + espmega.installCard(9, &ct5); + ct5.bindFRAM(&espmega.fram, 5050); + espmega.installCard(10, &ct5); + ct6.bindFRAM(&espmega.fram, 5060); + espmega.iot->registerCard(5); + espmega.iot->registerCard(6); + espmega.iot->registerCard(7); + espmega.iot->registerCard(8); + espmega.iot->registerCard(9); + espmega.iot->registerCard(10); + } + else + { + ESP_LOGE("ISE OS", "Analog card not available, current transformer cards cannot and will not be installed."); + } + #endif // ------------ End Current Transformer Cards Initialization Routine ------------ @@ -285,7 +307,7 @@ void setup() espmega.iot->registerCard(0); // Register the Input Card espmega.iot->registerCard(1); // Register the Output Card espmega.iot->registerCard(2); // Register the Climate Card Daikin - espmega.iot->registerCard(10); // Register the Climate Card York + espmega.iot->registerCard(3); // Register the Climate Card York // ------------ End IoT Card Registration Routine ------------ @@ -293,6 +315,8 @@ void setup() auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega); iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard_daikin, &climateCard_york, &pm_switch, &pm_fan_speed, &pm_lock, &ac_lock, espmega.iot); espmega.iot->registerRelativeMqttCallback(&handleMqttMessage); + iseDisplayOTA.begin("/isedisp", &iseDisplay, espmega.webServer); + internalDisplayOTA.begin("/intdisp", espmega.display, espmega.webServer); iseDisplay.registerPageChangeCallback(&handlePageChange); // ------------ End External Display Initialization Routine ------------ } @@ -321,6 +345,8 @@ void pmswitchupdatedisplay(char *value) { ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue()); iseDisplay.updateAirPurifierState(); + iseDisplay.updateSystemtoggle(); + iseDisplay.updateAllStandbyToggle(); ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", pm_switch.getValue(), !pm_switch.getValue()); } void pmlockupdatedisplay(char *value) @@ -350,6 +376,28 @@ void loop() iseDisplay.updateDateTimeText(time); last_time_updated = millis(); } +#ifdef ANALOG_ENABLE + // Send out analog Data every 6 seconds + static uint32_t last_analog_sent = 0; + if (millis() - last_analog_sent > 6000) + { + espmega.iot->publish("/debug/up", "1"); + if (analogCardAvailable || CT_FORCE_ENABLE) + { + espmega.iot->publish("/debug/log", "Sending Analog Card Data"); + char topic_buffer[50]; + char payload_buffer[50]; + // Publish ADC Pin 0-7 + for (uint8_t i = 0; i < 8; i++) + { + sprintf(topic_buffer, "/debug/analog/%d", i); + sprintf(payload_buffer, "%d", analogCard.analogRead(i)); + espmega.iot->publish(topic_buffer, payload_buffer); + } + } + last_analog_sent = millis(); + } +#endif } void on_pin_change(uint8_t pin, uint8_t value) @@ -486,6 +534,7 @@ void handlePageChange(uint8_t page) case PAGE_STANDBY: iseDisplay.updateLightGroupStatePageStandby(); iseDisplay.updateAirPurifierStateStandby(); + iseDisplay.updateAllStandbyToggle(); break; case PAGE_DASHBOARD: iseDisplay.updateLightGroupStatePageDashboard(); diff --git a/src/main.hpp b/src/main.hpp index 3f98d5c..48d9e98 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -5,6 +5,7 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #include #include #include +#include @@ -25,16 +26,16 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #define AIR_CONDITIONER_YORK_IR_PIN 15 #define AIR_CONDITIONER_RMT_CHANNEL0 RMT_CHANNEL_0 #define AIR_CONDITIONER_RMT_CHANNEL1 RMT_CHANNEL_1 - -// // CT Configuration -// #define CT_FORCE_ENABLE false -// #define CT_RMS_VOLTAGE 1.0 -// #define CT_PIN_LIGHT_PHASE1 0 -// #define CT_PIN_LIGHT_PHASE2 1 -// #define CT_PIN_SOCKET 2 -// #define CT_PIN_AC_PHASE1 3 -// #define CT_PIN_AC_PHASE2 4 -// #define CT_PIN_AC_PHASE3 5 +// CT Configuration +#define ANALOG_ENABLE +#define CT_FORCE_ENABLE true +#define CT_RMS_VOLTAGE 220.0 +#define CT_PIN_LIGHT_PHASE1 0 +#define CT_PIN_LIGHT_PHASE2 1 +#define CT_PIN_SOCKET 2 +#define CT_PIN_AC_PHASE1 3 +#define CT_PIN_AC_PHASE2 4 +#define CT_PIN_AC_PHASE3 5 void handleMqttMessage(char *topic, char *payload); void subscribeToMqttTopics();