Skip to main content
Version: Latest

电子价签Demo

本文档介绍基于 F101 平台的电子价签(ESL)演示方案,涵盖系统架构、界面设计及部署流程。通过阅读本文档,你可以了解 ESL 方案的完整技术栈和部署方法,快速搭建电子价签演示系统。

方案概述​

本方案基于 F101 芯片打造高性能电子价签参考设计,重点展示多媒体视频播放与图片/UI 叠加在商用场景的应用效果。Demo 通过 MPP VDEC 硬件解码 MP4 视频,并在视频上叠加商品图片、价格和 UI,为零售场景提供动态价签展示方案。

核心功能:

  • MP4 视频硬解码:应用文末全屏补丁后支持 1024×600 全屏播放(原始导出布局为 854×480)
  • PNG/JPEG 图片解码:商品图片快速加载
  • 多图层叠加:视频层 + 图片层 + UI 层
  • AW Studio 可视化设计:界面由 AW Studio 导出,可直接二次开发

软件系统:FreeRTOS + LVGL 9 + AW Studio + Eyesee MPP(VDEC/VO)+ G2D 硬件加速

硬件平台​

  • 芯片方案:F101s3
  • 开发板:EVB1 评估板
  • 显示屏:1024×600 RGB 接口 LCD 屏,支持全屏显示
  • 存储介质:SPI Nor Flash(视频和图片资源打包进 res 分区)

原始 AW Studio 导出布局为 854×480;应用本文末尾的全屏补丁(854×480 → 1024×600)后,UI 和视频铺满 1024×600 全屏。

效果展示​

电子价签 Demo 全屏演示(已应用 854×480 → 1024×600 全屏补丁):

演示内容:

  1. 视频播放:商品宣传 MP4 视频循环播放
  2. 价格标签叠加:视频上叠加商品图片、价格和促销信息
  3. UI 交互:LVGL 界面与视频层叠加显示
note

固件请通过全志客户服务平台下载。开发者也可按照下方配置使用步骤自行编译生成固件。

配置使用​

快速配置(推荐)​

SDK 已内置 ESL demo 的 quick_config 配置项,会同时配置 LVGL、MPP 视频解码和 res 分区:

source envsetup.sh
lunch_rtos f101s3_evb1

quick_config_rtos -c "lvgl run esl demo"

mrtos && pack

执行时会提示是否覆盖当前 RTOS 配置,输入 y 确认。

该配置项会完成:

  • 选中 compile lvgl9 esl demo
  • 开启 AW Multimedia / libcedarc(H.264/MJPEG/PNG)
  • 开启 Eyesee MPP 的 VDEC、VO、硬件显示、DEMUXER、MOV/MP4 解析
  • 开启 G2D、display transp(UI 透明叠加视频层)、PNG/JPEG 硬解、自动同步资源
  • 把 res 分区调为 10240 KB

应用后直接执行 lv9_esl_demo 即可。下面保留手动 menuconfig 配置,便于裁剪或排查。

启用 ESL Demo​

在 SDK 根目录执行:

mrtos menuconfig

选择 ESL demo:

System components -->
thirdparty components -->
littlevgl-9.3.0 -->
--- littlevgl-9.3.0
operating system (free-rtos) --->
lvgl9 demos select (compile lvgl9 esl demo) --->
lvgl9 disp port (display on free rtos disp2) --->
-*- lvgl-9.3.0 use sunxifb g2d
-*- lvgl-9.3.0 use sunxifb g2d draw
[*] lvgl-9.3.0 use sunxifb display transp
[ ] lvgl-9.3.0 use sunxifb direct mode
[*] lvgl-9.3.0 use sunxi png hardware decoding
[*] lvgl-9.3.0 use sunxi jpeg hardware decoding
[*] Auto sync LVGL resources to board data/res

必须开启 use sunxifb display transp:ESL 的视频在独立的 VO 视频层,LVGL UI 需要背景透明才能叠在视频上。关闭该选项后,LVGL 会输出不透明背景,视频画面会被遮住。

开启后 LVGL 显示格式为 ARGB8888;ESL 的 lv_conf.h 固定使用 32 位颜色深度。

启用 MPP 视频解码​

ESL Demo 使用 MPP VDEC 解码 MP4,需要开启以下组件:

System components -->
aw components -->
[*] AW Multimedia
[*] AW Multimedia libcedarc
[*] AW Multimedia libcedarc vdec h264
Eyesee MPP (Media Processing Platform) --->
[*] Eyesee MPP Support
[*] Enable VDEC (Video Decoder) component
[*] Enable VO (Video Output) component
[*] Enable hardware display
[*] Enable DEMUXER component
[*] Enable AAC parser
[*] Enable MOV/MP4 parser

配置显示驱动​

Drivers Options -->
soc related device drivers -->
Video support for sunxi -->
[*] DISP Driver Support(sunxi-disp2)

媒体资源​

Demo 自带两个商品视频和对应的价格标签图片,位于:

lv9_esl_demo/res/assets/videos/ # MP4 视频
lv9_esl_demo/res/assets/images/ # 价格标签图片

打开 Auto sync LVGL resources to board data/res 后,编译时会自动拷贝到:

board/f101s3/evb1/data/res/lv9_esl_demo/

运行时访问路径为:

A:/res/lv9_esl_demo/assets/images/...
/res/lv9_esl_demo/assets/videos/... # MPP 使用标准文件路径,不加 A: 盘符

ESL 资源总量约 4.875 MB,默认 res 分区只有 1024 KB,需要调大。quick_config 会自动调到 10240 KB;手动配置时修改 board/f101s3/evb1/configs/sys_partition_nor.fex:

[partition]
name = res
size = 10240 ; 与 quick_config 一致,按实际资源总量调整
downloadfile = "data_res.fex"
user_type = 0x8000

如果关闭自动同步,手动把 lv9_esl_demo/res 下的内容复制到 board/f101s3/evb1/data/res/lv9_esl_demo/ 即可。

编译烧录​

  1. 编译固件:
mrtos && pack

也可以使用快捷命令 mp。

  1. 烧录固件到开发板,参考《首次编译烧录》文档。

  2. 开发板启动后,在串口终端执行:

lv9_esl_demo

自定义内容​

  • 替换视频/图片:按原文件名替换 lv9_esl_demo/res/assets/ 下的素材后重新编译。视频建议使用 H.264 + AAC 的 MP4 格式。
  • 修改界面:使用 AW Studio 打开对应工程修改后重新导出,不要直接修改 src/ui 下标注为自动生成的文件。
  • 切换商品:修改 src/ui/pages/ui_supermarket_price_tag.c 中的视频/图片资源引用;正式项目建议通过 AW Studio 重新导出。

全屏显示修改(可选)​

原始 AW Studio 导出布局为 854×480,全屏补丁改为 1024×600。

先确认当前代码是否已经包含全屏修改:如果页面和视频对象的 lv_obj_set_size 已经是 1024, 600,且价格标签叠加层位置为 0, 435、尺寸为 1024, 165,说明已经改好,不需要重复修改。

如果要对旧代码应用补丁,将下面的内容保存为 lv9_esl_fullscreen_1024x600.patch,在 lichee/rtos-components 目录执行:

git apply lv9_esl_fullscreen_1024x600.patch

补丁内容:

diff --git a/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/pages/ui_supermarket_price_tag.c b/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/pages/ui_supermarket_price_tag.c
index f3792aab..7ac105ac 100644
--- a/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/pages/ui_supermarket_price_tag.c
+++ b/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/pages/ui_supermarket_price_tag.c
@@ -23,7 +23,7 @@ lv_obj_t *supermarket_price_tag_overlay_2 = NULL;
void ui_supermarket_price_tag_screen_init(void) {
ui_supermarket_price_tag = lv_obj_create(NULL);
lv_obj_clear_flag(ui_supermarket_price_tag, LV_OBJ_FLAG_SCROLLABLE);
- lv_obj_set_size(ui_supermarket_price_tag, 854, 480);
+ lv_obj_set_size(ui_supermarket_price_tag, 1024, 600);

lv_obj_set_style_pad_top(ui_supermarket_price_tag, 0, 0);
lv_obj_set_style_pad_right(ui_supermarket_price_tag, 0, 0);
@@ -37,7 +37,7 @@ void ui_supermarket_price_tag_screen_init(void) {
/* template: custom-video */
supermarket_product_video_1 = lv_obj_create(ui_supermarket_price_tag);
lv_obj_set_pos(supermarket_product_video_1, 0, 0);
- lv_obj_set_size(supermarket_product_video_1, 854, 480);
+ lv_obj_set_size(supermarket_product_video_1, 1024, 600);
lv_obj_remove_flag(supermarket_product_video_1, LV_OBJ_FLAG_CLICKABLE);
lv_obj_remove_flag(supermarket_product_video_1, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_remove_flag(supermarket_product_video_1, LV_OBJ_FLAG_SCROLLABLE);
@@ -60,8 +60,8 @@ void ui_supermarket_price_tag_screen_init(void) {
.poster_path = "",
.x = 0,
.y = 0,
- .width = 854,
- .height = 480,
+ .width = 1024,
+ .height = 600,
.layer = AW_STUDIO_VIDEO_LAYER_UNDERLAY,
.fit = AW_STUDIO_VIDEO_FIT_COVER,
.backend = AW_STUDIO_VIDEO_BACKEND_MPP,
@@ -83,8 +83,8 @@ void ui_supermarket_price_tag_screen_init(void) {
lv_obj_add_event_cb(supermarket_product_video_1, ui_supermarket_price_tag_aw_logic_supermarket_price_tag_video_ready, LV_EVENT_READY, NULL);
/* template: basic-image */
supermarket_price_tag_overlay_2 = lv_image_create(ui_supermarket_price_tag);
- lv_obj_set_pos(supermarket_price_tag_overlay_2, 0, 348);
- lv_obj_set_size(supermarket_price_tag_overlay_2, 854, 132);
+ lv_obj_set_pos(supermarket_price_tag_overlay_2, 0, 435);
+ lv_obj_set_size(supermarket_price_tag_overlay_2, 1024, 165);
lv_obj_remove_flag(supermarket_price_tag_overlay_2, LV_OBJ_FLAG_CLICK_FOCUSABLE);
lv_obj_remove_flag(supermarket_price_tag_overlay_2, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_remove_flag(supermarket_price_tag_overlay_2, LV_OBJ_FLAG_SCROLL_ELASTIC);
diff --git a/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/runtime/ui_video_mpp_backend.c b/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/runtime/ui_video_mpp_backend.c
index e94237d7..9db0a75c 100644
--- a/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/runtime/ui_video_mpp_backend.c
+++ b/thirdparty/littlevgl-9/lv9_esl_demo/src/ui/runtime/ui_video_mpp_backend.c
@@ -189,6 +189,8 @@ typedef struct {
char mpp_source_url[AW_STUDIO_MPP_SOURCE_PATH_MAX + 8];
aw_studio_video_descriptor_t descriptor;
aw_studio_mpp_video_channels_t channels;
+ int video_width; /* decoded stream size, must match the VO layer canvas */
+ int video_height;
} aw_studio_mpp_video_slot_t;

static aw_studio_mpp_video_slot_t aw_studio_mpp_slots[AW_STUDIO_MPP_MAX_SLOTS];
@@ -529,6 +531,13 @@ static bool aw_studio_mpp_prepare_vo(aw_studio_mpp_video_slot_t * slot) {
aw_studio_mpp_emit(slot, AW_STUDIO_VIDEO_EVENT_ERROR, "mpp vo layer configuration missing");
return false;
}
+ /* The layer canvas must equal the decoded frame size; the DE scales the
+ * canvas up to stDispRect (screen size) instead of treating a larger
+ * canvas as the frame stride. */
+ if (slot->video_width > 0 && slot->video_height > 0) {
+ layer_attr.stImageSize.Width = (unsigned int)slot->video_width;
+ layer_attr.stImageSize.Height = (unsigned int)slot->video_height;
+ }
(void)AW_MPI_VO_Enable(slot->channels.vo_dev);
(void)AW_MPI_VO_EnableVideoLayer(slot->channels.vo_layer);
(void)AW_MPI_VO_SetVideoLayerAttr(slot->channels.vo_layer, &layer_attr);
@@ -545,11 +554,21 @@ static bool aw_studio_mpp_prepare_vo(aw_studio_mpp_video_slot_t * slot) {
callback.callback = aw_studio_mpp_callback;
(void)AW_MPI_VO_RegisterCallback(slot->channels.vo_layer, slot->channels.vo_chn, &callback);
(void)AW_MPI_VO_SetChnDispBufNum(slot->channels.vo_layer, slot->channels.vo_chn, 2U);
+ /* The renderer uses this rect as the crop region inside the decoded
+ * buffer, so it must stay within the stream size. Scaling happens on the
+ * layer rect (stDispRect) above. */
RECT_S rect;
- rect.X = slot->descriptor.x;
- rect.Y = slot->descriptor.y;
- rect.Width = (unsigned int)(slot->descriptor.width > 0 ? slot->descriptor.width : 1);
- rect.Height = (unsigned int)(slot->descriptor.height > 0 ? slot->descriptor.height : 1);
+ if (slot->video_width > 0 && slot->video_height > 0) {
+ rect.X = 0;
+ rect.Y = 0;
+ rect.Width = (unsigned int)slot->video_width;
+ rect.Height = (unsigned int)slot->video_height;
+ } else {
+ rect.X = slot->descriptor.x;
+ rect.Y = slot->descriptor.y;
+ rect.Width = (unsigned int)(slot->descriptor.width > 0 ? slot->descriptor.width : 1);
+ rect.Height = (unsigned int)(slot->descriptor.height > 0 ? slot->descriptor.height : 1);
+ }
(void)AW_MPI_VO_SetFrameDisplayRegion(slot->channels.vo_layer, slot->channels.vo_chn, &rect);
return true;
}
@@ -808,6 +827,8 @@ static bool aw_studio_mpp_start_file_slot(aw_studio_mpp_video_slot_t * slot) {
if (height <= 0) {
height = 720;
}
+ slot->video_width = width;
+ slot->video_height = height;
VDEC_CHN_ATTR_S vdec_attr;
memset(&vdec_attr, 0, sizeof(vdec_attr));
vdec_attr.mType = video_info != NULL ? video_info->mCodecType : PT_H264;