diff --git a/examples/factory_test/ui.cpp b/examples/factory_test/ui.cpp index 992d7f5..909a86d 100644 --- a/examples/factory_test/ui.cpp +++ b/examples/factory_test/ui.cpp @@ -131,6 +131,7 @@ lv_obj_t * scr5_add_info_lab(lv_obj_t *parent, lv_obj_t *label, const char *s) #define MENU_PROPORTION (0.55) #define MENU_LAB_PROPORTION (1 - MENU_PROPORTION) +static lv_obj_t *menu_batt_lab = NULL; lv_obj_t *item_cont; lv_obj_t *menu_cont; lv_obj_t *menu_icon; @@ -414,6 +415,14 @@ void create0(lv_obj_t *parent) lv_group_focus_obj(lv_obj_get_child(item_cont, fouce_item)); lv_group_set_wrap(lv_group_get_default(), false); + + // battery label + menu_batt_lab = lv_label_create(parent); + lv_obj_align(menu_batt_lab, LV_ALIGN_TOP_RIGHT, -10, 10); + lv_obj_set_style_text_align(menu_batt_lab, LV_TEXT_ALIGN_RIGHT, 0); + lv_label_set_recolor(menu_batt_lab, true); + lv_label_set_text_fmt(menu_batt_lab, "#0000ff %s %s #", LV_SYMBOL_BATTERY_2, LV_SYMBOL_CHARGE); + lv_obj_add_flag(menu_batt_lab, LV_OBJ_FLAG_HIDDEN); } void entry0(void) { @@ -429,7 +438,12 @@ void exit0(void) { lv_msg_unsubscribe_obj(MSG_CLOCK_MINUTE, menu_time_lab); lv_msg_unsubscribe_obj(MSG_CLOCK_SECOND, menu_time_lab); } -void destroy0(void) {} +void destroy0(void) { + if(menu_batt_lab){ + lv_obj_del(menu_batt_lab); + menu_batt_lab = NULL; + } +} scr_lifecycle_t screen0 = { .create = create0, @@ -2343,51 +2357,45 @@ static scr_lifecycle_t screen8 = { }; #endif //************************************[ UI ENTRY ]****************************************** -static lv_obj_t *starting_up; -static lv_obj_t *starting_dp; -static void starting_up_anim_cb(void * var, int32_t v) +void charge_detection_timer_cb(lv_timer_t *t) { - lv_obj_set_y((lv_obj_t *)starting_up, 0-v); - lv_obj_set_y((lv_obj_t *)starting_dp, LV_VER_RES/2+v); -} + if(!PPM.isCharging() || (menu_batt_lab == NULL)) { + if(menu_batt_lab) + lv_obj_add_flag(menu_batt_lab, LV_OBJ_FLAG_HIDDEN); + return; + } -static void starting_up_ready_cb(struct _lv_anim_t * a) -{ - lv_obj_del(starting_up); - lv_obj_del(starting_dp); + static int sec = 0; + lv_obj_clear_flag(menu_batt_lab, LV_OBJ_FLAG_HIDDEN); + lv_label_set_text_fmt(menu_batt_lab, "#%x %s #", EMBED_COLOR_TEXT, LV_SYMBOL_CHARGE); + + // switch (sec) + // { + // case 0: + // lv_label_set_text_fmt(menu_batt_lab, "#%x %s %s #", EMBED_COLOR_TEXT, LV_SYMBOL_BATTERY_EMPTY, LV_SYMBOL_CHARGE); + // break; + // case 1: + // lv_label_set_text_fmt(menu_batt_lab, "#%x %s %s #", EMBED_COLOR_TEXT, LV_SYMBOL_BATTERY_1, LV_SYMBOL_CHARGE); + // break; + // case 2: + // lv_label_set_text_fmt(menu_batt_lab, "#%x %s %s #", EMBED_COLOR_TEXT, LV_SYMBOL_BATTERY_2, LV_SYMBOL_CHARGE); + // break; + // case 3: + // lv_label_set_text_fmt(menu_batt_lab, "#%x %s %s #", EMBED_COLOR_TEXT, LV_SYMBOL_BATTERY_3, LV_SYMBOL_CHARGE); + // break; + // case 4: + // lv_label_set_text_fmt(menu_batt_lab, "#%x %s %s #", EMBED_COLOR_TEXT, LV_SYMBOL_BATTERY_FULL, LV_SYMBOL_CHARGE); + // break; + // default: + // break; + // } + // sec++; + // if(sec > 4){ + // sec = 0; + // } } -static void ui_embed_starting_up(void) -{ - starting_up = lv_obj_create(lv_layer_top()); - lv_obj_set_size(starting_up, lv_pct(100), lv_pct(50)); - lv_obj_set_style_bg_color(starting_up, lv_color_hex(0x000000), LV_PART_MAIN); - lv_obj_set_scrollbar_mode(starting_up, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_border_width(starting_up, 0, LV_PART_MAIN); - lv_obj_set_style_radius(starting_up, 0, 0); - lv_obj_set_style_pad_all(starting_up, 0, LV_PART_MAIN); - // lv_obj_add_flag(starting_up, LV_OBJ_FLAG_HIDDEN); - - starting_dp = lv_obj_create(lv_layer_top()); - lv_obj_set_size(starting_dp, lv_pct(100), lv_pct(50)); - lv_obj_set_style_bg_color(starting_dp, lv_color_hex(0x000000), LV_PART_MAIN); - lv_obj_set_scrollbar_mode(starting_dp, LV_SCROLLBAR_MODE_OFF); - lv_obj_set_style_border_width(starting_dp, 0, LV_PART_MAIN); - lv_obj_set_style_radius(starting_dp, 0, 0); - lv_obj_set_style_pad_all(starting_dp, 0, LV_PART_MAIN); - // lv_obj_add_flag(starting_dp, LV_OBJ_FLAG_HIDDEN); - - lv_anim_t a; - lv_anim_init(&a); - lv_anim_set_var(&a, NULL); - lv_anim_set_values(&a, 0, LV_VER_RES/2); - lv_anim_set_time(&a, 2000); - lv_anim_set_path_cb(&a, lv_anim_path_linear); - lv_anim_set_exec_cb(&a, starting_up_anim_cb); - lv_anim_set_ready_cb(&a, starting_up_ready_cb); - lv_anim_start(&a); -} void ui_entry(void) { @@ -2420,5 +2428,7 @@ void ui_entry(void) scr_mgr_switch(SCREEN0_ID, false); // main scr - // ui_embed_starting_up(); + + + lv_timer_create(charge_detection_timer_cb, 1000, NULL); } diff --git a/examples/factory_test/ui.h b/examples/factory_test/ui.h index 08f660e..570b12e 100644 --- a/examples/factory_test/ui.h +++ b/examples/factory_test/ui.h @@ -8,7 +8,7 @@ #include "peripheral/peripheral.h" -#define T_EMBED_CC1101_SF_VER "v1.0 20241211" +#define T_EMBED_CC1101_SF_VER "v1.0-20241225" // The default is landscape screen, HEIGHT and WIDTH swap #define DISPALY_WIDTH TFT_HEIGHT diff --git a/firmware/factory_v1.0_20241203.bin b/firmware/factory_v1.0_20241225.bin similarity index 95% rename from firmware/factory_v1.0_20241203.bin rename to firmware/factory_v1.0_20241225.bin index 4de84a9..8a57744 100644 Binary files a/firmware/factory_v1.0_20241203.bin and b/firmware/factory_v1.0_20241225.bin differ