11/****************************************************************************
22 * apps/examples/lvgldemo/boot_screen.c
33 *
4- * 开机界面:白底 + 居中 openvela logo(RGB565 图像数据)+ 底部进度条。
5- * 主循环通过 boot_screen_update() 推进进度与"正在启动"状态文字。
4+ * Boot screen: white background, centered openvela logo (RGB565 data)
5+ * and a progress bar at the bottom. The main loop calls
6+ * boot_screen_update() to advance the progress and the status text.
67 ****************************************************************************/
78
9+ /****************************************************************************
10+ * Included Files
11+ ****************************************************************************/
12+
13+ #include <stdint.h>
14+
815#include "boot_screen.h"
916#include "logo_data.h"
1017
11- #include <stdint.h>
18+ /****************************************************************************
19+ * Pre-processor Definitions
20+ ****************************************************************************/
1221
13- LV_FONT_DECLARE ( zh_font_16 );
22+ /* Light theme colors, consistent with the main screen */
1423
15- /* 与主界面一致的浅色主题配色 */
1624#define C_PROGRESS_BG lv_color_hex(0xe5e7eb)
1725#define C_PROGRESS_BAR lv_color_hex(0x3b82f6)
1826#define C_STATUS_TEXT lv_color_hex(0x6b7280)
1927
2028#define BOOT_BAR_W 420
2129#define BOOT_BAR_H 8
22- #define BOOT_BAR_Y 220 /* 相对屏幕中心的纵向偏移 */
30+ #define BOOT_BAR_Y 220 /* vertical offset from the screen center */
2331#define BOOT_TEXT_Y 185
2432
33+ /* Starting-up status text (Chinese, \u-escaped below) */
34+
35+ #define BOOT_STATUS_TEXT "\u6b63\u5728\u542f\u52a8"
36+
37+ /****************************************************************************
38+ * Private Data
39+ ****************************************************************************/
40+
41+ LV_FONT_DECLARE (zh_font_16 );
42+
2543static lv_obj_t * s_progress = NULL ;
2644static lv_obj_t * s_status = NULL ;
2745
@@ -39,40 +57,74 @@ static const lv_image_dsc_t boot_logo =
3957 .data = (const uint8_t * )logo_data ,
4058};
4159
60+ /****************************************************************************
61+ * Public Functions
62+ ****************************************************************************/
63+
64+ /****************************************************************************
65+ * Name: boot_screen_show
66+ *
67+ * Description:
68+ * Draw the boot screen (logo + progress bar + status label) on the
69+ * given screen object.
70+ *
71+ * Input Parameters:
72+ * scr - The LVGL screen object to draw onto.
73+ *
74+ ****************************************************************************/
75+
4276void boot_screen_show (lv_obj_t * scr )
4377{
4478 lv_obj_t * img ;
4579
4680 lv_obj_set_style_bg_color (scr , lv_color_white (), 0 );
4781 lv_obj_set_style_bg_opa (scr , LV_OPA_COVER , 0 );
4882
49- /* 居中 openvela logo,略向上留出底部进度区 */
83+ /* Centered openvela logo, shifted up to leave room for the bar */
84+
5085 img = lv_image_create (scr );
5186 lv_image_set_src (img , & boot_logo );
5287 lv_obj_align (img , LV_ALIGN_CENTER , 0 , -40 );
5388
54- /* 底部进度条 */
89+ /* Bottom progress bar */
90+
5591 s_progress = lv_bar_create (scr );
5692 lv_obj_remove_style_all (s_progress );
5793 lv_obj_set_size (s_progress , BOOT_BAR_W , BOOT_BAR_H );
5894 lv_obj_align (s_progress , LV_ALIGN_CENTER , 0 , BOOT_BAR_Y );
5995 lv_obj_set_style_bg_color (s_progress , C_PROGRESS_BG , 0 );
6096 lv_obj_set_style_bg_opa (s_progress , LV_OPA_COVER , 0 );
6197 lv_obj_set_style_radius (s_progress , BOOT_BAR_H / 2 , 0 );
62- lv_obj_set_style_bg_color (s_progress , C_PROGRESS_BAR , LV_PART_INDICATOR );
98+ lv_obj_set_style_bg_color (s_progress , C_PROGRESS_BAR ,
99+ LV_PART_INDICATOR );
63100 lv_obj_set_style_bg_opa (s_progress , LV_OPA_COVER , LV_PART_INDICATOR );
64- lv_obj_set_style_radius (s_progress , BOOT_BAR_H / 2 , LV_PART_INDICATOR );
101+ lv_obj_set_style_radius (s_progress , BOOT_BAR_H / 2 ,
102+ LV_PART_INDICATOR );
65103 lv_bar_set_range (s_progress , 0 , 100 );
66104 lv_bar_set_value (s_progress , 0 , LV_ANIM_OFF );
67105
68- /* 状态文字(进度条上方) */
106+ /* Status label above the progress bar */
107+
69108 s_status = lv_label_create (scr );
70109 lv_obj_set_style_text_color (s_status , C_STATUS_TEXT , 0 );
71110 lv_obj_set_style_text_font (s_status , & zh_font_16 , 0 );
72- lv_label_set_text (s_status , "正在启动" );
111+ lv_label_set_text (s_status , BOOT_STATUS_TEXT );
73112 lv_obj_align (s_status , LV_ALIGN_CENTER , 0 , BOOT_TEXT_Y );
74113}
75114
115+ /****************************************************************************
116+ * Name: boot_screen_update
117+ *
118+ * Description:
119+ * Advance the boot progress bar and refresh the status text.
120+ *
121+ * Input Parameters:
122+ * percent - Progress percentage (clamped to 0..100; negative clamps
123+ * to 0).
124+ * status - New status text, or NULL to keep the current text.
125+ *
126+ ****************************************************************************/
127+
76128void boot_screen_update (int percent , const char * status )
77129{
78130 if (s_progress != NULL )
0 commit comments