try remotevar
This commit is contained in:
parent
ab759ef08e
commit
6c8638319e
5 changed files with 60 additions and 18 deletions
|
|
@ -12,6 +12,5 @@
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = wt32-eth01
|
board = wt32-eth01
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = siwats/ESPMegaPROR3@^2.0.7
|
lib_deps = siwats/ESPMegaPROR3@^2.2.3
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
;build_flags = -DCORE_DEBUG_LEVEL=5
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include <ise_display.hpp>
|
#include <ise_display.hpp>
|
||||||
ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter)
|
ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter, 115200, 912600, 4, 17)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
// sat->sun
|
// sat->sun
|
||||||
|
|
@ -254,21 +254,41 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value)
|
||||||
{
|
{
|
||||||
// NEED to switch case for different page
|
// NEED to switch case for different page
|
||||||
|
|
||||||
// Question: can add another input and placeholder for page differentation
|
uint8_t current_page = this->currentPage;
|
||||||
// or that would mean changing the data structure of the callback
|
if (current_page == PAGE_STANDBY)
|
||||||
|
|
||||||
if (pin >= 1 && pin <= 4)
|
|
||||||
{
|
{
|
||||||
// Light
|
if (pin >= 1 && pin <= 4)
|
||||||
updateLightGroupStatePageDashboard();
|
{
|
||||||
updateLightGroupStatePageStandby();
|
// Light
|
||||||
time_since_last_screen_update = millis(); // update time since last activity
|
updateLightGroupStatePageDashboard();
|
||||||
|
updateLightGroupStatePageStandby();
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (pin == 4 || pin == 5)
|
else if (current_page == PAGE_DASHBOARD)
|
||||||
{
|
{
|
||||||
// Air Purifier
|
if (pin >= 1 && pin <= 4)
|
||||||
updateAirPurifierState();
|
{
|
||||||
time_since_last_screen_update = millis(); // update time since last activity
|
// Light
|
||||||
|
updateLightGroupStatePageStandby();
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ISEDisplay::updateDateTimeText(rtctime_t time)
|
void ISEDisplay::updateDateTimeText(rtctime_t time)
|
||||||
|
|
@ -295,16 +315,21 @@ void ISEDisplay::updateDateTimeText(rtctime_t time)
|
||||||
// appdeamon
|
// appdeamon
|
||||||
void ISEDisplay::updateWeather(uint8_t weather_code, float outside_temp)
|
void ISEDisplay::updateWeather(uint8_t weather_code, float outside_temp)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
void ISEDisplay::updatePMoutside(float pm25_outside)
|
void ISEDisplay::updatePMoutside(float pm25_outside)
|
||||||
{
|
{
|
||||||
|
// TODO : use remotevar to get data from appdaemon and update the display
|
||||||
|
|
||||||
}
|
}
|
||||||
void ISEDisplay::updatePMinside(float pm25_inside)
|
void ISEDisplay::updatePMinside(float pm25_inside)
|
||||||
{
|
{
|
||||||
|
// TODO : get data from HA's Xiaomi air purifier sensor
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed)
|
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed)
|
||||||
{
|
{
|
||||||
|
// TODO : set data to HA's Xiaomi air purifier sensor
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature)
|
void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature)
|
||||||
|
|
@ -364,8 +389,8 @@ 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()
|
||||||
}
|
}
|
||||||
updateuserACmode(); // call to update mode part of the display seperately
|
updateuserACmode(); // call to update mode part of the display seperately
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include <DigitalInputCard.hpp>
|
#include <DigitalInputCard.hpp>
|
||||||
#include <DigitalOutputCard.hpp>
|
#include <DigitalOutputCard.hpp>
|
||||||
#include <ClimateCard.hpp>
|
#include <ClimateCard.hpp>
|
||||||
|
#include <RemoteVariable.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A class for controlling the ESPMegaDisplay.
|
* @brief A class for controlling the ESPMegaDisplay.
|
||||||
|
|
|
||||||
15
src/main.cpp
15
src/main.cpp
|
|
@ -1,5 +1,6 @@
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
|
|
||||||
|
RemoteVariable pm25_out = 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"};
|
||||||
|
|
@ -101,6 +102,12 @@ void setup()
|
||||||
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega);
|
||||||
iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard);
|
iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard);
|
||||||
espmega.iot->registerRelativeMqttCallback(&handleMqttMessage);
|
espmega.iot->registerRelativeMqttCallback(&handleMqttMessage);
|
||||||
|
|
||||||
|
// placeholder
|
||||||
|
// PM2.5 PPM Remote Variable
|
||||||
|
// 12 bytes remote variable, 11 characters + null terminator
|
||||||
|
// Enable value request at /iqair/pm25_request
|
||||||
|
pm25_out.begin(12, "/iqair/pm25_ppm", espmega.iot, true, "/iqair/pm25_request");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|
@ -121,4 +128,12 @@ 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 pm25_out_value = 0;
|
||||||
|
// Read PM2.5 PPM from sensor
|
||||||
|
pm25_out_value = atoi(pm25_out.getValue());
|
||||||
|
return pm25_out_value;
|
||||||
}
|
}
|
||||||
|
|
@ -29,4 +29,6 @@ void sendExtStopBytes();
|
||||||
void setup();
|
void setup();
|
||||||
void loop();
|
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();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue