remote var now work
This commit is contained in:
parent
742027acf0
commit
34eeca14e0
6 changed files with 145 additions and 91 deletions
|
|
@ -12,7 +12,7 @@
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = wt32-eth01
|
board = wt32-eth01
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = siwats/ESPMegaPROR3@^2.2.4
|
lib_deps = siwats/ESPMegaPROR3@^2.2.5
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
build_flags = -DCORE_DEBUG_LEVEL=5
|
build_flags = -DCORE_DEBUG_LEVEL=5
|
||||||
upload_port = COM28
|
upload_port = COM28
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ object id:
|
||||||
5 s_pm_toggle
|
5 s_pm_toggle
|
||||||
6 s_time (txt) -> date
|
6 s_time (txt) -> date
|
||||||
7 s_date (txt) -> time
|
7 s_date (txt) -> time
|
||||||
8 s_outside_temp (txt) -> outside_temp
|
8 s_outside_temp (txt) -> temp_outside
|
||||||
9 idle_timer (timer) // wait one min for inactivity then dim screen
|
9 idle_timer (timer) // wait one min for inactivity then dim screen
|
||||||
10 s_weather_icon (pic)
|
10 weather_icon (pic)
|
||||||
|
|
||||||
|
|
||||||
picture id:
|
picture id:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
||||||
this->lightLevelRow2 = 0;
|
this->lightLevelRow2 = 0;
|
||||||
this->lightLevelRow3 = 0;
|
this->lightLevelRow3 = 0;
|
||||||
this->lightLevelRow4 = 0;
|
this->lightLevelRow4 = 0;
|
||||||
//this->time_since_last_screen_update = 0;
|
// this->time_since_last_screen_update = 0;
|
||||||
this->registerTouchCallback(bindedHandleTouch);
|
this->registerTouchCallback(bindedHandleTouch);
|
||||||
this->reset();
|
this->reset();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
@ -36,12 +36,12 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
||||||
this->updateAirPurifierState();
|
this->updateAirPurifierState();
|
||||||
this->updateACState();
|
this->updateACState();
|
||||||
this->updateLightGroupStatePageDashboard();
|
this->updateLightGroupStatePageDashboard();
|
||||||
this->outputCard->setValue(6,pm_fan_speed);
|
this->outputCard->setValue(6, pm_fan_speed);
|
||||||
this->outputCard->setValue(5,0);
|
this->outputCard->setValue(5, 0);
|
||||||
this->outputCard->setValue(1,0);
|
this->outputCard->setValue(1, 0);
|
||||||
this->outputCard->setValue(2,0);
|
this->outputCard->setValue(2, 0);
|
||||||
this->outputCard->setValue(3,0);
|
this->outputCard->setValue(3, 0);
|
||||||
this->outputCard->setValue(4,0);
|
this->outputCard->setValue(4, 0);
|
||||||
this->climateCard->setTemperature(ac_temperature);
|
this->climateCard->setTemperature(ac_temperature);
|
||||||
this->climateCard->setFanSpeed(ac_fan_speed);
|
this->climateCard->setFanSpeed(ac_fan_speed);
|
||||||
this->climateCard->setMode(ac_mode);
|
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)
|
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);
|
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)
|
if (page == PAGE_STANDBY)
|
||||||
{
|
{
|
||||||
switch (component)
|
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?
|
// 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
|
// 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
|
// 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);
|
this->jumpToPage(2);
|
||||||
// the function of the button is to open the dashboard from standby
|
// the function of the button is to open the dashboard from standby
|
||||||
break;
|
break;
|
||||||
|
|
@ -112,7 +112,6 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
else if (page == PAGE_DASHBOARD)
|
else if (page == PAGE_DASHBOARD)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
switch (component)
|
switch (component)
|
||||||
{
|
{
|
||||||
case COMPONENT_LIGHT_MASTER_BUTTON:
|
case COMPONENT_LIGHT_MASTER_BUTTON:
|
||||||
|
|
@ -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;
|
ac_fan_speed = (ac_fan_speed + 1) % 4;
|
||||||
ESP_LOGI("ISEDisplay", "New AC fan speed: %d", ac_fan_speed);
|
ESP_LOGI("ISEDisplay", "New AC fan speed: %d", ac_fan_speed);
|
||||||
this->climateCard->setFanSpeed(ac_fan_speed);
|
this->climateCard->setFanSpeed(ac_fan_speed);
|
||||||
//updateACState();
|
// updateACState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
this->climateCard->setTemperature(this->climateCard->getTemperature() - 1);
|
this->climateCard->setTemperature(this->climateCard->getTemperature() - 1);
|
||||||
//updateACState();
|
// updateACState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_AC_TEMP_UP_BUTTON:
|
case COMPONENT_AC_TEMP_UP_BUTTON:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
break;
|
break;
|
||||||
this->climateCard->setTemperature(this->climateCard->getTemperature() + 1);
|
this->climateCard->setTemperature(this->climateCard->getTemperature() + 1);
|
||||||
//updateACState();
|
// updateACState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_PM_TOGGLE_BUTTON:
|
case COMPONENT_PM_TOGGLE_BUTTON:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
|
|
@ -235,9 +234,9 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
break;
|
break;
|
||||||
pm_fan_speed = this->outputCard->getValue(6);
|
pm_fan_speed = this->outputCard->getValue(6);
|
||||||
ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed);
|
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));
|
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();
|
updateAirPurifierState();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_PM_FAN_SPEED_INCREASE:
|
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);
|
ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed);
|
||||||
if (pm_fan_speed >= 0 && pm_fan_speed <= 19)
|
if (pm_fan_speed >= 0 && pm_fan_speed <= 19)
|
||||||
this->outputCard->setValue(6, (pm_fan_speed + 1));
|
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();
|
updateAirPurifierState();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
@ -272,13 +271,13 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value)
|
||||||
{
|
{
|
||||||
// Light
|
// Light
|
||||||
updateLightGroupStatePageStandby();
|
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)
|
else if (pin == 4 || pin == 5)
|
||||||
{
|
{
|
||||||
// Air Purifier
|
// Air Purifier
|
||||||
updateAirPurifierStateStandby();
|
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)
|
else if (current_page == PAGE_DASHBOARD)
|
||||||
|
|
@ -287,13 +286,13 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value)
|
||||||
{
|
{
|
||||||
// Light
|
// Light
|
||||||
updateLightGroupStatePageDashboard();
|
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)
|
else if (pin == 4 || pin == 5)
|
||||||
{
|
{
|
||||||
// Air Purifier
|
// Air Purifier
|
||||||
updateAirPurifierState();
|
updateAirPurifierState();
|
||||||
//time_since_last_screen_update = millis(); // update time since last activity
|
// time_since_last_screen_update = millis(); // update time since last activity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -326,6 +325,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
||||||
{
|
{
|
||||||
weather_code = 63;
|
weather_code = 63;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(weather_string, "sunny") == 0)
|
||||||
|
{
|
||||||
|
weather_code = 63;
|
||||||
|
}
|
||||||
else if (strcmp(weather_string, "fair_night") == 0)
|
else if (strcmp(weather_string, "fair_night") == 0)
|
||||||
{
|
{
|
||||||
weather_code = 64;
|
weather_code = 64;
|
||||||
|
|
@ -334,11 +337,11 @@ void ISEDisplay::updateWeather(char *weather_string)
|
||||||
{
|
{
|
||||||
weather_code = 65;
|
weather_code = 65;
|
||||||
}
|
}
|
||||||
else if (strcmp(weather_string, "clearsky_day") == 0)
|
else if (strcmp(weather_string, "clear-day") == 0)
|
||||||
{
|
{
|
||||||
weather_code = 66;
|
weather_code = 66;
|
||||||
}
|
}
|
||||||
else if (strcmp(weather_string, "clearsky_night") == 0)
|
else if (strcmp(weather_string, "clear-night") == 0)
|
||||||
{
|
{
|
||||||
weather_code = 67;
|
weather_code = 67;
|
||||||
}
|
}
|
||||||
|
|
@ -346,6 +349,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
||||||
{
|
{
|
||||||
weather_code = 68;
|
weather_code = 68;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(weather_string, "partlycloudy") == 0)
|
||||||
|
{
|
||||||
|
weather_code = 68;
|
||||||
|
}
|
||||||
else if (strcmp(weather_string, "partlycloudy_night") == 0)
|
else if (strcmp(weather_string, "partlycloudy_night") == 0)
|
||||||
{
|
{
|
||||||
weather_code = 69;
|
weather_code = 69;
|
||||||
|
|
@ -366,6 +373,10 @@ void ISEDisplay::updateWeather(char *weather_string)
|
||||||
{
|
{
|
||||||
weather_code = 73;
|
weather_code = 73;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(weather_string, "rainy") == 0)
|
||||||
|
{
|
||||||
|
weather_code = 73;
|
||||||
|
}
|
||||||
else if (strcmp(weather_string, "lightrain") == 0)
|
else if (strcmp(weather_string, "lightrain") == 0)
|
||||||
{
|
{
|
||||||
weather_code = 74;
|
weather_code = 74;
|
||||||
|
|
@ -378,9 +389,11 @@ void ISEDisplay::updateWeather(char *weather_string)
|
||||||
{
|
{
|
||||||
weather_code = 68;
|
weather_code = 68;
|
||||||
}
|
}
|
||||||
|
ESP_LOGI("ISEDisplay", "Updating weather to: %s (%d)", weather_string, weather_code);
|
||||||
|
|
||||||
this->takeSerialMutex();
|
if (!this->takeSerialMutex())
|
||||||
this->displayAdapter->printf("weather_icon.pic=%s", weather_code);
|
return;
|
||||||
|
this->displayAdapter->printf("weather_icon.pic=%d", weather_code);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
|
@ -390,22 +403,37 @@ void ISEDisplay::updateTempOutside(float temp_outside)
|
||||||
|
|
||||||
// change temp_outside to int then display
|
// change temp_outside to int then display
|
||||||
u_int8_t temp_outside_int = (u_int8_t)temp_outside;
|
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->takeSerialMutex();
|
||||||
this->displayAdapter->printf("temp_outside.txt=%d", temp_outside_int);
|
this->displayAdapter->printf("outside_temp.txt=\"%d\"", temp_outside_int);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
void ISEDisplay::updatePMoutside(u_int16_t pm25_outside)
|
void ISEDisplay::updatePMoutside(u_int16_t pm25_outside)
|
||||||
{
|
{
|
||||||
this->takeSerialMutex();
|
ESP_LOGI("ISEDisplay", "Updating PM2.5 outside to: %d", pm25_outside);
|
||||||
this->displayAdapter->printf("pm_outside.txt=%d", pm25_outside);
|
u_int16_t curPage = this->currentPage;
|
||||||
this->sendStopBytes();
|
if (curPage == 2)
|
||||||
this->giveSerialMutex();
|
{
|
||||||
|
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
|
// 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
|
// 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)
|
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);
|
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);
|
this->climateCard->setFanSpeed(ac_fan_speed);
|
||||||
ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", ac_fan_speed);
|
ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", ac_fan_speed);
|
||||||
this->climateCard->setMode(ac_mode);
|
this->climateCard->setMode(ac_mode);
|
||||||
ESP_LOGI("ISEDisplay", "AC mode set to: %d", ac_mode);
|
ESP_LOGI("ISEDisplay", "AC mode set to: %d", ac_mode);
|
||||||
this->climateCard->setTemperature(ac_temperature);
|
this->climateCard->setTemperature(ac_temperature);
|
||||||
ESP_LOGI("ISEDisplay", "AC temperature set to: %d", ac_temperature);
|
ESP_LOGI("ISEDisplay", "AC temperature set to: %d", ac_temperature);
|
||||||
//updateACState();
|
// updateACState();
|
||||||
}
|
}
|
||||||
void ISEDisplay::toggleLightGroupState()
|
void ISEDisplay::toggleLightGroupState()
|
||||||
{
|
{
|
||||||
|
|
@ -447,7 +474,7 @@ void ISEDisplay::toggleLightGroupStateStandby()
|
||||||
{
|
{
|
||||||
setLightLevel(i, state ? 0 : 3);
|
setLightLevel(i, state ? 0 : 3);
|
||||||
}
|
}
|
||||||
//updateLightGroupStatePageStandby();
|
// updateLightGroupStatePageStandby();
|
||||||
}
|
}
|
||||||
void ISEDisplay::togglePM()
|
void ISEDisplay::togglePM()
|
||||||
{
|
{
|
||||||
|
|
@ -516,9 +543,9 @@ void ISEDisplay::changeUserACmode()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // ie mode is off
|
{ // ie mode is off
|
||||||
// do nothing as the state is keep in user_mode
|
// do nothing as the state is keep in user_mode
|
||||||
// the mode will change to user_mode when turn on by toggleAC()
|
// 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", "do nothing; user mode: %d , actual mode: %d", user_mode, mode);
|
||||||
}
|
}
|
||||||
updateuserACmode(); // call to update mode part of the display seperately
|
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_speed.val=");
|
||||||
this->displayAdapter->print(pm_fan_speed);
|
this->displayAdapter->print(pm_fan_speed);
|
||||||
//this->displayAdapter->print("\"");
|
// this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
||||||
this->displayAdapter->print("pm_speed.pco=");
|
this->displayAdapter->print("pm_speed.pco=");
|
||||||
|
|
@ -827,7 +854,7 @@ void ISEDisplay::updateACState()
|
||||||
|
|
||||||
this->displayAdapter->print("ac_temp.val=");
|
this->displayAdapter->print("ac_temp.val=");
|
||||||
this->displayAdapter->print(temperature);
|
this->displayAdapter->print(temperature);
|
||||||
//this->displayAdapter->print("\"");
|
// this->displayAdapter->print("\"");
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class ISEDisplay : public ESPMegaDisplay {
|
||||||
void updateWeather(char *weather_string);
|
void updateWeather(char *weather_string);
|
||||||
void updateTempOutside(float temp_outside);
|
void updateTempOutside(float temp_outside);
|
||||||
void updatePMoutside(u_int16_t pm25_outside);
|
void updatePMoutside(u_int16_t pm25_outside);
|
||||||
void updatePMinside(u_int8_t pm25_inside);
|
void updatePMinside(u_int16_t pm25_inside);
|
||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
122
src/main.cpp
122
src/main.cpp
|
|
@ -1,8 +1,9 @@
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
// RemoteVariable pm25_out = RemoteVariable();
|
RemoteVariable pm25_out = RemoteVariable();
|
||||||
// RemoteVariable temp_out = RemoteVariable();
|
RemoteVariable temp_out = RemoteVariable();
|
||||||
// RemoteVariable weather = RemoteVariable();
|
RemoteVariable weather = RemoteVariable();
|
||||||
|
RemoteVariable pm25_in = RemoteVariable();
|
||||||
|
|
||||||
const char *mode_names[] = {"off", "fan_only", "cool"};
|
const char *mode_names[] = {"off", "fan_only", "cool"};
|
||||||
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
|
||||||
|
|
@ -108,11 +109,13 @@ void setup()
|
||||||
// PM2.5 PPM Remote Variable
|
// PM2.5 PPM Remote Variable
|
||||||
// 12 bytes remote variable, 11 characters + null terminator
|
// 12 bytes remote variable, 11 characters + null terminator
|
||||||
// Enable value request at /iqair/pm25_request
|
// Enable value request at /iqair/pm25_request
|
||||||
// pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/value_request");
|
pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/request_value");
|
||||||
// // Temperature Remote Variable
|
// Temperature Remote Variable
|
||||||
// temp_out.begin(6, "/temp/value", espmega.iot, true, "/weather/temp_request");
|
temp_out.begin(6, "/temp/value", espmega.iot, true, "/temp/request_value");
|
||||||
// // Weather Remote Variable
|
// Weather Remote Variable
|
||||||
// weather.begin(45, "/weather", espmega.iot, true, "/weather_request");
|
weather.begin(45, "/weather/value", espmega.iot, true, "/weather/request_value");
|
||||||
|
// PM2.5 PPM Remote Variable
|
||||||
|
pm25_in.begin(6, "/pm/value", espmega.iot, true, "/pm/request_value");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|
@ -142,50 +145,71 @@ void loop()
|
||||||
iseDisplay.updateDateTimeText(time);
|
iseDisplay.updateDateTimeText(time);
|
||||||
last_time_updated = millis();
|
last_time_updated = millis();
|
||||||
}
|
}
|
||||||
// Update the PM2.5 PPM value every 5 minutes
|
//Update the PM2.5 PPM value every 15 seconds
|
||||||
// static uint32_t last_pm25_out_update = 0;
|
static uint32_t last_pm25_out_update = 0;
|
||||||
// if (millis() - last_pm25_out_update > 300000)
|
if (millis() - last_pm25_out_update > 15000)
|
||||||
// {
|
{
|
||||||
// uint16_t pm25_out_value = get_pm25_out();
|
uint16_t pm25_out_value = get_pm25_out();
|
||||||
// iseDisplay.updatePMoutside(pm25_out_value);
|
//ESP_LOGI("loopPM2.5","updating PM2.5 from MQTT inside loop: %d", pm25_out_value);
|
||||||
// last_pm25_out_update = millis();
|
iseDisplay.updatePMoutside(pm25_out_value);
|
||||||
// }
|
last_pm25_out_update = millis();
|
||||||
// // Update the temperature value every 5 minutes
|
}
|
||||||
// static uint32_t last_temp_out_update = 0;
|
// Update the PM2.5 PPM value every 15 seconds
|
||||||
// if (millis() - last_temp_out_update > 300000)
|
static uint32_t last_pm25_in_update = 0;
|
||||||
// {
|
if (millis() - last_pm25_in_update > 15000)
|
||||||
// float temp_out_value = get_temp_out();
|
{
|
||||||
// iseDisplay.updateTempOutside(temp_out_value);
|
uint8_t pm25_in_value = get_pm25_in();
|
||||||
// last_temp_out_update = millis();
|
iseDisplay.updatePMinside(pm25_in_value);
|
||||||
// }
|
last_pm25_in_update = millis();
|
||||||
// // Update the weather value every 5 minutes
|
}
|
||||||
// static uint32_t last_weather_update = 0;
|
// Update the temperature value every 15 seconds
|
||||||
// if (millis() - last_weather_update > 300000)
|
static uint32_t last_temp_out_update = 0;
|
||||||
// {
|
if (millis() - last_temp_out_update > 15000)
|
||||||
// char *weather_value = weather.getValue();
|
{
|
||||||
// iseDisplay.updateWeather(weather_value);
|
float temp_out_value = get_temp_out();
|
||||||
// last_weather_update = millis();
|
iseDisplay.updateTempOutside(temp_out_value);
|
||||||
// }
|
last_temp_out_update = millis();
|
||||||
|
}
|
||||||
|
// Update the weather value every 15 seconds
|
||||||
|
static uint32_t last_weather_update = 0;
|
||||||
|
if (millis() - last_weather_update > 15000)
|
||||||
|
{
|
||||||
|
char *weather_value = weather.getValue();
|
||||||
|
iseDisplay.updateWeather(weather_value);
|
||||||
|
last_weather_update = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_pin_change(uint8_t pin, uint8_t value)
|
void on_pin_change(uint8_t pin, uint8_t value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// uint16_t get_pm25_out()
|
uint16_t get_pm25_out()
|
||||||
// {
|
{
|
||||||
// uint16_t pm25_out_value = 0;
|
uint16_t pm25_out_value = 0;
|
||||||
// // Read PM2.5 PPM from sensor
|
// Read PM2.5 PPM from sensor
|
||||||
// pm25_out_value = atoi(pm25_out.getValue());
|
pm25_out_value = atoi(pm25_out.getValue());
|
||||||
// return pm25_out_value;
|
ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_out_value);
|
||||||
// }
|
return pm25_out_value;
|
||||||
// float get_temp_out()
|
}
|
||||||
// {
|
|
||||||
// float temp_out_value = 0;
|
uint16_t get_pm25_in()
|
||||||
// // Read temperature from sensor
|
{
|
||||||
// temp_out_value = atof(temp_out.getValue());
|
uint16_t pm25_in_value = 0;
|
||||||
// return temp_out_value;
|
// Read PM2.5 PPM from sensor
|
||||||
// }
|
pm25_in_value = atoi(pm25_in.getValue());
|
||||||
|
ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_in_value);
|
||||||
|
return pm25_in_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float get_temp_out()
|
||||||
|
{
|
||||||
|
float temp_out_value = 0;
|
||||||
|
// Read temperature from sensor
|
||||||
|
temp_out_value = atof(temp_out.getValue());
|
||||||
|
ESP_LOGI("Temperature", "getting Temperature from MQTT: %f", temp_out_value);
|
||||||
|
return temp_out_value;
|
||||||
|
}
|
||||||
|
|
||||||
void handlePageChange(uint8_t page)
|
void handlePageChange(uint8_t page)
|
||||||
{
|
{
|
||||||
|
|
@ -210,9 +234,11 @@ void handlePageChange(uint8_t page)
|
||||||
}
|
}
|
||||||
|
|
||||||
// iseDisplay.updatePMinside();
|
// iseDisplay.updatePMinside();
|
||||||
/* iseDisplay.updatePMoutside(get_pm25_out());
|
iseDisplay.updatePMoutside(get_pm25_out());
|
||||||
|
iseDisplay.updatePMinside(get_pm25_in());
|
||||||
iseDisplay.updateWeather(weather.getValue());
|
iseDisplay.updateWeather(weather.getValue());
|
||||||
iseDisplay.updateTempOutside(get_temp_out()); */
|
iseDisplay.updateTempOutside(get_temp_out());
|
||||||
|
|
||||||
/* iseDisplay.updateACState();
|
/* iseDisplay.updateACState();
|
||||||
iseDisplay.updateAirPurifierState();
|
iseDisplay.updateAirPurifierState();
|
||||||
iseDisplay.updateLightGroupStatePageStandby();
|
iseDisplay.updateLightGroupStatePageStandby();
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,5 @@ void loop();
|
||||||
void on_pin_change(uint8_t pin, uint8_t value);
|
void on_pin_change(uint8_t pin, uint8_t value);
|
||||||
|
|
||||||
uint16_t get_pm25_out();
|
uint16_t get_pm25_out();
|
||||||
|
uint16_t get_pm25_in();
|
||||||
float get_temp_out();
|
float get_temp_out();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue