From 5a62e430b8fc8539a534017a015d4aa35f97b030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=90=83=E6=B2=B9=E7=82=B8=E9=B8=A1?= <1425962791@qq.com> Date: Thu, 27 Nov 2025 10:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BC=80=E6=9C=BA=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Power_Pico/User/GUI/screens/ui_StartPage.c | 2 +- Power_Pico/User/GUI/ui.c | 47 ++++++++++------------ 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/Power_Pico/User/GUI/screens/ui_StartPage.c b/Power_Pico/User/GUI/screens/ui_StartPage.c index 66f1d0f..9a0dfb0 100644 --- a/Power_Pico/User/GUI/screens/ui_StartPage.c +++ b/Power_Pico/User/GUI/screens/ui_StartPage.c @@ -127,7 +127,7 @@ void ui_StartPage_screen_init(void) lv_obj_set_style_bg_opa(ui_Button4, 255, LV_PART_MAIN | LV_STATE_DEFAULT); _ui_StartPage_btn_animation(); - _flush_timer = lv_timer_create(ui_startpage_timer_cb, 500, NULL); + // _flush_timer = lv_timer_create(ui_startpage_timer_cb, 500, NULL); } diff --git a/Power_Pico/User/GUI/ui.c b/Power_Pico/User/GUI/ui.c index a721c25..ff0f36a 100644 --- a/Power_Pico/User/GUI/ui.c +++ b/Power_Pico/User/GUI/ui.c @@ -92,38 +92,32 @@ void ui_full_screen_refresh(lv_obj_t * screen) { } /////////////////////// Timer ////////////////////// - /** * Main timer for Refreshing the screens */ -static void main_timer(lv_timer_t * timer) +static void main_timer_cb(lv_timer_t * timer) { - static uint8_t first_time_in = 0; - static uint8_t count = 0; - static uint8_t backlight_level = 0; // 初始亮度为 0% - static uint8_t target_backlight_level = 0; // 目标亮度 + // do nothing +} - if (first_time_in == 0) { - // 获取目标亮度 - target_backlight_level = ui_get_back_light_level(); - first_time_in = 1; +////////////////////////// Animation ////////////////////// + +void ui_start_animation_done() { + // 初始化页面并加载主要界面 + lv_lib_pm_Init(); + for (uint8_t i = 0; i < sizeof(pages) / sizeof(pages[0]); i++) { + lv_lib_pm_register(&pages[i]); } + lv_lib_pm_load_init_screen(); +} - // 调整背光亮度 - if (backlight_level < target_backlight_level) { - backlight_level++; - ui_set_back_light_level(backlight_level); // 设置当前亮度 - } else { - // 初始化页面并加载主要界面 - lv_lib_pm_Init(); - for (uint8_t i = 0; i < sizeof(pages) / sizeof(pages[0]); i++) { - lv_lib_pm_register(&pages[i]); - } - lv_lib_pm_load_init_screen(); +void ui_anima_set_light_level(void * var, int32_t v) { + ui_set_back_light_level(v); +} - // 停止定时器,避免重复初始化 - lv_timer_del(timer); - } +static void _ui_Start_animation(void) { + uint8_t target_level = ui_get_back_light_level(); + lv_lib_anim_user_animation(NULL, 0, 2000, 0, target_level, 0, 0, 0, 0, lv_anim_path_ease_in, ui_anima_set_light_level, ui_start_animation_done); } /////////////////////// ui_initialize ////////////////////// @@ -137,10 +131,11 @@ void ui_init(void) // set system settings ui_set_display_rotation(ui_get_display_rotation()); - // timer - lv_timer_t * ui_MainTimer = lv_timer_create(main_timer, 50, NULL); + // main timer (you can add someting to do in the timer_cb if needed) + lv_timer_t * ui_MainTimer = lv_timer_create(main_timer_cb, 1000, NULL); // start up, just load one time only ui_StartPage_screen_init(); lv_scr_load(ui_StartPage); + _ui_Start_animation(); }