change to callback
This commit is contained in:
parent
974f7ac007
commit
ea4974893e
4 changed files with 170 additions and 42 deletions
|
|
@ -717,7 +717,7 @@ void ISEDisplay::updateAirPurifierState()
|
|||
return;
|
||||
}
|
||||
else if(currentPage ==1){
|
||||
updateAirPurifierStateStandby();
|
||||
updateAirPurifierStateStandby();
|
||||
return;
|
||||
}
|
||||
// Get the state
|
||||
|
|
|
|||
146
src/main.cpp
146
src/main.cpp
|
|
@ -100,6 +100,29 @@ void setup()
|
|||
climateCard.loadStateFromFRAM();
|
||||
climateCard.setFRAMAutoSave(true);
|
||||
espmega.display->bindClimateCard(&climateCard);
|
||||
// auto binded_display_update_on_pm25_out = std::bind(&display_update,0,std::placeholders::_1);
|
||||
// auto binded_display_update_on_pm25_in = std::bind(&display_update,1,std::placeholders::_1);
|
||||
// auto binded_display_update_on_temp_out = std::bind(&display_update,2,std::placeholders::_1);
|
||||
// auto binded_display_update_on_weather = std::bind(&display_update,3,std::placeholders::_1);
|
||||
// auto binded_display_update_on_pm_switch = std::bind(&display_update,4,std::placeholders::_1);
|
||||
// auto binded_display_update_on_pm_fan_speed = std::bind(&display_update,5,std::placeholders::_1);
|
||||
|
||||
// pm25_out.registerCallback(std::function<void (char*)>(binded_display_update_on_pm25_out));
|
||||
// pm25_in.registerCallback(std::function<void (char*)>(binded_display_update_on_pm25_in));
|
||||
// temp_out.registerCallback(std::function<void (char*)>(binded_display_update_on_temp_out));
|
||||
// weather.registerCallback(std::function<void (char*)>(binded_display_update_on_weather));
|
||||
// pm_switch.registerCallback(std::function<void (char*)>(binded_display_update_on_pm_switch));
|
||||
// pm_fan_speed.registerCallback(std::function<void (char*)>(binded_display_update_on_pm_fan_speed));
|
||||
|
||||
pm25_out.registerCallback(&pm25outupdatedisplay);
|
||||
pm25_in.registerCallback(&pm25inupdatedisplay);
|
||||
temp_out.registerCallback(&tempoutupdatedisplay);
|
||||
weather.registerCallback(&weatherupdatedisplay);
|
||||
pm_switch.registerCallback(&pmswitchupdatedisplay);
|
||||
pm_fan_speed.registerCallback(&pmfanspeedupdatedisplay);
|
||||
|
||||
|
||||
|
||||
// placeholder
|
||||
// PM2.5 PPM Remote Variable
|
||||
// 12 bytes remote variable, 11 characters + null terminator
|
||||
|
|
@ -128,6 +151,51 @@ void setup()
|
|||
|
||||
}
|
||||
|
||||
// void update_display(uint8_t type, char *value){
|
||||
// switch (type)
|
||||
// {
|
||||
// case 0:
|
||||
// iseDisplay.updatePMoutside(get_pm25_out());
|
||||
// break;
|
||||
// case 1:
|
||||
// iseDisplay.updatePMinside(get_pm25_in());
|
||||
// break;
|
||||
// case 2:
|
||||
// iseDisplay.updateTempOutside(get_temp_out());
|
||||
// break;
|
||||
// case 3:
|
||||
// iseDisplay.updateWeather(weather.getValue());
|
||||
// break;
|
||||
// case 4:
|
||||
// iseDisplay.updateAirPurifierState();
|
||||
// break;
|
||||
// case 5:
|
||||
// iseDisplay.updateAirPurifierState();
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
void pm25outupdatedisplay(char* value){
|
||||
iseDisplay.updatePMoutside(get_pm25_out());
|
||||
}
|
||||
void pm25inupdatedisplay(char* value){
|
||||
iseDisplay.updatePMinside(get_pm25_in());
|
||||
}
|
||||
void tempoutupdatedisplay(char* value){
|
||||
iseDisplay.updateTempOutside(get_temp_out());
|
||||
}
|
||||
void weatherupdatedisplay(char* value){
|
||||
iseDisplay.updateWeather(weather.getValue());
|
||||
}
|
||||
void pmfanspeedupdatedisplay(char* value){
|
||||
iseDisplay.updateAirPurifierState();
|
||||
}
|
||||
void pmswitchupdatedisplay(char* value){
|
||||
iseDisplay.updateAirPurifierState();
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
espmega.loop();
|
||||
|
|
@ -155,46 +223,46 @@ void loop()
|
|||
iseDisplay.updateDateTimeText(time);
|
||||
last_time_updated = millis();
|
||||
}
|
||||
// Update the PM2.5 PPM value every 15 seconds
|
||||
static uint32_t last_pm25_out_update = 0;
|
||||
if (millis() - last_pm25_out_update > 15000)
|
||||
{
|
||||
uint16_t pm25_out_value = get_pm25_out();
|
||||
// ESP_LOGI("loopPM2.5","updating PM2.5 from MQTT inside loop: %d", pm25_out_value);
|
||||
iseDisplay.updatePMoutside(pm25_out_value);
|
||||
last_pm25_out_update = millis();
|
||||
}
|
||||
// Update the PM2.5 PPM value every 15 seconds
|
||||
static uint32_t last_pm25_in_update = 0;
|
||||
if (millis() - last_pm25_in_update > 15000)
|
||||
{
|
||||
uint8_t pm25_in_value = get_pm25_in();
|
||||
iseDisplay.updatePMinside(pm25_in_value);
|
||||
last_pm25_in_update = millis();
|
||||
}
|
||||
// // Update the PM2.5 PPM value every 15 seconds
|
||||
// static uint32_t last_pm25_out_update = 0;
|
||||
// if (millis() - last_pm25_out_update > 15000)
|
||||
// {
|
||||
// uint16_t pm25_out_value = get_pm25_out();
|
||||
// // ESP_LOGI("loopPM2.5","updating PM2.5 from MQTT inside loop: %d", pm25_out_value);
|
||||
// iseDisplay.updatePMoutside(pm25_out_value);
|
||||
// last_pm25_out_update = millis();
|
||||
// }
|
||||
// // Update the PM2.5 PPM value every 15 seconds
|
||||
// static uint32_t last_pm25_in_update = 0;
|
||||
// if (millis() - last_pm25_in_update > 15000)
|
||||
// {
|
||||
// uint8_t pm25_in_value = get_pm25_in();
|
||||
// iseDisplay.updatePMinside(pm25_in_value);
|
||||
// last_pm25_in_update = millis();
|
||||
// }
|
||||
// Update the temperature value every 15 seconds
|
||||
static uint32_t last_temp_out_update = 0;
|
||||
if (millis() - last_temp_out_update > 15000)
|
||||
{
|
||||
float temp_out_value = get_temp_out();
|
||||
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();
|
||||
}
|
||||
// Update the PM state every 1 seconds
|
||||
static uint32_t last_pm_switch_update = 0;
|
||||
if (millis() - last_pm_switch_update > 500)
|
||||
{
|
||||
iseDisplay.updateAirPurifierState();
|
||||
last_pm_switch_update = millis();
|
||||
}
|
||||
// static uint32_t last_temp_out_update = 0;
|
||||
// if (millis() - last_temp_out_update > 15000)
|
||||
// {
|
||||
// float temp_out_value = get_temp_out();
|
||||
// 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();
|
||||
// }
|
||||
// // Update the PM state every 1 seconds
|
||||
// static uint32_t last_pm_switch_update = 0;
|
||||
// if (millis() - last_pm_switch_update > 500)
|
||||
// {
|
||||
// iseDisplay.updateAirPurifierState();
|
||||
// last_pm_switch_update = millis();
|
||||
// }
|
||||
}
|
||||
|
||||
void on_pin_change(uint8_t pin, uint8_t value)
|
||||
|
|
|
|||
|
|
@ -38,4 +38,11 @@ uint16_t get_pm25_out();
|
|||
uint16_t get_pm25_in();
|
||||
float get_temp_out();
|
||||
void toggle_pm_switch();
|
||||
void set_pm_fanspeed(uint8_t speed);
|
||||
void set_pm_fanspeed(uint8_t speed);
|
||||
void display_update();
|
||||
void pm25outupdatedisplay(char* value);
|
||||
void pm25inupdatedisplay(char* value);
|
||||
void tempoutupdatedisplay(char* value);
|
||||
void weatherupdatedisplay(char* value);
|
||||
void pmfanspeedupdatedisplay(char* value);
|
||||
void pmswitchupdatedisplay(char* value);
|
||||
Loading…
Add table
Add a link
Reference in a new issue