diff --git a/.gitignore b/.gitignore index 6caeb0e..89cc49c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ .vscode/c_cpp_properties.json .vscode/launch.json .vscode/ipch -/.vscode -/.vscode diff --git a/ise-display/fonts/BaiJ-48-ascii.zi b/ise-display/fonts/BaiJ-48-ascii.zi deleted file mode 100644 index 4d572a4..0000000 Binary files a/ise-display/fonts/BaiJ-48-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-B-24-ascii.zi b/ise-display/fonts/BaiJ-B-24-ascii.zi deleted file mode 100644 index c1d9392..0000000 Binary files a/ise-display/fonts/BaiJ-B-24-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-B-40.zi b/ise-display/fonts/BaiJ-B-40.zi deleted file mode 100644 index 3bd944c..0000000 Binary files a/ise-display/fonts/BaiJ-B-40.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-B-48-ascii.zi b/ise-display/fonts/BaiJ-B-48-ascii.zi deleted file mode 100644 index 81aabaa..0000000 Binary files a/ise-display/fonts/BaiJ-B-48-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-sb-24-ascii.zi b/ise-display/fonts/BaiJ-sb-24-ascii.zi deleted file mode 100644 index 1d0861a..0000000 Binary files a/ise-display/fonts/BaiJ-sb-24-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-sb-72-ascii.zi b/ise-display/fonts/BaiJ-sb-72-ascii.zi deleted file mode 100644 index 16c1773..0000000 Binary files a/ise-display/fonts/BaiJ-sb-72-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-sb-80-ascii.zi b/ise-display/fonts/BaiJ-sb-80-ascii.zi deleted file mode 100644 index 407cd64..0000000 Binary files a/ise-display/fonts/BaiJ-sb-80-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/BaiJ-sb-86-ascii.zi b/ise-display/fonts/BaiJ-sb-86-ascii.zi deleted file mode 100644 index 6f27432..0000000 Binary files a/ise-display/fonts/BaiJ-sb-86-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/baiJ-B-32-ascii.zi b/ise-display/fonts/baiJ-B-32-ascii.zi deleted file mode 100644 index 18a8e5c..0000000 Binary files a/ise-display/fonts/baiJ-B-32-ascii.zi and /dev/null differ diff --git a/ise-display/fonts/baiJ-sb-32-ascii.zi b/ise-display/fonts/baiJ-sb-32-ascii.zi deleted file mode 100644 index 72dae21..0000000 Binary files a/ise-display/fonts/baiJ-sb-32-ascii.zi and /dev/null 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/OPEN-bg.png b/ise-display/images/boot/OPEN-bg.png deleted file mode 100644 index 7f4a5c4..0000000 Binary files a/ise-display/images/boot/OPEN-bg.png and /dev/null differ diff --git a/ise-display/images/boot/OPEN-ref.png b/ise-display/images/boot/OPEN-ref.png deleted file mode 100644 index 8fdeede..0000000 Binary files a/ise-display/images/boot/OPEN-ref.png and /dev/null 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/main/C-degree/C off.png b/ise-display/images/main/C-degree/C off.png deleted file mode 100644 index f505db8..0000000 Binary files a/ise-display/images/main/C-degree/C off.png and /dev/null differ diff --git a/ise-display/images/main/C-degree/C on.png b/ise-display/images/main/C-degree/C on.png deleted file mode 100644 index 7dacc39..0000000 Binary files a/ise-display/images/main/C-degree/C on.png and /dev/null differ diff --git a/ise-display/images/main/ac/AC-off-pressed.png b/ise-display/images/main/ac/AC-off-pressed.png deleted file mode 100644 index 7f21e3d..0000000 Binary files a/ise-display/images/main/ac/AC-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/ac/AC-off.png b/ise-display/images/main/ac/AC-off.png deleted file mode 100644 index 73a356a..0000000 Binary files a/ise-display/images/main/ac/AC-off.png and /dev/null differ diff --git a/ise-display/images/main/ac/AC-on-pressed.png b/ise-display/images/main/ac/AC-on-pressed.png deleted file mode 100644 index d635d44..0000000 Binary files a/ise-display/images/main/ac/AC-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/ac/AC-on.png b/ise-display/images/main/ac/AC-on.png deleted file mode 100644 index 052e027..0000000 Binary files a/ise-display/images/main/ac/AC-on.png and /dev/null differ diff --git a/ise-display/images/main/background/Background-c.png b/ise-display/images/main/background/Background-c.png deleted file mode 100644 index 3f69291..0000000 Binary files a/ise-display/images/main/background/Background-c.png and /dev/null differ diff --git a/ise-display/images/main/background/Background.png b/ise-display/images/main/background/Background.png deleted file mode 100644 index 0ff021b..0000000 Binary files a/ise-display/images/main/background/Background.png and /dev/null differ diff --git a/ise-display/images/main/background/Reference - Active mode.png b/ise-display/images/main/background/Reference - Active mode.png deleted file mode 100644 index 570a2d8..0000000 Binary files a/ise-display/images/main/background/Reference - Active mode.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Auto-off-pressed.png b/ise-display/images/main/fan/Fan-speed-Auto-off-pressed.png deleted file mode 100644 index 68fe571..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Auto-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Auto-off.png b/ise-display/images/main/fan/Fan-speed-Auto-off.png deleted file mode 100644 index 95fb2e4..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Auto-off.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Auto-on-pressed.png b/ise-display/images/main/fan/Fan-speed-Auto-on-pressed.png deleted file mode 100644 index a267a9a..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Auto-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Auto-on.png b/ise-display/images/main/fan/Fan-speed-Auto-on.png deleted file mode 100644 index 4a1d774..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Auto-on.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-High-off-pressed.png b/ise-display/images/main/fan/Fan-speed-High-off-pressed.png deleted file mode 100644 index 0adee9a..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-High-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-High-off.png b/ise-display/images/main/fan/Fan-speed-High-off.png deleted file mode 100644 index c45b2dc..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-High-off.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-High-on-pressed.png b/ise-display/images/main/fan/Fan-speed-High-on-pressed.png deleted file mode 100644 index a57e83e..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-High-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-High-on.png b/ise-display/images/main/fan/Fan-speed-High-on.png deleted file mode 100644 index 2943849..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-High-on.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Low-off-pressed.png b/ise-display/images/main/fan/Fan-speed-Low-off-pressed.png deleted file mode 100644 index f013e41..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Low-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Low-off.png b/ise-display/images/main/fan/Fan-speed-Low-off.png deleted file mode 100644 index b272008..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Low-off.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Low-on-pressed.png b/ise-display/images/main/fan/Fan-speed-Low-on-pressed.png deleted file mode 100644 index 3157a58..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Low-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Low-on.png b/ise-display/images/main/fan/Fan-speed-Low-on.png deleted file mode 100644 index f073fe9..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Low-on.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Mid-off-pressed.png b/ise-display/images/main/fan/Fan-speed-Mid-off-pressed.png deleted file mode 100644 index d3ab352..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Mid-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Mid-off.png b/ise-display/images/main/fan/Fan-speed-Mid-off.png deleted file mode 100644 index 76121d7..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Mid-off.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Mid-on-pressed.png b/ise-display/images/main/fan/Fan-speed-Mid-on-pressed.png deleted file mode 100644 index d3bc616..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Mid-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/fan/Fan-speed-Mid-on.png b/ise-display/images/main/fan/Fan-speed-Mid-on.png deleted file mode 100644 index 27d903d..0000000 Binary files a/ise-display/images/main/fan/Fan-speed-Mid-on.png and /dev/null differ diff --git a/ise-display/images/main/light/light-button-off-prressed.png b/ise-display/images/main/light/light-button-off-prressed.png deleted file mode 100644 index a41755a..0000000 Binary files a/ise-display/images/main/light/light-button-off-prressed.png and /dev/null differ diff --git a/ise-display/images/main/light/light-button-off.png b/ise-display/images/main/light/light-button-off.png deleted file mode 100644 index 1e9ac73..0000000 Binary files a/ise-display/images/main/light/light-button-off.png and /dev/null differ diff --git a/ise-display/images/main/light/light-button-on-pressed.png b/ise-display/images/main/light/light-button-on-pressed.png deleted file mode 100644 index 3926c29..0000000 Binary files a/ise-display/images/main/light/light-button-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/light/light-button-on.png b/ise-display/images/main/light/light-button-on.png deleted file mode 100644 index 31cc051..0000000 Binary files a/ise-display/images/main/light/light-button-on.png and /dev/null differ diff --git a/ise-display/images/main/light/light-state-0.png b/ise-display/images/main/light/light-state-0.png deleted file mode 100644 index 274097f..0000000 Binary files a/ise-display/images/main/light/light-state-0.png and /dev/null differ diff --git a/ise-display/images/main/light/light-state-1.png b/ise-display/images/main/light/light-state-1.png deleted file mode 100644 index 04892a6..0000000 Binary files a/ise-display/images/main/light/light-state-1.png and /dev/null differ diff --git a/ise-display/images/main/light/light-state-2.png b/ise-display/images/main/light/light-state-2.png deleted file mode 100644 index 11b14c6..0000000 Binary files a/ise-display/images/main/light/light-state-2.png and /dev/null differ diff --git a/ise-display/images/main/light/light-state-3.png b/ise-display/images/main/light/light-state-3.png deleted file mode 100644 index 8378813..0000000 Binary files a/ise-display/images/main/light/light-state-3.png and /dev/null differ diff --git a/ise-display/images/main/lock/lock.png b/ise-display/images/main/lock/lock.png deleted file mode 100644 index ab49ebd..0000000 Binary files a/ise-display/images/main/lock/lock.png and /dev/null differ diff --git a/ise-display/images/main/lock/no lock.png b/ise-display/images/main/lock/no lock.png deleted file mode 100644 index 57e7394..0000000 Binary files a/ise-display/images/main/lock/no lock.png and /dev/null differ diff --git a/ise-display/images/main/master-light/Master-light-all.png b/ise-display/images/main/master-light/Master-light-all.png deleted file mode 100644 index 63eb473..0000000 Binary files a/ise-display/images/main/master-light/Master-light-all.png and /dev/null differ diff --git a/ise-display/images/main/master-light/Master-light-state0.png b/ise-display/images/main/master-light/Master-light-state0.png deleted file mode 100644 index 1f2dd8e..0000000 Binary files a/ise-display/images/main/master-light/Master-light-state0.png and /dev/null differ diff --git a/ise-display/images/main/master-light/Master-light-state1.png b/ise-display/images/main/master-light/Master-light-state1.png deleted file mode 100644 index 572ca51..0000000 Binary files a/ise-display/images/main/master-light/Master-light-state1.png and /dev/null differ diff --git a/ise-display/images/main/master-light/Master-light-state2.png b/ise-display/images/main/master-light/Master-light-state2.png deleted file mode 100644 index 3feacc3..0000000 Binary files a/ise-display/images/main/master-light/Master-light-state2.png and /dev/null differ diff --git a/ise-display/images/main/master-light/Master-light-state3.png b/ise-display/images/main/master-light/Master-light-state3.png deleted file mode 100644 index 60bf1a4..0000000 Binary files a/ise-display/images/main/master-light/Master-light-state3.png and /dev/null differ diff --git a/ise-display/images/main/master-light/master-light-button-off-pressed.png b/ise-display/images/main/master-light/master-light-button-off-pressed.png deleted file mode 100644 index fc2f69e..0000000 Binary files a/ise-display/images/main/master-light/master-light-button-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/master-light/master-light-button-off.png b/ise-display/images/main/master-light/master-light-button-off.png deleted file mode 100644 index e3528e0..0000000 Binary files a/ise-display/images/main/master-light/master-light-button-off.png and /dev/null differ diff --git a/ise-display/images/main/master-light/master-light-button-on.png b/ise-display/images/main/master-light/master-light-button-on.png deleted file mode 100644 index 56d4bec..0000000 Binary files a/ise-display/images/main/master-light/master-light-button-on.png and /dev/null differ diff --git a/ise-display/images/main/master-light/master-light-button-pressed.png b/ise-display/images/main/master-light/master-light-button-pressed.png deleted file mode 100644 index 5cce401..0000000 Binary files a/ise-display/images/main/master-light/master-light-button-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-cool-off-pressed.png b/ise-display/images/main/mode/Mode-cool-off-pressed.png deleted file mode 100644 index 6aaef2f..0000000 Binary files a/ise-display/images/main/mode/Mode-cool-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-cool-off.png b/ise-display/images/main/mode/Mode-cool-off.png deleted file mode 100644 index 57b5072..0000000 Binary files a/ise-display/images/main/mode/Mode-cool-off.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-cool-on-pressed.png b/ise-display/images/main/mode/Mode-cool-on-pressed.png deleted file mode 100644 index 973dced..0000000 Binary files a/ise-display/images/main/mode/Mode-cool-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-cool-on.png b/ise-display/images/main/mode/Mode-cool-on.png deleted file mode 100644 index ce61894..0000000 Binary files a/ise-display/images/main/mode/Mode-cool-on.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-dry-off-pressed.png b/ise-display/images/main/mode/Mode-dry-off-pressed.png deleted file mode 100644 index 06c1932..0000000 Binary files a/ise-display/images/main/mode/Mode-dry-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-dry-off.png b/ise-display/images/main/mode/Mode-dry-off.png deleted file mode 100644 index b4d86c2..0000000 Binary files a/ise-display/images/main/mode/Mode-dry-off.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-dry-on-pressed.png b/ise-display/images/main/mode/Mode-dry-on-pressed.png deleted file mode 100644 index 94c8c87..0000000 Binary files a/ise-display/images/main/mode/Mode-dry-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-dry-on.png b/ise-display/images/main/mode/Mode-dry-on.png deleted file mode 100644 index 486ae31..0000000 Binary files a/ise-display/images/main/mode/Mode-dry-on.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-fan-off-pressed.png b/ise-display/images/main/mode/Mode-fan-off-pressed.png deleted file mode 100644 index 3b8ea67..0000000 Binary files a/ise-display/images/main/mode/Mode-fan-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-fan-off.png b/ise-display/images/main/mode/Mode-fan-off.png deleted file mode 100644 index fd3110e..0000000 Binary files a/ise-display/images/main/mode/Mode-fan-off.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-fan-on-pressed.png b/ise-display/images/main/mode/Mode-fan-on-pressed.png deleted file mode 100644 index b83978a..0000000 Binary files a/ise-display/images/main/mode/Mode-fan-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/mode/Mode-fan-on.png b/ise-display/images/main/mode/Mode-fan-on.png deleted file mode 100644 index 9f950ad..0000000 Binary files a/ise-display/images/main/mode/Mode-fan-on.png and /dev/null differ diff --git a/ise-display/images/main/pm/PM-off-pressed.png b/ise-display/images/main/pm/PM-off-pressed.png deleted file mode 100644 index cf092a2..0000000 Binary files a/ise-display/images/main/pm/PM-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/pm/PM-off.png b/ise-display/images/main/pm/PM-off.png deleted file mode 100644 index e277882..0000000 Binary files a/ise-display/images/main/pm/PM-off.png and /dev/null differ diff --git a/ise-display/images/main/pm/PM-on-pressed.png b/ise-display/images/main/pm/PM-on-pressed.png deleted file mode 100644 index 6ea9c11..0000000 Binary files a/ise-display/images/main/pm/PM-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/pm/PM-on.png b/ise-display/images/main/pm/PM-on.png deleted file mode 100644 index 791813f..0000000 Binary files a/ise-display/images/main/pm/PM-on.png and /dev/null differ diff --git a/ise-display/images/main/temp-control/temp-min-pressed.png b/ise-display/images/main/temp-control/temp-min-pressed.png deleted file mode 100644 index 8c3ff5a..0000000 Binary files a/ise-display/images/main/temp-control/temp-min-pressed.png and /dev/null differ diff --git a/ise-display/images/main/temp-control/temp-min.png b/ise-display/images/main/temp-control/temp-min.png deleted file mode 100644 index 4bc9c43..0000000 Binary files a/ise-display/images/main/temp-control/temp-min.png and /dev/null differ diff --git a/ise-display/images/main/temp-control/temp-plus-pressed.png b/ise-display/images/main/temp-control/temp-plus-pressed.png deleted file mode 100644 index ae5fc98..0000000 Binary files a/ise-display/images/main/temp-control/temp-plus-pressed.png and /dev/null differ diff --git a/ise-display/images/main/temp-control/temp-plus.png b/ise-display/images/main/temp-control/temp-plus.png deleted file mode 100644 index e944126..0000000 Binary files a/ise-display/images/main/temp-control/temp-plus.png and /dev/null differ diff --git a/ise-display/images/main/toggle-all/toggle-all-off-pressed.png b/ise-display/images/main/toggle-all/toggle-all-off-pressed.png deleted file mode 100644 index fc6b65a..0000000 Binary files a/ise-display/images/main/toggle-all/toggle-all-off-pressed.png and /dev/null differ diff --git a/ise-display/images/main/toggle-all/toggle-all-off.png b/ise-display/images/main/toggle-all/toggle-all-off.png deleted file mode 100644 index cf0ae56..0000000 Binary files a/ise-display/images/main/toggle-all/toggle-all-off.png and /dev/null differ diff --git a/ise-display/images/main/toggle-all/toggle-all-on-pressed.png b/ise-display/images/main/toggle-all/toggle-all-on-pressed.png deleted file mode 100644 index c179c3f..0000000 Binary files a/ise-display/images/main/toggle-all/toggle-all-on-pressed.png and /dev/null differ diff --git a/ise-display/images/main/toggle-all/toggle-all-on.png b/ise-display/images/main/toggle-all/toggle-all-on.png deleted file mode 100644 index d85c19a..0000000 Binary files a/ise-display/images/main/toggle-all/toggle-all-on.png and /dev/null 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/AC/Standby-AC-off-pressed.png b/ise-display/images/standby/AC/Standby-AC-off-pressed.png deleted file mode 100644 index e6f23ec..0000000 Binary files a/ise-display/images/standby/AC/Standby-AC-off-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/AC/Standby-AC-off.png b/ise-display/images/standby/AC/Standby-AC-off.png deleted file mode 100644 index 768a986..0000000 Binary files a/ise-display/images/standby/AC/Standby-AC-off.png and /dev/null differ diff --git a/ise-display/images/standby/AC/Standby-AC-on-pressed.png b/ise-display/images/standby/AC/Standby-AC-on-pressed.png deleted file mode 100644 index e06a8e0..0000000 Binary files a/ise-display/images/standby/AC/Standby-AC-on-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/AC/Standby-AC-on.png b/ise-display/images/standby/AC/Standby-AC-on.png deleted file mode 100644 index 3db2828..0000000 Binary files a/ise-display/images/standby/AC/Standby-AC-on.png and /dev/null differ diff --git a/ise-display/images/standby/Master Switch-1.png b/ise-display/images/standby/Master Switch-1.png new file mode 100644 index 0000000..6802509 Binary files /dev/null and b/ise-display/images/standby/Master Switch-1.png differ diff --git a/ise-display/images/standby/Master Switch.png b/ise-display/images/standby/Master Switch.png new file mode 100644 index 0000000..639fbee Binary files /dev/null and b/ise-display/images/standby/Master Switch.png differ diff --git a/ise-display/images/standby/PM/Standby-PM-off-pressed.png b/ise-display/images/standby/PM/Standby-PM-off-pressed.png deleted file mode 100644 index 7ed59b4..0000000 Binary files a/ise-display/images/standby/PM/Standby-PM-off-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/PM/Standby-PM-off.png b/ise-display/images/standby/PM/Standby-PM-off.png deleted file mode 100644 index dff27a9..0000000 Binary files a/ise-display/images/standby/PM/Standby-PM-off.png and /dev/null differ diff --git a/ise-display/images/standby/PM/Standby-PM-on-pressed.png b/ise-display/images/standby/PM/Standby-PM-on-pressed.png deleted file mode 100644 index 34efbef..0000000 Binary files a/ise-display/images/standby/PM/Standby-PM-on-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/PM/Standby-PM-on.png b/ise-display/images/standby/PM/Standby-PM-on.png deleted file mode 100644 index abee3e1..0000000 Binary files a/ise-display/images/standby/PM/Standby-PM-on.png and /dev/null differ diff --git a/ise-display/images/standby/Standby-mode-bg.png b/ise-display/images/standby/Standby-mode-bg.png deleted file mode 100644 index fdb1401..0000000 Binary files a/ise-display/images/standby/Standby-mode-bg.png and /dev/null differ diff --git a/ise-display/images/standby/Standby-mode-ref.png b/ise-display/images/standby/Standby-mode-ref.png deleted file mode 100644 index b6f7005..0000000 Binary files a/ise-display/images/standby/Standby-mode-ref.png and /dev/null differ diff --git a/ise-display/images/standby/adv/Standby-adv-off-pressed.png b/ise-display/images/standby/adv/Standby-adv-off-pressed.png deleted file mode 100644 index d0aadfd..0000000 Binary files a/ise-display/images/standby/adv/Standby-adv-off-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/adv/Standby-adv-off.png b/ise-display/images/standby/adv/Standby-adv-off.png deleted file mode 100644 index 6855f2b..0000000 Binary files a/ise-display/images/standby/adv/Standby-adv-off.png and /dev/null differ diff --git a/ise-display/images/standby/adv/Standby-adv-on-pressed.png b/ise-display/images/standby/adv/Standby-adv-on-pressed.png deleted file mode 100644 index 266fa2e..0000000 Binary files a/ise-display/images/standby/adv/Standby-adv-on-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/adv/Standby-adv-on.png b/ise-display/images/standby/adv/Standby-adv-on.png deleted file mode 100644 index b0918ca..0000000 Binary files a/ise-display/images/standby/adv/Standby-adv-on.png and /dev/null 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/light/Standby-light-off-pressed.png b/ise-display/images/standby/light/Standby-light-off-pressed.png deleted file mode 100644 index 6ac8f56..0000000 Binary files a/ise-display/images/standby/light/Standby-light-off-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/light/Standby-light-off.png b/ise-display/images/standby/light/Standby-light-off.png deleted file mode 100644 index bbff71a..0000000 Binary files a/ise-display/images/standby/light/Standby-light-off.png and /dev/null differ diff --git a/ise-display/images/standby/light/Standby-light-on-pressed.png b/ise-display/images/standby/light/Standby-light-on-pressed.png deleted file mode 100644 index 8efe17e..0000000 Binary files a/ise-display/images/standby/light/Standby-light-on-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/light/Standby-light-on.png b/ise-display/images/standby/light/Standby-light-on.png deleted file mode 100644 index 58df375..0000000 Binary files a/ise-display/images/standby/light/Standby-light-on.png and /dev/null 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-dashboard-p.png b/ise-display/images/standby/s-dashboard-p.png new file mode 100644 index 0000000..6802509 Binary files /dev/null and b/ise-display/images/standby/s-dashboard-p.png differ diff --git a/ise-display/images/standby/s-dashboard.png b/ise-display/images/standby/s-dashboard.png new file mode 100644 index 0000000..639fbee Binary files /dev/null and b/ise-display/images/standby/s-dashboard.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/images/standby/toggle/Standby-toggle-off-pressed.png b/ise-display/images/standby/toggle/Standby-toggle-off-pressed.png deleted file mode 100644 index f71e161..0000000 Binary files a/ise-display/images/standby/toggle/Standby-toggle-off-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/toggle/Standby-toggle-off.png b/ise-display/images/standby/toggle/Standby-toggle-off.png deleted file mode 100644 index c2edacd..0000000 Binary files a/ise-display/images/standby/toggle/Standby-toggle-off.png and /dev/null differ diff --git a/ise-display/images/standby/toggle/Standby-toggle-on-pressed.png b/ise-display/images/standby/toggle/Standby-toggle-on-pressed.png deleted file mode 100644 index 3061724..0000000 Binary files a/ise-display/images/standby/toggle/Standby-toggle-on-pressed.png and /dev/null differ diff --git a/ise-display/images/standby/toggle/Standby-toggle-on.png b/ise-display/images/standby/toggle/Standby-toggle-on.png deleted file mode 100644 index 54d423a..0000000 Binary files a/ise-display/images/standby/toggle/Standby-toggle-on.png and /dev/null differ diff --git a/ise-display/ise-display-v2.HMI b/ise-display/ise-display-prod.HMI similarity index 84% rename from ise-display/ise-display-v2.HMI rename to ise-display/ise-display-prod.HMI index 5e71a9f..16c9582 100644 Binary files a/ise-display/ise-display-v2.HMI and b/ise-display/ise-display-prod.HMI differ diff --git a/ise-display/ise-display-v2.tft b/ise-display/ise-display-v2.tft deleted file mode 100644 index 8cf3fec..0000000 Binary files a/ise-display/ise-display-v2.tft and /dev/null differ diff --git a/ise-display/old-ise-display-v2.tft b/ise-display/old-ise-display-v2.tft deleted file mode 100644 index f64401e..0000000 Binary files a/ise-display/old-ise-display-v2.tft and /dev/null differ diff --git a/platformio.ini b/platformio.ini index 5d21a24..700cbce 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,6 +12,8 @@ platform = espressif32 board = wt32-eth01 framework = arduino -lib_deps = siwats/ESPMegaPROR3@^2.9.4 +lib_deps = siwats/ESPMegaPROR3@^2.3.7 monitor_speed = 115200 -build_flags = -DCORE_DEBUG_LEVEL=0 -DSW_VERSION='"ise-final-1.3"' -DBOARD_MODEL='"ESPMegaPRO R3.3b"' \ No newline at end of file +build_flags = -DCORE_DEBUG_LEVEL=0 +upload_port = COM4 +monitor_port = COM4 \ No newline at end of file diff --git a/src/ise_display.cpp b/src/ise_display.cpp index 097e3c7..fa3c2f1 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -5,30 +5,27 @@ ISEDisplay::ISEDisplay(HardwareSerial *adapter, const uint8_t *light_array, uint this->row = row; this->column = column; } +// Work left +// TODO : Implement +// debug to work -void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard_daikin, ClimateCard *climateCard_york, RemoteVariable *pm_switch, RemoteVariable *pm_fan_speed, RemoteVariable *ac_lock, RemoteVariable *pm_lock, ESPMegaIoT *iot) +void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCard, ClimateCard *climateCard_daikin, ClimateCard *climateCard_york, RemoteVariable* pm_switch, RemoteVariable* pm_fan_speed) { - this->iot = iot; this->inputCard = inputCard; this->outputCard = outputCard; this->climateCard_daikin = climateCard_daikin; this->climateCard_york = climateCard_york; this->pm_switch = pm_switch; - this->pm_lock = pm_lock; - this->ac_lock = ac_lock; this->remote_pm_fan_speed = pm_fan_speed; 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 bindedHandleTouch = std::bind(&ISEDisplay::handleTouch, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); this->outputCallbackHandle = this->outputCard->registerChangeCallback(bindedHandlePWMChange); this->climateCallbackHandle = this->climateCard_daikin->registerChangeCallback(bindedHandleACChange); - // this->climateCallbackHandle = this->climateCard_york->registerChangeCallback(bindedHandleACChange); - this->user_mode = 2; // initialized to cool by default - this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; // initialized to get value - this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; // initialized to get value - this->pm_fan_speed = 18; - remote_pm_fan_speed->setIntValue(this->pm_fan_speed); - // remote_pm_fan_speed->setValue(pm_fan_speed); + //this->climateCallbackHandle = this->climateCard_york->registerChangeCallback(bindedHandleACChange); + this->user_mode = 1; // initialized to cool by default + this->pm_fan_speed = 10; + //remote_pm_fan_speed->setValue(pm_fan_speed); this->ac_fan_speed = 0; this->ac_mode = 0; this->ac_temperature = 25; @@ -36,28 +33,33 @@ void ISEDisplay::begin(DigitalInputCard *inputCard, DigitalOutputCard *outputCar this->lightLevelRow2 = 0; this->lightLevelRow3 = 0; this->lightLevelRow4 = 0; - this->time_since_last_ac_change = 0; - this->ac_press_pending = false; - this->time_since_ac_staggered_start_call = 0; - this->ac_staggered_start_call_pending = false; // this->time_since_last_screen_update = 0; this->registerTouchCallback(bindedHandleTouch); this->reset(); delay(1000); + // TODO : Will the light be on or off when the system is started?, You need to jump to its respective page // first jump to main then if no activity jump to standby this->jumpToPage(2); // change this back later to 2 delay(100); this->updateAirPurifierState(); - this->updateSystemtoggle(); - this->updateAllStandbyToggle(); this->updateACState(); this->updateLightGroupStatePageDashboard(); - // intialize AC state - if (ac_lock_state == false) - { - setACstate(ac_fan_speed, ac_mode, ac_temperature); // default to off with temp 25 and fan on Auto + // this->outputCard->setValue(1, 0); + // this->outputCard->setValue(2, 0); + // this->outputCard->setValue(3, 0); + // this->outputCard->setValue(4, 0); + // this->climateCard->setTemperature(ac_temperature); + // this->climateCard->setFanSpeed(ac_fan_speed); + // this->climateCard->setMode(ac_mode); + this->climateCard_daikin->setState(ac_mode, ac_fan_speed, ac_temperature); + if(ac_mode == 3){ + this->climateCard_york->setState(0, ac_fan_speed, ac_temperature); } + else{ + this->climateCard_york->setState(ac_mode, ac_fan_speed, ac_temperature); + } + } void ISEDisplay::loop() { @@ -65,118 +67,55 @@ void ISEDisplay::loop() // If there is data, process the data recieveSerialCommand(); - // Check if the AC state has been changed - if (ac_press_pending && (millis() - time_since_last_ac_change) > 500) - { - ESP_LOGI("ISEDisplay", "Sending AC IR code"); - sendACIRcode(); - ESP_LOGI("ISEDisplay", "AC IR code sent"); - ac_press_pending = false; - ESP_LOGI("ISEDisplay", "AC press pending set to false"); - } - // check for ac staggered start - if (ac_staggered_start_call_pending && (millis() - time_since_ac_staggered_start_call) > 3000) - { - ESP_LOGI("ISEDisplay", "Sending Staggered AC IR code (York)"); - sendACIRcode(); - ESP_LOGI("ISEDisplay", "AC Staggered AC IR code (York) sent"); - ac_staggered_start_call_pending = false; - ESP_LOGI("ISEDisplay", "AC staggered start call pending set to false"); - } + // Update the time since the last screen update using millis() - // Check if the MQTT connection has been lost - static uint32_t last_mqtt_connected_check = 0; - if (last_mqtt_connected_check == 0) - { - last_mqtt_connected_check = millis() + 15000; // Wait 15 seconds before checking - ESP_LOGD("ISE Display", "Waiting 15 seconds before checking MQTT connection"); - } - static bool first_disconnect = true; - // ESP_LOGI("ISEDisplay", "init first disconnect set to true"); - if (millis() - last_mqtt_connected_check > 3000) - { - ESP_LOGD("ISE Display", "Checking MQTT Connection, Connection is %s", this->iot->mqttConnected() ? "true" : "false"); - if (!this->iot->mqttConnected()) - { - ESP_LOGI("ISEDisplay", "MQTT is disconnected"); - if (first_disconnect) - { - // When MQTT is disconnected, enter standalone mode - // A/C lock is lifted - // PM lock are lifted - ESP_LOGI("ISEDisplay", "Entering standalone mode"); - this->ac_lock_state = false; - ESP_LOGI("ISEDisplay", "AC lock state set to false"); - this->pm_lock_state = false; - ESP_LOGI("ISEDisplay", "PM lock state set to false"); - first_disconnect = false; - ESP_LOGI("ISEDisplay", "first disconnect set to false"); - } - } - else - { - if (first_disconnect == false) - { - // When MQTT is connected, exit standalone mode - // A/C lock is set - // PM lock is set + // u_int32_t current_time = millis(); - ESP_LOGI("ISEDisplay", "Exiting standalone mode"); - - first_disconnect = true; - ESP_LOGI("ISEDisplay", "first disconnect set to true"); - this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "AC lock state set to %d", this->ac_lock_state); - this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "PM lock state set to %d", this->pm_lock_state); - updateACState(); - ESP_LOGI("ISEDisplay", "AC state updated"); - updateAirPurifierState(); - ESP_LOGI("ISEDisplay", "Air purifier state updated"); - } - } - last_mqtt_connected_check = millis(); - ESP_LOGI("ISEDisplay", "last mqtt connected check set to current time"); - } - // ESP_LOGV("ISEDisplay", "this Loop is finish"); + // if (current_time - this->time_since_last_screen_update > 120000) + // { + // // jump to standby page if there is no activity for 2 minutes + // if(this->currentPage != 1){ + // this->jumpToPage(1); + // ESP_LOGI("ISEDisplay", "Jumping to standby page"); + // } + // } } void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type) { ESP_LOGD("ISEDisplay", "Touch detected on page %d, component %d, touch type %d", page, component, touch_type); + // time_since_last_screen_update = millis(); // update time since last activity char buffer[4]; if (page == PAGE_STANDBY) { switch (component) { - case COMPONENT_OBJ_STANDBY_LOGO: + case COMPONENT_STANDBY_OPEN_ALL_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - //this->jumpToPage(2); - break; - case COMPONENT_OBJ_STANDBY_BTN_OPEN_ALL_TOGGLE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - //allToggleStandby(); + // TODO : Should you really jump to page 2 here? should't page jumping be handled reactivly? + // EX. if atleast one light is on, then jump to active page, else jump to standby page + // This will allow page to change correctly when the system is started and when controlled remotely which won't call handleTouch + // time_since_last_screen_update = millis(); this->jumpToPage(2); // the function of the button is to open the dashboard from standby break; - case COMPONENT_OBJ_STANDBY_BTN_LIGHT_TOGGLE: + case COMPONENT_STANDBY_LIGHT_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; + // TODO : So this does nothing? Shouldn't it turn on the lights? + // should turn it on now toggleLightGroupStateStandby(); break; - case COMPONENT_OBJ_STANDBY_BTN_AC_TOGGLE: + case COMPONENT_STANDBY_AC_TOGGLE: + // TODO : What's the expexted behavior of standby? Does it enter standby when the lights are all off and ignore the AC + // or does it only enter standby when ac is also off and purifier is off, or is it a timed thing? if (touch_type != TOUCH_TYPE_RELEASE) break; - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } toggleAC(); + break; - case COMPONENT_OBJ_STANDBY_BTN_PM_TOGGLE: + case COMPONENT_STANDBY_PM_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; togglePMStandby(); @@ -185,245 +124,151 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type break; } } + else if (page == PAGE_DASHBOARD) { switch (component) { - case COMPONENT_OBJ_DASHBOARD_NUM_AC_TEMP: - break; - case COMPONENT_OBJ_DASHBOARD_BTN_AC_TOGGLE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - - // if ac_lock is true do nothing - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } - - toggleAC(); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_AC_MODE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // if ac_lock is true do nothing - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } - changeUserACmode(); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_AC_FAN_SPEED: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // if ac_lock is true do nothing - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } - // ac_fan_speed = this->climateCard_daikin->getFanSpeed(); - ac_fan_speed = this->ac_fan_speed; - // mode= auto, high, mid, low - ESP_LOGI("ISEDisplay", "Current AC fan speed: %d", ac_fan_speed); - ac_fan_speed = (ac_fan_speed + 1) % 4; - ESP_LOGI("ISEDisplay", "New AC fan speed: %d", ac_fan_speed); - setACstate(ac_fan_speed, ac_mode, ac_temperature); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_MINUS: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // if ac_lock is true do nothing - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } - // ac_temperature = this->climateCard_daikin->getTemperature() - 1; - ac_temperature = this->ac_temperature - 1; - setACstate(ac_fan_speed, ac_mode, ac_temperature); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_PLUS: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // if ac_lock is true do nothing - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - break; - } - // ac_temperature = this->climateCard_daikin->getTemperature() + 1; - ac_temperature = this->ac_temperature + 1; - setACstate(ac_fan_speed, ac_mode, ac_temperature); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_PM_TOGGLE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // if pm_lock is true do nothing - if (this->pm_lock_state == true) - { - ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); - break; - } - togglePM(); - break; - case COMPONENT_OBJ_DASHBOARD_TXT_PM_INSIDE: - break; - case COMPONENT_OBJ_DASHBOARD_TXT_PM_OUTSIDE: - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW1: - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW2: - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW3: - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW4: - break; - case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW1: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - toggleLightIndividual(1); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW2: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - toggleLightIndividual(2); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW3: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - toggleLightIndividual(3); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW4: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - toggleLightIndividual(4); - break; - case COMPONENT_OBJ_DASHBOARD_TIMER_TEN_SEC: - break; - case COMPONENT_OBJ_DASHBOARD_VAL_TIME_PAST: - break; - case COMPONENT_OBJ_DASHBOARD_TIMER_INACTIVE_CHECK: - break; - case COMPONENT_OBJ_DASHBOARD_BTN_SYSTEM_TOGGLE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // implement system toggle - // check light on or off - // check ac on or off - // check pm on or off - toggleSystem(); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_PM_SPEED: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // implement pm speed change - changePMfanspeed(); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_PM_MODE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // implement pm mode change - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_MASTER_LIGHT: - break; - case COMPONENT_OBJ_DASHBOARD_LOGO: - jumpToPage(1); - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_PM_LOCK: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // toggle_pm_lock(); - break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_AC_LOCK: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - // toggle_ac_lock(); - break; - case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_MASTER: + case COMPONENT_LIGHT_MASTER_BUTTON: + // TODO : this only update the display to match the light, it doesn't toggle the light. if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightGroupState(); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV1: + // TODOlater : can't this be done better with array lookup? + case COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightGroupState(1); + for (uint8_t i = 1; i <= 4; i++) + { + setLightLevel(i, 1); + } break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV2: + case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightGroupState(2); + for (uint8_t i = 1; i <= 4; i++) + { + setLightLevel(i, 2); + } break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV3: + case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightGroupState(3); + for (uint8_t i = 1; i <= 4; i++) + { + setLightLevel(i, 3); + } break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV1: + case COMPONENT_LIGHT_ROW1_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(1, 1); + lightLevelRow1 = this->getNumber("light_r1_slide.val"); + toggleSliderLight(1, lightLevelRow1); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV2: + case COMPONENT_LIGHT_ROW2_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(1, 2); + lightLevelRow2 = this->getNumber("light_r2_slide.val"); + toggleSliderLight(2, lightLevelRow2); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV3: + case COMPONENT_LIGHT_ROW3_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(1, 3); + lightLevelRow3 = this->getNumber("light_r3_slide.val"); + toggleSliderLight(3, lightLevelRow3); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV1: + case COMPONENT_LIGHT_ROW4_SLIDER: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(2, 1); + lightLevelRow4 = this->getNumber("light_r4_slide.val"); + toggleSliderLight(4, lightLevelRow4); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV2: + case COMPONENT_LIGHT_ROW1_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(2, 2); + toggleLightIndividual(1); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV3: + case COMPONENT_LIGHT_ROW2_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(2, 3); + toggleLightIndividual(2); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV1: + case COMPONENT_LIGHT_ROW3_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(3, 1); + toggleLightIndividual(3); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV2: + case COMPONENT_LIGHT_ROW4_SWITCH: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(3, 2); + toggleLightIndividual(4); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV3: + // TODO : Don't we have fan only mode too? can you really just switch between 0 and 1? + case COMPONENT_AC_TOGGLE_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(3, 3); + toggleAC(); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV1: + case COMPONENT_AC_MODE: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(4, 1); + changeUserACmode(); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV2: + case COMPONENT_AC_FAN_SPEED: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(4, 2); + ac_fan_speed = this->climateCard_daikin->getFanSpeed(); + // We have auto, low, mid, high right?, that's 0,1,2,3 a modulo operation of 3 only gives 0,1,2 + // mod 4 should fixed it + ESP_LOGI("ISEDisplay", "Current AC fan speed: %d", ac_fan_speed); + ac_fan_speed = (ac_fan_speed + 1) % 4; + ESP_LOGI("ISEDisplay", "New AC fan speed: %d", ac_fan_speed); + this->climateCard_daikin->setFanSpeed(ac_fan_speed); + this->climateCard_york->setFanSpeed(ac_fan_speed); + // updateACState(); break; - case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV3: + case COMPONENT_AC_TEMP_DOWN_BUTTON: if (touch_type != TOUCH_TYPE_RELEASE) break; - setLightLevel(4, 3); + this->climateCard_daikin->setTemperature(this->climateCard_daikin->getTemperature() - 1); + this->climateCard_york->setTemperature(this->climateCard_york->getTemperature() - 1); + // updateACState(); break; - case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_C_DEGREE: + case COMPONENT_AC_TEMP_UP_BUTTON: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + this->climateCard_daikin->setTemperature(this->climateCard_daikin->getTemperature() + 1); + this->climateCard_york->setTemperature(this->climateCard_york->getTemperature() + 1); + // updateACState(); + break; + case COMPONENT_PM_TOGGLE_BUTTON: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + togglePM(); + break; + case COMPONENT_PM_FAN_SPEED_DECREASE: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + pm_fan_speed = (int) atof(remote_pm_fan_speed->getValue()); + ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed); + if (pm_fan_speed >= 1 && pm_fan_speed <= 20) + itoa(pm_fan_speed - 1, buffer, DEC); + remote_pm_fan_speed->setValue(buffer); + ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed); + //updateAirPurifierState(); + break; + case COMPONENT_PM_FAN_SPEED_INCREASE: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + pm_fan_speed = (int) atof(remote_pm_fan_speed->getValue()); + ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", pm_fan_speed); + if (pm_fan_speed >= 0 && pm_fan_speed <= 19) + itoa(pm_fan_speed + 1, buffer, DEC); + remote_pm_fan_speed->setValue(buffer); + ESP_LOGI("ISEDisplay", "New PM fan speed: %d", pm_fan_speed); + //updateAirPurifierState(); break; default: break; @@ -441,27 +286,25 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) // NEED to switch case for different page uint8_t current_page = this->currentPage; - - // uint8_t first_pin = *(light_array); - // uint8_t last_pin = *(light_array + 7); + + //uint8_t first_pin = *(light_array); + //uint8_t last_pin = *(light_array + 7); if (current_page == PAGE_STANDBY) { - if (LIGHT_ROW1_COLUMN1 || LIGHT_ROW1_COLUMN2 || LIGHT_ROW2_COLUMN1 || LIGHT_ROW2_COLUMN2 || LIGHT_ROW3_COLUMN1 || LIGHT_ROW3_COLUMN2 || LIGHT_ROW4_COLUMN1 || LIGHT_ROW4_COLUMN2) // change + if (LIGHT_ROW1_COLUMN1 || LIGHT_ROW1_COLUMN2 || LIGHT_ROW2_COLUMN1 || LIGHT_ROW2_COLUMN2 || LIGHT_ROW3_COLUMN1 || LIGHT_ROW3_COLUMN2 || LIGHT_ROW4_COLUMN1 || LIGHT_ROW4_COLUMN2) //change { // Light updateLightGroupStatePageStandby(); - updateAllStandbyToggle(); // time_since_last_screen_update = millis(); // update time since last activity } } else if (current_page == PAGE_DASHBOARD) { - if (LIGHT_ROW1_COLUMN1 || LIGHT_ROW1_COLUMN2 || LIGHT_ROW2_COLUMN1 || LIGHT_ROW2_COLUMN2 || LIGHT_ROW3_COLUMN1 || LIGHT_ROW3_COLUMN2 || LIGHT_ROW4_COLUMN1 || LIGHT_ROW4_COLUMN2) // change + if (LIGHT_ROW1_COLUMN1 || LIGHT_ROW1_COLUMN2 || LIGHT_ROW2_COLUMN1 || LIGHT_ROW2_COLUMN2 || LIGHT_ROW3_COLUMN1 || LIGHT_ROW3_COLUMN2 || LIGHT_ROW4_COLUMN1 || LIGHT_ROW4_COLUMN2) //change { // Light updateLightGroupStatePageDashboard(); - updateSystemtoggle(); // time_since_last_screen_update = millis(); // update time since last activity } } @@ -472,38 +315,115 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) } void ISEDisplay::updateDateTimeText(rtctime_t time) { - if (this->currentPage == 1) - { - if (!this->takeSerialMutex()) - return; - // Send the time to the display + if (!this->takeSerialMutex()) + return; + // Send the time to the display - this->displayAdapter->printf("time.txt=\"%02d:%02d\"", time.hours, time.minutes); - this->sendStopBytes(); + 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("date.txt=\"%02d.%02d.%d\"", time.day, time.month, time.year); + this->sendStopBytes(); - this->giveSerialMutex(); - } + this->giveSerialMutex(); } // TODO : Implement // user remote var // appdeamon +void ISEDisplay::updateWeather(char *weather_string) +{ + // TODO : use remotevar to get weather data from appdaemon and update the display + u_int8_t weather_code = 68; -// void ISEDisplay::updateTempOutside(float temp_outside) -// { -// // TODO : use remotevar to get PM2.5 data from appdaemon and update the display + if (strcmp(weather_string, "fair_day") == 0) + { + weather_code = 63; + } + else if (strcmp(weather_string, "sunny") == 0) + { + weather_code = 63; + } + else if (strcmp(weather_string, "fair_night") == 0) + { + weather_code = 64; + } + else if (strcmp(weather_string, "cloudy") == 0) + { + weather_code = 65; + } + else if (strcmp(weather_string, "clear-day") == 0) + { + weather_code = 66; + } + else if (strcmp(weather_string, "clear-night") == 0) + { + weather_code = 67; + } + else if (strcmp(weather_string, "partlycloudy_day") == 0) + { + weather_code = 68; + } + else if (strcmp(weather_string, "partlycloudy") == 0) + { + weather_code = 68; + } + else if (strcmp(weather_string, "partlycloudy_night") == 0) + { + weather_code = 69; + } + else if (strcmp(weather_string, "heavyrain") == 0) + { + weather_code = 70; + } + else if (strcmp(weather_string, "heavyrainandthunder") == 0) + { + weather_code = 71; + } + else if (strcmp(weather_string, "rainandthunder") == 0) + { + weather_code = 72; + } + else if (strcmp(weather_string, "rain") == 0) + { + weather_code = 73; + } + else if (strcmp(weather_string, "rainy") == 0) + { + weather_code = 73; + } + else if (strcmp(weather_string, "lightrain") == 0) + { + weather_code = 74; + } + else if (strcmp(weather_string, "fog") == 0) + { + weather_code = 75; + } + else + { + weather_code = 68; + } + ESP_LOGI("ISEDisplay", "Updating weather to: %s (%d)", weather_string, weather_code); -// // change temp_outside to int then display -// u_int8_t temp_outside_int = (u_int8_t)temp_outside; -// ESP_LOGI("ISEDisplay", "Updating temperature outside to: %d", temp_outside_int); -// if (!this->takeSerialMutex()) -// return; -// this->displayAdapter->printf("outside_temp.txt=\"%d\"", temp_outside_int); -// this->sendStopBytes(); -// this->giveSerialMutex(); -// } + if (!this->takeSerialMutex()) + return; + this->displayAdapter->printf("weather_icon.pic=%d", weather_code); + this->sendStopBytes(); + this->giveSerialMutex(); +} +void ISEDisplay::updateTempOutside(float temp_outside) +{ + // TODO : use remotevar to get PM2.5 data from appdaemon and update the display + + // change temp_outside to int then display + u_int8_t temp_outside_int = (u_int8_t)temp_outside; + ESP_LOGI("ISEDisplay", "Updating temperature outside to: %d", temp_outside_int); + if (!this->takeSerialMutex()) + return; + this->displayAdapter->printf("outside_temp.txt=\"%d\"", temp_outside_int); + this->sendStopBytes(); + this->giveSerialMutex(); +} void ISEDisplay::updatePMoutside(u_int16_t pm25_outside) { ESP_LOGI("ISEDisplay", "Updating PM2.5 outside to: %d", pm25_outside); @@ -535,129 +455,32 @@ void ISEDisplay::updatePMinside(u_int16_t pm25_inside) void ISEDisplay::setPMstate(bool is_pm_on, uint8_t pm_fan_speed) { - //check pm_lock if true do nothing - this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; - if (this->pm_lock_state == true) - { - ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); - return; - } ESP_LOGI("ISEDisplay", "Setting PM state: %d, fan speed: %d", is_pm_on, pm_fan_speed); char buffer[4]; itoa(pm_fan_speed, buffer, DEC); remote_pm_fan_speed->setValue(buffer); - pm_switch->setValue(is_pm_on ? "on" : "off"); -} - -void ISEDisplay::setPMlockstate(bool is_pm_lock_on) -{ - ESP_LOGI("ISEDisplay", "Setting PM lock state: %d", is_pm_lock_on); - pm_lock->setValue(is_pm_lock_on ? "on" : "off"); -} - -void ISEDisplay::setAClockstate(bool is_ac_lock_on) -{ - ESP_LOGI("ISEDisplay", "Setting AC lock state: %d", is_ac_lock_on); - ac_lock->setValue(is_ac_lock_on ? "on" : "off"); + pm_switch->setValue(is_pm_on ? "1" : "0"); } void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature) { - ESP_LOGI("ISEDisplay", "AC state before change is: fan speed: %d, mode: %d, temperature: %d", this->ac_fan_speed, this->ac_mode, this->ac_temperature); - ESP_LOGI("ISEDisplay", "Setting AC state in memory to: = fan speed: %d, mode: %d, temperature: %d", ac_fan_speed, ac_mode, ac_temperature); + ESP_LOGI("ISEDisplay", "Setting AC state: = fan speed: %d, mode: %d, temperature: %d", ac_fan_speed, ac_mode, ac_temperature); - this->ac_fan_speed = ac_fan_speed; - this->ac_mode = ac_mode; - this->ac_temperature = ac_temperature; - //check ac_lock if true do nothing - this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; - if (this->ac_lock_state == true) - { - ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - return; + //this->climateCard->setFanSpeed(ac_fan_speed); + ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", ac_fan_speed); + //this->climateCard->setMode(ac_mode); + ESP_LOGI("ISEDisplay", "AC mode set to: %d", ac_mode); + //this->climateCard->setTemperature(ac_temperature); + ESP_LOGI("ISEDisplay", "AC temperature set to: %d", ac_temperature); + this->climateCard_daikin->setState(ac_mode, ac_fan_speed, ac_temperature); + if(ac_mode == 3){ + this->climateCard_york->setState(0, ac_fan_speed, ac_temperature); } - // check ac_temp is within bound of daikin - if (this->ac_temperature < DAIKIN_MIN_TEMP) - { - this->ac_temperature = DAIKIN_MIN_TEMP; + else{ + this->climateCard_york->setState(ac_mode, ac_fan_speed, ac_temperature); } - else if (this->ac_temperature > DAIKIN_MAX_TEMP) - { - this->ac_temperature = DAIKIN_MAX_TEMP; - } - this->time_since_last_ac_change = millis(); - this->ac_press_pending = true; - updateACState(); - updateSystemtoggle(); - updateAllStandbyToggle(); + // updateACState(); } -void ISEDisplay::sendACIRcode() -{ - uint8_t cur_ac_fan_speed = this->ac_fan_speed; - uint8_t cur_ac_mode = this->ac_mode; - uint8_t before_change_ac_mode = this->climateCard_daikin->getMode(); - uint8_t cur_ac_temperature = this->ac_temperature; - uint8_t york_temp = cur_ac_temperature; - // this->climateCard->setFanSpeed(ac_fan_speed); - ESP_LOGI("ISEDisplay", "AC fan speed set to: %d", cur_ac_fan_speed); - // this->climateCard->setMode(ac_mode); - ESP_LOGI("ISEDisplay", "AC mode before change is set to: %d", before_change_ac_mode); - ESP_LOGI("ISEDisplay", "AC mode set to: %d", cur_ac_mode); - // this->climateCard->setTemperature(ac_temperature); - ESP_LOGI("ISEDisplay", "AC temperature set to: %d", cur_ac_temperature); - // check if temp is within range of min and max for york if not set an min or max for only york - if (ac_staggered_start_call_pending == false) - { - ESP_LOGI("ISEDisplay", "AC Staggered start call pending is false"); - this->climateCard_daikin->setState(cur_ac_mode, cur_ac_fan_speed, cur_ac_temperature); - ESP_LOGI("ISEDisplay", "Daikin AC IR code sent"); - } - if (cur_ac_temperature < YORK_MIN_TEMP) - { - york_temp = YORK_MIN_TEMP; - } - else if (cur_ac_temperature > YORK_MAX_TEMP) - { - york_temp = YORK_MAX_TEMP; - } - if (cur_ac_mode == 3 && ac_staggered_start_call_pending == false) - { - ESP_LOGI("ISEDisplay", "AC Staggered start call pending is false"); - this->climateCard_york->setState(0, cur_ac_fan_speed, york_temp); - ESP_LOGI("ISEDisplay", "York AC IR code sent to off mode due to swtiching to dry on Daikin"); - } - else - { - // want to stagger start york ac when change state from off (mode 0) to on (mode 1,2,3) by 1 sec without delaying other code - if (before_change_ac_mode == 0 && ac_staggered_start_call_pending == false) - { - ESP_LOGI("ISEDisplay", "cur_ac_mode is 0 and ac_staggered_start_call_pending is false"); - this->time_since_ac_staggered_start_call = millis(); - this->ac_staggered_start_call_pending = true; - ESP_LOGI("ISEDisplay", "AC staggered start call pending set to true and call time set to current time"); - } - else - { - ESP_LOGI("ISEDisplay", "AC Staggered start call pending is true or cur_ac_mode is not 0"); - this->climateCard_york->setState(cur_ac_mode, cur_ac_fan_speed, york_temp); - ESP_LOGI("ISEDisplay", "York AC IR code sent"); - // wondering if there is a case where the ac_staggered_start_call_pending is not set to false after setState have been called - } - } - // get value of mode fanspeed and temp and print compare to store value - ESP_LOGI("ISEDisplay", "AC IR code sent"); - ESP_LOGI("ISEDisplay", "NOTE: ac_staggered_start_call_pending is %d", ac_staggered_start_call_pending); - if (ac_staggered_start_call_pending == true) - { - ESP_LOGI("ISEDisplay", "thus the york ac will not be set to current mode if ac_staggered_start_call_pending is true will be trigger after 1 sec"); - } - ESP_LOGI("ISEDisplay", "Daikin fan speed: %d, Daikin mode: %d, Daikin temperature: %d", cur_ac_fan_speed, cur_ac_mode, cur_ac_temperature); - ESP_LOGI("ISEDisplay", "York fan speed: %d, York mode: %d, York temperature: %d", cur_ac_fan_speed, cur_ac_mode, york_temp); - ESP_LOGI("ISEDisplay", "getting value of mode, fanspeed and temp from climate card"); - ESP_LOGI("ISEDisplay", "Daikin fan speed: %d, Daikin mode: %d, Daikin temperature: %d", this->climateCard_daikin->getFanSpeed(), this->climateCard_daikin->getMode(), this->climateCard_daikin->getTemperature()); - ESP_LOGI("ISEDisplay", "York fan speed: %d, York mode: %d, York temperature: %d", this->climateCard_york->getFanSpeed(), this->climateCard_york->getMode(), this->climateCard_york->getTemperature()); -} - void ISEDisplay::toggleLightGroupState() { // Get the current group state @@ -668,17 +491,6 @@ void ISEDisplay::toggleLightGroupState() { setLightLevel(i, state ? 0 : 3); } - // for loop might slow it down maybe? idk -} -void ISEDisplay::setLightGroupState(uint8_t level) -{ - // Get the current group state - ESP_LOGI("ISEDisplay", "Current light group state: %d", level); - // Toggle light - for (uint8_t i = 1; i <= 4; i++) - { - setLightLevel(i, level); - } } void ISEDisplay::toggleLightGroupStateStandby() { @@ -695,41 +507,12 @@ void ISEDisplay::toggleLightGroupStateStandby() void ISEDisplay::togglePM() { // Get the current group state - bool ispmlock = this->pm_lock_state; - if (ispmlock) - { - ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); - return; - } - else - { - bool state = strcmp(pm_switch->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Current PM state: %d", state); - // Toggle the state - pm_switch->setValue(state ? "off" : "on"); - ESP_LOGI("ISEDisplay", "New PM state: %d", state); - // updateAirPurifierState(); - } -} -void ISEDisplay::toggleACLock() -{ - // Get the current group state - bool state = strcmp(ac_lock->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Current AC lock state: %d", state); + bool state = strcmp(pm_switch->getValue(), "on") == 0; + ESP_LOGI("ISEDisplay", "Current PM state: %d", state); // Toggle the state - ac_lock->setValue(state ? "off" : "on"); - ESP_LOGI("ISEDisplay", "New AC lock state: %d", state); - // updateAirPurifierStateStandby(); -} -void ISEDisplay::togglePMLock() -{ - // Get the current group state - bool state = strcmp(pm_lock->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Current PM lock state: %d", state); - // Toggle the state - pm_lock->setValue(state ? "off" : "on"); - ESP_LOGI("ISEDisplay", "New PM lock state: %d", state); - // updateAirPurifierStateStandby(); + pm_switch->setValue(state ? "off" : "on"); + ESP_LOGI("ISEDisplay", "New PM state: %d", state); + //updateAirPurifierState(); } void ISEDisplay::togglePMStandby() { @@ -739,126 +522,63 @@ void ISEDisplay::togglePMStandby() // Toggle the state pm_switch->setValue(state ? "off" : "on"); ESP_LOGI("ISEDisplay", "New PM state: %d", state); - // updateAirPurifierStateStandby(); + //updateAirPurifierStateStandby(); } void ISEDisplay::toggleAC() { // Get the current group state - // uint8_t mode = this->climateCard_daikin->getMode(); - uint8_t mode = this->ac_mode; + uint8_t mode = this->climateCard_daikin->getMode(); + // get fan speed and temperature + uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); + uint8_t temperature = this->climateCard_daikin->getTemperature(); + ESP_LOGI("ISEDisplay", "Current AC mode: %d", mode); - ESP_LOGI("ISEDisplay", "Current user mode: %d", user_mode); - // get value of mode, fanspeed and temp and print compare to store value - ESP_LOGI("ISEDisplay", "Daikin fan speed: %d, Daikin mode: %d, Daikin temperature: %d", this->climateCard_daikin->getFanSpeed(), this->climateCard_daikin->getMode(), this->climateCard_daikin->getTemperature()); - ESP_LOGI("ISEDisplay", "York fan speed: %d, York mode: %d, York temperature: %d", this->climateCard_york->getFanSpeed(), this->climateCard_york->getMode(), this->climateCard_york->getTemperature()); // Toggle the state - if (mode != 0) + if (mode == 0) { - // update mode to new mode - mode = 0; - ESP_LOGI("ISEDisplay", "change actual AC mode to off: %d", mode); + ESP_LOGI("ISEDisplay", " User mode: %d", user_mode); + setACstate(fan_speed, user_mode, temperature); } else - { // ie mode is off - // do nothing as the state is keep in user_mode - // the mode will change to user_mode when turn on by toggleAC() - ESP_LOGI("ISEDisplay", "do nothing; user mode: %d , actual mode: %d", user_mode, mode); - mode = user_mode; + { + ESP_LOGI("ISEDisplay", "User mode BEFORE: %d", user_mode); + // update user mode to new mode + user_mode = mode; + // change actual mode to off + ESP_LOGI("ISEDisplay", "User mode AFTER: %d", user_mode); + setACstate(fan_speed, 0, temperature); } - // get fan speed and temperature - // uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); - // uint8_t temperature = this->climateCard_daikin->getTemperature(); - uint8_t fan_speed = this->ac_fan_speed; - uint8_t temperature = this->ac_temperature; - ESP_LOGI("ISEDisplay", "Current AC mode: %d", mode); - // Toggle the state - setACstate(fan_speed, mode, temperature); } void ISEDisplay::changeUserACmode() { // Get the current group state - uint8_t mode = this->ac_mode; - // uint8_t mode = this->climateCard_daikin->getMode(); + uint8_t mode = this->climateCard_daikin->getMode(); ESP_LOGI("ISEDisplay", "Current actual AC mode: %d", mode); // Toggle the state - // user mode alternate between 1, 2, and 3 + // user mode alternate between 1 and 2 ESP_LOGI("ISEDisplay", "User mode BEFORE: %d", user_mode); - // user_mode = (user_mode) % 3 + 1; //loop from 1 to 2 to 3 then back to 1 - // Cycle user_mode from 2 to 1 to 3 - switch (user_mode) - { - case 2: // If current mode is cool (2), change to fan (1) - user_mode = 1; - break; - case 1: // If current mode is fan (1), change to dry (3) - user_mode = 3; - break; - case 3: // If current mode is dry (3), change to cool (2) - default: - user_mode = 2; - break; - } + user_mode = (user_mode) % 2 + 1; ESP_LOGI("ISEDisplay", "User mode AFTER: %d", user_mode); if (mode != 0) { // update mode to new mode mode = user_mode; ESP_LOGI("ISEDisplay", "change actual AC mode to user mode: %d", mode); - setACstate(this->ac_fan_speed, mode, this->ac_temperature); } else { // ie mode is off // do nothing as the state is keep in user_mode // the mode will change to user_mode when turn on by toggleAC() - ESP_LOGI("ISEDisplay", "update just user mode display; user mode: %d , actual mode: %d", user_mode, mode); - updateuserACmode(); + ESP_LOGI("ISEDisplay", "do nothing; user mode: %d , actual mode: %d", user_mode, mode); } - - // updateuserACmode(); // call to update mode part of the display seperately -} -void ISEDisplay::changePMfanspeed() -{ - // Get the current group state - uint8_t fan_speed = this->pm_fan_speed; - uint8_t new_fan_speed = fan_speed; - // uint8_t fan_speed = this->climateCard_york->getFanSpeed(); - ESP_LOGI("ISEDisplay", "Current PM fan speed: %d", fan_speed); - // Toggle the state - // fan_speed have 3 state high mid low switch between them - switch (fan_speed) - { - case PM_FAN_SPEED_LOW: - new_fan_speed = PM_FAN_SPEED_MID; - break; - case PM_FAN_SPEED_MID: - new_fan_speed = PM_FAN_SPEED_HIGH; - break; - case PM_FAN_SPEED_HIGH: - new_fan_speed = PM_FAN_SPEED_LOW; - break; - default: - new_fan_speed = PM_FAN_SPEED_HIGH; - break; - } - ESP_LOGI("ISEDisplay", "New PM fan speed: %d", new_fan_speed); - this->pm_fan_speed = new_fan_speed; - ESP_LOGI("ISEDisplay", "Setting PM fan speed in memory to: %d", this->pm_fan_speed); - remote_pm_fan_speed->setIntValue(this->pm_fan_speed); - ESP_LOGI("ISEDisplay", "Setting PM fan speed in remote var to: %d", remote_pm_fan_speed->getValueAsInt()); - updateAirPurifierState(); + updateuserACmode(); // call to update mode part of the display seperately } void ISEDisplay::setLightLevel(uint8_t row, uint8_t level) { // Set the light level // this->outputCard->setValue(row, level); - - // only value between 1 and 4 is valid - ESP_LOGI("ISEDisplay", "Setting light level for row %d to %d", row, level); - - uint8_t primary_pin = *(light_array + 2 * (row - 1)); - uint8_t secondary_pin = *(light_array + 2 * (row - 1) + 1); - - ESP_LOGI("ISEDisplay", "Primary pin: %d, Secondary pin: %d", primary_pin, secondary_pin); + uint8_t primary_pin = *(light_array + 2*(row - 1)); + uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1); bool primary = false; bool secondary = false; @@ -868,45 +588,36 @@ void ISEDisplay::setLightLevel(uint8_t row, uint8_t level) case 0: primary = false; secondary = false; - ESP_LOGI("ISEDisplay", "Primary pin is %d, Secondary pin is %d", primary, secondary); break; case 1: primary = false; secondary = true; - ESP_LOGI("ISEDisplay", "Primary pin is %d, Secondary pin is %d", primary, secondary); break; case 2: primary = true; secondary = false; - ESP_LOGI("ISEDisplay", "Primary pin is %d, Secondary pin is %d", primary, secondary); break; case 3: primary = true; secondary = true; - ESP_LOGI("ISEDisplay", "Primary pin is %d, Secondary pin is %d", primary, secondary); break; default: - ESP_LOGE("ISEDisplay", "Invalid light level: %d", level); break; } this->outputCard->setState(primary_pin, primary); this->outputCard->setState(secondary_pin, secondary); - ESP_LOGI("ISEDisplay", "Light level set for row %d", row); } u_int8_t ISEDisplay::getLightLevel(uint8_t row) { u_int8_t lightLevel = 0; - ESP_LOGI("ISEDisplay", "Getting light level for row %d", row); - // lightLevel = this->outputCard->getValue(row); - // row can only be between 1 and 4 - uint8_t primary_pin = *(light_array + 2 * (row - 1)); - uint8_t secondary_pin = *(light_array + 2 * (row - 1) + 1); - ESP_LOGI("ISEDisplay", "Primary pin: %d, Secondary pin: %d", primary_pin, secondary_pin); + + //lightLevel = this->outputCard->getValue(row); + uint8_t primary_pin = *(light_array + 2*(row - 1)); + uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1); bool primary = this->outputCard->getState(primary_pin); bool secondary = this->outputCard->getState(secondary_pin); - ESP_LOGI("ISEDisplay", "Primary pin state: %d, Secondary pin state: %d", primary, secondary); if (primary && secondary) { lightLevel = 3; @@ -923,20 +634,19 @@ u_int8_t ISEDisplay::getLightLevel(uint8_t row) { lightLevel = 0; } - ESP_LOGI("ISEDisplay", "Light level for row %d is %d", row, lightLevel); + return lightLevel; } -// change to light with the assignment +//change to light with the assignment -lightPosition ISEDisplay::getRowCol(uint8_t pin) -{ +lightPosition ISEDisplay::getRowCol(uint8_t pin){ lightPosition position; - // uint8_t row = this->row; - // uint8_t column = this->column; - // const uint8_t *light_array = this->light_array; - // should return the row and column of the light from pin in a row by column array pointer pass from main using pointer arithmetic - for (uint8_t i = 0; i < row * column; i++) + //uint8_t row = this->row; + //uint8_t column = this->column; + //const uint8_t *light_array = this->light_array; + // should return the row and column of the light from pin in a row by column array pointer pass from main using pointer arithmetic + for (uint8_t i = 0; i < row*column; i++) { uint8_t value = *(light_array + i); if (value == pin) @@ -949,6 +659,7 @@ lightPosition ISEDisplay::getRowCol(uint8_t pin) return position; } + void ISEDisplay::updateLightGroupStatePageStandby() { // Calculate the state @@ -958,11 +669,11 @@ void ISEDisplay::updateLightGroupStatePageStandby() return; this->displayAdapter->print("s_light_toggle.pic="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON : COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF); + this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON : COMPONENT_STANDBY_LIGHT_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("s_light_toggle.pic2="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED : COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); @@ -970,115 +681,50 @@ void ISEDisplay::updateLightGroupStatePageStandby() void ISEDisplay::updateLightGroupStatePageDashboard() { // Calculate the state - bool state_master = calculateLightGroupState(); - uint8_t firstState = getLightLevel(1); - bool allMatch = true; - + bool state = calculateLightGroupState(); // Send the state to the display if (!this->takeSerialMutex()) return; - this->displayAdapter->print("light_m_sw.pic="); - this->displayAdapter->print(state_master ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF); + this->displayAdapter->print("light_master.pic="); + this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON : COMPONENT_LIGHT_MASTER_OFF); this->sendStopBytes(); - this->displayAdapter->print("light_m_sw.pic2="); - this->displayAdapter->print(state_master ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED); + this->displayAdapter->print("light_master.pic2="); + this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON_PRESSED : COMPONENT_LIGHT_MASTER_OFF_PRESSED); this->sendStopBytes(); - // this->displayAdapter->print("light_m_sw.pic="); - // this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF); - // this->sendStopBytes(); - - // this->displayAdapter->print("light_m_sw.pic2="); - // this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED : COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED); - // this->sendStopBytes(); - for (uint8_t i = 1; i <= 4; i++) { u_int8_t state = getLightLevel(i); - - if (i > 1 && state != firstState) - { - allMatch = false; - } - switch (state) { case 0: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_0); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_OFF_PRESSED); + this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_0); this->sendStopBytes(); break; case 1: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_1); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); + this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_1); this->sendStopBytes(); break; case 2: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_2); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); + this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_2); this->sendStopBytes(); break; case 3: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_3); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON); - this->sendStopBytes(); - - this->displayAdapter->print("light_row"); - this->displayAdapter->print(i); - this->displayAdapter->print("_sw.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED); + this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_3); this->sendStopBytes(); break; default: @@ -1086,57 +732,8 @@ void ISEDisplay::updateLightGroupStatePageDashboard() } } - if (allMatch) - { - // All states match, change the master light level which is the firststate - // use switch case - switch (firstState) - { - case 0: - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_0); - this->sendStopBytes(); - break; - case 1: - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_1); - this->sendStopBytes(); - break; - case 2: - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_2); - this->sendStopBytes(); - break; - case 3: - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_3); - this->sendStopBytes(); - break; - default: - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_D); - this->sendStopBytes(); - break; - } - } - else - { - this->displayAdapter->print("master_light.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_D); - this->sendStopBytes(); - } - this->giveSerialMutex(); } -void ISEDisplay::updateLightSwitch() -{ - // DEPRECATED - // Calculate the state - // not in use due to worse performance - - // check state and set for each individual light row - // if state is 0 set to off and other(1,2,3) to on -} bool ISEDisplay::calculateLightGroupState() { // Check if all lights are on @@ -1153,107 +750,7 @@ bool ISEDisplay::calculateLightGroupState() } return lightOn; } -bool ISEDisplay::calculateAllState() -{ - bool lightState = calculateLightGroupState(); - bool pmState = strcmp(pm_switch->getValue(), "on") == 0; - bool acState = false; - if (ac_mode != 0) - { - acState = true; - } - return lightState || pmState || acState; -} -void ISEDisplay::toggleSystem() -{ - // toggleLightGroupState(); - // // check for ac lock and pm lock, if lock is on do nothing - // if (this->ac_lock_state == true) - // { - // ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); - // } - // else - // { - // toggleAC(); - // } - // if (this->pm_lock_state == true) - // { - // ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); - // } - // else - // { - // togglePM(); - // } - bool state = calculateAllState(); - if (state) - { - //if AC mode is not zero, toggleAC() - if(ac_mode != 0) { - toggleAC(); - } - setLightGroupState(0); - setPMstate(false, pm_fan_speed); - } - else - { - if(ac_mode == 0) { - toggleAC(); - } - setLightGroupState(3); - setPMstate(true, pm_fan_speed); - } - - - - - - -} -void ISEDisplay::allToggleStandby() -{ - bool lightState = calculateLightGroupState(); - bool pmState = strcmp(pm_switch->getValue(), "on") == 0; - if (ac_mode != 0) - { - setACstate(0, ac_fan_speed, ac_temperature); - } - else{ - setACstate(2, ac_fan_speed, ac_temperature); - } - if (lightState) - { - setLightGroupState(0); - } - else - { - setLightGroupState(3); - } - if (pmState) - { - setPMstate(false, pm_fan_speed); - } - else - { - setPMstate(true, pm_fan_speed); - } - -} -void ISEDisplay::updateAllStandbyToggle() -{ - bool state = calculateAllState(); - if (!this->takeSerialMutex()) - return; - this->displayAdapter->print("s_open_all.pic="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON : COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("s_open_all.pic2="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF_PRESSED); - this->sendStopBytes(); - - this->giveSerialMutex(); -} void ISEDisplay::toggleLightIndividual(uint8_t row) { // Get the current state @@ -1269,36 +766,48 @@ void ISEDisplay::toggleLightIndividual(uint8_t row) // Set the state setLightLevel(row, state); } -void ISEDisplay::updateSystemtoggle() +void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel) { - bool state = calculateAllState(); - if (!this->takeSerialMutex()) - return; - this->displayAdapter->print("system_toggle.pic="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_ON : COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_OFF); - this->sendStopBytes(); + // Get the current state + uint8_t state = 0; - this->displayAdapter->print("system_toggle.pic2="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_ON_PRESSED : COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_OFF_PRESSED); - this->sendStopBytes(); - - this->giveSerialMutex(); + if (lightLevel < 10) + { + state = 0; + } + else if (lightLevel < 33) + { + state = 1; + } + else if (lightLevel <= 66) + { + state = 2; + } + else if (lightLevel > 66) + { + state = 3; + } + else + { + state = 0; + } + // Set the state + setLightLevel(row, state); } void ISEDisplay::updateAirPurifierStateStandby() { // Get the state bool state = strcmp(pm_switch->getValue(), "on") == 0; - this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; // Send the state to the display if (!this->takeSerialMutex()) return; this->displayAdapter->print("s_pm_toggle.pic="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_PM_TOGGLE_ON : COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PM_PIC_ON : COMPONENT_STANDBY_PM_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("s_pm_toggle.pic2="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_PM_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PM_PIC_ON_PRESSED : COMPONENT_STANDBY_PM_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); @@ -1306,206 +815,69 @@ void ISEDisplay::updateAirPurifierStateStandby() void ISEDisplay::updateAirPurifierState() { - // check for page - if (currentPage == PAGE_DASHBOARD) - { + //check for page + if(currentPage == PAGE_DASHBOARD){ ESP_LOGI("ISEDisplay", "Updating dashboard"); // Get the state bool state = strcmp(pm_switch->getValue(), "on") == 0; - this->pm_lock_state = strcmp(pm_lock->getValue(), "on") == 0; ESP_LOGI("ISEDisplay", "Updating air purifier state to: %d", state); - pm_fan_speed = this->pm_fan_speed; - ESP_LOGI("ISEDisplay", "Updating air purifier fan speed to: %d", pm_fan_speed); + pm_fan_speed = (int) atof(remote_pm_fan_speed->getValue()); // Send the state to the display if (!this->takeSerialMutex()) - return; + return; this->displayAdapter->print("pm_sw.pic="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON : COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF); + this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON : COMPONENT_PM_TOGGLE_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("pm_sw.pic2="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON_PRESSED : COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED); this->sendStopBytes(); - this->displayAdapter->print("pm_lock.pic="); - this->displayAdapter->print(this->pm_lock_state ? COMPONENT_DASHBOARD_PIC_LOCK : COMPONENT_DASHBOARD_PIC_UNLOCK); + this->displayAdapter->print("pm_speed.val="); + this->displayAdapter->print(pm_fan_speed); + // this->displayAdapter->print("\""); this->sendStopBytes(); - this->displayAdapter->print("pm_mode.pic="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON : COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF); + this->displayAdapter->print("pm_speed.pco="); + this->displayAdapter->print(state ? 34486 : 33841); this->sendStopBytes(); - this->displayAdapter->print("pm_mode.pic2="); - this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON_PRESSED : COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF_PRESSED); - this->sendStopBytes(); - - switch (pm_fan_speed) - { - case PM_FAN_SPEED_LOW: - if (state) - { // state is on - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON_PRESSED); - this->sendStopBytes(); - } - else - { // state is off - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF_PRESSED); - this->sendStopBytes(); - } - break; - case PM_FAN_SPEED_MID: - if (state) - { // state is on - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON_PRESSED); - this->sendStopBytes(); - } - else - { // state is off - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF_PRESSED); - this->sendStopBytes(); - } - break; - case PM_FAN_SPEED_HIGH: - if (state) - { // state is on - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON_PRESSED); - this->sendStopBytes(); - } - else - { // state is off - this->displayAdapter->print("pm_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF); - this->sendStopBytes(); - - this->displayAdapter->print("pm_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF_PRESSED); - this->sendStopBytes(); - } - break; - default: - break; - } - - // this->displayAdapter->print("pm_speed.val="); - // this->displayAdapter->print(pm_fan_speed); - // // this->displayAdapter->print("\""); - // this->sendStopBytes(); - - // this->displayAdapter->print("pm_speed.pco="); - // this->displayAdapter->print(state ? 34486 : 33841); - // this->sendStopBytes(); - this->giveSerialMutex(); } - - else if (currentPage == PAGE_STANDBY) - { + + else if(currentPage == PAGE_STANDBY){ ESP_LOGI("ISEDisplay", "Updating standby"); - updateAirPurifierStateStandby(); + updateAirPurifierStateStandby(); } } void ISEDisplay::handleACChange(uint8_t mode, uint8_t fan_speed, uint8_t temperature) { ESP_LOGI("ISEDisplay", "AC state changed: mode: %d, fan speed: %d, temperature: %d", mode, fan_speed, temperature); updateACState(); - updateSystemtoggle(); - updateAllStandbyToggle(); } void ISEDisplay::updateuserACmode() { - // uint8_t mode = this->climateCard_daikin->getMode(); - uint8_t mode = this->ac_mode; if (!this->takeSerialMutex()) return; ESP_LOGI("ISEDisplay", "updating display user AC mode to: %d", user_mode); switch (user_mode) { case 1: - if (mode == 0) - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_mode.pic="); + this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_mode.pic2="); + this->displayAdapter->print(COMPONENT_AC_MODE_COOL_PIC_PRESSED); + this->sendStopBytes(); break; case 2: - if (mode == 0) - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_ON_PRESSED); - this->sendStopBytes(); - } - break; - - case 3: - if (mode == 0) - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_mode.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_mode.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_mode.pic="); + this->displayAdapter->print(COMPONENT_AC_MODE_FAN_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_mode.pic2="); + this->displayAdapter->print(COMPONENT_AC_MODE_FAN_PIC_PRESSED); + this->sendStopBytes(); break; default: break; @@ -1514,96 +886,43 @@ void ISEDisplay::updateuserACmode() } void ISEDisplay::updateACfanSpeed() { - // uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); - // uint8_t mode = this->climateCard_daikin->getMode(); - uint8_t fan_speed = this->ac_fan_speed; - uint8_t mode = this->ac_mode; - this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; - + uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); ESP_LOGI("ISEDisplay", "updating display AC fan speed to: %d", fan_speed); if (!this->takeSerialMutex()) return; switch (fan_speed) { case 0: - if (mode == 0) - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_speed.pic="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_AUTO_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_speed.pic2="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_AUTO_PIC_PRESSED); + this->sendStopBytes(); break; case 1: - if (mode == 0) - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_speed.pic="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_HIGH_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_speed.pic2="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_HIGH_PIC_PRESSED); + this->sendStopBytes(); break; case 2: - if (mode == 0) - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_speed.pic="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_MID_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_speed.pic2="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_MID_PIC_PRESSED); + this->sendStopBytes(); break; case 3: - if (mode == 0) - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF_PRESSED); - this->sendStopBytes(); - } - else - { - this->displayAdapter->print("ac_speed.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON); - this->sendStopBytes(); - this->displayAdapter->print("ac_speed.pic2="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON_PRESSED); - this->sendStopBytes(); - } + this->displayAdapter->print("ac_speed.pic="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_LOW_PIC); + this->sendStopBytes(); + this->displayAdapter->print("ac_speed.pic2="); + this->displayAdapter->print(COMPONENT_AC_FAN_MODE_LOW_PIC_PRESSED); + this->sendStopBytes(); break; default: break; @@ -1615,14 +934,9 @@ void ISEDisplay::updateACState() // TODOlater : The cognitive complexity here is so high, maybe break up the method a bit? // Get the state - // uint8_t mode = this->climateCard_daikin->getMode(); - // uint8_t temperature = this->climateCard_daikin->getTemperature(); - uint8_t mode = this->ac_mode; - uint8_t temperature = this->ac_temperature; - this->ac_lock_state = strcmp(ac_lock->getValue(), "on") == 0; - - if (currentPage != 1) - { + uint8_t mode = this->climateCard_daikin->getMode(); + uint8_t temperature = this->climateCard_daikin->getTemperature(); + if(currentPage != 1){ if (!this->takeSerialMutex()) return; @@ -1630,41 +944,40 @@ void ISEDisplay::updateACState() if (mode == 0) { this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(COMPONENT_COLOR_INACTIVE_GREY); + this->displayAdapter->print(33841); this->sendStopBytes(); - this->displayAdapter->print("c_degree.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_DEGREE_C_OFF); + this->displayAdapter->print("ac_temp.pic="); + this->displayAdapter->print(COMPONENT_AC_STATUS_OFF); this->sendStopBytes(); } else { this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(COMPONENT_COLOR_ACTIVE_BLUE); + this->displayAdapter->print(34486); this->sendStopBytes(); - this->displayAdapter->print("c_degree.pic="); - this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_DEGREE_C_ON); + this->displayAdapter->print("ac_temp.pic="); + this->displayAdapter->print(COMPONENT_AC_STATUS_ON); this->sendStopBytes(); + + user_mode = mode; } this->displayAdapter->print("ac_sw.pic="); - this->displayAdapter->print(mode != 0 ? COMPONENT_DASHBOARD_PIC_AC_TOGGLE_ON : COMPONENT_DASHBOARD_PIC_AC_TOGGLE_OFF); + this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON : COMPONENT_AC_TOGGLE_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("ac_sw.pic2="); - this->displayAdapter->print(mode != 0 ? COMPONENT_DASHBOARD_PIC_AC_TOGGLE_ON_PRESSED : COMPONENT_DASHBOARD_PIC_AC_TOGGLE_OFF_PRESSED); - this->sendStopBytes(); - this->displayAdapter->print("ac_lock.pic="); - this->displayAdapter->print(this->ac_lock_state ? COMPONENT_DASHBOARD_PIC_LOCK : COMPONENT_DASHBOARD_PIC_UNLOCK); + this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON_PRESSED : COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); updateuserACmode(); updateACfanSpeed(); - + if (!this->takeSerialMutex()) return; - + this->displayAdapter->print("ac_temp.val="); this->displayAdapter->print(temperature); // this->displayAdapter->print("\""); @@ -1677,15 +990,16 @@ void ISEDisplay::updateACState() return; this->displayAdapter->print("s_ac_toggle.pic="); - this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_PIC_AC_TOGGLE_ON : COMPONENT_STANDBY_PIC_AC_TOGGLE_OFF); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON : COMPONENT_STANDBY_AC_PIC_OFF); this->sendStopBytes(); this->displayAdapter->print("s_ac_toggle.pic2="); - this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_PIC_AC_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_AC_TOGGLE_OFF_PRESSED); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON_PRESSED : COMPONENT_STANDBY_AC_PIC_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); } + ESP_LOGI("ISEDisplay", "display AC state updated"); } diff --git a/src/ise_display.hpp b/src/ise_display.hpp index 9be7e1b..ca985a5 100644 --- a/src/ise_display.hpp +++ b/src/ise_display.hpp @@ -2,7 +2,6 @@ #include "ise_display_definitions.hpp" #include -#include #include #include #include @@ -25,13 +24,11 @@ struct lightPosition { class ISEDisplay : public ESPMegaDisplay { public: ISEDisplay(HardwareSerial* adapter, const uint8_t *light_array, uint8_t row, uint8_t column); - void begin(DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard_daikin, ClimateCard* climateCard_york, RemoteVariable* pm_switch, RemoteVariable* pm_fan_speed, RemoteVariable* ac_lock, RemoteVariable* pm_lock, ESPMegaIoT *iot); + void begin(DigitalInputCard* inputCard, DigitalOutputCard* outputCard, ClimateCard* climateCard_daikin, ClimateCard* climateCard_york, RemoteVariable* pm_switch, RemoteVariable* pm_fan_speed); void updateLightGroupStatePageDashboard(); void updateLightGroupStatePageStandby(); void updateAirPurifierState(); void updateAirPurifierStateStandby(); - void updateSystemtoggle(); - void updateAllStandbyToggle(); void updateDateTimeText(rtctime_t time); void updateWeather(char *weather_string); void updateTempOutside(float temp_outside); @@ -57,7 +54,6 @@ class ISEDisplay : public ESPMegaDisplay { DigitalOutputCard *outputCard; ClimateCard *climateCard_daikin; ClimateCard *climateCard_york; - ESPMegaIoT *iot; const uint8_t *light_array; uint8_t row; @@ -65,20 +61,12 @@ class ISEDisplay : public ESPMegaDisplay { RemoteVariable *pm_switch; RemoteVariable *remote_pm_fan_speed; - RemoteVariable *ac_lock; - RemoteVariable *pm_lock; uint8_t outputCallbackHandle; uint8_t climateCallbackHandle; - uint32_t time_since_last_ac_change; - uint32_t time_since_ac_staggered_start_call; - bool ac_staggered_start_call_pending; uint8_t user_mode; - uint8_t ac_lock_state; - uint8_t pm_lock_state; uint8_t ac_mode; uint8_t ac_fan_speed; uint8_t ac_temperature; - bool ac_press_pending; uint8_t pm_fan_speed; uint8_t time_since_last_screen_update; u_int8_t lightLevelRow1; @@ -86,28 +74,18 @@ class ISEDisplay : public ESPMegaDisplay { u_int8_t lightLevelRow3; u_int8_t lightLevelRow4; - + void updateuserACmode(); void updateACfanSpeed(); - void updateLightSwitch(); bool calculateLightGroupState(); - bool calculateAllState(); - void toggleSystem(); - void sendACIRcode(); - void setPMlockstate(bool is_pm_lock_on); - void setAClockstate(bool is_ac_lock_on); - void toggleACLock(); - void togglePMLock(); - void allToggleStandby(); void toggleLightGroupState(); void toggleLightGroupStateStandby(); void toggleLightIndividual(uint8_t row); + void toggleSliderLight(uint8_t row,uint8_t lightLevel); void togglePM(); void togglePMStandby(); void toggleAC(); - void setLightGroupState(uint8_t level); void toggleACStandby(); void changeUserACmode(); - void changePMfanspeed(); }; diff --git a/src/ise_display_definitions.hpp b/src/ise_display_definitions.hpp index 19a849b..216181a 100644 --- a/src/ise_display_definitions.hpp +++ b/src/ise_display_definitions.hpp @@ -1,6 +1,13 @@ #pragma once //start definition +#define CT_RMS_VOLTAGE 220.0 +#define CT_PIN_LIGHT_PHASE1 0 +#define CT_PIN_LIGHT_PHASE2 1 +#define CT_PIN_SOCKET 2 +#define CT_PIN_AC_PHASE1 3 +#define CT_PIN_AC_PHASE2 4 +#define CT_PIN_AC_PHASE3 5 /* tentetive pin mapping @@ -23,13 +30,6 @@ change light assignment 8: row 4 column 2 */ -#define DAIKIN_MAX_TEMP 32 -#define DAIKIN_MIN_TEMP 16 - -#define YORK_MAX_TEMP 30 -#define YORK_MIN_TEMP 18 - - #define LIGHT_ROW1_COLUMN1 10 #define LIGHT_ROW1_COLUMN2 11 #define LIGHT_ROW2_COLUMN1 9 @@ -66,10 +66,6 @@ lights have 4 states #define MOTION_FRONT 8 #define MOTION_REAR 9 -//PM fanspeed setting -#define PM_FAN_SPEED_LOW 1 -#define PM_FAN_SPEED_MID 5 -#define PM_FAN_SPEED_HIGH 9 // #define DISPLAY_TIMEOUT 5*60*1000 // 5 minutes @@ -83,463 +79,178 @@ lights have 4 states #define PAGE_STANDBY 1 #define PAGE_DASHBOARD 2 -//gmov logo size -#define COMPONENT_LOGO_500X500 0 //original size -#define COMPONENT_LOGO_260X260 1 //use for boot page loading -#define COMPONENT_LOGO_140X140 2 //use for standby page logo -#define COMPONENT_LOGO_62X62 3 //use for dashboard page top left logo - -//font -#define COMPONENT_FONT_K2D_SB_24 0 //use for date -#define COMPONENT_FONT_BAIJ_B_32 1 //use for PM -#define COMPONENT_FONT_BAIJ_B_48 2 //use for time -#define COMPONENT_FONT_BAIJ_SB_80 3 //use for AC temperature -#define COMPONENT_FONT_BAIJ_B_40 4 //use for PM - -//color (PCO) -#define COMPONENT_COLOR_ACTIVE_BLUE 7775 -#define COMPONENT_COLOR_INACTIVE_GREY 44405 -#define COMPONENT_COLOR_WHITE 65535 -#define COMPONENT_COLOR_BLACK 0 - - -//-------------BOOT PAGE---------------- -//logo gmov boot -#define COMPONENT_OBJ_BOOT_LOGO 1 - -//boot background -#define COMPONENT_BOOT_BACKGROUND_PIC 0 -#define COMPONENT_BOOT_BACKGROUND_PIC_REFERENCE 1 - -//-------------STANDBY PAGE---------------- -//standby page object id and object name -#define COMPONENT_OBJ_STANDBY_LOGO 1 //logo -#define COMPONENT_OBJ_STANDBY_BTN_OPEN_ALL_TOGGLE 2 //s_open_all -#define COMPONENT_OBJ_STANDBY_BTN_LIGHT_TOGGLE 3 //s_light_toggle -#define COMPONENT_OBJ_STANDBY_BTN_AC_TOGGLE 4 //s_ac_toggle -#define COMPONENT_OBJ_STANDBY_BTN_PM_TOGGLE 5 //s_pm_toggle -#define COMPONENT_OBJ_STANDBY_TXT_TIME 6 //time -#define COMPONENT_OBJ_STANDBY_TXT_DATE 7 //date -#define COMPONENT_OBJ_STANDBY_TIMER_IDLE 8 //idle_timer -#define COMPONENT_OBJ_STANDBY_TXT_PM_OUTSIDE 9 //pm_out -#define COMPONENT_OBJ_STANDBY_TXT_PM_INSIDE 10 //pm_in - -//---------standby page picture id and picture name------------ - -//Standby background -#define COMPONENT_STANDBY_PIC_BACKGROUND 2 -#define COMPONENT_STANDBY_PIC_BACKGROUND_REFERENCE 3 - -//Standby open all toggle -#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_OFF 4 -#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_OFF_PRESSED 5 -#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON 6 -#define COMPONENT_STANDBY_PIC_OPEN_ALL_TOGGLE_ON_PRESSED 7 - -//Standby adv setting toggle -#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF 88 -#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_OFF_PRESSED 89 -#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON 90 -#define COMPONENT_STANDBY_PIC_ADV_SETTING_TOGGLE_ON_PRESSED 91 - -//Standby light toggle -#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF 8 -#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF_PRESSED 9 -#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON 10 -#define COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON_PRESSED 11 - -//Standby AC toggle -#define COMPONENT_STANDBY_PIC_AC_TOGGLE_OFF 12 -#define COMPONENT_STANDBY_PIC_AC_TOGGLE_OFF_PRESSED 13 -#define COMPONENT_STANDBY_PIC_AC_TOGGLE_ON 14 -#define COMPONENT_STANDBY_PIC_AC_TOGGLE_ON_PRESSED 15 - -//Standby PM toggle -#define COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF 16 -#define COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF_PRESSED 17 -#define COMPONENT_STANDBY_PIC_PM_TOGGLE_ON 18 -#define COMPONENT_STANDBY_PIC_PM_TOGGLE_ON_PRESSED 19 - -//-------------DASHBOARD PAGE---------------- -//dashboard page object id and object name - -//AC -#define COMPONENT_OBJ_DASHBOARD_NUM_AC_TEMP 1 //ac_temp -#define COMPONENT_OBJ_DASHBOARD_BTN_AC_TOGGLE 2 //ac_sw -#define COMPONENT_OBJ_DASHBOARD_BTN_AC_MODE 3 //ac_mode -#define COMPONENT_OBJ_DASHBOARD_BTN_AC_FAN_SPEED 4 //ac_speed -#define COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_MINUS 5 //ac_minus -#define COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_PLUS 6 //ac_plus - -//PM -#define COMPONENT_OBJ_DASHBOARD_BTN_PM_TOGGLE 7 //pm_sw -#define COMPONENT_OBJ_DASHBOARD_TXT_PM_INSIDE 8 //pm_in -#define COMPONENT_OBJ_DASHBOARD_TXT_PM_OUTSIDE 9 //pm_out - -//DECAPRICATED -#define DONTUSE_COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_MASTER 10 //DONT USE THIS D_light_master - -//Light Pic Holder -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW1 11 //light_row1 -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW2 12 //light_row2 -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW3 13 //light_row3 -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_LIGHT_ROW4 14 //light_row4 - -//Light Button -#define COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW1 15 //light_row1_sw -#define COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW2 16 //light_row2_sw -#define COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW3 17 //light_row3_sw -#define COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW4 18 //light_row4_sw - -//Timer -#define COMPONENT_OBJ_DASHBOARD_TIMER_TEN_SEC 19 //time_10sec -#define COMPONENT_OBJ_DASHBOARD_VAL_TIME_PAST 20 //time_past -#define COMPONENT_OBJ_DASHBOARD_TIMER_INACTIVE_CHECK 21 //inactive_check - -//System toggle -#define COMPONENT_OBJ_DASHBOARD_BTN_SYSTEM_TOGGLE 22 //system_toggle - -//PM Button -#define COMPONENT_OBJ_DASHBOARD_BTN_PM_SPEED 23 //pm_speed -#define COMPONENT_OBJ_DASHBOARD_BTN_PM_MODE 24 //pm_mode - -//Light Master Pic Holder -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_MASTER_LIGHT 25 //master_light - -//Logo -#define COMPONENT_OBJ_DASHBOARD_LOGO 26 //small_ise_logo - -//Lock Pic Holder -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_PM_LOCK 27 //pm_lock -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_AC_LOCK 28 //ac_lock - -//Light Master Button -#define COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_MASTER 29 //light_m_sw - -//Light Master Hotspot -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV1 30 //light_m_lv1 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV2 31 //light_m_lv2 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV3 32 //light_m_lv3 - -//Light Row1 Hotspot -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV1 33 //light_row1_lv1 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV2 34 //light_row1_lv2 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV3 35 //light_row1_lv3 - -//Light Row2 Hotspot -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV1 36 //light_row2_lv1 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV2 37 //light_row2_lv2 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV3 38 //light_row2_lv3 - -//Light Row3 Hotspot -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV1 39 //light_row3_lv1 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV2 40 //light_row3_lv2 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV3 41 //light_row3_lv3 - -//Light Row4 Hotspot -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV1 42 //light_row4_lv1 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV2 43 //light_row4_lv2 -#define COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV3 44 //light_row4_lv3 - -//Degree Pic Holder -#define COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_C_DEGREE 45 //c_degree - -//-----------------dashboard page picture id and picture name---------------- - -//Dashboard Background -#define COMPONENT_DASHBOARD_PIC_BACKGROUND_WITH_C 20 -#define COMPONENT_DASHBOARD_PIC_BACKGROUND 21 //use this -#define COMPONENT_DASHBOARD_PIC_BACKGROUND_REFERENCE 22 - -//System Toggle Button -#define COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_OFF 23 -#define COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_OFF_PRESSED 24 -#define COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_ON 25 -#define COMPONENT_DASHBOARD_PIC_SYSTEM_TOGGLE_ON_PRESSED 26 - -//AC Temperature Minus -#define COMPONENT_DASHBOARD_PIC_AC_TEMP_MINUS 27 -#define COMPONENT_DASHBOARD_PIC_AC_TEMP_MINUS_PRESSED 28 - -//AC Temperature Plus -#define COMPONENT_DASHBOARD_PIC_AC_TEMP_PLUS 29 -#define COMPONENT_DASHBOARD_PIC_AC_TEMP_PLUS_PRESSED 30 - -//AC Mode Cool -#define COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_OFF 31 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_OFF_PRESSED 32 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_ON 33 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_COOL_ON_PRESSED 34 - -//AC Mode Dry -#define COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_OFF 35 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_OFF_PRESSED 36 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_ON 37 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_DRY_ON_PRESSED 38 - -//AC Mode Fan -#define COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF 39 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_OFF_PRESSED 40 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON 41 -#define COMPONENT_DASHBOARD_PIC_AC_MODE_FAN_ON_PRESSED 42 - -//AC Fan Speed Auto -#define COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_OFF 43 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_OFF_PRESSED 44 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_ON 45 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_AUTO_ON_PRESSED 46 - -//AC Fan Speed High -#define COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF 47 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_OFF_PRESSED 48 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON 49 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_HIGH_ON_PRESSED 50 - -//AC Fan Speed Mid -#define COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF 51 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_MID_OFF_PRESSED 52 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON 53 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_MID_ON_PRESSED 54 - -//AC Fan Speed Low -#define COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF 55 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_OFF_PRESSED 56 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON 57 -#define COMPONENT_DASHBOARD_PIC_AC_FAN_LOW_ON_PRESSED 58 - -//AC Toggle Button -#define COMPONENT_DASHBOARD_PIC_AC_TOGGLE_OFF 59 -#define COMPONENT_DASHBOARD_PIC_AC_TOGGLE_OFF_PRESSED 60 -#define COMPONENT_DASHBOARD_PIC_AC_TOGGLE_ON 61 -#define COMPONENT_DASHBOARD_PIC_AC_TOGGLE_ON_PRESSED 62 - -//PM Toggle Button -#define COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF 63 -#define COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF_PRESSED 64 -#define COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON 65 -#define COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON_PRESSED 66 - -//Light Switch Button -#define COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_OFF 67 -#define COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_OFF_PRESSED 68 -#define COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON 69 -#define COMPONENT_DASHBOARD_PIC_LIGHT_SWITCH_ON_PRESSED 70 - -//Light Row Level -#define COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_0 71 -#define COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_1 72 -#define COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_2 73 -#define COMPONENT_DASHBOARD_PIC_LIGHT_ROW_LEVEL_3 74 - -//Light Master Switch Button -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF 75 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_OFF_PRESSED 76 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON 77 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_ON_PRESSED 78 - -//Light Master Level -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_D 79 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_0 80 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_1 81 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_2 82 -#define COMPONENT_DASHBOARD_PIC_LIGHT_MASTER_LEVEL_3 83 - -//Lock Pic -#define COMPONENT_DASHBOARD_PIC_LOCK 84 -#define COMPONENT_DASHBOARD_PIC_UNLOCK 85 - -//Degree Pic -#define COMPONENT_DASHBOARD_PIC_DEGREE_C_OFF 86 -#define COMPONENT_DASHBOARD_PIC_DEGREE_C_ON 87 - - - - - - - - - - - - - - - -//-----------------DECAPRICATED---------------- - //boot page //logo gmov boot -#define OLD_COMP_LOGO_BOOT 1 -#define OLD_COMP_LOGO_BOOT_VID 1 +#define COMPONENT_LOGO_BOOT 1 +#define COMPONENT_LOGO_BOOT_VID 1 //boot background -#define OLD_COMP_BACKGROUND_BOOT_PIC 43 +#define COMPONENT_BACKGROUND_BOOT_PIC 43 //standby page object id -#define OLD_COMP_LOGO_STANDBY 1 -#define OLD_COMP_LOGO_STANDBY_VID 2 +#define COMPONENT_LOGO_STANDBY 1 +#define COMPONENT_LOGO_STANDBY_VID 2 -#define OLD_COMP_STANDBY_OPEN_ALL_TOGGLE 2 -#define OLD_COMP_STANDBY_LIGHT_TOGGLE 3 -#define OLD_COMP_STANDBY_AC_TOGGLE 4 -#define OLD_COMP_STANDBY_PM_TOGGLE 5 +#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 OLD_COMP_STANDBY_TIME_TXT 6 -#define OLD_COMP_STANDBY_DATE_TXT 7 -#define OLD_COMP_STANDBY_OUTSIDE_TEMP_TXT 8 +#define COMPONENT_STANDBY_TIME_TXT 6 +#define COMPONENT_STANDBY_DATE_TXT 7 +#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8 -#define OLD_COMP_STANDBY_TIMER 9 -#define OLD_COMP_STANDBY_WEATHER_ICON 10 +#define COMPONENT_STANDBY_TIMER 9 +#define COMPONENT_STANDBY_WEATHER_ICON 10 //standby page picture id -#define OLD_COMP_BACKGROUND_PIC 44 -#define OLD_COMP_BACKGROUND_REFERENCE_PIC 45 +#define COMPONENT_BACKGROUND_PIC 44 +#define COMPONENT_BACKGROUND_REFERENCE_PIC 45 -#define OLD_COMP_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF 46 -#define OLD_COMP_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF_PRESSED 47 -#define OLD_COMP_STANDBY_OPEN_ALL_TOGGLE_PIC_ON 48 -#define OLD_COMP_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49 +#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 OLD_COMP_STANDBY_AC_PIC_OFF 50 -#define OLD_COMP_STANDBY_AC_PIC_OFF_PRESSED 51 -#define OLD_COMP_STANDBY_AC_PIC_ON 52 -#define OLD_COMP_STANDBY_AC_PIC_ON_PRESSED 53 +#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 OLD_COMP_STANDBY_LIGHT_PIC_OFF 54 -#define OLD_COMP_STANDBY_LIGHT_PIC_OFF_PRESSED 55 -#define OLD_COMP_STANDBY_LIGHT_PIC_ON 56 -#define OLD_COMP_STANDBY_LIGHT_PIC_ON_PRESSED 57 +#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 OLD_COMP_STANDBY_PM_PIC_OFF 58 -#define OLD_COMP_STANDBY_PM_PIC_OFF_PRESSED 59 -#define OLD_COMP_STANDBY_PM_PIC_ON 60 -#define OLD_COMP_STANDBY_PM_PIC_ON_PRESSED 61 +#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 OLD_COMP_REFERENCE_BACKGROUND_PIC 62 +#define COMPONENT_REFERENCE_BACKGROUND_PIC 62 //dashboard page //dashboard page object id -#define OLD_COMP_AC_TOGGLE_BUTTON 3 -#define OLD_COMP_AC_MODE 4 -#define OLD_COMP_AC_FAN_SPEED 5 -#define OLD_COMP_AC_TEMP_DOWN_BUTTON 6 -#define OLD_COMP_AC_TEMP_UP_BUTTON 7 +#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 OLD_COMP_PM_TOGGLE_BUTTON 8 -#define OLD_COMP_PM_FAN_SPEED_DECREASE 9 -#define OLD_COMP_PM_FAN_SPEED_INCREASE 10 +#define COMPONENT_PM_TOGGLE_BUTTON 8 +#define COMPONENT_PM_FAN_SPEED_DECREASE 9 +#define COMPONENT_PM_FAN_SPEED_INCREASE 10 -#define OLD_COMP_PM_INSIDE_TXT 11 -#define OLD_COMP_PM_OUTSIDE_TXT 12 +#define COMPONENT_PM_INSIDE_TXT 11 +#define COMPONENT_PM_OUTSIDE_TXT 12 -#define OLD_COMP_LIGHT_MASTER_BUTTON 13 -#define OLD_COMP_LIGHT_ROW1_PIC_PLACEHOLDER 14 -#define OLD_COMP_LIGHT_ROW2_PIC_PLACEHOLDER 15 -#define OLD_COMP_LIGHT_ROW3_PIC_PLACEHOLDER 16 -#define OLD_COMP_LIGHT_ROW4_PIC_PLACEHOLDER 17 +#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 OLD_COMP_LIGHT_MASTER_LEVEL1_TOUCHPOINT 18 -#define OLD_COMP_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19 -#define OLD_COMP_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20 +#define COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT 18 +#define COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19 +#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20 -#define OLD_COMP_DASHBOARD_TIME_TXT 21 -#define OLD_COMP_DASHBOARD_DATE_TXT 22 -#define OLD_COMP_DASHBOARD_OUTSIDE_TEMP_TXT 23 +#define COMPONENT_DASHBOARD_TIME_TXT 21 +#define COMPONENT_DASHBOARD_DATE_TXT 22 +#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 23 -#define OLD_COMP_LIGHT_ROW1_SLIDER 24 -#define OLD_COMP_LIGHT_ROW2_SLIDER 25 -#define OLD_COMP_LIGHT_ROW3_SLIDER 26 -#define OLD_COMP_LIGHT_ROW4_SLIDER 27 +#define COMPONENT_LIGHT_ROW1_SLIDER 24 +#define COMPONENT_LIGHT_ROW2_SLIDER 25 +#define COMPONENT_LIGHT_ROW3_SLIDER 26 +#define COMPONENT_LIGHT_ROW4_SLIDER 27 -#define OLD_COMP_LIGHT_ROW1_SWITCH 28 -#define OLD_COMP_LIGHT_ROW2_SWITCH 29 -#define OLD_COMP_LIGHT_ROW3_SWITCH 30 -#define OLD_COMP_LIGHT_ROW4_SWITCH 31 +#define COMPONENT_LIGHT_ROW1_SWITCH 28 +#define COMPONENT_LIGHT_ROW2_SWITCH 29 +#define COMPONENT_LIGHT_ROW3_SWITCH 30 +#define COMPONENT_LIGHT_ROW4_SWITCH 31 -#define OLD_COMP_DASHBOARD_WEATHER_ICON 32 +#define COMPONENT_DASHBOARD_WEATHER_ICON 32 //dashboard page picture id -#define OLD_COMP_DASHBOARD_REFERENCE_BACKGROUND_PIC 0 -#define OLD_COMP_DASHBOARD_BACKGROUND_PIC 1 -#define OLD_COMP_DASHBOARD_BACKGROUND_VARIANT_PIC 2 +#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0 +#define COMPONENT_DASHBOARD_BACKGROUND_PIC 1 +#define COMPONENT_DASHBOARD_BACKGROUND_VARIANT_PIC 2 //AC on/off -#define OLD_COMP_AC_TOGGLE_PIC_OFF 3 -#define OLD_COMP_AC_TOGGLE_PIC_OFF_PRESSED 4 -#define OLD_COMP_AC_TOGGLE_PIC_ON 5 -#define OLD_COMP_AC_TOGGLE_PIC_ON_PRESSED 6 -#define OLD_COMP_AC_TEMP_DOWN_PIC 7 -#define OLD_COMP_AC_TEMP_DOWN_PIC_PRESSED 8 -#define OLD_COMP_AC_TEMP_UP_PIC 9 -#define OLD_COMP_AC_TEMP_UP_PIC_PRESSED 10 +#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 OLD_COMP_AC_FAN_MODE_AUTO_PIC 11 -#define OLD_COMP_AC_FAN_MODE_AUTO_PIC_PRESSED 12 -#define OLD_COMP_AC_FAN_MODE_HIGH_PIC 13 -#define OLD_COMP_AC_FAN_MODE_HIGH_PIC_PRESSED 14 -#define OLD_COMP_AC_FAN_MODE_MID_PIC 15 -#define OLD_COMP_AC_FAN_MODE_MID_PIC_PRESSED 16 -#define OLD_COMP_AC_FAN_MODE_LOW_PIC 17 -#define OLD_COMP_AC_FAN_MODE_LOW_PIC_PRESSED 18 +#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 OLD_COMP_AC_MODE_DRY_PIC 19 -#define OLD_COMP_AC_MODE_DRY_PIC_PRESSED 20 -#define OLD_COMP_AC_MODE_COOL_PIC 21 -#define OLD_COMP_AC_MODE_COOL_PIC_PRESSED 22 -#define OLD_COMP_AC_MODE_FAN_PIC 23 -#define OLD_COMP_AC_MODE_FAN_PIC_PRESSED 24 +#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 //pm; air purifier -#define OLD_COMP_PM_TOGGLE_PIC_OFF 25 -#define OLD_COMP_PM_TOGGLE_PIC_OFF_PRESSED 26 -#define OLD_COMP_PM_TOGGLE_PIC_ON 27 -#define OLD_COMP_PM_TOGGLE_PIC_ON_PRESSED 28 +#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 OLD_COMP_PM_FAN_SPEED_DECREASE_PIC 29 -#define OLD_COMP_PM_FAN_SPEED_DECREASE_PIC_PRESSED 30 -#define OLD_COMP_PM_FAN_SPEED_INCREASE_PIC 31 -#define OLD_COMP_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32 +#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 //AC status indicator -#define OLD_COMP_AC_STATUS_OFF 33 -#define OLD_COMP_AC_STATUS_ON 34 +#define COMPONENT_AC_STATUS_OFF 33 +#define COMPONENT_AC_STATUS_ON 34 //light master -#define OLD_COMP_LIGHT_MASTER_OFF 35 -#define OLD_COMP_LIGHT_MASTER_OFF_PRESSED 36 -#define OLD_COMP_LIGHT_MASTER_ON 37 -#define OLD_COMP_LIGHT_MASTER_ON_PRESSED 38 +#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 //light level component -#define OLD_COMP_LIGHT_LEVEL_0 39 -#define OLD_COMP_LIGHT_LEVEL_1 40 -#define OLD_COMP_LIGHT_LEVEL_2 41 -#define OLD_COMP_LIGHT_LEVEL_3 42 +#define COMPONENT_LIGHT_LEVEL_0 39 +#define COMPONENT_LIGHT_LEVEL_1 40 +#define COMPONENT_LIGHT_LEVEL_2 41 +#define COMPONENT_LIGHT_LEVEL_3 42 //weather icon legend -#define OLD_COMP_WEATHER_ICON_FAIR_DAY 63 -#define OLD_COMP_WEATHER_ICON_FAIR_NIGHT 64 -#define OLD_COMP_WEATHER_ICON_CLOUDY 65 -#define OLD_COMP_WEATHER_ICON_CLEARSKY_DAY 66 -#define OLD_COMP_WEATHER_ICON_CLEARSKY_NIGHT 67 -#define OLD_COMP_WEATHER_ICON_PARTLYCLOUDY_DAY 68 -#define OLD_COMP_WEATHER_ICON_PARTLYCLOUDY_NIGHT 69 -#define OLD_COMP_WEATHER_ICON_HEAVY_RAIN 70 -#define OLD_COMP_WEATHER_ICON_HEAVY_RAIN_AND_THUNDER 71 -#define OLD_COMP_WEATHER_ICON_RAIN_AND_THUNDER 72 -#define OLD_COMP_WEATHER_ICON_RAIN 73 -#define OLD_COMP_WEATHER_ICON_LIGHT_RAIN 74 -#define OLD_COMP_WEATHER_ICON_FOG 75 +#define COMPONENT_WEATHER_ICON_FAIR_DAY 63 +#define COMPONENT_WEATHER_ICON_FAIR_NIGHT 64 +#define COMPONENT_WEATHER_ICON_CLOUDY 65 +#define COMPONENT_WEATHER_ICON_CLEARSKY_DAY 66 +#define COMPONENT_WEATHER_ICON_CLEARSKY_NIGHT 67 +#define COMPONENT_WEATHER_ICON_PARTLYCLOUDY_DAY 68 +#define COMPONENT_WEATHER_ICON_PARTLYCLOUDY_NIGHT 69 +#define COMPONENT_WEATHER_ICON_HEAVY_RAIN 70 +#define COMPONENT_WEATHER_ICON_HEAVY_RAIN_AND_THUNDER 71 +#define COMPONENT_WEATHER_ICON_RAIN_AND_THUNDER 72 +#define COMPONENT_WEATHER_ICON_RAIN 73 +#define COMPONENT_WEATHER_ICON_LIGHT_RAIN 74 +#define COMPONENT_WEATHER_ICON_FOG 75 //need to toggle 4 row of light independently and have one master switch that can control all diff --git a/src/main.cpp b/src/main.cpp index fc54fcd..ff31584 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,50 +1,15 @@ #include -/*********************************************** - * Begin Configuration * - ***********************************************/ - -// Analog Card & Current Transformer Configuration -#ifdef ANALOG_ENABLE -bool analogCardAvailable = false; -AnalogCard analogCard = AnalogCard(); -float voltage = CT_RMS_VOLTAGE; -#define CT_INTERVAL 5000 -CurrentTransformerCard ct1 = CurrentTransformerCard(&analogCard, 0, &voltage, &adc2current, CT_INTERVAL); -CurrentTransformerCard ct2 = CurrentTransformerCard(&analogCard, 1, &voltage, &adc2current, CT_INTERVAL); -CurrentTransformerCard ct3 = CurrentTransformerCard(&analogCard, 2, &voltage, &adc2current, CT_INTERVAL); -CurrentTransformerCard ct4 = CurrentTransformerCard(&analogCard, 3, &voltage, &adc2current, CT_INTERVAL); -CurrentTransformerCard ct5 = CurrentTransformerCard(&analogCard, 6, &voltage, &adc2current, CT_INTERVAL); -CurrentTransformerCard ct6 = CurrentTransformerCard(&analogCard, 7, &voltage, &adc2current, CT_INTERVAL); -float adc2current(uint16_t adc_val) -{ - // float voltage = adc_val * 0.0007-0.1994; - if (adc_val > 64000) { - // ADC Value is too high, return 0 - return 0; - } - float adc_voltage = adc_val * 0.0007; - // 0-10V Output with 30A Current Rating CT - float ct_current = adc_voltage / 10.0 * 30.0; - return ct_current; -} - -#endif - - -// Remote Variables RemoteVariable pm25_in = RemoteVariable(); RemoteVariable pm25_out = RemoteVariable(); RemoteVariable temp_out = RemoteVariable(); RemoteVariable weather = RemoteVariable(); RemoteVariable pm_switch = RemoteVariable(); RemoteVariable pm_fan_speed = RemoteVariable(); -RemoteVariable pm_lock = RemoteVariable(); -RemoteVariable ac_lock = RemoteVariable(); - - -// Light Configuration +const char *mode_names_daikin[] = {"off", "cool", "fan_only", "dry"}; +const char *mode_names_york[] = {"off", "cool", "fan_only"}; +const char *fan_speed_names[] = {"auto", "high", "medium", "low"}; uint8_t row = 4; uint8_t column = 2; const uint8_t light_array[4][2] = { @@ -53,14 +18,10 @@ const uint8_t light_array[4][2] = { {LIGHT_ROW3_COLUMN1, LIGHT_ROW3_COLUMN2}, {LIGHT_ROW4_COLUMN1, LIGHT_ROW4_COLUMN2}}; -// Air Conditioner Configuration -const char *mode_names_daikin[] = {"off", "fan_only", "cool", "dry"}; -const char *mode_names_york[] = {"off", "fan_only", "cool"}; -const char *fan_speed_names[] = {"auto", "high", "medium", "low"}; AirConditioner ac_daikin = { - .max_temperature = DAIKIN_MAX_TEMP, - .min_temperature = DAIKIN_MIN_TEMP, + .max_temperature = 32, + .min_temperature = 16, .modes = 4, .mode_names = mode_names_daikin, .fan_speeds = 4, @@ -68,8 +29,8 @@ AirConditioner ac_daikin = { .getInfraredCode = &getInfraredCode_daikin}; AirConditioner ac_york = { - .max_temperature = YORK_MAX_TEMP, - .min_temperature = YORK_MIN_TEMP, + .max_temperature = 30, + .min_temperature = 18, .modes = 3, .mode_names = mode_names_york, .fan_speeds = 4, @@ -82,453 +43,18 @@ AirConditioner ac_york = { ESPMegaPRO espmega = ESPMegaPRO(); ISEDisplay iseDisplay = ISEDisplay(&iseDisplayAdapter, &light_array[0][0], row, column); -ESPMegaDisplayOTA iseDisplayOTA = ESPMegaDisplayOTA(); -ESPMegaDisplayOTA internalDisplayOTA = ESPMegaDisplayOTA(); - ClimateCard climateCard_daikin = ClimateCard(AIR_CONDITIONER_DAIKIN_IR_PIN, ac_daikin, - AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN, - AIR_CONDITIONER_RMT_CHANNEL0); + AIR_CONDITIONER_SENSOR_TYPE, AIR_CONDITIONER_SENSOR_PIN, + AIR_CONDITIONER_RMT_CHANNEL0); ClimateCard climateCard_york = ClimateCard(AIR_CONDITIONER_YORK_IR_PIN, ac_york, - AC_SENSOR_TYPE_NONE, 0, - AIR_CONDITIONER_RMT_CHANNEL1); + AC_SENSOR_TYPE_NONE, 0, + AIR_CONDITIONER_RMT_CHANNEL1); + + void handleMqttMessage(char *topic, char *payload) { - // Unused for now -} -void mqttSubscribeCallback() -{ - espmega.updateTimeFromNTP(); -} - -void setup() -{ - - - // ------------ Display Pre Initialization Routine ------------ - Serial.begin(115200); - iseDisplayAdapter.begin(ISE_DISPLAY_BAUD_RATE, SERIAL_8N1, ISE_DISPLAY_RX_PIN, ISE_DISPLAY_TX_PIN); - sendExtStopBytes(); - iseDisplayAdapter.print("rest"); - sendExtStopBytes(); - sendStopBytes(); - Serial.print("rest"); - sendStopBytes(); - Serial.print("boot_state.txt=\"Core Initializing . . .\""); - sendStopBytes(); - // ------------ End Display Pre Initialization Routine ------------ - - - // Give flow of control to OS and scheduler - espmega.begin(); - - // Set time zone to UTC+7 - espmega.setTimezone("ICT-7"); - - // set debounce time to 500 for pin 0-11 - for (uint16_t i = 0; i < 16; i++) - { - espmega.inputs.setDebounceTime(i, 75); - } - - // ------------ IoT Module Initialization Routine ------------ - Serial.print("boot_state.txt=\"IoT Initializing . . .\""); - sendStopBytes(); - espmega.enableIotModule(); - ETH.begin(); - espmega.iot->bindEthernetInterface(Ð); - Serial.print("boot_state.txt=\"Network Initializing . . .\""); - sendStopBytes(); - espmega.iot->loadNetworkConfig(); - espmega.iot->connectNetwork(); - Serial.print("boot_state.txt=\"MQTT Initializing . . .\""); - sendStopBytes(); - espmega.iot->loadMqttConfig(); - espmega.iot->registerSubscribeCallback(&mqttSubscribeCallback); - espmega.iot->connectToMqtt(); - Serial.print("boot_state.txt=\"Display Initializing . . .\""); - espmega.enableWebServer(80); - // ------------ End IoT Module Initialization Routine ------------ - - // ------------ Display Post Initialization Routine ------------ - espmega.enableInternalDisplay(&Serial); - // ------------ End Display Post Initialization Routine ------------ - - // ------------ Inputs and Outputs Initialization Routine ------------ - espmega.inputs.registerCallback(on_pin_change); - espmega.outputs.setAutoSaveToFRAM(true); - // Set value of pin 0-12 to 4095 - for (uint8_t i = 0; i < 13; i++) - { - espmega.outputs.setValue(i, 4095); - } - // ------------ End Inputs and Outputs Initialization Routine ------------ - espmega.outputs.setState(12, true); - espmega.outputs.setValue(12, 4095); - espmega.installCard(2, &climateCard_daikin); - climateCard_daikin.bindFRAM(&espmega.fram, 5000); - climateCard_daikin.loadStateFromFRAM(); - climateCard_daikin.setFRAMAutoSave(true); - espmega.display->bindClimateCard(&climateCard_daikin); - -// Input callbacks -// pre-load the input buffers - ESP_LOGV("ISE IoT OS", "Pre-loading input buffers"); - espmega.inputs.preloadInputBuffer(); - - // ------------ Climate Cards Initialization Routine ------------ - ESP_LOGD("ISE OS", "Setting up climate cards"); - - // Daikin Climate Card - ESP_LOGD("ISE OS", "Installing daikin climate card"); - espmega.installCard(2, &climateCard_daikin); - climateCard_daikin.bindFRAM(&espmega.fram, 5000); - climateCard_daikin.loadStateFromFRAM(); - climateCard_daikin.setFRAMAutoSave(true); - // Bind daikin climate card to the internal display - espmega.display->bindClimateCard(&climateCard_daikin); - - // York Climate Card - ESP_LOGD("ISE OS", "Installing york climate card"); - espmega.installCard(3, &climateCard_york); - climateCard_york.bindFRAM(&espmega.fram, 5005); - climateCard_york.loadStateFromFRAM(); - climateCard_york.setFRAMAutoSave(true); - // ------------ End Climate Cards Initialization Routine ------------ - - // ------------ Current Transformer Cards Initialization Routine ------------ - #ifdef ANALOG_ENABLE - ESP_LOGD("ISE OS", "Installing current transformer cards"); - // First try to install the analog card - analogCardAvailable = espmega.installCard(4, &analogCard); - // If the analog card is available, install the current transformer cards - // If the analog card is not available, current transformer cards will not be installed - // Unless CT_FORCE_ENABLE is set to true - // This is to prevent soft locking the device when the device tries to read from an ADC channel that does not exist - if (analogCardAvailable || CT_FORCE_ENABLE) - { - ESP_LOGV("ISE OS", "Analog card available, installing current transformer cards"); - espmega.installCard(5, &ct1); - ct1.bindFRAM(&espmega.fram, 5010); - ct1.loadEnergy(); - ct1.setEnergyAutoSave(true); - espmega.installCard(6, &ct2); - ct2.bindFRAM(&espmega.fram, 5020); - ct2.loadEnergy(); - ct2.setEnergyAutoSave(true); - espmega.installCard(7, &ct3); - ct3.bindFRAM(&espmega.fram, 5030); - ct3.loadEnergy(); - ct3.setEnergyAutoSave(true); - espmega.installCard(8, &ct4); - ct4.bindFRAM(&espmega.fram, 5040); - ct4.loadEnergy(); - ct4.setEnergyAutoSave(true); - espmega.installCard(9, &ct5); - ct5.bindFRAM(&espmega.fram, 5050); - ct5.loadEnergy(); - ct5.setEnergyAutoSave(true); - espmega.installCard(10, &ct5); - ct6.bindFRAM(&espmega.fram, 5060); - ct6.loadEnergy(); - ct6.setEnergyAutoSave(true); - espmega.iot->registerCard(5); - espmega.iot->registerCard(6); - espmega.iot->registerCard(7); - espmega.iot->registerCard(8); - espmega.iot->registerCard(9); - espmega.iot->registerCard(10); - } - else - { - ESP_LOGE("ISE OS", "Analog card not available, current transformer cards cannot and will not be installed."); - } - #endif - // ------------ End Current Transformer Cards Initialization Routine ------------ - - - // ------------ Remote Variables Initialization Routine ------------ - pm25_out.registerCallback(&pm25outupdatedisplay); - pm25_in.registerCallback(&pm25inupdatedisplay); - temp_out.registerCallback(&tempoutupdatedisplay); - weather.registerCallback(&weatherupdatedisplay); - pm_switch.registerCallback(&pmswitchupdatedisplay); - pm_fan_speed.registerCallback(&pmfanspeedupdatedisplay); - pm_lock.registerCallback(&pmlockupdatedisplay); - ac_lock.registerCallback(&aclockupdatedisplay); - - - // PM2.5 PPM Remote Variable - pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/request_value"); - // Temperature Remote Variable - temp_out.begin(6, "/temp/value", espmega.iot, true, "/temp/request_value"); - // Weather Remote Variable - weather.begin(45, "/weather/value", espmega.iot, true, "/weather/request_value"); - // PM2.5 PPM Remote Variable - pm25_in.begin(6, "/pm/value", espmega.iot, true, "/pm/request_value"); - // Air Purifier Switch Remote Variable - pm_switch.begin(6, "/pm/switch_state", espmega.iot, true, "/pm/request_switch_state"); - pm_switch.enableSetValue("/pm/set_switch_state"); - // Air Purifier Fan Speed Remote Variable - pm_fan_speed.begin(6, "/pm/fan_speed", espmega.iot, true, "/pm/request_fan_speed"); - pm_fan_speed.enableSetValue("/pm/set_fan_speed"); - // Air Purifier Lock Remote Variable - pm_lock.begin(6, "/pm/lock_state", espmega.iot, true, "/pm/request_lock_pm_state"); - pm_lock.enableSetValue("/pm/set_lock_pm_state"); - // Air Conditioner Lock Remote Variable - ac_lock.begin(6, "/ac/lock_state", espmega.iot, true, "/ac/request_lock_ac_state"); - ac_lock.enableSetValue("/ac/set_lock_ac_state"); - // ------------ End Remote Variables Initialization Routine ------------ - - - // ------------ IoT Card Registration Routine ------------ - espmega.iot->registerCard(0); // Register the Input Card - espmega.iot->registerCard(1); // Register the Output Card - espmega.iot->registerCard(2); // Register the Climate Card Daikin - espmega.iot->registerCard(3); // Register the Climate Card York - // ------------ End IoT Card Registration Routine ------------ - - - // ------------ External Display Initialization Routine ------------ - auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega); - iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard_daikin, &climateCard_york, &pm_switch, &pm_fan_speed, &pm_lock, &ac_lock, espmega.iot); - espmega.iot->registerRelativeMqttCallback(&handleMqttMessage); - iseDisplayOTA.begin("/isedisp", &iseDisplay, espmega.webServer); - internalDisplayOTA.begin("/intdisp", espmega.display, espmega.webServer); - iseDisplay.registerPageChangeCallback(&handlePageChange); - // ------------ End External Display Initialization Routine ------------ -} - -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) -{ - ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue()); - iseDisplay.updateAirPurifierState(); - iseDisplay.updateSystemtoggle(); - iseDisplay.updateAllStandbyToggle(); - ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", pm_switch.getValue(), !pm_switch.getValue()); -} -void pmlockupdatedisplay(char *value) -{ - ESP_LOGI("PM lock", "getting PM lock state from MQTT: %d", pm_lock.getValue()); - iseDisplay.updateAirPurifierState(); - ESP_LOGI("PM lock", "toggling PM lock state from: %d to %d", pm_lock.getValue(), !pm_lock.getValue()); -} -void aclockupdatedisplay(char *value) -{ - ESP_LOGI("AC lock", "getting AC lock state from MQTT: %d", ac_lock.getValue()); - iseDisplay.updateACState(); - ESP_LOGI("AC lock", "toggling AC lock state from: %d to %d", ac_lock.getValue(), !ac_lock.getValue()); -} - -void loop() -{ - espmega.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(); - } -#ifdef ANALOG_ENABLE - // Send out analog Data every 6 seconds - static uint32_t last_analog_sent = 0; - if (millis() - last_analog_sent > 6000) - { - espmega.iot->publish("/debug/up", "1"); - if (analogCardAvailable || CT_FORCE_ENABLE) - { - espmega.iot->publish("/debug/log", "Sending Analog Card Data"); - char topic_buffer[50]; - char payload_buffer[50]; - // Publish ADC Pin 0-7 - for (uint8_t i = 0; i < 8; i++) - { - sprintf(topic_buffer, "/debug/analog/%d", i); - sprintf(payload_buffer, "%d", analogCard.analogRead(i)); - espmega.iot->publish(topic_buffer, payload_buffer); - } - } - last_analog_sent = millis(); - } -#endif -} - -void on_pin_change(uint8_t pin, uint8_t value) -{ - switch (pin) - { - case LIGHT_ROW1_COLUMN1_IN: - espmega.outputs.setState(LIGHT_ROW1_COLUMN1, !espmega.outputs.getState(LIGHT_ROW1_COLUMN1)); - break; - case LIGHT_ROW1_COLUMN2_IN: - espmega.outputs.setState(LIGHT_ROW1_COLUMN2, !espmega.outputs.getState(LIGHT_ROW1_COLUMN2)); - break; - case LIGHT_ROW2_COLUMN1_IN: - espmega.outputs.setState(LIGHT_ROW2_COLUMN1, !espmega.outputs.getState(LIGHT_ROW2_COLUMN1)); - break; - case LIGHT_ROW2_COLUMN2_IN: - espmega.outputs.setState(LIGHT_ROW2_COLUMN2, !espmega.outputs.getState(LIGHT_ROW2_COLUMN2)); - break; - case LIGHT_ROW3_COLUMN1_IN: - espmega.outputs.setState(LIGHT_ROW3_COLUMN1, !espmega.outputs.getState(LIGHT_ROW3_COLUMN1)); - break; - case LIGHT_ROW3_COLUMN2_IN: - espmega.outputs.setState(LIGHT_ROW3_COLUMN2, !espmega.outputs.getState(LIGHT_ROW3_COLUMN2)); - break; - case LIGHT_ROW4_COLUMN1_IN: - espmega.outputs.setState(LIGHT_ROW4_COLUMN1, !espmega.outputs.getState(LIGHT_ROW4_COLUMN1)); - break; - case LIGHT_ROW4_COLUMN2_IN: - espmega.outputs.setState(LIGHT_ROW4_COLUMN2, !espmega.outputs.getState(LIGHT_ROW4_COLUMN2)); - break; - case COMPUTER_DESK_SWITCH_IN: - espmega.outputs.setState(COMPUTER_DESK_SWITCH_OUT, !espmega.outputs.getState(COMPUTER_DESK_SWITCH_OUT)); - break; - } -} - -uint16_t get_pm25_out() -{ - uint16_t pm25_out_value = 0; - // Read PM2.5 PPM from home assistant - pm25_out_value = atoi(pm25_out.getValue()); - ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_out_value); - return pm25_out_value; -} - -uint16_t get_pm25_in() -{ - uint16_t pm25_in_value = 0; - // Read PM2.5 PPM from home assistant - pm25_in_value = atoi(pm25_in.getValue()); - ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_in_value); - return pm25_in_value; -} - -float get_temp_out() -{ - float temp_out_value = 0; - // Read temperature from home assistant - temp_out_value = atof(temp_out.getValue()); - ESP_LOGI("Temperature", "getting Temperature from MQTT: %f", temp_out_value); - return temp_out_value; -} - -uint8_t get_pm_fanspeed() -{ - uint8_t pm_fan_speed_value = 0; - // Read PM2.5 fan speed from home assistant - pm_fan_speed_value = (int)atof(pm_fan_speed.getValue()); - ESP_LOGI("PM fan speed", "getting PM2.5 PPM from MQTT: %d", pm_fan_speed_value); - return pm_fan_speed_value; -} - -bool get_pm_lock() -{ - ESP_LOGI("PM lock", "getting PM lock state from MQTT: %d", pm_lock.getValue()); - bool is_pm_lock_on = strcmp(pm_lock.getValue(), "on") == 0; - return is_pm_lock_on; -} - -bool get_ac_lock() -{ - ESP_LOGI("AC lock", "getting AC lock state from MQTT: %d", ac_lock.getValue()); - bool is_ac_lock_on = strcmp(ac_lock.getValue(), "on") == 0; - return is_ac_lock_on; -} - -/** - * @brief Get the PM switch state from home assistant - * @return true if the PM switch is on, false if the PM switch is off - */ -bool get_pm_switch() -{ - ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue()); - bool is_pm_switch_on = strcmp(pm_switch.getValue(), "on") == 0; - return is_pm_switch_on; -} - -void toggle_pm_switch() -{ - bool is_pm_switch_on = get_pm_switch(); - ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", is_pm_switch_on, !is_pm_switch_on); - pm_switch.setValue(is_pm_switch_on ? "0" : "1"); -} - -void toggle_ac_lock() -{ - bool is_ac_lock_on = get_ac_lock(); - ESP_LOGI("AC lock", "toggling AC lock state from: %d to %d", is_ac_lock_on, !is_ac_lock_on); - ac_lock.setValue(is_ac_lock_on ? "0" : "1"); -} - -void toggle_pm_lock() -{ - bool is_pm_lock_on = get_pm_lock(); - ESP_LOGI("PM lock", "toggling PM lock state from: %d to %d", is_pm_lock_on, !is_pm_lock_on); - pm_lock.setValue(is_pm_lock_on ? "0" : "1"); -} - -void set_pm_fanspeed(uint8_t speed) -{ - ESP_LOGI("PM fan speed", "setting PM fan speed to: %d", speed); - char buffer[4]; - itoa(speed, buffer, DEC); - pm_fan_speed.setValue(buffer); -} - -void handlePageChange(uint8_t page) -{ - ESP_LOGI("Page", "Page change to: %d", page); - rtctime_t time = espmega.getTime(); - iseDisplay.updateDateTimeText(time); - switch (page) - { - case PAGE_STANDBY: - iseDisplay.updateLightGroupStatePageStandby(); - iseDisplay.updateAirPurifierStateStandby(); - iseDisplay.updateAllStandbyToggle(); - break; - case PAGE_DASHBOARD: - iseDisplay.updateLightGroupStatePageDashboard(); - iseDisplay.updateAirPurifierState(); - iseDisplay.updateSystemtoggle(); - break; - default: - break; - } - - iseDisplay.updatePMoutside(get_pm25_out()); - iseDisplay.updatePMinside(get_pm25_in()); - //iseDisplay.updateWeather(weather.getValue()); - //iseDisplay.updateTempOutside(get_temp_out()); - iseDisplay.updateACState(); } void sendStopBytes() @@ -543,4 +69,384 @@ void sendExtStopBytes() iseDisplayAdapter.write(0xFF); iseDisplayAdapter.write(0xFF); iseDisplayAdapter.write(0xFF); +} + +void setup() +{ + gpio_config_t gpio_2_conf; + gpio_2_conf.intr_type = GPIO_INTR_DISABLE; + gpio_2_conf.mode = GPIO_MODE_INPUT; + gpio_2_conf.pull_up_en = GPIO_PULLUP_ENABLE; + gpio_config(&gpio_2_conf); + // If GPIO 2 is pulled low, clear the FRAM then reboot (Reset the device to factory defaults) + bool clear_fram = !gpio_get_level(GPIO_NUM_2); + Serial.begin(115200); + iseDisplayAdapter.begin(ISE_DISPLAY_BAUD_RATE, SERIAL_8N1, ISE_DISPLAY_RX_PIN, ISE_DISPLAY_TX_PIN); + sendExtStopBytes(); + iseDisplayAdapter.print("rest"); + sendExtStopBytes(); + sendStopBytes(); + Serial.print("rest"); + sendStopBytes(); + Serial.print("boot_state.txt=\"Core Initializing . . .\""); + sendStopBytes(); + espmega.begin(); + // if (clear_fram) + // { + // Serial.print("boot_state.txt=\"Factory Resetting . . .\""); + // sendStopBytes(); + // for (uint16_t i = 0; i < 32768; i++) + // { + // espmega.fram.write8(i, 0); + // } + // esp_restart(); + // } + Serial.print("boot_state.txt=\"IoT Initializing . . .\""); + sendStopBytes(); + espmega.enableIotModule(); + ETH.begin(); + espmega.iot->bindEthernetInterface(Ð); + Serial.print("boot_state.txt=\"Network Initializing . . .\""); + sendStopBytes(); + espmega.iot->loadNetworkConfig(); + espmega.iot->connectNetwork(); + Serial.print("boot_state.txt=\"MQTT Initializing . . .\""); + sendStopBytes(); + espmega.iot->loadMqttConfig(); + espmega.iot->connectToMqtt(); + Serial.print("boot_state.txt=\"Display Initializing . . .\""); + espmega.enableInternalDisplay(&Serial); + espmega.enableWebServer(80); + espmega.inputs.registerCallback(on_pin_change); + espmega.outputs.setAutoSaveToFRAM(true); + // Set value of pin 0-12 to 4095 + for (uint8_t i = 0; i < 13; i++) + { + espmega.outputs.setValue(i, 4095); + } + espmega.outputs.setState(12, true); + espmega.outputs.setValue(12,4095); + + espmega.installCard(2, &climateCard_daikin); + climateCard_daikin.bindFRAM(&espmega.fram, 5000); + climateCard_daikin.loadStateFromFRAM(); + climateCard_daikin.setFRAMAutoSave(true); + //espmega.display->bindclimateCard(&climateCard_daikin); + + espmega.installCard(10, &climateCard_daikin); + climateCard_york.bindFRAM(&espmega.fram, 5000); + climateCard_york.loadStateFromFRAM(); + climateCard_york.setFRAMAutoSave(true); + espmega.display->bindClimateCard(&climateCard_york); + + // 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(binded_display_update_on_pm25_out)); + // pm25_in.registerCallback(std::function(binded_display_update_on_pm25_in)); + // temp_out.registerCallback(std::function(binded_display_update_on_temp_out)); + // weather.registerCallback(std::function(binded_display_update_on_weather)); + // pm_switch.registerCallback(std::function(binded_display_update_on_pm_switch)); + // pm_fan_speed.registerCallback(std::function(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 + // Enable value request at /iqair/pm25_request + pm25_out.begin(6, "/aqi/value", espmega.iot, true, "/aqi/request_value"); + // Temperature Remote Variable + temp_out.begin(6, "/temp/value", espmega.iot, true, "/temp/request_value"); + // Weather Remote Variable + weather.begin(45, "/weather/value", espmega.iot, true, "/weather/request_value"); + // PM2.5 PPM Remote Variable + pm25_in.begin(6, "/pm/value", espmega.iot, true, "/pm/request_value"); + // Air Purifier Switch Remote Variable + pm_switch.begin(6, "/pm/switch_state", espmega.iot, true, "/pm/request_switch_state"); + pm_switch.enableSetValue("/pm/set_switch_state"); + // Air Purifier Fan Speed Remote Variable + pm_fan_speed.begin(6, "/pm/fan_speed", espmega.iot, true, "/pm/request_fan_speed"); + pm_fan_speed.enableSetValue("/pm/set_fan_speed"); + espmega.iot->registerCard(0); // Register the Input Card + espmega.iot->registerCard(1); // Register the Output Card + espmega.iot->registerCard(2); // Register the Climate Card Daikin + espmega.iot->registerCard(10); // Register the Climate Card York + auto bindedGetTime = std::bind(&ESPMegaPRO::getTime, &espmega); + iseDisplay.begin(&espmega.inputs, &espmega.outputs, &climateCard_daikin, &climateCard_york, &pm_switch, &pm_fan_speed); + espmega.iot->registerRelativeMqttCallback(&handleMqttMessage); + iseDisplay.registerPageChangeCallback(&handlePageChange); + + +} + +// 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){ + ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue()); + iseDisplay.updateAirPurifierState(); + ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", pm_switch.getValue(), !pm_switch.getValue()); +} + + +void loop() +{ + espmega.loop(); + iseDisplay.loop(); + + // Update the time every 15 seconds + // static bool run_when_init = false; // No static ? , this shit will reset to 0 every loop + static uint32_t last_time_updated = 0; + // rtctime_t time = espmega.getTime(); + // when init update once then update every 15 seconds + // You don't need this, when it go from page 0 to 1 it call handlePageChange + // if(!run_when_init){ + // time = espmega.getTime(); + // iseDisplay.updateDateTimeText(time); + // last_time_updated = millis(); + // run_when_init = true; + // } + + if (millis() - last_time_updated > 15000) + { + rtctime_t time = espmega.getTime(); + // log time + ESP_LOGI("time", "Time: %d:%d:%d", time.hours, time.minutes, time.seconds); + ESP_LOGI("Date", "Date: %d/%d/%d", time.day, time.month, time.year); + 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 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(); + // } +} + +void on_pin_change(uint8_t pin, uint8_t value) +{ + // For input pin 0-3, map it with output pin 0-3 + // For input pin 4-7, map it with output pin 8-11 + // For input pin 12, map it with output pin 12 + // When Input pin change, Toggle the output pin + switch (pin){ + case LIGHT_ROW1_COLUMN1_IN: + espmega.outputs.setState(LIGHT_ROW1_COLUMN1, !espmega.outputs.getState(LIGHT_ROW1_COLUMN1)); + break; + case LIGHT_ROW1_COLUMN2_IN: + espmega.outputs.setState(LIGHT_ROW1_COLUMN2, !espmega.outputs.getState(LIGHT_ROW1_COLUMN2)); + break; + case LIGHT_ROW2_COLUMN1_IN: + espmega.outputs.setState(LIGHT_ROW2_COLUMN1, !espmega.outputs.getState(LIGHT_ROW2_COLUMN1)); + break; + case LIGHT_ROW2_COLUMN2_IN: + espmega.outputs.setState(LIGHT_ROW2_COLUMN2, !espmega.outputs.getState(LIGHT_ROW2_COLUMN2)); + break; + case LIGHT_ROW3_COLUMN1_IN: + espmega.outputs.setState(LIGHT_ROW3_COLUMN1, !espmega.outputs.getState(LIGHT_ROW3_COLUMN1)); + break; + case LIGHT_ROW3_COLUMN2_IN: + espmega.outputs.setState(LIGHT_ROW3_COLUMN2, !espmega.outputs.getState(LIGHT_ROW3_COLUMN2)); + break; + case LIGHT_ROW4_COLUMN1_IN: + espmega.outputs.setState(LIGHT_ROW4_COLUMN1, !espmega.outputs.getState(LIGHT_ROW4_COLUMN1)); + break; + case LIGHT_ROW4_COLUMN2_IN: + espmega.outputs.setState(LIGHT_ROW4_COLUMN2, !espmega.outputs.getState(LIGHT_ROW4_COLUMN2)); + break; + case COMPUTER_DESK_SWITCH_IN: + espmega.outputs.setState(COMPUTER_DESK_SWITCH_OUT, !espmega.outputs.getState(COMPUTER_DESK_SWITCH_OUT)); + break; + } + // if (pin < 4) + // { + // bool new_value = !espmega.outputs.getState(pin); + // espmega.outputs.setState(pin, new_value); + // } + // else if (pin < 8) + // { + // bool new_value = !espmega.outputs.getState(pin + 4); + // espmega.outputs.setState(pin + 4, new_value); + // } + // else if (pin == 12) + // { + // bool new_value = !espmega.outputs.getState(12); + // espmega.outputs.setState(12, new_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()); + ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_out_value); + return pm25_out_value; +} + +uint16_t get_pm25_in() +{ + uint16_t pm25_in_value = 0; + // Read PM2.5 PPM from sensor + pm25_in_value = atoi(pm25_in.getValue()); + ESP_LOGI("PM2.5", "getting PM2.5 PPM from MQTT: %d", pm25_in_value); + return pm25_in_value; +} + +float get_temp_out() +{ + float temp_out_value = 0; + // Read temperature from sensor + temp_out_value = atof(temp_out.getValue()); + ESP_LOGI("Temperature", "getting Temperature from MQTT: %f", temp_out_value); + return temp_out_value; +} + +uint8_t get_pm_fanspeed() +{ + uint8_t pm_fan_speed_value = 0; + // Read PM2.5 fan speed from sensor + pm_fan_speed_value = (int) atof(pm_fan_speed.getValue()); + ESP_LOGI("PM fan speed", "getting PM2.5 PPM from MQTT: %d", pm_fan_speed_value); + return pm_fan_speed_value; +} + +bool get_pm_switch() +{ + ESP_LOGI("PM switch", "getting PM switch state from MQTT: %d", pm_switch.getValue()); + bool is_pm_switch_on = strcmp(pm_switch.getValue(),"on")== 0; + return is_pm_switch_on; +} +void toggle_pm_switch() +{ + bool is_pm_switch_on = get_pm_switch(); + ESP_LOGI("PM switch", "toggling PM switch state from: %d to %d", is_pm_switch_on, !is_pm_switch_on); + pm_switch.setValue(is_pm_switch_on ? "0" : "1"); +} +void set_pm_fanspeed(uint8_t speed) +{ + ESP_LOGI("PM fan speed", "setting PM fan speed to: %d", speed); + char buffer[4]; + itoa(speed, buffer, DEC); + pm_fan_speed.setValue(buffer); +} + +void handlePageChange(uint8_t page) +{ + + // Which already send the time + // printESP_LOGI the page have changed + ESP_LOGI("Page", "Page change to: %d", page); + rtctime_t time = espmega.getTime(); + iseDisplay.updateDateTimeText(time); + switch (page) + { + case PAGE_STANDBY: + iseDisplay.updateLightGroupStatePageStandby(); + iseDisplay.updateAirPurifierStateStandby(); + break; + case PAGE_DASHBOARD: + iseDisplay.updateLightGroupStatePageDashboard(); + iseDisplay.updateAirPurifierState(); + break; + default: + break; + } + + // iseDisplay.updatePMinside(); + iseDisplay.updatePMoutside(get_pm25_out()); + iseDisplay.updatePMinside(get_pm25_in()); + iseDisplay.updateWeather(weather.getValue()); + iseDisplay.updateTempOutside(get_temp_out()); + iseDisplay.updateACState(); + /* + iseDisplay.updateAirPurifierState(); + iseDisplay.updateLightGroupStatePageStandby(); + iseDisplay.updateLightGroupStatePageDashboard(); + iseDisplay.updateuserACmode(); + iseDisplay.updateAirPurifierStateStandby(); */ } \ No newline at end of file diff --git a/src/main.hpp b/src/main.hpp index 6dbc3e0..aad6fa7 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -4,8 +4,6 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #include #include #include -#include -#include @@ -23,19 +21,9 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #define AIR_CONDITIONER_SENSOR_TYPE AC_SENSOR_TYPE_DHT22 #define AIR_CONDITIONER_SENSOR_PIN 32 #define AIR_CONDITIONER_DAIKIN_IR_PIN 5 -#define AIR_CONDITIONER_YORK_IR_PIN 15 +#define AIR_CONDITIONER_YORK_IR_PIN 8 #define AIR_CONDITIONER_RMT_CHANNEL0 RMT_CHANNEL_0 #define AIR_CONDITIONER_RMT_CHANNEL1 RMT_CHANNEL_1 -// CT Configuration -#define ANALOG_ENABLE -#define CT_FORCE_ENABLE true -#define CT_RMS_VOLTAGE 220.0 -#define CT_PIN_LIGHT_PHASE1 0 -#define CT_PIN_LIGHT_PHASE2 1 -#define CT_PIN_SOCKET 2 -#define CT_PIN_AC_PHASE1 3 -#define CT_PIN_AC_PHASE2 4 -#define CT_PIN_AC_PHASE3 5 void handleMqttMessage(char *topic, char *payload); void subscribeToMqttTopics(); @@ -49,15 +37,9 @@ void loop(); void on_pin_change(uint8_t pin, uint8_t value); -void mqttSubscribeCallback(); - uint16_t get_pm25_out(); uint16_t get_pm25_in(); float get_temp_out(); -bool get_pm_lock(); -bool get_ac_lock(); -void toggle_ac_lock(); -void toggle_pm_lock(); void toggle_pm_switch(); void set_pm_fanspeed(uint8_t speed); void display_update(); @@ -66,7 +48,4 @@ void pm25inupdatedisplay(char* value); void tempoutupdatedisplay(char* value); void weatherupdatedisplay(char* value); void pmfanspeedupdatedisplay(char* value); -void pmlockupdatedisplay(char* value); -void aclockupdatedisplay(char* value); -void pmswitchupdatedisplay(char* value); -float adc2current(uint16_t adc_val); \ No newline at end of file +void pmswitchupdatedisplay(char* value); \ No newline at end of file