comment our remote var

This commit is contained in:
reaw 2024-02-09 12:56:54 +07:00
parent 733ed54f9b
commit c99348bb72
3 changed files with 60 additions and 53 deletions

View file

@ -12,7 +12,7 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar
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::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);
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
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(3,0);
this->outputCard->setValue(4,0);
// this->climateCard->setTemperature(ac_temperature);
// this->climateCard->setFanSpeed(ac_fan_speed);
// this->climateCard->setMode(ac_mode);
this->climateCard->setTemperature(ac_temperature);
this->climateCard->setFanSpeed(ac_fan_speed);
this->climateCard->setMode(ac_mode);
}
void ISEDisplay::loop()
{
@ -64,7 +64,6 @@ void ISEDisplay::loop()
this->jumpToPage(1);
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?
// 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;
@ -130,6 +130,7 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type
{
setLightLevel(i, 1);
}
updateLightGroupStatePageDashboard();
break;
case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT:
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);
}
updateLightGroupStatePageDashboard();
break;
case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT:
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);
}
updateLightGroupStatePageDashboard();
break;
case COMPONENT_LIGHT_ROW1_SLIDER:
if (touch_type != TOUCH_TYPE_RELEASE)
@ -517,7 +520,6 @@ void ISEDisplay::setLightLevel(uint8_t row, uint8_t level)
if (row == i)
this->outputCard->setValue(row, level);
}
updateLightGroupStatePageDashboard();
}
void ISEDisplay::updateLightGroupStatePageStandby()
@ -621,7 +623,6 @@ void ISEDisplay::toggleLightIndividual(uint8_t row)
// Set the state
setLightLevel(row, state);
updateLightGroupStatePageDashboard();
updateLightGroupStatePageStandby();
}
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
setLightLevel(row, state);
updateLightGroupStatePageDashboard();
}
void ISEDisplay::updateAirPurifierStateStandby()
{
@ -696,6 +698,10 @@ void ISEDisplay::updateAirPurifierState()
this->giveSerialMutex();
}
void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature)
{
updateACState();
}
void ISEDisplay::updateuserACmode()
{
this->takeSerialMutex();

View file

@ -35,6 +35,7 @@ class ISEDisplay : public ESPMegaDisplay {
void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
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 setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature);
void setLightLevel(uint8_t row, uint8_t level);

View file

@ -1,8 +1,8 @@
#include <main.hpp>
RemoteVariable pm25_out = RemoteVariable();
RemoteVariable temp_out = RemoteVariable();
RemoteVariable weather = RemoteVariable();
// RemoteVariable pm25_out = RemoteVariable();
// RemoteVariable temp_out = RemoteVariable();
// RemoteVariable weather = RemoteVariable();
const char *mode_names[] = {"off", "fan_only", "cool"};
const char *fan_speed_names[] = {"auto", "high", "medium", "low"};
@ -109,11 +109,11 @@ void setup()
// PM2.5 PPM Remote Variable
// 12 bytes remote variable, 11 characters + null terminator
// Enable value request at /iqair/pm25_request
pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/value_request");
// Temperature Remote Variable
temp_out.begin(6, "/temp/value", espmega.iot, true, "/weather/temp_request");
// Weather Remote Variable
weather.begin(45, "/weather", espmega.iot, true, "/weather_request");
// pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/value_request");
// // Temperature Remote Variable
// temp_out.begin(6, "/temp/value", espmega.iot, true, "/weather/temp_request");
// // Weather Remote Variable
// weather.begin(45, "/weather", espmega.iot, true, "/weather_request");
}
void loop()
@ -145,29 +145,29 @@ void loop()
last_time_updated = millis();
}
// Update the PM2.5 PPM value every 5 minutes
static uint32_t last_pm25_out_update = 0;
if (millis() - last_pm25_out_update > 300000)
{
uint16_t pm25_out_value = get_pm25_out();
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;
if (millis() - last_temp_out_update > 300000)
{
float temp_out_value = get_temp_out();
iseDisplay.updateTempOutside(temp_out_value);
last_temp_out_update = millis();
}
// Update the weather value every 5 minutes
static uint32_t last_weather_update = 0;
if (millis() - last_weather_update > 300000)
{
char *weather_value = weather.getValue();
iseDisplay.updateWeather(weather_value);
last_weather_update = millis();
}
// static uint32_t last_pm25_out_update = 0;
// if (millis() - last_pm25_out_update > 300000)
// {
// uint16_t pm25_out_value = get_pm25_out();
// 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;
// if (millis() - last_temp_out_update > 300000)
// {
// float temp_out_value = get_temp_out();
// iseDisplay.updateTempOutside(temp_out_value);
// last_temp_out_update = millis();
// }
// // Update the weather value every 5 minutes
// static uint32_t last_weather_update = 0;
// if (millis() - last_weather_update > 300000)
// {
// char *weather_value = weather.getValue();
// iseDisplay.updateWeather(weather_value);
// 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 pm25_out_value = 0;
// Read PM2.5 PPM from sensor
pm25_out_value = atoi(pm25_out.getValue());
return pm25_out_value;
}
float get_temp_out()
{
float temp_out_value = 0;
// Read temperature from sensor
temp_out_value = atof(temp_out.getValue());
return temp_out_value;
}
// uint16_t get_pm25_out()
// {
// uint16_t pm25_out_value = 0;
// // Read PM2.5 PPM from sensor
// pm25_out_value = atoi(pm25_out.getValue());
// return pm25_out_value;
// }
// float get_temp_out()
// {
// float temp_out_value = 0;
// // Read temperature from sensor
// temp_out_value = atof(temp_out.getValue());
// return temp_out_value;
// }
void handlePageChange(uint8_t page) {