comment our remote var
This commit is contained in:
parent
733ed54f9b
commit
c99348bb72
3 changed files with 60 additions and 53 deletions
|
|
@ -12,7 +12,7 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
||||||
this->outputCard = outputCard;
|
this->outputCard = outputCard;
|
||||||
this->climateCard = climateCard;
|
this->climateCard = climateCard;
|
||||||
auto bindedHandlePWMChange = std::bind(&ISEDisplay::handlePWMChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
auto bindedHandlePWMChange = std::bind(&ISEDisplay::handlePWMChange, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
auto bindedHandleACChange = std::bind(&ISEDisplay::setACstate, 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);
|
auto bindedHandleTouch = std::bind(&ISEDisplay::handleTouch, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||||
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
|
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
|
||||||
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
||||||
|
|
@ -43,9 +43,9 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
|
||||||
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);
|
||||||
}
|
}
|
||||||
void ISEDisplay::loop()
|
void ISEDisplay::loop()
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +64,6 @@ void ISEDisplay::loop()
|
||||||
this->jumpToPage(1);
|
this->jumpToPage(1);
|
||||||
ESP_LOGI("ISEDisplay", "Jumping to standby page");
|
ESP_LOGI("ISEDisplay", "Jumping to standby page");
|
||||||
}
|
}
|
||||||
ESP_LOGI("ISEDisplay", "No activity for 2 minutes & currently at standby page");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,6 +81,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();
|
||||||
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;
|
||||||
|
|
@ -130,6 +130,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
{
|
{
|
||||||
setLightLevel(i, 1);
|
setLightLevel(i, 1);
|
||||||
}
|
}
|
||||||
|
updateLightGroupStatePageDashboard();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT:
|
case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
|
|
@ -138,6 +139,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
{
|
{
|
||||||
setLightLevel(i, 2);
|
setLightLevel(i, 2);
|
||||||
}
|
}
|
||||||
|
updateLightGroupStatePageDashboard();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT:
|
case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
|
|
@ -146,6 +148,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
|
||||||
{
|
{
|
||||||
setLightLevel(i, 3);
|
setLightLevel(i, 3);
|
||||||
}
|
}
|
||||||
|
updateLightGroupStatePageDashboard();
|
||||||
break;
|
break;
|
||||||
case COMPONENT_LIGHT_ROW1_SLIDER:
|
case COMPONENT_LIGHT_ROW1_SLIDER:
|
||||||
if (touch_type != TOUCH_TYPE_RELEASE)
|
if (touch_type != TOUCH_TYPE_RELEASE)
|
||||||
|
|
@ -517,7 +520,6 @@ void ISEDisplay::setLightLevel(uint8_t row, uint8_t level)
|
||||||
if (row == i)
|
if (row == i)
|
||||||
this->outputCard->setValue(row, level);
|
this->outputCard->setValue(row, level);
|
||||||
}
|
}
|
||||||
updateLightGroupStatePageDashboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISEDisplay::updateLightGroupStatePageStandby()
|
void ISEDisplay::updateLightGroupStatePageStandby()
|
||||||
|
|
@ -621,7 +623,6 @@ void ISEDisplay::toggleLightIndividual(uint8_t row)
|
||||||
// Set the state
|
// Set the state
|
||||||
setLightLevel(row, state);
|
setLightLevel(row, state);
|
||||||
updateLightGroupStatePageDashboard();
|
updateLightGroupStatePageDashboard();
|
||||||
updateLightGroupStatePageStandby();
|
|
||||||
}
|
}
|
||||||
void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel)
|
void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel)
|
||||||
{
|
{
|
||||||
|
|
@ -650,6 +651,7 @@ void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel)
|
||||||
}
|
}
|
||||||
// Set the state
|
// Set the state
|
||||||
setLightLevel(row, state);
|
setLightLevel(row, state);
|
||||||
|
updateLightGroupStatePageDashboard();
|
||||||
}
|
}
|
||||||
void ISEDisplay::updateAirPurifierStateStandby()
|
void ISEDisplay::updateAirPurifierStateStandby()
|
||||||
{
|
{
|
||||||
|
|
@ -696,12 +698,16 @@ void ISEDisplay::updateAirPurifierState()
|
||||||
|
|
||||||
this->giveSerialMutex();
|
this->giveSerialMutex();
|
||||||
}
|
}
|
||||||
|
void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature)
|
||||||
|
{
|
||||||
|
updateACState();
|
||||||
|
}
|
||||||
void ISEDisplay::updateuserACmode()
|
void ISEDisplay::updateuserACmode()
|
||||||
{
|
{
|
||||||
this->takeSerialMutex();
|
this->takeSerialMutex();
|
||||||
switch (user_mode)
|
switch (user_mode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
this->displayAdapter->print("ac_mode.pic=");
|
this->displayAdapter->print("ac_mode.pic=");
|
||||||
this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC);
|
this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC);
|
||||||
this->sendStopBytes();
|
this->sendStopBytes();
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ class ISEDisplay : public ESPMegaDisplay {
|
||||||
|
|
||||||
void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
|
void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
|
||||||
void handlePWMChange(uint8_t pin, bool state, uint16_t value);
|
void handlePWMChange(uint8_t pin, bool state, uint16_t value);
|
||||||
|
void handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
|
||||||
void setPMstate(bool is_pm_on, uint8_t pm_fan_speed);
|
void setPMstate(bool is_pm_on, uint8_t pm_fan_speed);
|
||||||
void setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature);
|
void setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature);
|
||||||
void setLightLevel(uint8_t row, uint8_t level);
|
void setLightLevel(uint8_t row, uint8_t level);
|
||||||
|
|
|
||||||
90
src/main.cpp
90
src/main.cpp
|
|
@ -1,8 +1,8 @@
|
||||||
#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();
|
||||||
|
|
||||||
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"};
|
||||||
|
|
@ -109,11 +109,11 @@ 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/value_request");
|
||||||
// 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, "/weather/temp_request");
|
||||||
// Weather Remote Variable
|
// // Weather Remote Variable
|
||||||
weather.begin(45, "/weather", espmega.iot, true, "/weather_request");
|
// weather.begin(45, "/weather", espmega.iot, true, "/weather_request");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|
@ -145,29 +145,29 @@ void loop()
|
||||||
last_time_updated = millis();
|
last_time_updated = millis();
|
||||||
}
|
}
|
||||||
// Update the PM2.5 PPM value every 5 minutes
|
// Update the PM2.5 PPM value every 5 minutes
|
||||||
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 > 300000)
|
||||||
{
|
// {
|
||||||
uint16_t pm25_out_value = get_pm25_out();
|
// uint16_t pm25_out_value = get_pm25_out();
|
||||||
iseDisplay.updatePMoutside(pm25_out_value);
|
// iseDisplay.updatePMoutside(pm25_out_value);
|
||||||
last_pm25_out_update = millis();
|
// last_pm25_out_update = millis();
|
||||||
}
|
// }
|
||||||
// Update the temperature value every 5 minutes
|
// // Update the temperature value every 5 minutes
|
||||||
static uint32_t last_temp_out_update = 0;
|
// static uint32_t last_temp_out_update = 0;
|
||||||
if (millis() - last_temp_out_update > 300000)
|
// if (millis() - last_temp_out_update > 300000)
|
||||||
{
|
// {
|
||||||
float temp_out_value = get_temp_out();
|
// float temp_out_value = get_temp_out();
|
||||||
iseDisplay.updateTempOutside(temp_out_value);
|
// iseDisplay.updateTempOutside(temp_out_value);
|
||||||
last_temp_out_update = millis();
|
// last_temp_out_update = millis();
|
||||||
}
|
// }
|
||||||
// Update the weather value every 5 minutes
|
// // Update the weather value every 5 minutes
|
||||||
static uint32_t last_weather_update = 0;
|
// static uint32_t last_weather_update = 0;
|
||||||
if (millis() - last_weather_update > 300000)
|
// if (millis() - last_weather_update > 300000)
|
||||||
{
|
// {
|
||||||
char *weather_value = weather.getValue();
|
// char *weather_value = weather.getValue();
|
||||||
iseDisplay.updateWeather(weather_value);
|
// iseDisplay.updateWeather(weather_value);
|
||||||
last_weather_update = millis();
|
// last_weather_update = millis();
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,20 +176,20 @@ 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;
|
// return pm25_out_value;
|
||||||
}
|
// }
|
||||||
float get_temp_out()
|
// float get_temp_out()
|
||||||
{
|
// {
|
||||||
float temp_out_value = 0;
|
// float temp_out_value = 0;
|
||||||
// Read temperature from sensor
|
// // Read temperature from sensor
|
||||||
temp_out_value = atof(temp_out.getValue());
|
// temp_out_value = atof(temp_out.getValue());
|
||||||
return temp_out_value;
|
// return temp_out_value;
|
||||||
}
|
// }
|
||||||
|
|
||||||
void handlePageChange(uint8_t page) {
|
void handlePageChange(uint8_t page) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue