remote var now work
This commit is contained in:
parent
742027acf0
commit
34eeca14e0
6 changed files with 145 additions and 91 deletions
|
|
@ -25,7 +25,7 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
|||
this->lightLevelRow2 = 0;
|
||||
this->lightLevelRow3 = 0;
|
||||
this->lightLevelRow4 = 0;
|
||||
//this->time_since_last_screen_update = 0;
|
||||
// this->time_since_last_screen_update = 0;
|
||||
this->registerTouchCallback(bindedHandleTouch);
|
||||
this->reset();
|
||||
delay(1000);
|
||||
|
|
@ -36,12 +36,12 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
|||
this->updateAirPurifierState();
|
||||
this->updateACState();
|
||||
this->updateLightGroupStatePageDashboard();
|
||||
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->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);
|
||||
|
|
@ -69,7 +69,7 @@ void ISEDisplay::loop()
|
|||
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
|
||||
// time_since_last_screen_update = millis(); // update time since last activity
|
||||
if (page == PAGE_STANDBY)
|
||||
{
|
||||
switch (component)
|
||||
|
|
@ -80,7 +80,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
|||
// 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();
|
||||
// time_since_last_screen_update = millis();
|
||||
this->jumpToPage(2);
|
||||
// the function of the button is to open the dashboard from standby
|
||||
break;
|
||||
|
|
@ -111,7 +111,6 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
|||
|
||||
else if (page == PAGE_DASHBOARD)
|
||||
{
|
||||
|
||||
|
||||
switch (component)
|
||||
{
|
||||
|
|
@ -211,19 +210,19 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
|||
ac_fan_speed = (ac_fan_speed + 1) % 4;
|
||||
ESP_LOGI("ISEDisplay", "New AC fan speed: %d", ac_fan_speed);
|
||||
this->climateCard->setFanSpeed(ac_fan_speed);
|
||||
//updateACState();
|
||||
// updateACState();
|
||||
break;
|
||||
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||
break;
|
||||
this->climateCard->setTemperature(this->climateCard->getTemperature() - 1);
|
||||
//updateACState();
|
||||
// updateACState();
|
||||
break;
|
||||
case COMPONENT_AC_TEMP_UP_BUTTON:
|
||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||
break;
|
||||
this->climateCard->setTemperature(this->climateCard->getTemperature() + 1);
|
||||
//updateACState();
|
||||
// updateACState();
|
||||
break;
|
||||
case COMPONENT_PM_TOGGLE_BUTTON:
|
||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||
|
|
@ -235,9 +234,9 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
|||
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)
|
||||
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);
|
||||
ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed);
|
||||
updateAirPurifierState();
|
||||
break;
|
||||
case COMPONENT_PM_FAN_SPEED_INCREASE:
|
||||
|
|
@ -247,7 +246,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
|||
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);
|
||||
ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed);
|
||||
updateAirPurifierState();
|
||||
break;
|
||||
default:
|
||||
|
|
@ -272,13 +271,13 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value)
|
|||
{
|
||||
// Light
|
||||
updateLightGroupStatePageStandby();
|
||||
//time_since_last_screen_update = millis(); // update time since last activity
|
||||
// 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
|
||||
// time_since_last_screen_update = millis(); // update time since last activity
|
||||
}
|
||||
}
|
||||
else if (current_page == PAGE_DASHBOARD)
|
||||
|
|
@ -287,13 +286,13 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value)
|
|||
{
|
||||
// Light
|
||||
updateLightGroupStatePageDashboard();
|
||||
//time_since_last_screen_update = millis(); // update time since last activity
|
||||
// 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
|
||||
// time_since_last_screen_update = millis(); // update time since last activity
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -326,6 +325,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
|||
{
|
||||
weather_code = 63;
|
||||
}
|
||||
else if (strcmp(weather_string, "sunny") == 0)
|
||||
{
|
||||
weather_code = 63;
|
||||
}
|
||||
else if (strcmp(weather_string, "fair_night") == 0)
|
||||
{
|
||||
weather_code = 64;
|
||||
|
|
@ -334,11 +337,11 @@ void ISEDisplay::updateWeather(char *weather_string)
|
|||
{
|
||||
weather_code = 65;
|
||||
}
|
||||
else if (strcmp(weather_string, "clearsky_day") == 0)
|
||||
else if (strcmp(weather_string, "clear-day") == 0)
|
||||
{
|
||||
weather_code = 66;
|
||||
}
|
||||
else if (strcmp(weather_string, "clearsky_night") == 0)
|
||||
else if (strcmp(weather_string, "clear-night") == 0)
|
||||
{
|
||||
weather_code = 67;
|
||||
}
|
||||
|
|
@ -346,6 +349,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
|||
{
|
||||
weather_code = 68;
|
||||
}
|
||||
else if (strcmp(weather_string, "partlycloudy") == 0)
|
||||
{
|
||||
weather_code = 68;
|
||||
}
|
||||
else if (strcmp(weather_string, "partlycloudy_night") == 0)
|
||||
{
|
||||
weather_code = 69;
|
||||
|
|
@ -366,6 +373,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
|||
{
|
||||
weather_code = 73;
|
||||
}
|
||||
else if (strcmp(weather_string, "rainy") == 0)
|
||||
{
|
||||
weather_code = 73;
|
||||
}
|
||||
else if (strcmp(weather_string, "lightrain") == 0)
|
||||
{
|
||||
weather_code = 74;
|
||||
|
|
@ -378,9 +389,11 @@ void ISEDisplay::updateWeather(char *weather_string)
|
|||
{
|
||||
weather_code = 68;
|
||||
}
|
||||
ESP_LOGI("ISEDisplay", "Updating weather to: %s (%d)", weather_string, weather_code);
|
||||
|
||||
this->takeSerialMutex();
|
||||
this->displayAdapter->printf("weather_icon.pic=%s", weather_code);
|
||||
if (!this->takeSerialMutex())
|
||||
return;
|
||||
this->displayAdapter->printf("weather_icon.pic=%d", weather_code);
|
||||
this->sendStopBytes();
|
||||
this->giveSerialMutex();
|
||||
}
|
||||
|
|
@ -390,22 +403,37 @@ void ISEDisplay::updateTempOutside(float temp_outside)
|
|||
|
||||
// change temp_outside to int then display
|
||||
u_int8_t temp_outside_int = (u_int8_t)temp_outside;
|
||||
ESP_LOGI("ISEDisplay", "Updating temperature outside to: %d", temp_outside_int);
|
||||
this->takeSerialMutex();
|
||||
this->displayAdapter->printf("temp_outside.txt=%d", temp_outside_int);
|
||||
this->displayAdapter->printf("outside_temp.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();
|
||||
ESP_LOGI("ISEDisplay", "Updating PM2.5 outside to: %d", pm25_outside);
|
||||
u_int16_t curPage = this->currentPage;
|
||||
if (curPage == 2)
|
||||
{
|
||||
this->takeSerialMutex();
|
||||
this->displayAdapter->printf("pm_out.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)
|
||||
void ISEDisplay::updatePMinside(u_int16_t pm25_inside)
|
||||
{
|
||||
// TODO : get data from HA's Xiaomi air purifier sensor
|
||||
ESP_LOGI("ISEDisplay", "Updating PM2.5 inside to: %d", pm25_inside);
|
||||
u_int16_t curPage = this->currentPage;
|
||||
if (curPage == 2)
|
||||
{
|
||||
this->takeSerialMutex();
|
||||
this->displayAdapter->printf("pm_in.txt=\"%d\"", pm25_inside);
|
||||
this->sendStopBytes();
|
||||
this->giveSerialMutex();
|
||||
}
|
||||
}
|
||||
|
||||
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed)
|
||||
|
|
@ -417,14 +445,13 @@ void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_te
|
|||
{
|
||||
ESP_LOGI("ISEDisplay", "Setting AC state: = fan speed: %d, mode: %d, temperature: %d", ac_fan_speed, ac_mode, ac_temperature);
|
||||
|
||||
|
||||
this->climateCard->setFanSpeed(ac_fan_speed);
|
||||
ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", ac_fan_speed);
|
||||
this->climateCard->setMode(ac_mode);
|
||||
ESP_LOGI("ISEDisplay", "AC mode set to: %d", ac_mode);
|
||||
this->climateCard->setTemperature(ac_temperature);
|
||||
ESP_LOGI("ISEDisplay", "AC temperature set to: %d", ac_temperature);
|
||||
//updateACState();
|
||||
// updateACState();
|
||||
}
|
||||
void ISEDisplay::toggleLightGroupState()
|
||||
{
|
||||
|
|
@ -447,7 +474,7 @@ void ISEDisplay::toggleLightGroupStateStandby()
|
|||
{
|
||||
setLightLevel(i, state ? 0 : 3);
|
||||
}
|
||||
//updateLightGroupStatePageStandby();
|
||||
// updateLightGroupStatePageStandby();
|
||||
}
|
||||
void ISEDisplay::togglePM()
|
||||
{
|
||||
|
|
@ -516,9 +543,9 @@ void ISEDisplay::changeUserACmode()
|
|||
}
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
updateuserACmode(); // call to update mode part of the display seperately
|
||||
}
|
||||
|
|
@ -696,7 +723,7 @@ void ISEDisplay::updateAirPurifierState()
|
|||
|
||||
this->displayAdapter->print("pm_speed.val=");
|
||||
this->displayAdapter->print(pm_fan_speed);
|
||||
//this->displayAdapter->print("\"");
|
||||
// this->displayAdapter->print("\"");
|
||||
this->sendStopBytes();
|
||||
|
||||
this->displayAdapter->print("pm_speed.pco=");
|
||||
|
|
@ -716,7 +743,7 @@ void ISEDisplay::updateuserACmode()
|
|||
ESP_LOGI("ISEDisplay", "updating display user AC mode to: %d", user_mode);
|
||||
switch (user_mode)
|
||||
{
|
||||
case 1:
|
||||
case 1:
|
||||
this->displayAdapter->print("ac_mode.pic=");
|
||||
this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC);
|
||||
this->sendStopBytes();
|
||||
|
|
@ -827,7 +854,7 @@ void ISEDisplay::updateACState()
|
|||
|
||||
this->displayAdapter->print("ac_temp.val=");
|
||||
this->displayAdapter->print(temperature);
|
||||
//this->displayAdapter->print("\"");
|
||||
// this->displayAdapter->print("\"");
|
||||
this->sendStopBytes();
|
||||
|
||||
this->giveSerialMutex();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue