it fucking builds!
This commit is contained in:
parent
f2c0eb6bf1
commit
e5ecd5f3a0
5 changed files with 162 additions and 272 deletions
|
|
@ -5,271 +5,106 @@ ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISEDisplay::begin(std::function<rtctime_t()> getTime, DigitalInputCard *inputCard,
|
void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard)
|
||||||
DigitalOutputCard *outputCard, ClimateCard *climateCard)
|
|
||||||
{
|
{
|
||||||
this->getTime = getTime;
|
/*
|
||||||
|
ISEDisplay(HardwareSerial* adapter);
|
||||||
|
void begin(DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
|
||||||
|
|
||||||
|
void updateDateTimeText(rtctime_t time);
|
||||||
|
void updateWeather(uint8_t weather_code, float outside_temp);
|
||||||
|
void updatePMoutside(float pm25_outside);
|
||||||
|
void updatePMinside(float pm25_inside);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
|
||||||
|
void handlePWMChange(uint8_t pin, bool state, uint16_t value);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
*/
|
||||||
this->inputCard = inputCard;
|
this->inputCard = inputCard;
|
||||||
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);
|
auto bindedHandlePWMChange = std::bind(&ISEDisplay::handlePWMChange, 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 bindedHandleACChange = std::bind(&ISEDisplay::setACstate, 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);
|
||||||
auto bindedHandlePayload = std::bind(&ISEDisplay::handlePayload, 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);
|
||||||
this->registerTouchCallback(bindedHandleTouch);
|
this->registerTouchCallback(bindedHandleTouch);
|
||||||
this->registerPayloadCallback(bindedHandlePayload);
|
|
||||||
this->reset();
|
this->reset();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
this->jumpToPage(1);
|
this->jumpToPage(1);
|
||||||
delay(100);
|
delay(100);
|
||||||
this->sendClock();
|
|
||||||
this->setACControlEnabled(true);
|
|
||||||
this->updateLightGroupState();
|
this->updateLightGroupState();
|
||||||
this->updateFanGroupState();
|
|
||||||
this->updateAirPurifierState();
|
this->updateAirPurifierState();
|
||||||
this->updateACState();
|
this->updateACState();
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t event)
|
|
||||||
{
|
|
||||||
if (page != PAGE_DASHBOARD)
|
|
||||||
return;
|
|
||||||
switch (component)
|
|
||||||
{
|
|
||||||
case COMPONENT_LIGHT_TOGGLE_BUTTON:
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
toggleLightGroupState();
|
|
||||||
break;
|
|
||||||
case COMPONENT_FAN_TOGGLE_BUTTON:
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
toggleFanGroupState();
|
|
||||||
break;
|
|
||||||
case COMPONENT_AIR_PURIFIER_TOGGLE_BUTTON:
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->outputCard->setState(7, !this->outputCard->getState(7));
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_TEMP_UP_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setTemperature(this->climateCard->getTemperature() + 1);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_TEMP_DOWN_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setTemperature(this->climateCard->getTemperature() - 1);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_MODE_OFF_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setMode(0);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_MODE_FAN_ONLY_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setMode(1);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_MODE_COOL_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setMode(2);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_FAN_MODE_AUTO_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setFanSpeed(0);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_FAN_MODE_LOW_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setFanSpeed(3);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_FAN_MODE_MEDIUM_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setFanSpeed(2);
|
|
||||||
break;
|
|
||||||
case COMPONENT_AC_FAN_MODE_HIGH_BUTTON:
|
|
||||||
if (!ac_control_enabled) break;
|
|
||||||
if (event != TOUCH_TYPE_RELEASE)
|
|
||||||
break;
|
|
||||||
this->climateCard->setFanSpeed(1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::handlePWMChange(uint8_t pin, uint8_t value)
|
|
||||||
{
|
|
||||||
// Is the pin a light, fan, or air purifier?
|
|
||||||
if (pin >= 0 && pin <= 3)
|
|
||||||
{
|
|
||||||
// Light
|
|
||||||
updateLightGroupState();
|
|
||||||
}
|
|
||||||
else if (pin >= 4 && pin <= 6)
|
|
||||||
{
|
|
||||||
// Fan
|
|
||||||
updateFanGroupState();
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (pin == 7)
|
|
||||||
{
|
|
||||||
// Air Purifier
|
|
||||||
updateAirPurifierState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature)
|
|
||||||
{
|
|
||||||
// Update AC Controls
|
|
||||||
updateACState();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::sendClock()
|
|
||||||
{
|
|
||||||
// Get the time
|
|
||||||
rtctime_t time = this->getTime();
|
|
||||||
// Send the time to the display
|
|
||||||
this->displayAdapter->print("clock.txt=");
|
|
||||||
// We use 24 hour format, HH:MM
|
|
||||||
this->displayAdapter->print(time.hours);
|
|
||||||
this->displayAdapter->print(":");
|
|
||||||
this->displayAdapter->print(time.minutes);
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ISEDisplay::calculateLightGroupState() {
|
|
||||||
// Check if all lights are on
|
|
||||||
bool lightOn = false;
|
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
|
||||||
if (this->outputCard->getState(i)) {
|
|
||||||
lightOn = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lightOn;
|
|
||||||
}
|
|
||||||
bool ISEDisplay::calculateFanGroupState() {
|
|
||||||
// Check if all fans are on
|
|
||||||
bool fanOn = false;
|
|
||||||
for (uint8_t i = 4; i < 7; i++) {
|
|
||||||
if (this->outputCard->getState(i)) {
|
|
||||||
fanOn = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fanOn;
|
|
||||||
}
|
|
||||||
void ISEDisplay::setLightGrouptState(bool state) {
|
|
||||||
// Set all lights to state
|
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
|
||||||
this->outputCard->setState(i, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ISEDisplay::setFanGroupState(bool state) {
|
|
||||||
// Set all fans to state
|
|
||||||
for (uint8_t i = 4; i < 7; i++) {
|
|
||||||
this->outputCard->setState(i, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void ISEDisplay::toggleLightGroupState() {
|
|
||||||
// Get the current group state
|
|
||||||
bool state = calculateLightGroupState();
|
|
||||||
// Toggle the state
|
|
||||||
state = !state;
|
|
||||||
// Set the state
|
|
||||||
setLightGrouptState(state);
|
|
||||||
}
|
|
||||||
void ISEDisplay::toggleFanGroupState() {
|
|
||||||
// Get the current group state
|
|
||||||
bool state = calculateFanGroupState();
|
|
||||||
// Toggle the state
|
|
||||||
state = !state;
|
|
||||||
// Set the state
|
|
||||||
setFanGroupState(state);
|
|
||||||
}
|
|
||||||
void ISEDisplay::updateLightGroupState() {
|
|
||||||
// Calculate the state
|
|
||||||
bool state = calculateLightGroupState();
|
|
||||||
// Send the state to the display
|
|
||||||
this->displayAdapter->print("lt_bt.pic=");
|
|
||||||
this->displayAdapter->print(state ? COMPONENT_LIGHT_TOGGLE_PIC_ON : COMPONENT_LIGHT_TOGGLE_PIC_OFF);
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
void ISEDisplay::updateFanGroupState() {
|
|
||||||
// Calculate the state
|
|
||||||
bool state = calculateFanGroupState();
|
|
||||||
// Send the state to the display
|
|
||||||
this->displayAdapter->print("fan_bt.pic=");
|
|
||||||
this->displayAdapter->print(state ? COMPONENT_FAN_TOGGLE_PIC_ON : COMPONENT_FAN_TOGGLE_PIC_OFF);
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
void ISEDisplay::updateAirPurifierState() {
|
|
||||||
// Get the state
|
|
||||||
bool state = this->outputCard->getState(7);
|
|
||||||
// Send the state to the display
|
|
||||||
this->displayAdapter->print("puri_bt.pic=");
|
|
||||||
this->displayAdapter->print(state ? COMPONENT_AIR_PURIFIER_TOGGLE_PIC_ON : COMPONENT_AIR_PURIFIER_TOGGLE_PIC_OFF);
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
void ISEDisplay::updateACState() {
|
|
||||||
// Get the state
|
|
||||||
uint8_t mode = this->climateCard->getMode();
|
|
||||||
uint8_t fan_speed = this->climateCard->getFanSpeed();
|
|
||||||
uint8_t temperature = this->climateCard->getTemperature();
|
|
||||||
// Send the state to the display
|
|
||||||
this->displayAdapter->print("mode_off_btn.pic=");
|
|
||||||
this->displayAdapter->print(mode == 0 ? COMPONENT_AC_MODE_OFF_PIC_ACTIVE : COMPONENT_AC_MODE_OFF_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("mode_fan_btn.pic=");
|
|
||||||
this->displayAdapter->print(mode == 1 ? COMPONENT_AC_MODE_FAN_ONLY_PIC_ACTIVE : COMPONENT_AC_MODE_FAN_ONLY_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("mode_cool_btn.pic=");
|
|
||||||
this->displayAdapter->print(mode == 2 ? COMPONENT_AC_MODE_COOL_PIC_ACTIVE : COMPONENT_AC_MODE_COOL_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("fan_auto_btn.pic=");
|
|
||||||
this->displayAdapter->print(fan_speed == 0 ? COMPONENT_AC_FAN_MODE_AUTO_PIC_ACTIVE : COMPONENT_AC_FAN_MODE_AUTO_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("fan_1_btn.pic=");
|
|
||||||
this->displayAdapter->print(fan_speed == 3 ? COMPONENT_AC_FAN_MODE_HIGH_PIC_ACTIVE : COMPONENT_AC_FAN_MODE_HIGH_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("fan_2_btn.pic=");
|
|
||||||
this->displayAdapter->print(fan_speed == 2 ? COMPONENT_AC_FAN_MODE_MEDIUM_PIC_ACTIVE : COMPONENT_AC_FAN_MODE_MEDIUM_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("fan_3_btn.pic=");
|
|
||||||
this->displayAdapter->print(fan_speed == 1 ? COMPONENT_AC_FAN_MODE_LOW_PIC_ACTIVE : COMPONENT_AC_FAN_MODE_LOW_PIC_INACTIVE);
|
|
||||||
this->sendStopBytes();
|
|
||||||
this->displayAdapter->print("temp_txt.txt=\"");
|
|
||||||
this->displayAdapter->print(temperature);
|
|
||||||
this->displayAdapter->print("C\"");
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::setACControlEnabled(bool enabled) {
|
|
||||||
ac_control_enabled = enabled;
|
|
||||||
this->displayAdapter->print("dashboard.pic=");
|
|
||||||
this->displayAdapter->print(enabled ? COMPONENT_BACKGROUND_AC_UNLOCK : COMPONENT_BACKGROUND_AC_LOCK);
|
|
||||||
this->sendStopBytes();
|
|
||||||
}
|
|
||||||
bool ISEDisplay::getACControlEnabled() {
|
|
||||||
return ac_control_enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ISEDisplay::handlePayload(uint8_t payload_type, uint8_t *payload, uint8_t length)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void ISEDisplay::updateDateTimeText(rtctime_t time){
|
||||||
|
this->takeSerialMutex();
|
||||||
|
// Send the time to the display
|
||||||
|
|
||||||
|
this->displayAdapter->printf("time.txt=%02d:%02d", time.hours, time.minutes);
|
||||||
|
this->sendStopBytes();
|
||||||
|
|
||||||
|
this->displayAdapter->printf("date.txt=%02d.%02d.%d", time.day, time.month, time.year);
|
||||||
|
this->sendStopBytes();
|
||||||
|
|
||||||
|
this->displayAdapter->printf("s_time.txt=%02d:%02d", time.hours, time.minutes);
|
||||||
|
this->sendStopBytes();
|
||||||
|
|
||||||
|
this->displayAdapter->printf("s_date.txt=%02d.%02d.%d", time.day, time.month, time.year);
|
||||||
|
this->sendStopBytes();
|
||||||
|
|
||||||
|
this->giveSerialMutex();
|
||||||
|
}
|
||||||
|
void ISEDisplay::updateWeather(uint8_t weather_code, float outside_temp){
|
||||||
|
|
||||||
|
}
|
||||||
|
void ISEDisplay::updatePMoutside(float pm25_outside){
|
||||||
|
|
||||||
|
}
|
||||||
|
void ISEDisplay::updatePMinside(float pm25_inside){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::setLightLevel(uint8_t row, uint8_t level){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::updateLightGroupState(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::updateAirPurifierState(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ISEDisplay::updateACState(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,22 +42,27 @@
|
||||||
//standby page picture id
|
//standby page picture id
|
||||||
#define COMPONENT_BACKGROUND_PIC 44
|
#define COMPONENT_BACKGROUND_PIC 44
|
||||||
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45
|
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45
|
||||||
|
|
||||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF 46
|
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF 46
|
||||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF_PRESSED 47
|
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF_PRESSED 47
|
||||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON 48
|
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON 48
|
||||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49
|
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49
|
||||||
|
|
||||||
#define COMPONENT_STANDBY_AC_PIC_OFF 50
|
#define COMPONENT_STANDBY_AC_PIC_OFF 50
|
||||||
#define COMPONENT_STANDBY_AC_PIC_OFF_PRESSED 51
|
#define COMPONENT_STANDBY_AC_PIC_OFF_PRESSED 51
|
||||||
#define COMPONENT_STANDBY_AC_PIC_ON 52
|
#define COMPONENT_STANDBY_AC_PIC_ON 52
|
||||||
#define COMPONENT_STANDBY_AC_PIC_ON_PRESSED 53
|
#define COMPONENT_STANDBY_AC_PIC_ON_PRESSED 53
|
||||||
|
|
||||||
#define COMPONENT_STANDBY_LIGHT_PIC_OFF 54
|
#define COMPONENT_STANDBY_LIGHT_PIC_OFF 54
|
||||||
#define COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED 55
|
#define COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED 55
|
||||||
#define COMPONENT_STANDBY_LIGHT_PIC_ON 56
|
#define COMPONENT_STANDBY_LIGHT_PIC_ON 56
|
||||||
#define COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED 57
|
#define COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED 57
|
||||||
|
|
||||||
#define COMPONENT_STANDBY_PM_PIC_OFF 58
|
#define COMPONENT_STANDBY_PM_PIC_OFF 58
|
||||||
#define COMPONENT_STANDBY_PM_PIC_OFF_PRESSED 59
|
#define COMPONENT_STANDBY_PM_PIC_OFF_PRESSED 59
|
||||||
#define COMPONENT_STANDBY_PM_PIC_ON 60
|
#define COMPONENT_STANDBY_PM_PIC_ON 60
|
||||||
#define COMPONENT_STANDBY_PM_PIC_ON_PRESSED 61
|
#define COMPONENT_STANDBY_PM_PIC_ON_PRESSED 61
|
||||||
|
|
||||||
#define COMPONENT_REFERENCE_BACKGROUND_PIC 62
|
#define COMPONENT_REFERENCE_BACKGROUND_PIC 62
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -112,6 +117,7 @@
|
||||||
#define COMPONENT_DASHBOARD_DATE_TXT 38
|
#define COMPONENT_DASHBOARD_DATE_TXT 38
|
||||||
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 39
|
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 39
|
||||||
|
|
||||||
|
|
||||||
//dashboard page picture id
|
//dashboard page picture id
|
||||||
|
|
||||||
#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0
|
#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0
|
||||||
|
|
@ -144,7 +150,7 @@
|
||||||
#define COMPONENT_AC_MODE_FAN_PIC 23
|
#define COMPONENT_AC_MODE_FAN_PIC 23
|
||||||
#define COMPONENT_AC_MODE_FAN_PIC_PRESSED 24
|
#define COMPONENT_AC_MODE_FAN_PIC_PRESSED 24
|
||||||
|
|
||||||
|
//pm; air purifier
|
||||||
#define COMPONENT_PM_TOGGLE_PIC_OFF 25
|
#define COMPONENT_PM_TOGGLE_PIC_OFF 25
|
||||||
#define COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED 26
|
#define COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED 26
|
||||||
#define COMPONENT_PM_TOGGLE_PIC_ON 27
|
#define COMPONENT_PM_TOGGLE_PIC_ON 27
|
||||||
|
|
@ -155,14 +161,17 @@
|
||||||
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC 31
|
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC 31
|
||||||
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32
|
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32
|
||||||
|
|
||||||
|
//AC status indicator
|
||||||
#define COMPONENT_AC_STATUS_OFF 33
|
#define COMPONENT_AC_STATUS_OFF 33
|
||||||
#define COMPONENT_AC_STATUS_ON 34
|
#define COMPONENT_AC_STATUS_ON 34
|
||||||
|
|
||||||
|
//light master
|
||||||
#define COMPONENT_LIGHT_MASTER_OFF 35
|
#define COMPONENT_LIGHT_MASTER_OFF 35
|
||||||
#define COMPONENT_LIGHT_MASTER_OFF_PRESSED 36
|
#define COMPONENT_LIGHT_MASTER_OFF_PRESSED 36
|
||||||
#define COMPONENT_LIGHT_MASTER_ON 37
|
#define COMPONENT_LIGHT_MASTER_ON 37
|
||||||
#define COMPONENT_LIGHT_MASTER_ON_PRESSED 38
|
#define COMPONENT_LIGHT_MASTER_ON_PRESSED 38
|
||||||
|
|
||||||
|
//light level component
|
||||||
#define COMPONENT_LIGHT_LEVEL_1 39
|
#define COMPONENT_LIGHT_LEVEL_1 39
|
||||||
#define COMPONENT_LIGHT_LEVEL_2 40
|
#define COMPONENT_LIGHT_LEVEL_2 40
|
||||||
#define COMPONENT_LIGHT_LEVEL_3 41
|
#define COMPONENT_LIGHT_LEVEL_3 41
|
||||||
|
|
@ -178,33 +187,66 @@
|
||||||
*
|
*
|
||||||
* Made for ISE building 2 room 303/2.
|
* Made for ISE building 2 room 303/2.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//need to toggle 4 row of light independently and have one master switch that can control all
|
||||||
|
|
||||||
|
//need to toggle AC on/off, fan speed, mode, and temperature
|
||||||
|
|
||||||
|
//need to toggle air purifier on/off and fan speed
|
||||||
|
|
||||||
|
//display pm2.5 both outside and inside
|
||||||
|
|
||||||
|
//need to display time, date, and outside temperature for standby and dashbaord page in separate value
|
||||||
|
|
||||||
|
|
||||||
|
// Function to update date and time on screen-> void updateDateTimeText();
|
||||||
|
|
||||||
|
// Function to receieve touch input -> void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
|
||||||
|
|
||||||
|
// Touch input will call a function that update the light at its respective row -> void setLightLevel(uint8_t row, uint8_t level);
|
||||||
|
|
||||||
|
// Function to React to change in light, contactor -> void handlePWMChange(uint8_t pin, bool state, uint16_t value);
|
||||||
|
|
||||||
|
// Function to Set AC state -> void setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature);
|
||||||
|
|
||||||
|
// Function to Set Air Purifier -> setPMstate(bool is_pm_on, uint8_t pm_fan_speed);
|
||||||
|
|
||||||
|
// Function to update pm2.5 inside on screen -> void updatePMinside(); // get internal info from HA's air purifier sensor
|
||||||
|
// Function to update pm2.5 outside on screen -> void updatePMoutside(); // call API
|
||||||
|
|
||||||
|
// Function to get weather forcast and outside temperature and update screen -> void handleWeatherCallback();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ISEDisplay : public ESPMegaDisplay {
|
class ISEDisplay : public ESPMegaDisplay {
|
||||||
public:
|
public:
|
||||||
ISEDisplay(HardwareSerial* adapter);
|
ISEDisplay(HardwareSerial* adapter);
|
||||||
void begin(std::function<rtctime_t()> getTime, DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
|
void begin(DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard);
|
||||||
void handleTouch(uint8_t page, uint8_t component, uint8_t event);
|
|
||||||
void handlePWMChange(uint8_t pin, uint8_t value);
|
void updateDateTimeText(rtctime_t time);
|
||||||
void handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
|
void updateWeather(uint8_t weather_code, float outside_temp);
|
||||||
void handlePayload(uint8_t payload_type, uint8_t* payload, uint8_t length);
|
void updatePMoutside(float pm25_outside);
|
||||||
void sendClock();
|
void updatePMinside(float pm25_inside);
|
||||||
void setACControlEnabled(bool enabled);
|
|
||||||
bool getACControlEnabled();
|
|
||||||
private:
|
private:
|
||||||
bool ac_control_enabled = true;
|
|
||||||
std::function<rtctime_t()> getTime;
|
void handleTouch(uint8_t page, uint8_t component, uint8_t touch_type);
|
||||||
|
void handlePWMChange(uint8_t pin, bool state, uint16_t value);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
DigitalInputCard* inputCard;
|
DigitalInputCard* inputCard;
|
||||||
DigitalOutputCard* outputCard;
|
DigitalOutputCard *outputCard;
|
||||||
|
ClimateCard *climateCard;
|
||||||
uint8_t outputCallbackHandle;
|
uint8_t outputCallbackHandle;
|
||||||
ClimateCard* climateCard;
|
|
||||||
uint8_t climateCallbackHandle;
|
uint8_t climateCallbackHandle;
|
||||||
bool calculateLightGroupState();
|
|
||||||
bool calculateFanGroupState();
|
|
||||||
void setLightGrouptState(bool state);
|
|
||||||
void setFanGroupState(bool state);
|
|
||||||
void toggleLightGroupState();
|
|
||||||
void toggleFanGroupState();
|
|
||||||
void updateLightGroupState();
|
void updateLightGroupState();
|
||||||
void updateFanGroupState();
|
|
||||||
void updateAirPurifierState();
|
void updateAirPurifierState();
|
||||||
void updateACState();
|
void updateACState();
|
||||||
};
|
};
|
||||||
13
src/main.cpp
13
src/main.cpp
|
|
@ -1,5 +1,6 @@
|
||||||
#include <main.hpp>
|
#include <main.hpp>
|
||||||
#include <cud_display.hpp>
|
#include <cud_display.hpp>
|
||||||
|
#include <ise_display.hpp>
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* Begin Configuration *
|
* Begin Configuration *
|
||||||
|
|
@ -38,6 +39,7 @@ AirConditioner ac = {
|
||||||
|
|
||||||
ESPMegaPRO espmega = ESPMegaPRO();
|
ESPMegaPRO espmega = ESPMegaPRO();
|
||||||
CUDDisplay cudDisplay = CUDDisplay(&cudDisplayAdapter);
|
CUDDisplay cudDisplay = CUDDisplay(&cudDisplayAdapter);
|
||||||
|
ISEDisplay iseDisplay = ISEDisplay(&cudDisplayAdapter);
|
||||||
|
|
||||||
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
||||||
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN,
|
||||||
|
|
@ -49,6 +51,7 @@ void handleMqttMessage(char *topic, char *payload)
|
||||||
strcpy(temperature, payload);
|
strcpy(temperature, payload);
|
||||||
int temp_int;
|
int temp_int;
|
||||||
temp_int = atoi(temperature);
|
temp_int = atoi(temperature);
|
||||||
|
|
||||||
Serial.printf("MQTT Message: %s %s\n", topic, payload);
|
Serial.printf("MQTT Message: %s %s\n", topic, payload);
|
||||||
if (!strcmp(topic, AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC))
|
if (!strcmp(topic, AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC))
|
||||||
{
|
{
|
||||||
|
|
@ -167,6 +170,16 @@ void loop()
|
||||||
{
|
{
|
||||||
espmega.loop();
|
espmega.loop();
|
||||||
cudDisplay.loop();
|
cudDisplay.loop();
|
||||||
|
iseDisplay.loop();
|
||||||
|
|
||||||
|
// Update the time every 15 seconds
|
||||||
|
static uint32_t last_time_updated = 0;
|
||||||
|
if (millis() - last_time_updated > 15000)
|
||||||
|
{
|
||||||
|
rtctime_t time = espmega.getTime();
|
||||||
|
iseDisplay.updateDateTimeText(time);
|
||||||
|
last_time_updated = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_pin_change(uint8_t pin, uint8_t value)
|
void on_pin_change(uint8_t pin, uint8_t value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue