From c014b725328ee7455a6bb6ce822b0c3ba8df8e3f Mon Sep 17 00:00:00 2001 From: reaw55 <58457329+reaw55@users.noreply.github.com> Date: Wed, 27 Dec 2023 00:12:00 +0700 Subject: [PATCH] make light control UI change more efficient --- src/user_code.cpp | 74 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/src/user_code.cpp b/src/user_code.cpp index 010470b..1aba714 100644 --- a/src/user_code.cpp +++ b/src/user_code.cpp @@ -228,53 +228,97 @@ void virtual_interrupt_user_callback(int pin, int state) void update_lcd_row1() { bool master_state = row_is_on(ROW1_LIGHT1,ROW1_LIGHT2); - row1_master.Set_background_image_pic(master_state?9:10); + //row1_master.Set_background_image_pic(master_state?9:10); + elcd_send_stop_bit(); + elcd.print("row1_master.pic="); + elcd.print(master_state?9:10); + elcd_send_stop_bit(); + + bool lt1_state = pwm_get_state(ROW1_LIGHT1); bool lt2_state = pwm_get_state(ROW1_LIGHT2); //also update the light1 and light2 buttons background to reflect the current state - row1_lv1.Set_background_image_pic(lt1_state?5:6); - row1_lv2.Set_background_image_pic(lt2_state?7:8); - + //row1_lv1.Set_background_image_pic(lt1_state?5:6); + //row1_lv2.Set_background_image_pic(lt2_state?7:8); + elcd.print("row1_lv1.pic="); + elcd.print(lt1_state?5:6); + elcd_send_stop_bit(); + elcd.print("row1_lv2.pic="); + elcd.print(lt2_state?7:8); + elcd_send_stop_bit(); } void update_lcd_row2() { bool master_state = row_is_on(ROW2_LIGHT1,ROW2_LIGHT2); - row2_master.Set_background_image_pic(master_state?11:12); + //row2_master.Set_background_image_pic(master_state?11:12); + elcd_send_stop_bit(); + elcd.print("row2_master.pic="); + elcd.print(master_state?11:12); + elcd_send_stop_bit(); bool lt1_state = pwm_get_state(ROW2_LIGHT1); bool lt2_state = pwm_get_state(ROW2_LIGHT2); //also update the light1 and light2 buttons background to reflect the current state - row2_lv1.Set_background_image_pic(lt1_state?5:6); - row2_lv2.Set_background_image_pic(lt2_state?7:8); - + //row2_lv1.Set_background_image_pic(lt1_state?5:6); + //row2_lv2.Set_background_image_pic(lt2_state?7:8); + elcd.print("row1_lv1.pic="); + elcd.print(lt1_state?5:6); + elcd_send_stop_bit(); + elcd.print("row1_lv2.pic="); + elcd.print(lt2_state?7:8); + elcd_send_stop_bit(); } void update_lcd_row3() { bool master_state = row_is_on(ROW3_LIGHT1,ROW3_LIGHT2); - row3_master.Set_background_image_pic(master_state?13:14); + //row3_master.Set_background_image_pic(master_state?13:14); + elcd_send_stop_bit(); + elcd.print("row3_master.pic="); + elcd.print(master_state?13:14); + elcd_send_stop_bit(); bool lt1_state = pwm_get_state(ROW3_LIGHT1); bool lt2_state = pwm_get_state(ROW3_LIGHT2); //also update the light1 and light2 buttons background to reflect the current state - row3_lv1.Set_background_image_pic(lt1_state?5:6); - row3_lv2.Set_background_image_pic(lt2_state?7:8); + //row3_lv1.Set_background_image_pic(lt1_state?5:6); + //row3_lv2.Set_background_image_pic(lt2_state?7:8); + elcd.print("row3_lv1.pic="); + elcd.print(lt1_state?5:6); + elcd_send_stop_bit(); + elcd.print("row1_lv2.pic="); + elcd.print(lt2_state?7:8); + elcd_send_stop_bit(); } void update_lcd_row4() { bool master_state = row_is_on(ROW4_LIGHT1,ROW4_LIGHT2); - row4_master.Set_background_image_pic(master_state?15:16); + //row4_master.Set_background_image_pic(master_state?15:16); + elcd_send_stop_bit(); + elcd.print("row4_master.pic="); + elcd.print(master_state?15:16); + elcd_send_stop_bit(); bool lt1_state = pwm_get_state(ROW4_LIGHT1); bool lt2_state = pwm_get_state(ROW4_LIGHT2); //also update the light1 and light2 buttons background to reflect the current state - row4_lv1.Set_background_image_pic(lt1_state?5:6); - row4_lv2.Set_background_image_pic(lt2_state?7:8); + //row4_lv1.Set_background_image_pic(lt1_state?5:6); + //row4_lv2.Set_background_image_pic(lt2_state?7:8); + elcd.print("row4_lv1.pic="); + elcd.print(lt1_state?5:6); + elcd_send_stop_bit(); + elcd.print("row4_lv2.pic="); + elcd.print(lt2_state?7:8); + elcd_send_stop_bit(); } void update_toggle_button() { //calcuate the current state of the toggle button bool current_state = row_is_on(ROW1_LIGHT1,ROW1_LIGHT2) || row_is_on(ROW2_LIGHT1,ROW2_LIGHT2) || row_is_on(ROW3_LIGHT1,ROW3_LIGHT2) || row_is_on(ROW4_LIGHT1,ROW4_LIGHT2); - light_toggle.Set_background_image_pic(current_state?3:4); + //light_toggle.Set_background_image_pic(current_state?3:4); + elcd_send_stop_bit(); + elcd.print("light_toggle.pic="); + elcd.print(current_state?3:4); + elcd_send_stop_bit(); } void update_lcd_ac() {