create hmi and define component
This commit is contained in:
parent
8a19674b0e
commit
f2c0eb6bf1
86 changed files with 643 additions and 0 deletions
153
src/codebook.txt
Normal file
153
src/codebook.txt
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
|
||||
|
||||
page 0 boot screen
|
||||
|
||||
video id:
|
||||
|
||||
0 logo 500x500px
|
||||
1 logo 260x260px
|
||||
2 logo 140x140px
|
||||
|
||||
|
||||
object id:
|
||||
|
||||
0 page (pic 43)
|
||||
1 logo gmov
|
||||
|
||||
|
||||
picture id:
|
||||
|
||||
43 background
|
||||
|
||||
|
||||
|
||||
page 1 standby
|
||||
|
||||
object id:
|
||||
|
||||
0 page
|
||||
1 logo gmov
|
||||
2 s_open_all
|
||||
3 s_light_toggle
|
||||
4 s_ac_toggle
|
||||
5 s_pm_toggle
|
||||
6 s_time (txt)
|
||||
7 s_date (txt)
|
||||
8 s_outside_temp (txt)
|
||||
|
||||
|
||||
picture id:
|
||||
|
||||
44 background
|
||||
45 ref
|
||||
46 s-open-all-off
|
||||
47 s-open-all-off-p
|
||||
48 s-open-all-on
|
||||
49 s-open-all-on-p
|
||||
50 s-ac-off
|
||||
51 s-ac-off-p
|
||||
52 s-ac-on
|
||||
53 s-ac-on-p
|
||||
54 s-light-off
|
||||
55 s-light-off-p
|
||||
56 s-light-on
|
||||
57 s-light-on-p
|
||||
58 s-pm-off
|
||||
59 s-pm-off-p
|
||||
60 s-pm-on
|
||||
61 s-pm-on-p
|
||||
62 reference-background
|
||||
|
||||
|
||||
|
||||
page 2 dashboard
|
||||
|
||||
picture id:
|
||||
|
||||
0 reference-background
|
||||
1 background
|
||||
2 background-variant
|
||||
3 ac-off
|
||||
4 ac-off-p
|
||||
5 ac-on
|
||||
6 ac-on-p
|
||||
7 ac-minus
|
||||
8 ac-minus-p
|
||||
9 ac-plus
|
||||
10 ac-plus-p
|
||||
11 fan-auto
|
||||
12 fan-auto-p
|
||||
13 fan-high
|
||||
14 fan-high-p
|
||||
15 fan-mid
|
||||
16 fan-mid-p
|
||||
17 fan-low
|
||||
18 fan-low-p
|
||||
19 mode-dry
|
||||
20 mode-dry-p
|
||||
21 mode-cool
|
||||
22 mode-cool-p
|
||||
23 mode-fan
|
||||
24 mode-fan-p
|
||||
25 pm-off
|
||||
26 pm-off-p
|
||||
27 pm-on
|
||||
28 pm-on-p
|
||||
29 pm-minus
|
||||
30 pm-minus-p
|
||||
31 pm-plus
|
||||
32 pm-plus-p
|
||||
33 ac-status-off
|
||||
34 ac-status-on
|
||||
35 light-master-off
|
||||
36 light-master-off-p
|
||||
37 light-master-on
|
||||
38 light-master-on-p
|
||||
39 light-level-1
|
||||
40 light-level-2
|
||||
41 light-level-3
|
||||
42 light-level-4
|
||||
|
||||
|
||||
object id:
|
||||
|
||||
0 main
|
||||
1 ac_temp (number)
|
||||
2 pm_fan (number 0-20)
|
||||
3 ac_sw
|
||||
4 ac_mode
|
||||
5 ac_speed
|
||||
6 ac_minus
|
||||
7 ac_plus
|
||||
8 pm_sw
|
||||
9 pm_minus
|
||||
10 pm_plus
|
||||
11 pm_in (txt)
|
||||
12 pm_out (txt)
|
||||
13 light_master
|
||||
14 light_row1 (pic)
|
||||
15 light_row2 (pic)
|
||||
16 light_row3 (pic)
|
||||
17 light_row4 (pic)
|
||||
18 light_m_l1
|
||||
19 light_m_l2
|
||||
20 light_m_l3
|
||||
21 light_1_l0
|
||||
22 light_1_l1
|
||||
23 light_1_l2
|
||||
24 light_1_l3
|
||||
25 light_2_l0
|
||||
26 light_2_l1
|
||||
27 light_2_l2
|
||||
28 light_2_l3
|
||||
29 light_3_l0
|
||||
30 light_3_l1
|
||||
31 light_3_l2
|
||||
32 light_3_l3
|
||||
33 light_4_l0
|
||||
34 light_4_l1
|
||||
35 light_4_l2
|
||||
36 light_4_l3
|
||||
37 time (txt)
|
||||
38 date (txt)
|
||||
39 outside_temp (txt)
|
||||
275
src/ise_display.cpp
Normal file
275
src/ise_display.cpp
Normal file
|
|
@ -0,0 +1,275 @@
|
|||
#include <ise_display.hpp>
|
||||
|
||||
ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ISEDisplay::begin(std::function<rtctime_t()> getTime, DigitalInputCard *inputCard,
|
||||
DigitalOutputCard *outputCard, ClimateCard *climateCard)
|
||||
{
|
||||
this->getTime = getTime;
|
||||
this->inputCard = inputCard;
|
||||
this->outputCard = outputCard;
|
||||
this->climateCard = climateCard;
|
||||
auto bindedHandlePWMChange = std::bind(&ISEDisplay::handlePWMChange, this, std::placeholders::_1, std::placeholders::_2);
|
||||
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 bindedHandlePayload = std::bind(&ISEDisplay::handlePayload, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
|
||||
this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange);
|
||||
this->climateCallbackHandle = this->climateCard->registerChangeCallback(bindedHandleACChange);
|
||||
this->registerTouchCallback(bindedHandleTouch);
|
||||
this->registerPayloadCallback(bindedHandlePayload);
|
||||
this->reset();
|
||||
delay(1000);
|
||||
this->jumpToPage(1);
|
||||
delay(100);
|
||||
this->sendClock();
|
||||
this->setACControlEnabled(true);
|
||||
this->updateLightGroupState();
|
||||
this->updateFanGroupState();
|
||||
this->updateAirPurifierState();
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
210
src/ise_display.hpp
Normal file
210
src/ise_display.hpp
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
#pragma once
|
||||
#include <ESPMegaDisplay.hpp>
|
||||
#include <TimeStructure.hpp>
|
||||
#include <DigitalInputCard.hpp>
|
||||
#include <DigitalOutputCard.hpp>
|
||||
#include <ClimateCard.hpp>
|
||||
|
||||
|
||||
// Touch Types
|
||||
#define TOUCH_TYPE_PRESS 1
|
||||
#define TOUCH_TYPE_RELEASE 0
|
||||
|
||||
// Page IDs
|
||||
#define PAGE_BOOT 0
|
||||
#define PAGE_STANDBY 1
|
||||
#define PAGE_DASHBOARD 2
|
||||
|
||||
//boot page
|
||||
|
||||
//logo gmov boot
|
||||
#define COMPONENT_LOGO_BOOT 1
|
||||
#define COMPONENT_LOGO_BOOT_VID 1
|
||||
|
||||
//boot background
|
||||
#define COMPONENT_BACKGROUND_BOOT_PIC 43
|
||||
|
||||
|
||||
//standby page object id
|
||||
#define COMPONENT_LOGO_STANDBY 1
|
||||
#define COMPONENT_LOGO_STANDBY_VID 2
|
||||
|
||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE 2
|
||||
#define COMPONENT_STANDBY_LIGHT_TOGGLE 3
|
||||
#define COMPONENT_STANDBY_AC_TOGGLE 4
|
||||
#define COMPONENT_STANDBY_PM_TOGGLE 5
|
||||
|
||||
//text
|
||||
#define COMPONENT_STANDBY_TIME_TXT 6
|
||||
#define COMPONENT_STANDBY_DATE_TXT 7
|
||||
#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8
|
||||
|
||||
//standby page picture id
|
||||
#define COMPONENT_BACKGROUND_PIC 44
|
||||
#define COMPONENT_BACKGROUND_REFERENCE_PIC 45
|
||||
#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_ON 48
|
||||
#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49
|
||||
#define COMPONENT_STANDBY_AC_PIC_OFF 50
|
||||
#define COMPONENT_STANDBY_AC_PIC_OFF_PRESSED 51
|
||||
#define COMPONENT_STANDBY_AC_PIC_ON 52
|
||||
#define COMPONENT_STANDBY_AC_PIC_ON_PRESSED 53
|
||||
#define COMPONENT_STANDBY_LIGHT_PIC_OFF 54
|
||||
#define COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED 55
|
||||
#define COMPONENT_STANDBY_LIGHT_PIC_ON 56
|
||||
#define COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED 57
|
||||
#define COMPONENT_STANDBY_PM_PIC_OFF 58
|
||||
#define COMPONENT_STANDBY_PM_PIC_OFF_PRESSED 59
|
||||
#define COMPONENT_STANDBY_PM_PIC_ON 60
|
||||
#define COMPONENT_STANDBY_PM_PIC_ON_PRESSED 61
|
||||
#define COMPONENT_REFERENCE_BACKGROUND_PIC 62
|
||||
|
||||
|
||||
|
||||
//dashboard page
|
||||
|
||||
//dashboard page object id
|
||||
#define COMPONENT_AC_TOGGLE_BUTTON 3
|
||||
#define COMPONENT_AC_MODE 4
|
||||
#define COMPONENT_AC_FAN_SPEED 5
|
||||
#define COMPONENT_AC_TEMP_DOWN_BUTTON 6
|
||||
#define COMPONENT_AC_TEMP_UP_BUTTON 7
|
||||
|
||||
#define COMPONENT_PM_TOGGLE_BUTTON 8
|
||||
#define COMPONENT_PM_FAN_SPEED_DECREASE 9
|
||||
#define COMPONENT_PM_FAN_SPEED_INCREASE 10
|
||||
|
||||
#define COMPONENT_PM_INSIDE_TXT 11
|
||||
#define COMPONENT_PM_OUTSIDE_TXT 12
|
||||
|
||||
#define COMPONENT_LIGHT_MASTER_BUTTON 13
|
||||
#define COMPONENT_LIGHT_ROW1_PIC_PLACEHOLDER 14
|
||||
#define COMPONENT_LIGHT_ROW2_PIC_PLACEHOLDER 15
|
||||
#define COMPONENT_LIGHT_ROW3_PIC_PLACEHOLDER 16
|
||||
#define COMPONENT_LIGHT_ROW4_PIC_PLACEHOLDER 17
|
||||
|
||||
#define COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT 18
|
||||
#define COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19
|
||||
#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20
|
||||
|
||||
#define COMPONENT_LIGHT_ROW1_LEVEL0_TOUCHPOINT 21
|
||||
#define COMPONENT_LIGHT_ROW1_LEVEL1_TOUCHPOINT 22
|
||||
#define COMPONENT_LIGHT_ROW1_LEVEL2_TOUCHPOINT 23
|
||||
#define COMPONENT_LIGHT_ROW1_LEVEL3_TOUCHPOINT 24
|
||||
|
||||
#define COMPONENT_LIGHT_ROW2_LEVEL0_TOUCHPOINT 25
|
||||
#define COMPONENT_LIGHT_ROW2_LEVEL1_TOUCHPOINT 26
|
||||
#define COMPONENT_LIGHT_ROW2_LEVEL2_TOUCHPOINT 27
|
||||
#define COMPONENT_LIGHT_ROW2_LEVEL3_TOUCHPOINT 28
|
||||
|
||||
#define COMPONENT_LIGHT_ROW3_LEVEL0_TOUCHPOINT 29
|
||||
#define COMPONENT_LIGHT_ROW3_LEVEL1_TOUCHPOINT 30
|
||||
#define COMPONENT_LIGHT_ROW3_LEVEL2_TOUCHPOINT 31
|
||||
#define COMPONENT_LIGHT_ROW3_LEVEL3_TOUCHPOINT 32
|
||||
|
||||
#define COMPONENT_LIGHT_ROW4_LEVEL0_TOUCHPOINT 33
|
||||
#define COMPONENT_LIGHT_ROW4_LEVEL1_TOUCHPOINT 34
|
||||
#define COMPONENT_LIGHT_ROW4_LEVEL2_TOUCHPOINT 35
|
||||
#define COMPONENT_LIGHT_ROW4_LEVEL3_TOUCHPOINT 36
|
||||
|
||||
#define COMPONENT_DASHBOARD_TIME_TXT 37
|
||||
#define COMPONENT_DASHBOARD_DATE_TXT 38
|
||||
#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 39
|
||||
|
||||
//dashboard page picture id
|
||||
|
||||
#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0
|
||||
#define COMPONENT_DASHBOARD_BACKGROUND_PIC 1
|
||||
#define COMPONENT_DASHBOARD_BACKGROUND_VARIANT_PIC 2
|
||||
|
||||
//AC on/off
|
||||
#define COMPONENT_AC_TOGGLE_PIC_OFF 3
|
||||
#define COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED 4
|
||||
#define COMPONENT_AC_TOGGLE_PIC_ON 5
|
||||
#define COMPONENT_AC_TOGGLE_PIC_ON_PRESSED 6
|
||||
#define COMPONENT_AC_TEMP_DOWN_PIC 7
|
||||
#define COMPONENT_AC_TEMP_DOWN_PIC_PRESSED 8
|
||||
#define COMPONENT_AC_TEMP_UP_PIC 9
|
||||
#define COMPONENT_AC_TEMP_UP_PIC_PRESSED 10
|
||||
|
||||
#define COMPONENT_AC_FAN_MODE_AUTO_PIC 11
|
||||
#define COMPONENT_AC_FAN_MODE_AUTO_PIC_PRESSED 12
|
||||
#define COMPONENT_AC_FAN_MODE_HIGH_PIC 13
|
||||
#define COMPONENT_AC_FAN_MODE_HIGH_PIC_PRESSED 14
|
||||
#define COMPONENT_AC_FAN_MODE_MID_PIC 15
|
||||
#define COMPONENT_AC_FAN_MODE_MID_PIC_PRESSED 16
|
||||
#define COMPONENT_AC_FAN_MODE_LOW_PIC 17
|
||||
#define COMPONENT_AC_FAN_MODE_LOW_PIC_PRESSED 18
|
||||
|
||||
#define COMPONENT_AC_MODE_DRY_PIC 19
|
||||
#define COMPONENT_AC_MODE_DRY_PIC_PRESSED 20
|
||||
#define COMPONENT_AC_MODE_COOL_PIC 21
|
||||
#define COMPONENT_AC_MODE_COOL_PIC_PRESSED 22
|
||||
#define COMPONENT_AC_MODE_FAN_PIC 23
|
||||
#define COMPONENT_AC_MODE_FAN_PIC_PRESSED 24
|
||||
|
||||
|
||||
#define COMPONENT_PM_TOGGLE_PIC_OFF 25
|
||||
#define COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED 26
|
||||
#define COMPONENT_PM_TOGGLE_PIC_ON 27
|
||||
#define COMPONENT_PM_TOGGLE_PIC_ON_PRESSED 28
|
||||
|
||||
#define COMPONENT_PM_FAN_SPEED_DECREASE_PIC 29
|
||||
#define COMPONENT_PM_FAN_SPEED_DECREASE_PIC_PRESSED 30
|
||||
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC 31
|
||||
#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32
|
||||
|
||||
#define COMPONENT_AC_STATUS_OFF 33
|
||||
#define COMPONENT_AC_STATUS_ON 34
|
||||
|
||||
#define COMPONENT_LIGHT_MASTER_OFF 35
|
||||
#define COMPONENT_LIGHT_MASTER_OFF_PRESSED 36
|
||||
#define COMPONENT_LIGHT_MASTER_ON 37
|
||||
#define COMPONENT_LIGHT_MASTER_ON_PRESSED 38
|
||||
|
||||
#define COMPONENT_LIGHT_LEVEL_1 39
|
||||
#define COMPONENT_LIGHT_LEVEL_2 40
|
||||
#define COMPONENT_LIGHT_LEVEL_3 41
|
||||
#define COMPONENT_LIGHT_LEVEL_4 42
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief A class for controlling the ESPMegaDisplay.
|
||||
*
|
||||
* Made for ISE building 2 room 303/2.
|
||||
*/
|
||||
class ISEDisplay : public ESPMegaDisplay {
|
||||
public:
|
||||
ISEDisplay(HardwareSerial* adapter);
|
||||
void begin(std::function<rtctime_t()> getTime, 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 handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature);
|
||||
void handlePayload(uint8_t payload_type, uint8_t* payload, uint8_t length);
|
||||
void sendClock();
|
||||
void setACControlEnabled(bool enabled);
|
||||
bool getACControlEnabled();
|
||||
private:
|
||||
bool ac_control_enabled = true;
|
||||
std::function<rtctime_t()> getTime;
|
||||
DigitalInputCard* inputCard;
|
||||
DigitalOutputCard* outputCard;
|
||||
uint8_t outputCallbackHandle;
|
||||
ClimateCard* climateCard;
|
||||
uint8_t climateCallbackHandle;
|
||||
bool calculateLightGroupState();
|
||||
bool calculateFanGroupState();
|
||||
void setLightGrouptState(bool state);
|
||||
void setFanGroupState(bool state);
|
||||
void toggleLightGroupState();
|
||||
void toggleFanGroupState();
|
||||
void updateLightGroupState();
|
||||
void updateFanGroupState();
|
||||
void updateAirPurifierState();
|
||||
void updateACState();
|
||||
};
|
||||
|
|
@ -45,6 +45,10 @@ ClimateCard climateCard = ClimateCard(AIR_CONDITIONER_IR_PIN, ac,
|
|||
|
||||
void handleMqttMessage(char *topic, char *payload)
|
||||
{
|
||||
char *temperature = (char*)calloc(16,sizeof(char));
|
||||
strcpy(temperature, payload);
|
||||
int temp_int;
|
||||
temp_int = atoi(temperature);
|
||||
Serial.printf("MQTT Message: %s %s\n", topic, payload);
|
||||
if (!strcmp(topic, AIR_CONDITIONER_LOCK_SET_RELATIVE_TOPIC))
|
||||
{
|
||||
|
|
@ -59,6 +63,7 @@ void handleMqttMessage(char *topic, char *payload)
|
|||
espmega.iot->publishRelative(AIR_CONDITIONER_LOCK_RELATIVE_TOPIC, "unlock");
|
||||
}
|
||||
}
|
||||
free(temperature);
|
||||
}
|
||||
|
||||
void lockAC()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue