diff --git a/.gitignore b/.gitignore index 89cc49c..6caeb0e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ .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 new file mode 100644 index 0000000..4d572a4 Binary files /dev/null and b/ise-display/fonts/BaiJ-48-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-B-24-ascii.zi b/ise-display/fonts/BaiJ-B-24-ascii.zi new file mode 100644 index 0000000..c1d9392 Binary files /dev/null and b/ise-display/fonts/BaiJ-B-24-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-B-40.zi b/ise-display/fonts/BaiJ-B-40.zi new file mode 100644 index 0000000..3bd944c Binary files /dev/null and b/ise-display/fonts/BaiJ-B-40.zi differ diff --git a/ise-display/fonts/BaiJ-B-48-ascii.zi b/ise-display/fonts/BaiJ-B-48-ascii.zi new file mode 100644 index 0000000..81aabaa Binary files /dev/null and b/ise-display/fonts/BaiJ-B-48-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-24-ascii.zi b/ise-display/fonts/BaiJ-sb-24-ascii.zi new file mode 100644 index 0000000..1d0861a Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-24-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-72-ascii.zi b/ise-display/fonts/BaiJ-sb-72-ascii.zi new file mode 100644 index 0000000..16c1773 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-72-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-80-ascii.zi b/ise-display/fonts/BaiJ-sb-80-ascii.zi new file mode 100644 index 0000000..407cd64 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-80-ascii.zi differ diff --git a/ise-display/fonts/BaiJ-sb-86-ascii.zi b/ise-display/fonts/BaiJ-sb-86-ascii.zi new file mode 100644 index 0000000..6f27432 Binary files /dev/null and b/ise-display/fonts/BaiJ-sb-86-ascii.zi differ diff --git a/ise-display/fonts/baiJ-B-32-ascii.zi b/ise-display/fonts/baiJ-B-32-ascii.zi new file mode 100644 index 0000000..18a8e5c Binary files /dev/null and b/ise-display/fonts/baiJ-B-32-ascii.zi differ diff --git a/ise-display/fonts/baiJ-sb-32-ascii.zi b/ise-display/fonts/baiJ-sb-32-ascii.zi new file mode 100644 index 0000000..72dae21 Binary files /dev/null and b/ise-display/fonts/baiJ-sb-32-ascii.zi differ diff --git a/ise-display/images/ac/ac-light-off.png b/ise-display/images/ac/ac-light-off.png deleted file mode 100644 index dfa928d..0000000 Binary files a/ise-display/images/ac/ac-light-off.png and /dev/null differ diff --git a/ise-display/images/ac/ac-light-on.png b/ise-display/images/ac/ac-light-on.png deleted file mode 100644 index fa08c30..0000000 Binary files a/ise-display/images/ac/ac-light-on.png and /dev/null differ diff --git a/ise-display/images/ac/ac-minus-p.png b/ise-display/images/ac/ac-minus-p.png deleted file mode 100644 index 796021e..0000000 Binary files a/ise-display/images/ac/ac-minus-p.png and /dev/null differ diff --git a/ise-display/images/ac/ac-minus.png b/ise-display/images/ac/ac-minus.png deleted file mode 100644 index 0642045..0000000 Binary files a/ise-display/images/ac/ac-minus.png and /dev/null differ diff --git a/ise-display/images/ac/ac-off-p.png b/ise-display/images/ac/ac-off-p.png deleted file mode 100644 index 03aef80..0000000 Binary files a/ise-display/images/ac/ac-off-p.png and /dev/null differ diff --git a/ise-display/images/ac/ac-off.png b/ise-display/images/ac/ac-off.png deleted file mode 100644 index 1e786eb..0000000 Binary files a/ise-display/images/ac/ac-off.png and /dev/null differ diff --git a/ise-display/images/ac/ac-on-p.png b/ise-display/images/ac/ac-on-p.png deleted file mode 100644 index 9286e73..0000000 Binary files a/ise-display/images/ac/ac-on-p.png and /dev/null differ diff --git a/ise-display/images/ac/ac-on.png b/ise-display/images/ac/ac-on.png deleted file mode 100644 index 738ed32..0000000 Binary files a/ise-display/images/ac/ac-on.png and /dev/null differ diff --git a/ise-display/images/ac/ac-plus-p.png b/ise-display/images/ac/ac-plus-p.png deleted file mode 100644 index de7ac55..0000000 Binary files a/ise-display/images/ac/ac-plus-p.png and /dev/null differ diff --git a/ise-display/images/ac/ac-plus.png b/ise-display/images/ac/ac-plus.png deleted file mode 100644 index fab33b5..0000000 Binary files a/ise-display/images/ac/ac-plus.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanAuto-p.png b/ise-display/images/ac/fanspeed/fanAuto-p.png deleted file mode 100644 index 6f70f5e..0000000 Binary files a/ise-display/images/ac/fanspeed/fanAuto-p.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanAuto.png b/ise-display/images/ac/fanspeed/fanAuto.png deleted file mode 100644 index 601dc5c..0000000 Binary files a/ise-display/images/ac/fanspeed/fanAuto.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanHigh-p.png b/ise-display/images/ac/fanspeed/fanHigh-p.png deleted file mode 100644 index 7388dfb..0000000 Binary files a/ise-display/images/ac/fanspeed/fanHigh-p.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanHigh.png b/ise-display/images/ac/fanspeed/fanHigh.png deleted file mode 100644 index c0f568f..0000000 Binary files a/ise-display/images/ac/fanspeed/fanHigh.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanLow-p.png b/ise-display/images/ac/fanspeed/fanLow-p.png deleted file mode 100644 index 4573232..0000000 Binary files a/ise-display/images/ac/fanspeed/fanLow-p.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanLow.png b/ise-display/images/ac/fanspeed/fanLow.png deleted file mode 100644 index f0e9a5b..0000000 Binary files a/ise-display/images/ac/fanspeed/fanLow.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanMid-p.png b/ise-display/images/ac/fanspeed/fanMid-p.png deleted file mode 100644 index 36b7daf..0000000 Binary files a/ise-display/images/ac/fanspeed/fanMid-p.png and /dev/null differ diff --git a/ise-display/images/ac/fanspeed/fanMid.png b/ise-display/images/ac/fanspeed/fanMid.png deleted file mode 100644 index 8e1ac19..0000000 Binary files a/ise-display/images/ac/fanspeed/fanMid.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeCool-p.png b/ise-display/images/ac/mode/modeCool-p.png deleted file mode 100644 index ce1cf2f..0000000 Binary files a/ise-display/images/ac/mode/modeCool-p.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeCool.png b/ise-display/images/ac/mode/modeCool.png deleted file mode 100644 index 39156c3..0000000 Binary files a/ise-display/images/ac/mode/modeCool.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeDry-p.png b/ise-display/images/ac/mode/modeDry-p.png deleted file mode 100644 index f21aba7..0000000 Binary files a/ise-display/images/ac/mode/modeDry-p.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeDry.png b/ise-display/images/ac/mode/modeDry.png deleted file mode 100644 index c3e5ef6..0000000 Binary files a/ise-display/images/ac/mode/modeDry.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeFan-p.png b/ise-display/images/ac/mode/modeFan-p.png deleted file mode 100644 index 45cad55..0000000 Binary files a/ise-display/images/ac/mode/modeFan-p.png and /dev/null differ diff --git a/ise-display/images/ac/mode/modeFan.png b/ise-display/images/ac/mode/modeFan.png deleted file mode 100644 index 3ac499f..0000000 Binary files a/ise-display/images/ac/mode/modeFan.png and /dev/null differ diff --git a/ise-display/images/background/bg-off-v.png b/ise-display/images/background/bg-off-v.png deleted file mode 100644 index f33e8bf..0000000 Binary files a/ise-display/images/background/bg-off-v.png and /dev/null differ diff --git a/ise-display/images/background/bg-off.png b/ise-display/images/background/bg-off.png deleted file mode 100644 index b5e3bc5..0000000 Binary files a/ise-display/images/background/bg-off.png and /dev/null differ diff --git a/ise-display/images/background/full-ref.png b/ise-display/images/background/full-ref.png deleted file mode 100644 index 0834ce1..0000000 Binary files a/ise-display/images/background/full-ref.png and /dev/null differ diff --git a/ise-display/images/boot/OPEN-bg.png b/ise-display/images/boot/OPEN-bg.png new file mode 100644 index 0000000..7f4a5c4 Binary files /dev/null and b/ise-display/images/boot/OPEN-bg.png differ diff --git a/ise-display/images/boot/OPEN-ref.png b/ise-display/images/boot/OPEN-ref.png new file mode 100644 index 0000000..8fdeede Binary files /dev/null and b/ise-display/images/boot/OPEN-ref.png differ diff --git a/ise-display/images/boot/bg.png b/ise-display/images/boot/bg.png deleted file mode 100644 index 030ed0b..0000000 Binary files a/ise-display/images/boot/bg.png and /dev/null differ diff --git a/ise-display/images/boot/ref.png b/ise-display/images/boot/ref.png deleted file mode 100644 index 932f215..0000000 Binary files a/ise-display/images/boot/ref.png and /dev/null differ diff --git a/ise-display/images/light/light-level0.png b/ise-display/images/light/light-level0.png deleted file mode 100644 index 554b4ed..0000000 Binary files a/ise-display/images/light/light-level0.png and /dev/null differ diff --git a/ise-display/images/light/light-level1.png b/ise-display/images/light/light-level1.png deleted file mode 100644 index 53cdd22..0000000 Binary files a/ise-display/images/light/light-level1.png and /dev/null differ diff --git a/ise-display/images/light/light-level2.png b/ise-display/images/light/light-level2.png deleted file mode 100644 index 84ec343..0000000 Binary files a/ise-display/images/light/light-level2.png and /dev/null differ diff --git a/ise-display/images/light/light-level3.png b/ise-display/images/light/light-level3.png deleted file mode 100644 index 614af4b..0000000 Binary files a/ise-display/images/light/light-level3.png and /dev/null differ diff --git a/ise-display/images/light/master-off-p.png b/ise-display/images/light/master-off-p.png deleted file mode 100644 index c0c15f0..0000000 Binary files a/ise-display/images/light/master-off-p.png and /dev/null differ diff --git a/ise-display/images/light/master-off.png b/ise-display/images/light/master-off.png deleted file mode 100644 index 6fcbc83..0000000 Binary files a/ise-display/images/light/master-off.png and /dev/null differ diff --git a/ise-display/images/light/master-on-p.png b/ise-display/images/light/master-on-p.png deleted file mode 100644 index a6ae700..0000000 Binary files a/ise-display/images/light/master-on-p.png and /dev/null differ diff --git a/ise-display/images/light/master-on.png b/ise-display/images/light/master-on.png deleted file mode 100644 index 600a2fa..0000000 Binary files a/ise-display/images/light/master-on.png and /dev/null differ diff --git a/ise-display/images/main/C-degree/C off.png b/ise-display/images/main/C-degree/C off.png new file mode 100644 index 0000000..f505db8 Binary files /dev/null and b/ise-display/images/main/C-degree/C off.png differ diff --git a/ise-display/images/main/C-degree/C on.png b/ise-display/images/main/C-degree/C on.png new file mode 100644 index 0000000..7dacc39 Binary files /dev/null and b/ise-display/images/main/C-degree/C on.png differ diff --git a/ise-display/images/main/ac/AC-off-pressed.png b/ise-display/images/main/ac/AC-off-pressed.png new file mode 100644 index 0000000..7f21e3d Binary files /dev/null and b/ise-display/images/main/ac/AC-off-pressed.png differ diff --git a/ise-display/images/main/ac/AC-off.png b/ise-display/images/main/ac/AC-off.png new file mode 100644 index 0000000..73a356a Binary files /dev/null and b/ise-display/images/main/ac/AC-off.png differ diff --git a/ise-display/images/main/ac/AC-on-pressed.png b/ise-display/images/main/ac/AC-on-pressed.png new file mode 100644 index 0000000..d635d44 Binary files /dev/null and b/ise-display/images/main/ac/AC-on-pressed.png differ diff --git a/ise-display/images/main/ac/AC-on.png b/ise-display/images/main/ac/AC-on.png new file mode 100644 index 0000000..052e027 Binary files /dev/null and b/ise-display/images/main/ac/AC-on.png differ diff --git a/ise-display/images/main/background/Background-c.png b/ise-display/images/main/background/Background-c.png new file mode 100644 index 0000000..3f69291 Binary files /dev/null and b/ise-display/images/main/background/Background-c.png differ diff --git a/ise-display/images/main/background/Background.png b/ise-display/images/main/background/Background.png new file mode 100644 index 0000000..0ff021b Binary files /dev/null and b/ise-display/images/main/background/Background.png differ diff --git a/ise-display/images/main/background/Reference - Active mode.png b/ise-display/images/main/background/Reference - Active mode.png new file mode 100644 index 0000000..570a2d8 Binary files /dev/null and b/ise-display/images/main/background/Reference - Active mode.png 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 new file mode 100644 index 0000000..68fe571 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Auto-off-pressed.png 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 new file mode 100644 index 0000000..95fb2e4 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Auto-off.png 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 new file mode 100644 index 0000000..a267a9a Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Auto-on-pressed.png 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 new file mode 100644 index 0000000..4a1d774 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Auto-on.png 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 new file mode 100644 index 0000000..0adee9a Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-High-off-pressed.png 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 new file mode 100644 index 0000000..c45b2dc Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-High-off.png 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 new file mode 100644 index 0000000..a57e83e Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-High-on-pressed.png 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 new file mode 100644 index 0000000..2943849 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-High-on.png 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 new file mode 100644 index 0000000..f013e41 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Low-off-pressed.png 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 new file mode 100644 index 0000000..b272008 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Low-off.png 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 new file mode 100644 index 0000000..3157a58 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Low-on-pressed.png 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 new file mode 100644 index 0000000..f073fe9 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Low-on.png 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 new file mode 100644 index 0000000..d3ab352 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Mid-off-pressed.png 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 new file mode 100644 index 0000000..76121d7 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Mid-off.png 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 new file mode 100644 index 0000000..d3bc616 Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Mid-on-pressed.png 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 new file mode 100644 index 0000000..27d903d Binary files /dev/null and b/ise-display/images/main/fan/Fan-speed-Mid-on.png 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 new file mode 100644 index 0000000..a41755a Binary files /dev/null and b/ise-display/images/main/light/light-button-off-prressed.png differ diff --git a/ise-display/images/main/light/light-button-off.png b/ise-display/images/main/light/light-button-off.png new file mode 100644 index 0000000..1e9ac73 Binary files /dev/null and b/ise-display/images/main/light/light-button-off.png 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 new file mode 100644 index 0000000..3926c29 Binary files /dev/null and b/ise-display/images/main/light/light-button-on-pressed.png differ diff --git a/ise-display/images/main/light/light-button-on.png b/ise-display/images/main/light/light-button-on.png new file mode 100644 index 0000000..31cc051 Binary files /dev/null and b/ise-display/images/main/light/light-button-on.png differ diff --git a/ise-display/images/main/light/light-state-0.png b/ise-display/images/main/light/light-state-0.png new file mode 100644 index 0000000..274097f Binary files /dev/null and b/ise-display/images/main/light/light-state-0.png differ diff --git a/ise-display/images/main/light/light-state-1.png b/ise-display/images/main/light/light-state-1.png new file mode 100644 index 0000000..04892a6 Binary files /dev/null and b/ise-display/images/main/light/light-state-1.png differ diff --git a/ise-display/images/main/light/light-state-2.png b/ise-display/images/main/light/light-state-2.png new file mode 100644 index 0000000..11b14c6 Binary files /dev/null and b/ise-display/images/main/light/light-state-2.png differ diff --git a/ise-display/images/main/light/light-state-3.png b/ise-display/images/main/light/light-state-3.png new file mode 100644 index 0000000..8378813 Binary files /dev/null and b/ise-display/images/main/light/light-state-3.png differ diff --git a/ise-display/images/main/lock/lock.png b/ise-display/images/main/lock/lock.png new file mode 100644 index 0000000..ab49ebd Binary files /dev/null and b/ise-display/images/main/lock/lock.png differ diff --git a/ise-display/images/main/lock/no lock.png b/ise-display/images/main/lock/no lock.png new file mode 100644 index 0000000..57e7394 Binary files /dev/null and b/ise-display/images/main/lock/no lock.png 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 new file mode 100644 index 0000000..63eb473 Binary files /dev/null and b/ise-display/images/main/master-light/Master-light-all.png 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 new file mode 100644 index 0000000..1f2dd8e Binary files /dev/null and b/ise-display/images/main/master-light/Master-light-state0.png 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 new file mode 100644 index 0000000..572ca51 Binary files /dev/null and b/ise-display/images/main/master-light/Master-light-state1.png 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 new file mode 100644 index 0000000..3feacc3 Binary files /dev/null and b/ise-display/images/main/master-light/Master-light-state2.png 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 new file mode 100644 index 0000000..60bf1a4 Binary files /dev/null and b/ise-display/images/main/master-light/Master-light-state3.png 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 new file mode 100644 index 0000000..fc2f69e Binary files /dev/null and b/ise-display/images/main/master-light/master-light-button-off-pressed.png 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 new file mode 100644 index 0000000..e3528e0 Binary files /dev/null and b/ise-display/images/main/master-light/master-light-button-off.png 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 new file mode 100644 index 0000000..56d4bec Binary files /dev/null and b/ise-display/images/main/master-light/master-light-button-on.png 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 new file mode 100644 index 0000000..5cce401 Binary files /dev/null and b/ise-display/images/main/master-light/master-light-button-pressed.png 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 new file mode 100644 index 0000000..6aaef2f Binary files /dev/null and b/ise-display/images/main/mode/Mode-cool-off-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-cool-off.png b/ise-display/images/main/mode/Mode-cool-off.png new file mode 100644 index 0000000..57b5072 Binary files /dev/null and b/ise-display/images/main/mode/Mode-cool-off.png 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 new file mode 100644 index 0000000..973dced Binary files /dev/null and b/ise-display/images/main/mode/Mode-cool-on-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-cool-on.png b/ise-display/images/main/mode/Mode-cool-on.png new file mode 100644 index 0000000..ce61894 Binary files /dev/null and b/ise-display/images/main/mode/Mode-cool-on.png 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 new file mode 100644 index 0000000..06c1932 Binary files /dev/null and b/ise-display/images/main/mode/Mode-dry-off-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-dry-off.png b/ise-display/images/main/mode/Mode-dry-off.png new file mode 100644 index 0000000..b4d86c2 Binary files /dev/null and b/ise-display/images/main/mode/Mode-dry-off.png 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 new file mode 100644 index 0000000..94c8c87 Binary files /dev/null and b/ise-display/images/main/mode/Mode-dry-on-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-dry-on.png b/ise-display/images/main/mode/Mode-dry-on.png new file mode 100644 index 0000000..486ae31 Binary files /dev/null and b/ise-display/images/main/mode/Mode-dry-on.png 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 new file mode 100644 index 0000000..3b8ea67 Binary files /dev/null and b/ise-display/images/main/mode/Mode-fan-off-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-fan-off.png b/ise-display/images/main/mode/Mode-fan-off.png new file mode 100644 index 0000000..fd3110e Binary files /dev/null and b/ise-display/images/main/mode/Mode-fan-off.png 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 new file mode 100644 index 0000000..b83978a Binary files /dev/null and b/ise-display/images/main/mode/Mode-fan-on-pressed.png differ diff --git a/ise-display/images/main/mode/Mode-fan-on.png b/ise-display/images/main/mode/Mode-fan-on.png new file mode 100644 index 0000000..9f950ad Binary files /dev/null and b/ise-display/images/main/mode/Mode-fan-on.png differ diff --git a/ise-display/images/main/pm/PM-off-pressed.png b/ise-display/images/main/pm/PM-off-pressed.png new file mode 100644 index 0000000..cf092a2 Binary files /dev/null and b/ise-display/images/main/pm/PM-off-pressed.png differ diff --git a/ise-display/images/main/pm/PM-off.png b/ise-display/images/main/pm/PM-off.png new file mode 100644 index 0000000..e277882 Binary files /dev/null and b/ise-display/images/main/pm/PM-off.png differ diff --git a/ise-display/images/main/pm/PM-on-pressed.png b/ise-display/images/main/pm/PM-on-pressed.png new file mode 100644 index 0000000..6ea9c11 Binary files /dev/null and b/ise-display/images/main/pm/PM-on-pressed.png differ diff --git a/ise-display/images/main/pm/PM-on.png b/ise-display/images/main/pm/PM-on.png new file mode 100644 index 0000000..791813f Binary files /dev/null and b/ise-display/images/main/pm/PM-on.png 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 new file mode 100644 index 0000000..8c3ff5a Binary files /dev/null and b/ise-display/images/main/temp-control/temp-min-pressed.png differ diff --git a/ise-display/images/main/temp-control/temp-min.png b/ise-display/images/main/temp-control/temp-min.png new file mode 100644 index 0000000..4bc9c43 Binary files /dev/null and b/ise-display/images/main/temp-control/temp-min.png 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 new file mode 100644 index 0000000..ae5fc98 Binary files /dev/null and b/ise-display/images/main/temp-control/temp-plus-pressed.png differ diff --git a/ise-display/images/main/temp-control/temp-plus.png b/ise-display/images/main/temp-control/temp-plus.png new file mode 100644 index 0000000..e944126 Binary files /dev/null and b/ise-display/images/main/temp-control/temp-plus.png 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 new file mode 100644 index 0000000..fc6b65a Binary files /dev/null and b/ise-display/images/main/toggle-all/toggle-all-off-pressed.png 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 new file mode 100644 index 0000000..cf0ae56 Binary files /dev/null and b/ise-display/images/main/toggle-all/toggle-all-off.png 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 new file mode 100644 index 0000000..c179c3f Binary files /dev/null and b/ise-display/images/main/toggle-all/toggle-all-on-pressed.png 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 new file mode 100644 index 0000000..d85c19a Binary files /dev/null and b/ise-display/images/main/toggle-all/toggle-all-on.png differ diff --git a/ise-display/images/pm/pm-minus-p.png b/ise-display/images/pm/pm-minus-p.png deleted file mode 100644 index f0e94aa..0000000 Binary files a/ise-display/images/pm/pm-minus-p.png and /dev/null differ diff --git a/ise-display/images/pm/pm-minus.png b/ise-display/images/pm/pm-minus.png deleted file mode 100644 index bbd6619..0000000 Binary files a/ise-display/images/pm/pm-minus.png and /dev/null differ diff --git a/ise-display/images/pm/pm-off-p.png b/ise-display/images/pm/pm-off-p.png deleted file mode 100644 index d216123..0000000 Binary files a/ise-display/images/pm/pm-off-p.png and /dev/null differ diff --git a/ise-display/images/pm/pm-off.png b/ise-display/images/pm/pm-off.png deleted file mode 100644 index 71922b3..0000000 Binary files a/ise-display/images/pm/pm-off.png and /dev/null differ diff --git a/ise-display/images/pm/pm-on-p.png b/ise-display/images/pm/pm-on-p.png deleted file mode 100644 index 0d546e4..0000000 Binary files a/ise-display/images/pm/pm-on-p.png and /dev/null differ diff --git a/ise-display/images/pm/pm-on.png b/ise-display/images/pm/pm-on.png deleted file mode 100644 index 9176fbf..0000000 Binary files a/ise-display/images/pm/pm-on.png and /dev/null differ diff --git a/ise-display/images/pm/pm-plus-p.png b/ise-display/images/pm/pm-plus-p.png deleted file mode 100644 index 83551b1..0000000 Binary files a/ise-display/images/pm/pm-plus-p.png and /dev/null differ diff --git a/ise-display/images/pm/pm-plus.png b/ise-display/images/pm/pm-plus.png deleted file mode 100644 index 40e40fa..0000000 Binary files a/ise-display/images/pm/pm-plus.png and /dev/null 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 new file mode 100644 index 0000000..e6f23ec Binary files /dev/null and b/ise-display/images/standby/AC/Standby-AC-off-pressed.png differ diff --git a/ise-display/images/standby/AC/Standby-AC-off.png b/ise-display/images/standby/AC/Standby-AC-off.png new file mode 100644 index 0000000..768a986 Binary files /dev/null and b/ise-display/images/standby/AC/Standby-AC-off.png 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 new file mode 100644 index 0000000..e06a8e0 Binary files /dev/null and b/ise-display/images/standby/AC/Standby-AC-on-pressed.png differ diff --git a/ise-display/images/standby/AC/Standby-AC-on.png b/ise-display/images/standby/AC/Standby-AC-on.png new file mode 100644 index 0000000..3db2828 Binary files /dev/null and b/ise-display/images/standby/AC/Standby-AC-on.png differ diff --git a/ise-display/images/standby/Master Switch-1.png b/ise-display/images/standby/Master Switch-1.png deleted file mode 100644 index 6802509..0000000 Binary files a/ise-display/images/standby/Master Switch-1.png and /dev/null differ diff --git a/ise-display/images/standby/Master Switch.png b/ise-display/images/standby/Master Switch.png deleted file mode 100644 index 639fbee..0000000 Binary files a/ise-display/images/standby/Master Switch.png and /dev/null 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 new file mode 100644 index 0000000..7ed59b4 Binary files /dev/null and b/ise-display/images/standby/PM/Standby-PM-off-pressed.png differ diff --git a/ise-display/images/standby/PM/Standby-PM-off.png b/ise-display/images/standby/PM/Standby-PM-off.png new file mode 100644 index 0000000..dff27a9 Binary files /dev/null and b/ise-display/images/standby/PM/Standby-PM-off.png 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 new file mode 100644 index 0000000..34efbef Binary files /dev/null and b/ise-display/images/standby/PM/Standby-PM-on-pressed.png differ diff --git a/ise-display/images/standby/PM/Standby-PM-on.png b/ise-display/images/standby/PM/Standby-PM-on.png new file mode 100644 index 0000000..abee3e1 Binary files /dev/null and b/ise-display/images/standby/PM/Standby-PM-on.png differ diff --git a/ise-display/images/standby/Standby-mode-bg.png b/ise-display/images/standby/Standby-mode-bg.png new file mode 100644 index 0000000..fdb1401 Binary files /dev/null and b/ise-display/images/standby/Standby-mode-bg.png differ diff --git a/ise-display/images/standby/Standby-mode-ref.png b/ise-display/images/standby/Standby-mode-ref.png new file mode 100644 index 0000000..b6f7005 Binary files /dev/null and b/ise-display/images/standby/Standby-mode-ref.png 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 new file mode 100644 index 0000000..d0aadfd Binary files /dev/null and b/ise-display/images/standby/adv/Standby-adv-off-pressed.png differ diff --git a/ise-display/images/standby/adv/Standby-adv-off.png b/ise-display/images/standby/adv/Standby-adv-off.png new file mode 100644 index 0000000..6855f2b Binary files /dev/null and b/ise-display/images/standby/adv/Standby-adv-off.png 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 new file mode 100644 index 0000000..266fa2e Binary files /dev/null and b/ise-display/images/standby/adv/Standby-adv-on-pressed.png differ diff --git a/ise-display/images/standby/adv/Standby-adv-on.png b/ise-display/images/standby/adv/Standby-adv-on.png new file mode 100644 index 0000000..b0918ca Binary files /dev/null and b/ise-display/images/standby/adv/Standby-adv-on.png differ diff --git a/ise-display/images/standby/bg.png b/ise-display/images/standby/bg.png deleted file mode 100644 index 1a8590f..0000000 Binary files a/ise-display/images/standby/bg.png and /dev/null 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 new file mode 100644 index 0000000..6ac8f56 Binary files /dev/null and b/ise-display/images/standby/light/Standby-light-off-pressed.png differ diff --git a/ise-display/images/standby/light/Standby-light-off.png b/ise-display/images/standby/light/Standby-light-off.png new file mode 100644 index 0000000..bbff71a Binary files /dev/null and b/ise-display/images/standby/light/Standby-light-off.png 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 new file mode 100644 index 0000000..8efe17e Binary files /dev/null and b/ise-display/images/standby/light/Standby-light-on-pressed.png differ diff --git a/ise-display/images/standby/light/Standby-light-on.png b/ise-display/images/standby/light/Standby-light-on.png new file mode 100644 index 0000000..58df375 Binary files /dev/null and b/ise-display/images/standby/light/Standby-light-on.png differ diff --git a/ise-display/images/standby/ref.png b/ise-display/images/standby/ref.png deleted file mode 100644 index 8e02b65..0000000 Binary files a/ise-display/images/standby/ref.png and /dev/null differ diff --git a/ise-display/images/standby/s-ac-off-p.png b/ise-display/images/standby/s-ac-off-p.png deleted file mode 100644 index d95a4c2..0000000 Binary files a/ise-display/images/standby/s-ac-off-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-ac-off.png b/ise-display/images/standby/s-ac-off.png deleted file mode 100644 index 0fa577d..0000000 Binary files a/ise-display/images/standby/s-ac-off.png and /dev/null differ diff --git a/ise-display/images/standby/s-ac-on-p.png b/ise-display/images/standby/s-ac-on-p.png deleted file mode 100644 index 6d5f822..0000000 Binary files a/ise-display/images/standby/s-ac-on-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-ac-on.png b/ise-display/images/standby/s-ac-on.png deleted file mode 100644 index 9607006..0000000 Binary files a/ise-display/images/standby/s-ac-on.png and /dev/null differ diff --git a/ise-display/images/standby/s-dashboard-p.png b/ise-display/images/standby/s-dashboard-p.png deleted file mode 100644 index 6802509..0000000 Binary files a/ise-display/images/standby/s-dashboard-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-dashboard.png b/ise-display/images/standby/s-dashboard.png deleted file mode 100644 index 639fbee..0000000 Binary files a/ise-display/images/standby/s-dashboard.png and /dev/null differ diff --git a/ise-display/images/standby/s-light-off-p.png b/ise-display/images/standby/s-light-off-p.png deleted file mode 100644 index ff2bbd6..0000000 Binary files a/ise-display/images/standby/s-light-off-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-light-off.png b/ise-display/images/standby/s-light-off.png deleted file mode 100644 index 139e29b..0000000 Binary files a/ise-display/images/standby/s-light-off.png and /dev/null differ diff --git a/ise-display/images/standby/s-light-on-p.png b/ise-display/images/standby/s-light-on-p.png deleted file mode 100644 index 90529cc..0000000 Binary files a/ise-display/images/standby/s-light-on-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-light-on.png b/ise-display/images/standby/s-light-on.png deleted file mode 100644 index 0f5c80a..0000000 Binary files a/ise-display/images/standby/s-light-on.png and /dev/null 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 deleted file mode 100644 index 2cab491..0000000 Binary files a/ise-display/images/standby/s-open-all-off-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-open-all-off.png b/ise-display/images/standby/s-open-all-off.png deleted file mode 100644 index 8309e14..0000000 Binary files a/ise-display/images/standby/s-open-all-off.png and /dev/null 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 deleted file mode 100644 index 34cf40f..0000000 Binary files a/ise-display/images/standby/s-open-all-on-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-open-all-on.png b/ise-display/images/standby/s-open-all-on.png deleted file mode 100644 index 833246f..0000000 Binary files a/ise-display/images/standby/s-open-all-on.png and /dev/null differ diff --git a/ise-display/images/standby/s-pm-off-p.png b/ise-display/images/standby/s-pm-off-p.png deleted file mode 100644 index 7f2fc06..0000000 Binary files a/ise-display/images/standby/s-pm-off-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-pm-off.png b/ise-display/images/standby/s-pm-off.png deleted file mode 100644 index 44a3063..0000000 Binary files a/ise-display/images/standby/s-pm-off.png and /dev/null differ diff --git a/ise-display/images/standby/s-pm-on-p.png b/ise-display/images/standby/s-pm-on-p.png deleted file mode 100644 index be813d0..0000000 Binary files a/ise-display/images/standby/s-pm-on-p.png and /dev/null differ diff --git a/ise-display/images/standby/s-pm-on.png b/ise-display/images/standby/s-pm-on.png deleted file mode 100644 index c42ff85..0000000 Binary files a/ise-display/images/standby/s-pm-on.png and /dev/null 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 new file mode 100644 index 0000000..f71e161 Binary files /dev/null and b/ise-display/images/standby/toggle/Standby-toggle-off-pressed.png differ diff --git a/ise-display/images/standby/toggle/Standby-toggle-off.png b/ise-display/images/standby/toggle/Standby-toggle-off.png new file mode 100644 index 0000000..c2edacd Binary files /dev/null and b/ise-display/images/standby/toggle/Standby-toggle-off.png 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 new file mode 100644 index 0000000..3061724 Binary files /dev/null and b/ise-display/images/standby/toggle/Standby-toggle-on-pressed.png differ diff --git a/ise-display/images/standby/toggle/Standby-toggle-on.png b/ise-display/images/standby/toggle/Standby-toggle-on.png new file mode 100644 index 0000000..54d423a Binary files /dev/null and b/ise-display/images/standby/toggle/Standby-toggle-on.png differ diff --git a/ise-display/ise-display-prod.HMI b/ise-display/ise-display-v2.HMI similarity index 84% rename from ise-display/ise-display-prod.HMI rename to ise-display/ise-display-v2.HMI index 16c9582..5e71a9f 100644 Binary files a/ise-display/ise-display-prod.HMI and b/ise-display/ise-display-v2.HMI differ diff --git a/ise-display/ise-display-v2.tft b/ise-display/ise-display-v2.tft new file mode 100644 index 0000000..8cf3fec Binary files /dev/null and b/ise-display/ise-display-v2.tft differ diff --git a/ise-display/old-ise-display-v2.tft b/ise-display/old-ise-display-v2.tft new file mode 100644 index 0000000..f64401e Binary files /dev/null and b/ise-display/old-ise-display-v2.tft differ diff --git a/platformio.ini b/platformio.ini index 700cbce..5d21a24 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,8 +12,6 @@ platform = espressif32 board = wt32-eth01 framework = arduino -lib_deps = siwats/ESPMegaPROR3@^2.3.7 +lib_deps = siwats/ESPMegaPROR3@^2.9.4 monitor_speed = 115200 -build_flags = -DCORE_DEBUG_LEVEL=0 -upload_port = COM4 -monitor_port = COM4 \ No newline at end of file +build_flags = -DCORE_DEBUG_LEVEL=0 -DSW_VERSION='"ise-final-1.3"' -DBOARD_MODEL='"ESPMegaPRO R3.3b"' \ No newline at end of file diff --git a/src/ise_display.cpp b/src/ise_display.cpp index fa3c2f1..097e3c7 100644 --- a/src/ise_display.cpp +++ b/src/ise_display.cpp @@ -5,27 +5,30 @@ 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) +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) { + 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 = 1; // initialized to cool by default - this->pm_fan_speed = 10; - //remote_pm_fan_speed->setValue(pm_fan_speed); + // 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->ac_fan_speed = 0; this->ac_mode = 0; this->ac_temperature = 25; @@ -33,33 +36,28 @@ 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(); - // 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); + // 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 } - else{ - this->climateCard_york->setState(ac_mode, ac_fan_speed, ac_temperature); - } - } void ISEDisplay::loop() { @@ -67,55 +65,118 @@ void ISEDisplay::loop() // If there is data, process the data recieveSerialCommand(); - // Update the time since the last screen update using millis() + // 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"); + } - // u_int32_t current_time = 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 - // 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"); - // } - // } + 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"); } 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_STANDBY_OPEN_ALL_TOGGLE: + case COMPONENT_OBJ_STANDBY_LOGO: if (touch_type != TOUCH_TYPE_RELEASE) break; - // 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); + break; + case COMPONENT_OBJ_STANDBY_BTN_OPEN_ALL_TOGGLE: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + //allToggleStandby(); this->jumpToPage(2); // the function of the button is to open the dashboard from standby break; - case COMPONENT_STANDBY_LIGHT_TOGGLE: + case COMPONENT_OBJ_STANDBY_BTN_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_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? + case COMPONENT_OBJ_STANDBY_BTN_AC_TOGGLE: 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_STANDBY_PM_TOGGLE: + case COMPONENT_OBJ_STANDBY_BTN_PM_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; togglePMStandby(); @@ -124,151 +185,245 @@ void ISEDisplay::handleTouch(uint8_t page, uint8_t component, uint8_t touch_type break; } } - else if (page == PAGE_DASHBOARD) { switch (component) { - 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(); + case COMPONENT_OBJ_DASHBOARD_NUM_AC_TEMP: break; - // TODOlater : can't this be done better with array lookup? - case COMPONENT_LIGHT_MASTER_LEVEL1_TOUCHPOINT: + case COMPONENT_OBJ_DASHBOARD_BTN_AC_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - for (uint8_t i = 1; i <= 4; i++) + + // if ac_lock is true do nothing + if (this->ac_lock_state == true) { - setLightLevel(i, 1); + ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); + break; } + + toggleAC(); break; - case COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT: + case COMPONENT_OBJ_DASHBOARD_BTN_AC_MODE: if (touch_type != TOUCH_TYPE_RELEASE) break; - for (uint8_t i = 1; i <= 4; i++) + // if ac_lock is true do nothing + if (this->ac_lock_state == true) { - setLightLevel(i, 2); + ESP_LOGI("ISEDisplay", "AC lock is on, do nothing"); + break; } + changeUserACmode(); break; - case COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT: + case COMPONENT_OBJ_DASHBOARD_BTN_AC_FAN_SPEED: if (touch_type != TOUCH_TYPE_RELEASE) break; - for (uint8_t i = 1; i <= 4; i++) + // if ac_lock is true do nothing + if (this->ac_lock_state == true) { - setLightLevel(i, 3); + 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_LIGHT_ROW1_SLIDER: + case COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_MINUS: if (touch_type != TOUCH_TYPE_RELEASE) break; - lightLevelRow1 = this->getNumber("light_r1_slide.val"); - toggleSliderLight(1, lightLevelRow1); + // 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_LIGHT_ROW2_SLIDER: + case COMPONENT_OBJ_DASHBOARD_BTN_AC_TEMP_PLUS: if (touch_type != TOUCH_TYPE_RELEASE) break; - lightLevelRow2 = this->getNumber("light_r2_slide.val"); - toggleSliderLight(2, lightLevelRow2); + // 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_LIGHT_ROW3_SLIDER: + case COMPONENT_OBJ_DASHBOARD_BTN_PM_TOGGLE: if (touch_type != TOUCH_TYPE_RELEASE) break; - lightLevelRow3 = this->getNumber("light_r3_slide.val"); - toggleSliderLight(3, lightLevelRow3); - break; - case COMPONENT_LIGHT_ROW4_SLIDER: - if (touch_type != TOUCH_TYPE_RELEASE) + // if pm_lock is true do nothing + if (this->pm_lock_state == true) + { + ESP_LOGI("ISEDisplay", "PM lock is on, do nothing"); break; - lightLevelRow4 = this->getNumber("light_r4_slide.val"); - toggleSliderLight(4, lightLevelRow4); + } + togglePM(); break; - case COMPONENT_LIGHT_ROW1_SWITCH: + 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_LIGHT_ROW2_SWITCH: + case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW2: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(2); break; - case COMPONENT_LIGHT_ROW3_SWITCH: + case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW3: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(3); break; - case COMPONENT_LIGHT_ROW4_SWITCH: + case COMPONENT_OBJ_DASHBOARD_BTN_LIGHT_ROW4: if (touch_type != TOUCH_TYPE_RELEASE) break; toggleLightIndividual(4); break; - // 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; - toggleAC(); + case COMPONENT_OBJ_DASHBOARD_TIMER_TEN_SEC: break; - case COMPONENT_AC_MODE: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - changeUserACmode(); + case COMPONENT_OBJ_DASHBOARD_VAL_TIME_PAST: break; - case COMPONENT_AC_FAN_SPEED: - if (touch_type != TOUCH_TYPE_RELEASE) - break; - 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(); + case COMPONENT_OBJ_DASHBOARD_TIMER_INACTIVE_CHECK: break; - case COMPONENT_AC_TEMP_DOWN_BUTTON: + case COMPONENT_OBJ_DASHBOARD_BTN_SYSTEM_TOGGLE: 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(); + // implement system toggle + // check light on or off + // check ac on or off + // check pm on or off + toggleSystem(); break; - case COMPONENT_AC_TEMP_UP_BUTTON: + case COMPONENT_OBJ_DASHBOARD_BTN_PM_SPEED: 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(); + // implement pm speed change + changePMfanspeed(); break; - case COMPONENT_PM_TOGGLE_BUTTON: + case COMPONENT_OBJ_DASHBOARD_BTN_PM_MODE: if (touch_type != TOUCH_TYPE_RELEASE) break; - togglePM(); + // implement pm mode change 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(); + case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_MASTER_LIGHT: break; - case COMPONENT_PM_FAN_SPEED_INCREASE: + case COMPONENT_OBJ_DASHBOARD_LOGO: + jumpToPage(1); + break; + case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_PM_LOCK: 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(); + // 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: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + toggleLightGroupState(); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV1: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightGroupState(1); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV2: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightGroupState(2); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_MASTER_LV3: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightGroupState(3); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV1: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(1, 1); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV2: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(1, 2); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW1_LV3: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(1, 3); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV1: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(2, 1); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV2: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(2, 2); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW2_LV3: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(2, 3); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV1: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(3, 1); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV2: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(3, 2); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW3_LV3: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(3, 3); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV1: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(4, 1); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV2: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(4, 2); + break; + case COMPONENT_OBJ_DASHBOARD_HOTSPOT_LIGHT_ROW4_LV3: + if (touch_type != TOUCH_TYPE_RELEASE) + break; + setLightLevel(4, 3); + break; + case COMPONENT_OBJ_DASHBOARD_HOLDER_PIC_C_DEGREE: break; default: break; @@ -286,25 +441,27 @@ 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 } } @@ -315,115 +472,38 @@ void ISEDisplay::handlePWMChange(uint8_t pin, bool state, uint16_t value) } void ISEDisplay::updateDateTimeText(rtctime_t time) { - if (!this->takeSerialMutex()) - return; - // Send the time to the display + if (this->currentPage == 1) + { + 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; - 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); +// void ISEDisplay::updateTempOutside(float temp_outside) +// { +// // TODO : use remotevar to get PM2.5 data from appdaemon and update the display - 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(); -} +// // 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); @@ -455,32 +535,129 @@ 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 ? "1" : "0"); + 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"); } void ISEDisplay::setACstate(uint8_t ac_fan_speed, uint8_t ac_mode, uint8_t ac_temperature) { - ESP_LOGI("ISEDisplay", "Setting AC state: = fan speed: %d, mode: %d, temperature: %d", ac_fan_speed, ac_mode, 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); - //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); + 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; } - else{ - this->climateCard_york->setState(ac_mode, 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; } - // updateACState(); + 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(); } +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 @@ -491,6 +668,17 @@ 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() { @@ -507,12 +695,41 @@ void ISEDisplay::toggleLightGroupStateStandby() void ISEDisplay::togglePM() { // Get the current group state - bool state = strcmp(pm_switch->getValue(), "on") == 0; - ESP_LOGI("ISEDisplay", "Current PM state: %d", 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); // Toggle the state - pm_switch->setValue(state ? "off" : "on"); - ESP_LOGI("ISEDisplay", "New PM state: %d", state); - //updateAirPurifierState(); + 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(); } void ISEDisplay::togglePMStandby() { @@ -522,63 +739,126 @@ 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(); - // get fan speed and temperature - uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); - uint8_t temperature = this->climateCard_daikin->getTemperature(); - + // uint8_t mode = this->climateCard_daikin->getMode(); + uint8_t mode = this->ac_mode; 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) - { - ESP_LOGI("ISEDisplay", " User mode: %d", user_mode); - setACstate(fan_speed, user_mode, temperature); - } - else - { - 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); - } -} -void ISEDisplay::changeUserACmode() -{ - // Get the current group state - uint8_t mode = this->climateCard_daikin->getMode(); - ESP_LOGI("ISEDisplay", "Current actual AC mode: %d", mode); - // Toggle the state - // user mode alternate between 1 and 2 - ESP_LOGI("ISEDisplay", "User mode BEFORE: %d", user_mode); - 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); + mode = 0; + ESP_LOGI("ISEDisplay", "change actual AC mode to off: %d", mode); } 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; } - updateuserACmode(); // call to update mode part of the display seperately + // 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(); + ESP_LOGI("ISEDisplay", "Current actual AC mode: %d", mode); + // Toggle the state + // user mode alternate between 1, 2, and 3 + 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; + } + 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(); + } + + // 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(); } void ISEDisplay::setLightLevel(uint8_t row, uint8_t level) { // Set the light level // this->outputCard->setValue(row, level); - uint8_t primary_pin = *(light_array + 2*(row - 1)); - uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1); + + // 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); bool primary = false; bool secondary = false; @@ -588,36 +868,45 @@ 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; - - //lightLevel = this->outputCard->getValue(row); - uint8_t primary_pin = *(light_array + 2*(row - 1)); - uint8_t secondary_pin = *(light_array + 2*(row - 1) + 1); + 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); 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; @@ -634,19 +923,20 @@ 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) @@ -659,7 +949,6 @@ lightPosition ISEDisplay::getRowCol(uint8_t pin){ return position; } - void ISEDisplay::updateLightGroupStatePageStandby() { // Calculate the state @@ -669,11 +958,11 @@ void ISEDisplay::updateLightGroupStatePageStandby() return; this->displayAdapter->print("s_light_toggle.pic="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON : COMPONENT_STANDBY_LIGHT_PIC_OFF); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON : COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF); this->sendStopBytes(); this->displayAdapter->print("s_light_toggle.pic2="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_LIGHT_PIC_ON_PRESSED : COMPONENT_STANDBY_LIGHT_PIC_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_LIGHT_TOGGLE_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); @@ -681,50 +970,115 @@ void ISEDisplay::updateLightGroupStatePageStandby() void ISEDisplay::updateLightGroupStatePageDashboard() { // Calculate the state - bool state = calculateLightGroupState(); + bool state_master = calculateLightGroupState(); + uint8_t firstState = getLightLevel(1); + bool allMatch = true; + // Send the state to the display if (!this->takeSerialMutex()) return; - this->displayAdapter->print("light_master.pic="); - this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON : COMPONENT_LIGHT_MASTER_OFF); + 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->sendStopBytes(); - this->displayAdapter->print("light_master.pic2="); - this->displayAdapter->print(state ? COMPONENT_LIGHT_MASTER_ON_PRESSED : COMPONENT_LIGHT_MASTER_OFF_PRESSED); + 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->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_LIGHT_LEVEL_0); + 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->sendStopBytes(); break; case 1: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_1); + 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->sendStopBytes(); break; case 2: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_2); + 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->sendStopBytes(); break; case 3: this->displayAdapter->print("light_row"); this->displayAdapter->print(i); this->displayAdapter->print(".pic="); - this->displayAdapter->print(COMPONENT_LIGHT_LEVEL_3); + 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->sendStopBytes(); break; default: @@ -732,8 +1086,57 @@ 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 @@ -750,7 +1153,107 @@ 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 @@ -766,48 +1269,36 @@ void ISEDisplay::toggleLightIndividual(uint8_t row) // Set the state setLightLevel(row, state); } -void ISEDisplay::toggleSliderLight(uint8_t row, uint8_t lightLevel) +void ISEDisplay::updateSystemtoggle() { - // Get the current state - uint8_t state = 0; + 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(); - 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); + 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(); } 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_PM_PIC_ON : COMPONENT_STANDBY_PM_PIC_OFF); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_PM_TOGGLE_ON : COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF); this->sendStopBytes(); this->displayAdapter->print("s_pm_toggle.pic2="); - this->displayAdapter->print(state ? COMPONENT_STANDBY_PM_PIC_ON_PRESSED : COMPONENT_STANDBY_PM_PIC_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_STANDBY_PIC_PM_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_PM_TOGGLE_OFF_PRESSED); this->sendStopBytes(); this->giveSerialMutex(); @@ -815,69 +1306,206 @@ 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 = (int) atof(remote_pm_fan_speed->getValue()); + pm_fan_speed = this->pm_fan_speed; + ESP_LOGI("ISEDisplay", "Updating air purifier fan speed to: %d", pm_fan_speed); // Send the state to the display if (!this->takeSerialMutex()) - return; + return; this->displayAdapter->print("pm_sw.pic="); - this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON : COMPONENT_PM_TOGGLE_PIC_OFF); + this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON : COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF); this->sendStopBytes(); this->displayAdapter->print("pm_sw.pic2="); - this->displayAdapter->print(state ? COMPONENT_PM_TOGGLE_PIC_ON_PRESSED : COMPONENT_PM_TOGGLE_PIC_OFF_PRESSED); + this->displayAdapter->print(state ? COMPONENT_DASHBOARD_PIC_PM_TOGGLE_ON_PRESSED : COMPONENT_DASHBOARD_PIC_PM_TOGGLE_OFF_PRESSED); this->sendStopBytes(); - this->displayAdapter->print("pm_speed.val="); - this->displayAdapter->print(pm_fan_speed); - // this->displayAdapter->print("\""); + this->displayAdapter->print("pm_lock.pic="); + this->displayAdapter->print(this->pm_lock_state ? COMPONENT_DASHBOARD_PIC_LOCK : COMPONENT_DASHBOARD_PIC_UNLOCK); this->sendStopBytes(); - this->displayAdapter->print("pm_speed.pco="); - this->displayAdapter->print(state ? 34486 : 33841); + 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->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: - 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(); + 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(); + } break; case 2: - 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(); + 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(); + } break; default: break; @@ -886,43 +1514,96 @@ void ISEDisplay::updateuserACmode() } void ISEDisplay::updateACfanSpeed() { - uint8_t fan_speed = this->climateCard_daikin->getFanSpeed(); + // 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; + ESP_LOGI("ISEDisplay", "updating display AC fan speed to: %d", fan_speed); if (!this->takeSerialMutex()) return; switch (fan_speed) { case 0: - 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(); + 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(); + } break; case 1: - 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(); + 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(); + } break; case 2: - 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(); + 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(); + } break; case 3: - 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(); + 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(); + } break; default: break; @@ -934,9 +1615,14 @@ 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(); - if(currentPage != 1){ + // 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) + { if (!this->takeSerialMutex()) return; @@ -944,40 +1630,41 @@ void ISEDisplay::updateACState() if (mode == 0) { this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(33841); + this->displayAdapter->print(COMPONENT_COLOR_INACTIVE_GREY); this->sendStopBytes(); - this->displayAdapter->print("ac_temp.pic="); - this->displayAdapter->print(COMPONENT_AC_STATUS_OFF); + this->displayAdapter->print("c_degree.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_DEGREE_C_OFF); this->sendStopBytes(); } else { this->displayAdapter->print("ac_temp.pco="); - this->displayAdapter->print(34486); + this->displayAdapter->print(COMPONENT_COLOR_ACTIVE_BLUE); this->sendStopBytes(); - this->displayAdapter->print("ac_temp.pic="); - this->displayAdapter->print(COMPONENT_AC_STATUS_ON); + this->displayAdapter->print("c_degree.pic="); + this->displayAdapter->print(COMPONENT_DASHBOARD_PIC_DEGREE_C_ON); this->sendStopBytes(); - - user_mode = mode; } this->displayAdapter->print("ac_sw.pic="); - this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON : COMPONENT_AC_TOGGLE_PIC_OFF); + this->displayAdapter->print(mode != 0 ? COMPONENT_DASHBOARD_PIC_AC_TOGGLE_ON : COMPONENT_DASHBOARD_PIC_AC_TOGGLE_OFF); this->sendStopBytes(); this->displayAdapter->print("ac_sw.pic2="); - this->displayAdapter->print(mode != 0 ? COMPONENT_AC_TOGGLE_PIC_ON_PRESSED : COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED); + 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->sendStopBytes(); this->giveSerialMutex(); updateuserACmode(); updateACfanSpeed(); - + if (!this->takeSerialMutex()) return; - + this->displayAdapter->print("ac_temp.val="); this->displayAdapter->print(temperature); // this->displayAdapter->print("\""); @@ -990,16 +1677,15 @@ void ISEDisplay::updateACState() return; this->displayAdapter->print("s_ac_toggle.pic="); - this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON : COMPONENT_STANDBY_AC_PIC_OFF); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_PIC_AC_TOGGLE_ON : COMPONENT_STANDBY_PIC_AC_TOGGLE_OFF); this->sendStopBytes(); this->displayAdapter->print("s_ac_toggle.pic2="); - this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_AC_PIC_ON_PRESSED : COMPONENT_STANDBY_AC_PIC_OFF_PRESSED); + this->displayAdapter->print(mode != 0 ? COMPONENT_STANDBY_PIC_AC_TOGGLE_ON_PRESSED : COMPONENT_STANDBY_PIC_AC_TOGGLE_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 ca985a5..9be7e1b 100644 --- a/src/ise_display.hpp +++ b/src/ise_display.hpp @@ -2,6 +2,7 @@ #include "ise_display_definitions.hpp" #include +#include #include #include #include @@ -24,11 +25,13 @@ 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); + 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 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); @@ -54,6 +57,7 @@ class ISEDisplay : public ESPMegaDisplay { DigitalOutputCard *outputCard; ClimateCard *climateCard_daikin; ClimateCard *climateCard_york; + ESPMegaIoT *iot; const uint8_t *light_array; uint8_t row; @@ -61,12 +65,20 @@ 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; @@ -74,18 +86,28 @@ 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 216181a..19a849b 100644 --- a/src/ise_display_definitions.hpp +++ b/src/ise_display_definitions.hpp @@ -1,13 +1,6 @@ #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 @@ -30,6 +23,13 @@ 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,6 +66,10 @@ 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 @@ -79,178 +83,463 @@ 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 COMPONENT_LOGO_BOOT 1 -#define COMPONENT_LOGO_BOOT_VID 1 +#define OLD_COMP_LOGO_BOOT 1 +#define OLD_COMP_LOGO_BOOT_VID 1 //boot background -#define COMPONENT_BACKGROUND_BOOT_PIC 43 +#define OLD_COMP_BACKGROUND_BOOT_PIC 43 //standby page object id -#define COMPONENT_LOGO_STANDBY 1 -#define COMPONENT_LOGO_STANDBY_VID 2 +#define OLD_COMP_LOGO_STANDBY 1 +#define OLD_COMP_LOGO_STANDBY_VID 2 -#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE 2 -#define COMPONENT_STANDBY_LIGHT_TOGGLE 3 -#define COMPONENT_STANDBY_AC_TOGGLE 4 -#define COMPONENT_STANDBY_PM_TOGGLE 5 +#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 //text -#define COMPONENT_STANDBY_TIME_TXT 6 -#define COMPONENT_STANDBY_DATE_TXT 7 -#define COMPONENT_STANDBY_OUTSIDE_TEMP_TXT 8 +#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_TIMER 9 -#define COMPONENT_STANDBY_WEATHER_ICON 10 +#define OLD_COMP_STANDBY_TIMER 9 +#define OLD_COMP_STANDBY_WEATHER_ICON 10 //standby page picture id -#define COMPONENT_BACKGROUND_PIC 44 -#define COMPONENT_BACKGROUND_REFERENCE_PIC 45 +#define OLD_COMP_BACKGROUND_PIC 44 +#define OLD_COMP_BACKGROUND_REFERENCE_PIC 45 -#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF 46 -#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_OFF_PRESSED 47 -#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON 48 -#define COMPONENT_STANDBY_OPEN_ALL_TOGGLE_PIC_ON_PRESSED 49 +#define 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_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_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_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_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_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_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_REFERENCE_BACKGROUND_PIC 62 +#define OLD_COMP_REFERENCE_BACKGROUND_PIC 62 //dashboard page //dashboard page object id -#define COMPONENT_AC_TOGGLE_BUTTON 3 -#define COMPONENT_AC_MODE 4 -#define COMPONENT_AC_FAN_SPEED 5 -#define COMPONENT_AC_TEMP_DOWN_BUTTON 6 -#define COMPONENT_AC_TEMP_UP_BUTTON 7 +#define 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_PM_TOGGLE_BUTTON 8 -#define COMPONENT_PM_FAN_SPEED_DECREASE 9 -#define COMPONENT_PM_FAN_SPEED_INCREASE 10 +#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_INSIDE_TXT 11 -#define COMPONENT_PM_OUTSIDE_TXT 12 +#define OLD_COMP_PM_INSIDE_TXT 11 +#define OLD_COMP_PM_OUTSIDE_TXT 12 -#define COMPONENT_LIGHT_MASTER_BUTTON 13 -#define COMPONENT_LIGHT_ROW1_PIC_PLACEHOLDER 14 -#define COMPONENT_LIGHT_ROW2_PIC_PLACEHOLDER 15 -#define COMPONENT_LIGHT_ROW3_PIC_PLACEHOLDER 16 -#define COMPONENT_LIGHT_ROW4_PIC_PLACEHOLDER 17 +#define 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_LEVEL1_TOUCHPOINT 18 -#define COMPONENT_LIGHT_MASTER_LEVEL2_TOUCHPOINT 19 -#define COMPONENT_LIGHT_MASTER_LEVEL3_TOUCHPOINT 20 +#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_DASHBOARD_TIME_TXT 21 -#define COMPONENT_DASHBOARD_DATE_TXT 22 -#define COMPONENT_DASHBOARD_OUTSIDE_TEMP_TXT 23 +#define OLD_COMP_DASHBOARD_TIME_TXT 21 +#define OLD_COMP_DASHBOARD_DATE_TXT 22 +#define OLD_COMP_DASHBOARD_OUTSIDE_TEMP_TXT 23 -#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_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_SWITCH 28 -#define COMPONENT_LIGHT_ROW2_SWITCH 29 -#define COMPONENT_LIGHT_ROW3_SWITCH 30 -#define COMPONENT_LIGHT_ROW4_SWITCH 31 +#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_DASHBOARD_WEATHER_ICON 32 +#define OLD_COMP_DASHBOARD_WEATHER_ICON 32 //dashboard page picture id -#define COMPONENT_DASHBOARD_REFERENCE_BACKGROUND_PIC 0 -#define COMPONENT_DASHBOARD_BACKGROUND_PIC 1 -#define COMPONENT_DASHBOARD_BACKGROUND_VARIANT_PIC 2 +#define OLD_COMP_DASHBOARD_REFERENCE_BACKGROUND_PIC 0 +#define OLD_COMP_DASHBOARD_BACKGROUND_PIC 1 +#define OLD_COMP_DASHBOARD_BACKGROUND_VARIANT_PIC 2 //AC on/off -#define COMPONENT_AC_TOGGLE_PIC_OFF 3 -#define COMPONENT_AC_TOGGLE_PIC_OFF_PRESSED 4 -#define COMPONENT_AC_TOGGLE_PIC_ON 5 -#define COMPONENT_AC_TOGGLE_PIC_ON_PRESSED 6 -#define COMPONENT_AC_TEMP_DOWN_PIC 7 -#define COMPONENT_AC_TEMP_DOWN_PIC_PRESSED 8 -#define COMPONENT_AC_TEMP_UP_PIC 9 -#define COMPONENT_AC_TEMP_UP_PIC_PRESSED 10 +#define 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_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_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_MODE_DRY_PIC 19 -#define COMPONENT_AC_MODE_DRY_PIC_PRESSED 20 -#define COMPONENT_AC_MODE_COOL_PIC 21 -#define COMPONENT_AC_MODE_COOL_PIC_PRESSED 22 -#define COMPONENT_AC_MODE_FAN_PIC 23 -#define COMPONENT_AC_MODE_FAN_PIC_PRESSED 24 +#define 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 //pm; air purifier -#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_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_FAN_SPEED_DECREASE_PIC 29 -#define COMPONENT_PM_FAN_SPEED_DECREASE_PIC_PRESSED 30 -#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC 31 -#define COMPONENT_PM_FAN_SPEED_INCREASE_PIC_PRESSED 32 +#define 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 //AC status indicator -#define COMPONENT_AC_STATUS_OFF 33 -#define COMPONENT_AC_STATUS_ON 34 +#define OLD_COMP_AC_STATUS_OFF 33 +#define OLD_COMP_AC_STATUS_ON 34 //light master -#define COMPONENT_LIGHT_MASTER_OFF 35 -#define COMPONENT_LIGHT_MASTER_OFF_PRESSED 36 -#define COMPONENT_LIGHT_MASTER_ON 37 -#define COMPONENT_LIGHT_MASTER_ON_PRESSED 38 +#define 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 //light level component -#define COMPONENT_LIGHT_LEVEL_0 39 -#define COMPONENT_LIGHT_LEVEL_1 40 -#define COMPONENT_LIGHT_LEVEL_2 41 -#define COMPONENT_LIGHT_LEVEL_3 42 +#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 //weather icon legend -#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 +#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 //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 ff31584..fc54fcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,15 +1,50 @@ #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(); -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"}; + + +// Light Configuration uint8_t row = 4; uint8_t column = 2; const uint8_t light_array[4][2] = { @@ -18,10 +53,14 @@ 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 = 32, - .min_temperature = 16, + .max_temperature = DAIKIN_MAX_TEMP, + .min_temperature = DAIKIN_MIN_TEMP, .modes = 4, .mode_names = mode_names_daikin, .fan_speeds = 4, @@ -29,8 +68,8 @@ AirConditioner ac_daikin = { .getInfraredCode = &getInfraredCode_daikin}; AirConditioner ac_york = { - .max_temperature = 30, - .min_temperature = 18, + .max_temperature = YORK_MAX_TEMP, + .min_temperature = YORK_MIN_TEMP, .modes = 3, .mode_names = mode_names_york, .fan_speeds = 4, @@ -43,18 +82,453 @@ 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() @@ -69,384 +543,4 @@ 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 aad6fa7..6dbc3e0 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -4,6 +4,8 @@ SET_LOOP_TASK_STACK_SIZE(32*1024); #include #include #include +#include +#include @@ -21,9 +23,19 @@ 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 8 +#define AIR_CONDITIONER_YORK_IR_PIN 15 #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(); @@ -37,9 +49,15 @@ 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(); @@ -48,4 +66,7 @@ void pm25inupdatedisplay(char* value); void tempoutupdatedisplay(char* value); void weatherupdatedisplay(char* value); void pmfanspeedupdatedisplay(char* value); -void pmswitchupdatedisplay(char* value); \ No newline at end of file +void pmlockupdatedisplay(char* value); +void aclockupdatedisplay(char* value); +void pmswitchupdatedisplay(char* value); +float adc2current(uint16_t adc_val); \ No newline at end of file