From b97c00605ec08c93832768012aeda53cae76696b Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 2 Oct 2023 16:04:44 +0700 Subject: [PATCH] update user code --- cud_display/cud_display.HMI | Bin 11984925 -> 11984925 bytes src/user_code.cpp | 84 ++++++++++++++++++++++++------------ src/user_code.hpp | 9 +++- 3 files changed, 63 insertions(+), 30 deletions(-) diff --git a/cud_display/cud_display.HMI b/cud_display/cud_display.HMI index 66d08d3f1b5ed08ce77294cb12203f51ec037d7d..0e2033a87fe2516daba328d9fd9b89f5dd55b83d 100644 GIT binary patch delta 792 zcmd6g&2LOm9ER_mnLDS6Sct@|+oU@S7J^c=>a(b-`lg+>O10H9zP}Cg)G)rvrI#`- zRkW&F<~k=9goua*8?g}mBXrlq#%W^4Um&q~7SDTr=Y7*}e>iEw$j^}7>W+mXjuo&h z%bn~*Y&%ov{IcztZoV+_$EmjE7K=!p{eIYLtNdDB!X*oJ^1Xb2e`Ls&*l zWf{v^!AiTWZldg!V zf=PDJD|zi#>lwbP4`wAER}DESLe=GD^p!vHqRpQ-+0gs)O-<|cRH+_%=TFI{sqcT% tmJfa=;B|jiHKu=TR5dG4Rb|igK$mLFiD~*PreH#}`7%AI{eIOn`!_KFHL?Hz delta 703 zcmd6gNlz3}7)9$fRs9IYoziPaSh&-LaRg}mO{L^i%e{(^~%lib|g?>o646Hd-BJY@^Z`)S7<5wWZ`Z>|#) zR=&)c5vDGYrXCrx7J20|R%n^@yJ);3?aGWRg&|@nFxUpi5Di@^d#61mouKd^JWeZ_ zQO2x{SsAl3X5%tMLnUQ)`hOVYm0VoLQkJot6|AJ33RY1`oYkyhEmf>zJsa4_CK7CB z3tLIDjqU89nw{*ThTZI8FZ-xvKXn|So`bj?qJhI4p^+wz(#$bhXr+yIj-yC%f|H!$ zG-o)=InHx|i(KL|SGdYGu5*JlaFbhP=-@VYxXV56)5!y}JfsVcZXWR%pC>$}hi5z| z#|wIS$tzy-hPS-qJs;?!pN|aii9tRy#4um@N}hmkflj3C;;zZgFqzV&bNtHhK~1Um;;ANO=zB>e0^FkiHXZilu-nCsTRgg-T@TeYvN3;rJV_vpsiI69`2 LMPbmVo0t3n*H;g( diff --git a/src/user_code.cpp b/src/user_code.cpp index 254d488..a19ab38 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -1,24 +1,47 @@ #include -//Timer Components -ESPMega_Timer timer1(0, 50, timer1_callback, 15001); +/* +Environment Details +P0-P2: Fans +P3-P6: Lights +P7: Air Purifier +I0-I2: Fan Switch +*/ + // Display Componets -// Link with Dual state button object with id 2 on page 1 named bt0 -NexDSButton bt0 = NexDSButton(1, 2, "bt0"); -NexText clock_txt = NexText(1,3,"clock_txt"); +NexText clock_txt = NexText(1,2,"clock"); +NexDSButton lt_bt = NexDSButton(1, 3, "lt_bt"); +NexDSButton fan_bt = NexDSButton(1, 4, "fan_bt"); +NexDSButton puri_bt = NexDSButton(1, 5, "puri_bt"); +NexButton up_bt = NexButton(1, 6, "up_bt"); +NexButton down_bt = NexButton(1, 7, "down_bt"); +NexButton mode_off_btn = NexButton(1, 8, "mode_off_btn"); +NexButton mode_fan_btn = NexButton(1, 9, "mode_fan_btn"); +NexButton mode_cool_btn = NexButton(1, 10, "mode_cool_btn"); +NexButton fan_auto_btn = NexButton(1, 11, "fan_auto_btn"); +NexButton fan_1_btn = NexButton(1, 12, "fan_1_btn"); +NexButton fan_2_btn = NexButton(1, 13, "fan_2_btn"); +NexButton fan_3_btn = NexButton(1, 14, "fan_3_btn"); + // List of Component ID Message to listen to NexTouch *nex_listen_list[] = { - &bt0, + <_bt, + &fan_bt, + &puri_bt, + &up_bt, + &down_bt, + &mode_off_btn, + &mode_fan_btn, + &mode_cool_btn, + &fan_auto_btn, + &fan_1_btn, + &fan_2_btn, + &fan_3_btn, NULL}; -void bt0PopCallback(void *ptr) -{ - pwm_toggle(2); -} - /* This Code will run right after ESPMega PRO's Peripheral Initialization Routine @@ -33,12 +56,13 @@ This code will run after every component is initialized */ void user_init() { - timer1.begin(); ESPMega_EXTLCD.print("page dashboard"); ESPMega_EXTLCD.write(0xFF); ESPMega_EXTLCD.write(0xFF); ESPMega_EXTLCD.write(0xFF); - bt0.attachPop(bt0PopCallback, &bt0); + lt_bt.attachPop(lt_btn_cb, <_bt); + fan_bt.attachPop(fan_btn_cb, &fan_bt); + } /* @@ -58,11 +82,7 @@ void virtual_interrupt_user_callback(int pin, int state) void pwm_changed_user_callback(int pin) { - if (pin == 2) - { - // inform the lcd when pwm 2 changed - bt0.setValue(pwm_get_state(2)); - } + } /* @@ -70,16 +90,24 @@ This code will run every 15 seconds */ void timer_tick_callback() { - if (standalone) - { - timer1.loop(); - } + } -void timer1_callback() -{ - for (int i = 0; i < 16; i++) - { - pwm_set_state(i, 1); - } +void lt_btn_cb(void *comp) { + +} +void fan_btn_cb(void *comp) { + +} +void puri_btn_cb(void *comp) { + +} +void ac_temp_adj_btn_cb(void *comp) { + +} +void ac_mode_adj_btn_cb(void *comp) { + +} +void ac_fan_adj_btn_cb(void *comp) { + } \ No newline at end of file diff --git a/src/user_code.hpp b/src/user_code.hpp index d8383cb..82e7ce8 100644 --- a/src/user_code.hpp +++ b/src/user_code.hpp @@ -22,8 +22,13 @@ void user_loop(); void virtual_interrupt_user_callback(int pin, int state); void pwm_changed_user_callback(int pin); void timer_tick_callback(); -void timer1_callback(); -void bt0PopCallback(void *ptr); +void lt_btn_cb(void *comp); +void fan_btn_cb(void *comp); +void puri_btn_cb(void *comp); +void ac_temp_adj_btn_cb(void *comp); +void ac_mode_adj_btn_cb(void *comp); +void ac_fan_adj_btn_cb(void *comp); + // ESPMega IoT Core Build-in Functions