diff --git a/ise-display/fonts/k2d-128-ascii.zi b/ise-display/fonts/k2d-128-ascii.zi new file mode 100644 index 0000000..7601fba Binary files /dev/null and b/ise-display/fonts/k2d-128-ascii.zi differ diff --git a/ise-display/fonts/k2d-32-ascii.zi b/ise-display/fonts/k2d-32-ascii.zi new file mode 100644 index 0000000..551759f Binary files /dev/null and b/ise-display/fonts/k2d-32-ascii.zi differ diff --git a/ise-display/fonts/k2d-40-ascii.zi b/ise-display/fonts/k2d-40-ascii.zi new file mode 100644 index 0000000..a1b00b4 Binary files /dev/null and b/ise-display/fonts/k2d-40-ascii.zi differ diff --git a/ise-display/fonts/k2d-48-ascii.zi b/ise-display/fonts/k2d-48-ascii.zi new file mode 100644 index 0000000..40e2c8f Binary files /dev/null and b/ise-display/fonts/k2d-48-ascii.zi differ diff --git a/ise-display/fonts/k2d-80-ascii.zi b/ise-display/fonts/k2d-80-ascii.zi new file mode 100644 index 0000000..ba6f67e Binary files /dev/null and b/ise-display/fonts/k2d-80-ascii.zi differ diff --git a/ise-display/fonts/k2d-sb-24-ascii.zi b/ise-display/fonts/k2d-sb-24-ascii.zi new file mode 100644 index 0000000..9c6a6cd Binary files /dev/null and b/ise-display/fonts/k2d-sb-24-ascii.zi differ diff --git a/ise-display/fonts/k2d-sb-28-ascii.zi b/ise-display/fonts/k2d-sb-28-ascii.zi new file mode 100644 index 0000000..5957789 Binary files /dev/null and b/ise-display/fonts/k2d-sb-28-ascii.zi differ diff --git a/ise-display/fonts/k2d-sb-32-ascii.zi b/ise-display/fonts/k2d-sb-32-ascii.zi new file mode 100644 index 0000000..4da309f Binary files /dev/null and b/ise-display/fonts/k2d-sb-32-ascii.zi differ diff --git a/ise-display/fonts/k2d-sb-72-ascii.zi b/ise-display/fonts/k2d-sb-72-ascii.zi new file mode 100644 index 0000000..c2a2097 Binary files /dev/null and b/ise-display/fonts/k2d-sb-72-ascii.zi differ diff --git a/ise-display/fonts/k2deb-80-ascii.zi b/ise-display/fonts/k2deb-80-ascii.zi new file mode 100644 index 0000000..da75756 Binary files /dev/null and b/ise-display/fonts/k2deb-80-ascii.zi differ diff --git a/ise-display/fonts/k2dm-80-ascii.zi b/ise-display/fonts/k2dm-80-ascii.zi new file mode 100644 index 0000000..4926ebe Binary files /dev/null and b/ise-display/fonts/k2dm-80-ascii.zi differ diff --git a/ise-display/fonts/k2dsb-72-ascii.zi b/ise-display/fonts/k2dsb-72-ascii.zi new file mode 100644 index 0000000..7f13b44 Binary files /dev/null and b/ise-display/fonts/k2dsb-72-ascii.zi differ diff --git a/ise-display/fonts/k2dsb-80-ascii.zi b/ise-display/fonts/k2dsb-80-ascii.zi new file mode 100644 index 0000000..1f0f27a Binary files /dev/null and b/ise-display/fonts/k2dsb-80-ascii.zi differ diff --git a/ise-display/fonts/raj-sb-80-ascii.zi b/ise-display/fonts/raj-sb-80-ascii.zi new file mode 100644 index 0000000..f6c1667 Binary files /dev/null and b/ise-display/fonts/raj-sb-80-ascii.zi differ diff --git a/ise-display/fonts/raj-sb-86-ascii.zi b/ise-display/fonts/raj-sb-86-ascii.zi new file mode 100644 index 0000000..058c57c Binary files /dev/null and b/ise-display/fonts/raj-sb-86-ascii.zi differ diff --git a/ise-display/images/ac/ac-light-off.png b/ise-display/images/ac/ac-light-off.png new file mode 100644 index 0000000..dfa928d Binary files /dev/null and b/ise-display/images/ac/ac-light-off.png differ diff --git a/ise-display/images/ac/ac-light-on.png b/ise-display/images/ac/ac-light-on.png new file mode 100644 index 0000000..fa08c30 Binary files /dev/null and b/ise-display/images/ac/ac-light-on.png differ diff --git a/ise-display/images/ac/ac-minus-p.png b/ise-display/images/ac/ac-minus-p.png new file mode 100644 index 0000000..796021e Binary files /dev/null and b/ise-display/images/ac/ac-minus-p.png differ diff --git a/ise-display/images/ac/ac-minus.png b/ise-display/images/ac/ac-minus.png new file mode 100644 index 0000000..0642045 Binary files /dev/null and b/ise-display/images/ac/ac-minus.png differ diff --git a/ise-display/images/ac/ac-off-p.png b/ise-display/images/ac/ac-off-p.png new file mode 100644 index 0000000..03aef80 Binary files /dev/null and b/ise-display/images/ac/ac-off-p.png differ diff --git a/ise-display/images/ac/ac-off.png b/ise-display/images/ac/ac-off.png new file mode 100644 index 0000000..1e786eb Binary files /dev/null and b/ise-display/images/ac/ac-off.png differ diff --git a/ise-display/images/ac/ac-on-p.png b/ise-display/images/ac/ac-on-p.png new file mode 100644 index 0000000..9286e73 Binary files /dev/null and b/ise-display/images/ac/ac-on-p.png differ diff --git a/ise-display/images/ac/ac-on.png b/ise-display/images/ac/ac-on.png new file mode 100644 index 0000000..738ed32 Binary files /dev/null and b/ise-display/images/ac/ac-on.png differ diff --git a/ise-display/images/ac/ac-plus-p.png b/ise-display/images/ac/ac-plus-p.png new file mode 100644 index 0000000..de7ac55 Binary files /dev/null and b/ise-display/images/ac/ac-plus-p.png differ diff --git a/ise-display/images/ac/ac-plus.png b/ise-display/images/ac/ac-plus.png new file mode 100644 index 0000000..fab33b5 Binary files /dev/null and b/ise-display/images/ac/ac-plus.png differ diff --git a/ise-display/images/ac/fanspeed/fanAuto-p.png b/ise-display/images/ac/fanspeed/fanAuto-p.png new file mode 100644 index 0000000..6f70f5e Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanAuto-p.png differ diff --git a/ise-display/images/ac/fanspeed/fanAuto.png b/ise-display/images/ac/fanspeed/fanAuto.png new file mode 100644 index 0000000..601dc5c Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanAuto.png differ diff --git a/ise-display/images/ac/fanspeed/fanHigh-p.png b/ise-display/images/ac/fanspeed/fanHigh-p.png new file mode 100644 index 0000000..7388dfb Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanHigh-p.png differ diff --git a/ise-display/images/ac/fanspeed/fanHigh.png b/ise-display/images/ac/fanspeed/fanHigh.png new file mode 100644 index 0000000..c0f568f Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanHigh.png differ diff --git a/ise-display/images/ac/fanspeed/fanLow-p.png b/ise-display/images/ac/fanspeed/fanLow-p.png new file mode 100644 index 0000000..4573232 Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanLow-p.png differ diff --git a/ise-display/images/ac/fanspeed/fanLow.png b/ise-display/images/ac/fanspeed/fanLow.png new file mode 100644 index 0000000..f0e9a5b Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanLow.png differ diff --git a/ise-display/images/ac/fanspeed/fanMid-p.png b/ise-display/images/ac/fanspeed/fanMid-p.png new file mode 100644 index 0000000..36b7daf Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanMid-p.png differ diff --git a/ise-display/images/ac/fanspeed/fanMid.png b/ise-display/images/ac/fanspeed/fanMid.png new file mode 100644 index 0000000..8e1ac19 Binary files /dev/null and b/ise-display/images/ac/fanspeed/fanMid.png differ diff --git a/ise-display/images/ac/mode/modeCool-p.png b/ise-display/images/ac/mode/modeCool-p.png new file mode 100644 index 0000000..ce1cf2f Binary files /dev/null and b/ise-display/images/ac/mode/modeCool-p.png differ diff --git a/ise-display/images/ac/mode/modeCool.png b/ise-display/images/ac/mode/modeCool.png new file mode 100644 index 0000000..39156c3 Binary files /dev/null and b/ise-display/images/ac/mode/modeCool.png differ diff --git a/ise-display/images/ac/mode/modeDry-p.png b/ise-display/images/ac/mode/modeDry-p.png new file mode 100644 index 0000000..f21aba7 Binary files /dev/null and b/ise-display/images/ac/mode/modeDry-p.png differ diff --git a/ise-display/images/ac/mode/modeDry.png b/ise-display/images/ac/mode/modeDry.png new file mode 100644 index 0000000..c3e5ef6 Binary files /dev/null and b/ise-display/images/ac/mode/modeDry.png differ diff --git a/ise-display/images/ac/mode/modeFan-p.png b/ise-display/images/ac/mode/modeFan-p.png new file mode 100644 index 0000000..45cad55 Binary files /dev/null and b/ise-display/images/ac/mode/modeFan-p.png differ diff --git a/ise-display/images/ac/mode/modeFan.png b/ise-display/images/ac/mode/modeFan.png new file mode 100644 index 0000000..3ac499f Binary files /dev/null and b/ise-display/images/ac/mode/modeFan.png differ diff --git a/ise-display/images/background/bg-off-v.png b/ise-display/images/background/bg-off-v.png new file mode 100644 index 0000000..f33e8bf Binary files /dev/null and b/ise-display/images/background/bg-off-v.png differ diff --git a/ise-display/images/background/bg-off.png b/ise-display/images/background/bg-off.png new file mode 100644 index 0000000..b5e3bc5 Binary files /dev/null and b/ise-display/images/background/bg-off.png differ diff --git a/ise-display/images/background/full-ref.png b/ise-display/images/background/full-ref.png new file mode 100644 index 0000000..0834ce1 Binary files /dev/null and b/ise-display/images/background/full-ref.png differ diff --git a/ise-display/images/boot/bg.png b/ise-display/images/boot/bg.png new file mode 100644 index 0000000..030ed0b Binary files /dev/null and b/ise-display/images/boot/bg.png differ diff --git a/ise-display/images/boot/ref.png b/ise-display/images/boot/ref.png new file mode 100644 index 0000000..932f215 Binary files /dev/null and b/ise-display/images/boot/ref.png differ diff --git a/ise-display/images/light/light-level0.png b/ise-display/images/light/light-level0.png new file mode 100644 index 0000000..554b4ed Binary files /dev/null and b/ise-display/images/light/light-level0.png differ diff --git a/ise-display/images/light/light-level1.png b/ise-display/images/light/light-level1.png new file mode 100644 index 0000000..53cdd22 Binary files /dev/null and b/ise-display/images/light/light-level1.png differ diff --git a/ise-display/images/light/light-level2.png b/ise-display/images/light/light-level2.png new file mode 100644 index 0000000..84ec343 Binary files /dev/null and b/ise-display/images/light/light-level2.png differ diff --git a/ise-display/images/light/light-level3.png b/ise-display/images/light/light-level3.png new file mode 100644 index 0000000..614af4b Binary files /dev/null and b/ise-display/images/light/light-level3.png differ diff --git a/ise-display/images/light/master-off-p.png b/ise-display/images/light/master-off-p.png new file mode 100644 index 0000000..c0c15f0 Binary files /dev/null and b/ise-display/images/light/master-off-p.png differ diff --git a/ise-display/images/light/master-off.png b/ise-display/images/light/master-off.png new file mode 100644 index 0000000..6fcbc83 Binary files /dev/null and b/ise-display/images/light/master-off.png differ diff --git a/ise-display/images/light/master-on-p.png b/ise-display/images/light/master-on-p.png new file mode 100644 index 0000000..a6ae700 Binary files /dev/null and b/ise-display/images/light/master-on-p.png differ diff --git a/ise-display/images/light/master-on.png b/ise-display/images/light/master-on.png new file mode 100644 index 0000000..600a2fa Binary files /dev/null and b/ise-display/images/light/master-on.png differ diff --git a/ise-display/images/pm/pm-minus-p.png b/ise-display/images/pm/pm-minus-p.png new file mode 100644 index 0000000..f0e94aa Binary files /dev/null and b/ise-display/images/pm/pm-minus-p.png differ diff --git a/ise-display/images/pm/pm-minus.png b/ise-display/images/pm/pm-minus.png new file mode 100644 index 0000000..bbd6619 Binary files /dev/null and b/ise-display/images/pm/pm-minus.png differ diff --git a/ise-display/images/pm/pm-off-p.png b/ise-display/images/pm/pm-off-p.png new file mode 100644 index 0000000..d216123 Binary files /dev/null and b/ise-display/images/pm/pm-off-p.png differ diff --git a/ise-display/images/pm/pm-off.png b/ise-display/images/pm/pm-off.png new file mode 100644 index 0000000..71922b3 Binary files /dev/null and b/ise-display/images/pm/pm-off.png differ diff --git a/ise-display/images/pm/pm-on-p.png b/ise-display/images/pm/pm-on-p.png new file mode 100644 index 0000000..0d546e4 Binary files /dev/null and b/ise-display/images/pm/pm-on-p.png differ diff --git a/ise-display/images/pm/pm-on.png b/ise-display/images/pm/pm-on.png new file mode 100644 index 0000000..9176fbf Binary files /dev/null and b/ise-display/images/pm/pm-on.png differ diff --git a/ise-display/images/pm/pm-plus-p.png b/ise-display/images/pm/pm-plus-p.png new file mode 100644 index 0000000..83551b1 Binary files /dev/null and b/ise-display/images/pm/pm-plus-p.png differ diff --git a/ise-display/images/pm/pm-plus.png b/ise-display/images/pm/pm-plus.png new file mode 100644 index 0000000..40e40fa Binary files /dev/null and b/ise-display/images/pm/pm-plus.png differ diff --git a/ise-display/images/standby/bg.png b/ise-display/images/standby/bg.png new file mode 100644 index 0000000..1a8590f Binary files /dev/null and b/ise-display/images/standby/bg.png differ diff --git a/ise-display/images/standby/ref.png b/ise-display/images/standby/ref.png new file mode 100644 index 0000000..8e02b65 Binary files /dev/null and b/ise-display/images/standby/ref.png differ diff --git a/ise-display/images/standby/s-ac-off-p.png b/ise-display/images/standby/s-ac-off-p.png new file mode 100644 index 0000000..d95a4c2 Binary files /dev/null and b/ise-display/images/standby/s-ac-off-p.png differ diff --git a/ise-display/images/standby/s-ac-off.png b/ise-display/images/standby/s-ac-off.png new file mode 100644 index 0000000..0fa577d Binary files /dev/null and b/ise-display/images/standby/s-ac-off.png differ diff --git a/ise-display/images/standby/s-ac-on-p.png b/ise-display/images/standby/s-ac-on-p.png new file mode 100644 index 0000000..6d5f822 Binary files /dev/null and b/ise-display/images/standby/s-ac-on-p.png differ diff --git a/ise-display/images/standby/s-ac-on.png b/ise-display/images/standby/s-ac-on.png new file mode 100644 index 0000000..9607006 Binary files /dev/null and b/ise-display/images/standby/s-ac-on.png differ diff --git a/ise-display/images/standby/s-light-off-p.png b/ise-display/images/standby/s-light-off-p.png new file mode 100644 index 0000000..ff2bbd6 Binary files /dev/null and b/ise-display/images/standby/s-light-off-p.png differ diff --git a/ise-display/images/standby/s-light-off.png b/ise-display/images/standby/s-light-off.png new file mode 100644 index 0000000..139e29b Binary files /dev/null and b/ise-display/images/standby/s-light-off.png differ diff --git a/ise-display/images/standby/s-light-on-p.png b/ise-display/images/standby/s-light-on-p.png new file mode 100644 index 0000000..90529cc Binary files /dev/null and b/ise-display/images/standby/s-light-on-p.png differ diff --git a/ise-display/images/standby/s-light-on.png b/ise-display/images/standby/s-light-on.png new file mode 100644 index 0000000..0f5c80a Binary files /dev/null and b/ise-display/images/standby/s-light-on.png differ diff --git a/ise-display/images/standby/s-open-all-off-p.png b/ise-display/images/standby/s-open-all-off-p.png new file mode 100644 index 0000000..2cab491 Binary files /dev/null and b/ise-display/images/standby/s-open-all-off-p.png differ diff --git a/ise-display/images/standby/s-open-all-off.png b/ise-display/images/standby/s-open-all-off.png new file mode 100644 index 0000000..8309e14 Binary files /dev/null and b/ise-display/images/standby/s-open-all-off.png differ diff --git a/ise-display/images/standby/s-open-all-on-p.png b/ise-display/images/standby/s-open-all-on-p.png new file mode 100644 index 0000000..34cf40f Binary files /dev/null and b/ise-display/images/standby/s-open-all-on-p.png differ diff --git a/ise-display/images/standby/s-open-all-on.png b/ise-display/images/standby/s-open-all-on.png new file mode 100644 index 0000000..833246f Binary files /dev/null and b/ise-display/images/standby/s-open-all-on.png differ diff --git a/ise-display/images/standby/s-pm-off-p.png b/ise-display/images/standby/s-pm-off-p.png new file mode 100644 index 0000000..7f2fc06 Binary files /dev/null and b/ise-display/images/standby/s-pm-off-p.png differ diff --git a/ise-display/images/standby/s-pm-off.png b/ise-display/images/standby/s-pm-off.png new file mode 100644 index 0000000..44a3063 Binary files /dev/null and b/ise-display/images/standby/s-pm-off.png differ diff --git a/ise-display/images/standby/s-pm-on-p.png b/ise-display/images/standby/s-pm-on-p.png new file mode 100644 index 0000000..be813d0 Binary files /dev/null and b/ise-display/images/standby/s-pm-on-p.png differ diff --git a/ise-display/images/standby/s-pm-on.png b/ise-display/images/standby/s-pm-on.png new file mode 100644 index 0000000..c42ff85 Binary files /dev/null and b/ise-display/images/standby/s-pm-on.png differ diff --git a/ise-display/ise-display-prod.HMI b/ise-display/ise-display-prod.HMI new file mode 100644 index 0000000..023ab66 Binary files /dev/null and b/ise-display/ise-display-prod.HMI differ diff --git a/ise-display/logo-gif.gmov b/ise-display/logo-gif.gmov new file mode 100644 index 0000000..734e7db Binary files /dev/null and b/ise-display/logo-gif.gmov differ diff --git a/ise-display/logof-gif.gmov b/ise-display/logof-gif.gmov new file mode 100644 index 0000000..fbce718 Binary files /dev/null and b/ise-display/logof-gif.gmov differ diff --git a/ise-display/logofd-gif.gmov b/ise-display/logofd-gif.gmov new file mode 100644 index 0000000..1cc2c62 Binary files /dev/null and b/ise-display/logofd-gif.gmov differ diff --git a/src/codebook.txt b/src/codebook.txt new file mode 100644 index 0000000..8ffe208 --- /dev/null +++ b/src/codebook.txt @@ -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) \ No newline at end of file diff --git a/src/ise_display.cpp b/src/ise_display.cpp new file mode 100644 index 0000000..7d1e04f --- /dev/null +++ b/src/ise_display.cpp @@ -0,0 +1,275 @@ +#include + +ISEDisplay::ISEDisplay(HardwareSerial *adapter) : ESPMegaDisplay(adapter) +{ + +} + +void ISEDisplay::begin(std::function 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) +{ + +} \ No newline at end of file diff --git a/src/ise_display.hpp b/src/ise_display.hpp new file mode 100644 index 0000000..a8b8717 --- /dev/null +++ b/src/ise_display.hpp @@ -0,0 +1,210 @@ +#pragma once +#include +#include +#include +#include +#include + + +// 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 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 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(); +}; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 590a374..cfcafd6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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()