#include ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17) { } // Work left // TODO : Implement // debug to work void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard) { this->inputCard = inputCard; this->outputCard = outputCard; this->climateCard = climateCard; auto bindedHandlePWMChange = std::bind(&ISEDisplay::handlePWMChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); auto bindedHandleACChange = std::bind(&ISEDisplay::handleACChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); auto bindedHandleTouch = std::bind(&ISEDisplay::handleTouch, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); 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(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() { // Check if there is data in the serial buffer // If there is data, process the data recieveSerialCommand(); // Update the time since the last screen update using millis() u_int32_t current_time = millis(); if (current_time - this->time_since_last_screen_update > 120000) { // jump to standby page if there is no activity for 2 minutes if(this->currentPage != 1){ this->jumpToPage(1); ESP_LOGI("ISEDisplay", "Jumping to 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) { case COMPONENT_STANDBY_OPEN_ALL_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; // TODO : Should you really jump to page 2 here? should't page jumping be handled reactivly? // EX. if atleast one light is on, then jump to active page, else jump to standby page // This will allow page to change correctly when the system is started and when controlled remotely which won't call handleTouch time_since_last_screen_update = millis(); this->jumpToPage(2); // the function of the button is to open the dashboard from standby break; case COMPONENT_STANDBY_LIGHT_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; // TODO : So this does nothing? Shouldn't it turn on the lights? // should turn it on now toggleLightGroupStateStandby(); break; case COMPONENT_STANDBY_AC_TOGGLE: // TODO : What's the expexted behavior of standby? Does it enter standby when the lights are all off and ignore the AC // or does it only enter standby when ac is also off and purifier is off, or is it a timed thing? if (touch_type != TOUCH_TYPE_RELEASE) break; toggleAC(); break; case COMPONENT_STANDBY_PM_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; togglePMStandby(); break; default: break; } } else if (page == PAGE_DASHBOARD) { switch (component) { case COMPONENT_LIGHT_MASTER_BUTTON: // TODO : this only update the display to match the light, it doesn't toggle the light. if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightGroupState(); break; // TODOlater : can't this be done better with array lookup? case COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; for (uint8_t i = 1; i <= 4; i++) { setLightLevel(i, 1); } updateLightGroupStatePageDashboard(); break; case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; for (uint8_t i = 1; i <= 4; i++) { setLightLevel(i, 2); } updateLightGroupStatePageDashboard(); break; case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; for (uint8_t i = 1; i <= 4; i++) { setLightLevel(i, 3); } updateLightGroupStatePageDashboard(); break; case COMPONENT_LIGHT_ROW1_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; lightLevelRow1 = this->getNumber("light_r1_slide.val"); toggleSliderLight(1, lightLevelRow1); break; case COMPONENT_LIGHT_ROW2_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; lightLevelRow2 = this->getNumber("light_r2_slide.val"); toggleSliderLight(2, lightLevelRow2); break; case COMPONENT_LIGHT_ROW3_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; lightLevelRow3 = this->getNumber("light_r3_slide.val"); toggleSliderLight(3, lightLevelRow3); break; case COMPONENT_LIGHT_ROW4_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; lightLevelRow4 = this->getNumber("light_r4_slide.val"); toggleSliderLight(4, lightLevelRow4); break; case COMPONENT_LIGHT_ROW1_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(1); break; case COMPONENT_LIGHT_ROW2_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(2); break; case COMPONENT_LIGHT_ROW3_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(3); break; case COMPONENT_LIGHT_ROW4_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(4); break; // TODO : Don't we have fan only mode too? can you really just switch between 0 and 1? case COMPONENT_AC_TOGGLE_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleAC(); break; case COMPONENT_AC_MODE: if (touch_type != TOUCH_TYPE_RELEASE) break; changeUserACmode(); break; case COMPONENT_AC_FAN_SPEED: if (touch_type != TOUCH_TYPE_RELEASE) break; 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((ac_fan_speed + 1) % 4); updateACState(); break; case COMPONENT_AC_TEMP_DOWN_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; this->climateCard->setTemperature(this->climateCard->getTemperature() - 1); updateACState(); break; case COMPONENT_AC_TEMP_UP_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; this->climateCard->setTemperature(this->climateCard->getTemperature() + 1); updateACState(); break; case COMPONENT_PM_TOGGLE_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; togglePM(); break; case COMPONENT_PM_FAN_SPEED_DECREASE: if (touch_type != TOUCH_TYPE_RELEASE) break; pm_fan_speed = this->outputCard->getValue(6); 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); 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: break; } } else { return; } } void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) { // NEED to switch case for different page uint8_t current_page = this->currentPage; if (current_page == PAGE_STANDBY) { if (pin >= 1 && pin <= 4) { // Light updateLightGroupStatePageStandby(); time_since_last_screen_update = millis(); // update time since last activity } else if (pin == 4 || pin == 5) { // Air Purifier updateAirPurifierStateStandby(); time_since_last_screen_update = millis(); // update time since last activity } } else if (current_page == PAGE_DASHBOARD) { if (pin >= 1 && pin <= 4) { // Light updateLightGroupStatePageDashboard(); time_since_last_screen_update = millis(); // update time since last activity } else if (pin == 4 || pin == 5) { // Air Purifier updateAirPurifierState(); time_since_last_screen_update = millis(); // update time since last activity } } else { return; } } void ISEDisplay::updateDateTimeText(rtctime_t time) { this->takeSerialMutex(); // Send the time to the display this->displayAdapter->printf("time.txt=\"%02d:%02d\"", time.hours, time.minutes); this->sendStopBytes(); this->displayAdapter->printf("date.txt=\"%02d.%02d.%d\"", time.day, time.month, time.year); this->sendStopBytes(); this->giveSerialMutex(); } // TODO : Implement // user remote var // appdeamon void ISEDisplay::updateWeather(char *weather_string) { // TODO : use remotevar to get weather data from appdaemon and update the display u_int8_t weather_code = 68; if (strcmp(weather_string, "fair_day") == 0) { weather_code = 63; } else if (strcmp(weather_string, "fair_night") == 0) { weather_code = 64; } else if (strcmp(weather_string, "cloudy") == 0) { weather_code = 65; } else if (strcmp(weather_string, "clearsky_day") == 0) { weather_code = 66; } else if (strcmp(weather_string, "clearsky_night") == 0) { weather_code = 67; } else if (strcmp(weather_string, "partlycloudy_day") == 0) { weather_code = 68; } else if (strcmp(weather_string, "partlycloudy_night") == 0) { weather_code = 69; } else if (strcmp(weather_string, "heavyrain") == 0) { weather_code = 70; } else if (strcmp(weather_string, "heavyrainandthunder") == 0) { weather_code = 71; } else if (strcmp(weather_string, "rainandthunder") == 0) { weather_code = 72; } else if (strcmp(weather_string, "rain") == 0) { weather_code = 73; } else if (strcmp(weather_string, "lightrain") == 0) { weather_code = 74; } else if (strcmp(weather_string, "fog") == 0) { weather_code = 75; } else { weather_code = 68; } this->takeSerialMutex(); this->displayAdapter->printf("weather_icon.pic=%s", weather_code); this->sendStopBytes(); this->giveSerialMutex(); } void ISEDisplay::updateTempOutside(float temp_outside) { // TODO : use remotevar to get PM2.5 data from appdaemon and update the display // 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->sendStopBytes(); this->giveSerialMutex(); } void ISEDisplay::updatePMoutside(u_int16_t pm25_outside) { this->takeSerialMutex(); 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 } void ISEDisplay::updatePMinside(u_int8_t pm25_inside) { // TODO : get data from HA's Xiaomi air purifier sensor } void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed) { // TODO : set data to HA's Xiaomi air purifier sensor } void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature) { this->climateCard->setTemperature(ac_temperature); this->climateCard->setFanSpeed(ac_fan_speed); this->climateCard->setMode(ac_mode); updateACState(); } void ISEDisplay::toggleLightGroupState() { // Get the current group state bool state = calculateLightGroupState(); ESP_LOGI("ISEDisplay", "Current light group state: %d", state); // Toggle light for (uint8_t i = 1; i <= 4; i++) { setLightLevel(i, state ? 0 : 3); } updateLightGroupStatePageDashboard(); } void ISEDisplay::toggleLightGroupStateStandby() { // Get the current group state bool state = calculateLightGroupState(); ESP_LOGI("ISEDisplay", "Current light group state: %d", state); // Toggle light for (uint8_t i = 1; i <= 4; i++) { setLightLevel(i, state ? 0 : 3); } updateLightGroupStatePageStandby(); } void ISEDisplay::togglePM() { // Get the current group state bool state = this->outputCard->getState(5); ESP_LOGI("ISEDisplay", "Current PM state: %d", state); // Toggle the state state = !state; // Set the state this->outputCard->setState(5, state); ESP_LOGI("ISEDisplay", "New PM state: %d", state); updateAirPurifierState(); } void ISEDisplay::togglePMStandby() { // Get the current group state bool state = this->outputCard->getState(5); ESP_LOGI("ISEDisplay", "Current PM state: %d", state); // Toggle the state state = !state; // Set the state this->outputCard->setState(5, state); ESP_LOGI("ISEDisplay", "New PM state: %d", state); updateAirPurifierStateStandby(); } void ISEDisplay::toggleAC() { // Get the current group state uint8_t mode = this->climateCard->getMode(); // get fan speed and temperature uint8_t fan_speed = this->climateCard->getFanSpeed(); uint8_t temperature = this->climateCard->getTemperature(); ESP_LOGI("ISEDisplay", "Current AC mode: %d", mode); // Toggle the state if (mode == 0) { ESP_LOGI("ISEDisplay", " User mode: %d", user_mode); setACstate(fan_speed, user_mode, temperature); } else { ESP_LOGI("ISEDisplay", "User mode BEFORE: %d", user_mode); // update user mode to new mode user_mode = mode; // change actual mode to off ESP_LOGI("ISEDisplay", "User mode AFTER: %d", user_mode); setACstate(fan_speed, 0, temperature); } } void ISEDisplay::changeUserACmode() { // Get the current group state uint8_t mode = this->climateCard->getMode(); // Toggle the state // user mode alternate between 1 and 2 user_mode = (user_mode + 1) % 2 + 1; if (mode != 0) { // update mode to new mode mode = user_mode; } 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() } updateuserACmode(); // call to update mode part of the display seperately } void ISEDisplay::setLightLevel(uint8_t row, uint8_t level) { for (uint8_t i = 1; i <= 4; i++) { if (row == i) this->outputCard->setValue(row, level); } } void ISEDisplay::updateLightGroupStatePageStandby() { // Calculate the state bool state = calculateLightGroupState(); // Send the state to the display this->takeSerialMutex(); this->displayAdapter->print("s_light_toggle.pic="); this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON : COMPONENT_STANDBY_LIGHT_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("s_light_toggle.pic2="); this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED : COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); } void ISEDisplay::updateLightGroupStatePageDashboard() { // Calculate the state bool state = calculateLightGroupState(); // Send the state to the display this->takeSerialMutex(); this->displayAdapter->print("light_master.pic="); this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON : COMPONENT_LIGHT_MASTER_OFF); this->sendStopBytes(); this->displayAdapter->print("light_master.pic2="); this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON_PRESSED : COMPONENT_LIGHT_MASTER_OFF_PRESSED); this->sendStopBytes(); for (uint8_t i = 1; i <= 4; i++) { u_int8_t state = this->outputCard->getValue(i); switch (state) { case 0: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_0); this->sendStopBytes(); break; case 1: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_1); this->sendStopBytes(); break; case 2: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_2); this->sendStopBytes(); break; case 3: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_3); this->sendStopBytes(); break; default: break; } } this->giveSerialMutex(); } bool ISEDisplay::calculateLightGroupState() { // Check if all lights are on bool lightOn = false; for (uint8_t i = 1; i <= 4; i++) { if (this->outputCard->getValue(i) != 0) { lightOn = true; break; } } return lightOn; } void ISEDisplay::toggleLightIndividual(uint8_t row) { // Get the current state uint8_t state = this->outputCard->getValue(row); if (state != 0) { state = 0; } else { state = 3; } // Set the state setLightLevel(row, state); updateLightGroupStatePageDashboard(); } void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel) { // Get the current state uint8_t state = 0; if (lightLevel < 10) { state = 0; } else if (lightLevel < 33) { state = 1; } else if (lightLevel <= 66) { state = 2; } else if (lightLevel > 66) { state = 3; } else { state = 0; } // Set the state setLightLevel(row, state); updateLightGroupStatePageDashboard(); } void ISEDisplay::updateAirPurifierStateStandby() { // Get the state bool state = this->outputCard->getState(5); // Send the state to the display this->takeSerialMutex(); this->displayAdapter->print("s_pm_toggle.pic="); this->displayAdapter->print(state ? COMPONENT_STANDBY_PM_PIC_ON : COMPONENT_STANDBY_PM_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("s_pm_toggle.pic2="); this->displayAdapter->print(state ? COMPONENT_STANDBY_PM_PIC_ON_PRESSED : COMPONENT_STANDBY_PM_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); } void ISEDisplay::updateAirPurifierState() { // Get the state bool state = this->outputCard->getState(5); pm_fan_speed = this->outputCard->getValue(6); // 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) { updateACState(); } void ISEDisplay::updateuserACmode() { this->takeSerialMutex(); switch (user_mode) { case 1: this->displayAdapter->print("ac_mode.pic="); this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_mode.pic2="); this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC_PRESSED); this->sendStopBytes(); break; case 2: this->displayAdapter->print("ac_mode.pic="); this->displayAdapter->print(COMPONENT_AC_MODE_FAN_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_mode.pic2="); this->displayAdapter->print(COMPONENT_AC_MODE_FAN_PIC_PRESSED); this->sendStopBytes(); break; default: break; } this->giveSerialMutex(); } void ISEDisplay::updateACfanSpeed() { uint8_t fan_speed = this->climateCard->getFanSpeed(); this->takeSerialMutex(); switch (fan_speed) { case 0: this->displayAdapter->print("ac_fan.pic="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_AUTO_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_fan.pic2="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_AUTO_PIC_PRESSED); this->sendStopBytes(); break; case 1: this->displayAdapter->print("ac_fan.pic="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_HIGH_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_fan.pic2="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_HIGH_PIC_PRESSED); this->sendStopBytes(); break; case 2: this->displayAdapter->print("ac_fan.pic="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_MID_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_fan.pic2="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_MID_PIC_PRESSED); this->sendStopBytes(); break; case 3: this->displayAdapter->print("ac_fan.pic="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_LOW_PIC); this->sendStopBytes(); this->displayAdapter->print("ac_fan.pic2="); this->displayAdapter->print(COMPONENT_AC_FAN_MODE_LOW_PIC_PRESSED); this->sendStopBytes(); break; default: break; } this->giveSerialMutex(); } void ISEDisplay::updateACState() { // TODOlater : The cognitive complexity here is so high, maybe break up the method a bit? // Get the state uint8_t mode = this->climateCard->getMode(); uint8_t temperature = this->climateCard->getTemperature(); this->takeSerialMutex(); // Send the state to the display if (mode == 0) { this->displayAdapter->print("ac_temp.pco="); this->displayAdapter->print(33841); this->sendStopBytes(); 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(); updateuserACmode(); updateACfanSpeed(); this->displayAdapter->print("ac_temp.val="); this->displayAdapter->print(temperature); //this->displayAdapter->print("\""); this->sendStopBytes(); this->giveSerialMutex(); }