Skip to content

Commit cd1e87e

Browse files
examples/lvgldemo: camera frame-callback architecture and style cleanup
- camera_module: restructure around a frame-callback contract (esp32p4_mipi_csi_frame_cb_t) with an explicit capture state machine (CSI_START -> STREAMING), current-frame snapshot for the LVGL timer, crop + nearest-neighbor scale into the preview canvas - ui_main / boot_screen / audio_beep / lvgldemo: translate file-header and inline comments to English (NuttX style), move declarations to the canonical section order, keep the UI <-> audio decoupling via board_audio_beep() - zh_font_16 / zh_font_40: regenerate with lv_font_conv (full CJK symbol set, no local build paths in headers) - lvgldemo: parameterize boot flow (BOOT_DURATION_MS, status text) Signed-off-by: IsXiaoXiaoZHou <zhou15325553865@outlook.com>
1 parent be5cb52 commit cd1e87e

7 files changed

Lines changed: 5110 additions & 1923 deletions

File tree

examples/lvgldemo/audio_beep.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
/****************************************************************************
22
* apps/examples/lvgldemo/audio_beep.c
33
*
4-
* 扬声器提示音播放。
4+
* Speaker beep placeholder implementation.
55
*
6-
* 说明:当前为占位实现(播放逻辑未接入),扬声器链路(ES8311 + I2S)
7-
* 在 openvela 侧完成后,替换此文件为真实播放实现。UI 通过
8-
* board_audio_beep() 触发提示音,二者解耦。
6+
* The real playback path (ES8311 + I2S on the openvela side) is not
7+
* wired yet; once it lands, replace the body of board_audio_beep()
8+
* with an actual playback implementation. The UI only calls
9+
* board_audio_beep(), so the two sides stay decoupled.
10+
****************************************************************************/
11+
12+
/****************************************************************************
13+
* Included Files
914
****************************************************************************/
1015

1116
#include <nuttx/config.h>
@@ -27,12 +32,13 @@
2732
* Name: board_audio_beep
2833
*
2934
* Description:
30-
* 播放一句话/提示音。真实实现待接入 openvela 音频链路后补充。
35+
* Play a short beep / spoken prompt. The real implementation will be
36+
* added once the openvela audio path is ready.
3137
****************************************************************************/
3238

3339
void board_audio_beep(void)
3440
{
3541
#if defined(CONFIG_AUDIO) && defined(CONFIG_AUDIO_I2S)
36-
/* 占位:后续实现通过 /dev/audio/pcm0 播放合成提示音。 */
42+
/* Placeholder: play a synthesized beep via /dev/audio/pcm0 later. */
3743
#endif
38-
}
44+
}

examples/lvgldemo/boot_screen.c

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
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+
2543
static lv_obj_t *s_progress = NULL;
2644
static 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+
4276
void 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+
76128
void boot_screen_update(int percent, const char *status)
77129
{
78130
if (s_progress != NULL)

0 commit comments

Comments
 (0)