add toogle; adjust code behavior

This commit is contained in:
reaw55 2024-04-20 14:25:12 +07:00
parent d4604d28c3
commit 88931f3001
17 changed files with 358 additions and 96 deletions

View file

@ -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();
@ -70,6 +73,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) > 1000)
{
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;
@ -151,7 +163,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 +214,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 +231,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 +244,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 +257,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 +315,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)
@ -435,6 +453,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 +548,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 +566,29 @@ 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();
}
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 +597,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 +645,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 +672,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 +758,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 +945,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 +963,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 +1000,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 +1019,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()
{
@ -1063,7 +1229,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 +1247,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 +1349,7 @@ 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();
}
void ISEDisplay::updateuserACmode()
{

View file

@ -69,6 +69,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;
@ -105,5 +107,6 @@ class ISEDisplay : public ESPMegaDisplay {
void setLightGroupState(uint8_t level);
void toggleACStandby();
void changeUserACmode();
void changePMfanspeed();
};

View file

@ -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

View file

@ -70,6 +70,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);
@ -293,6 +296,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 +326,7 @@ void pmswitchupdatedisplay(char *value)
{
ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue());
iseDisplay.updateAirPurifierState();
iseDisplay.updateSystemtoggle();
ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", pm_switch.getValue(), !pm_switch.getValue());
}
void pmlockupdatedisplay(char *value)

View file

@ -5,6 +5,7 @@ SET_LOOP_TASK_STACK_SIZE(32*1024);
#include <ir_codes_daikin.hpp>
#include <ir_codes_york.hpp>
#include <CurrentTransformerCard.hpp>
#include <ESPMegaDisplayOTA.hpp>
@ -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();