Skip to content

Commit 6a6a0a9

Browse files
JarmouniAkartben
authored andcommitted
samples: modules: lvgl: add multi-display sample
Add LVGL multi-display sample Signed-off-by: Abderrahmane JARMOUNI <git@jarmouni.me>
1 parent 4a75a93 commit 6a6a0a9

File tree

9 files changed

+416
-0
lines changed

9 files changed

+416
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) 2023 Fabian Blatz <fabianblatz@gmail.com>
2+
# Copyright (c) 2025 Abderrahmane JARMOUNI
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
cmake_minimum_required(VERSION 3.20.0)
6+
7+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
8+
project(lvgl_multi_display)
9+
10+
set(LVGL_DIR ${ZEPHYR_LVGL_MODULE_DIR})
11+
12+
FILE(GLOB app_sources src/*.c)
13+
target_sources(app PRIVATE ${app_sources})
14+
15+
target_include_directories(app PRIVATE
16+
${LVGL_DIR}/demos/
17+
)
18+
19+
target_sources_ifdef(CONFIG_LV_USE_DEMO_MUSIC app PRIVATE
20+
${LVGL_DIR}/demos/music/lv_demo_music_list.c
21+
${LVGL_DIR}/demos/music/lv_demo_music.c
22+
${LVGL_DIR}/demos/music/lv_demo_music_main.c
23+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_next.c
24+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_top_large.c
25+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_4_large.c
26+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_4.c
27+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_right.c
28+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_1.c
29+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_slider_knob_large.c
30+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_3.c
31+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_pause.c
32+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_pause_large.c
33+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_bottom_large.c
34+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_2_large.c
35+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_play_large.c
36+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_top.c
37+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_play_large.c
38+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_1_large.c
39+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_bottom.c
40+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_left_large.c
41+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_play.c
42+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_list_border.c
43+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_2.c
44+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_next_large.c
45+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_play.c
46+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_list_border_large.c
47+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_rnd.c
48+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_3.c
49+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_prev_large.c
50+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_loop.c
51+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_1.c
52+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_slider_knob.c
53+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_right_large.c
54+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_corner_large.c
55+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_left.c
56+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_2_large.c
57+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_3_large.c
58+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_1_large.c
59+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_2.c
60+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_prev.c
61+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_rnd_large.c
62+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_pause_large.c
63+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_3_large.c
64+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_pause.c
65+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_logo.c
66+
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_loop_large.c
67+
)
68+
69+
target_sources_ifdef(CONFIG_LV_USE_DEMO_BENCHMARK app PRIVATE
70+
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_avatar.c
71+
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_lvgl_logo_argb.c
72+
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_lvgl_logo_rgb.c
73+
${LVGL_DIR}/demos/benchmark/assets/lv_font_benchmark_montserrat_12_compr_az.c.c
74+
${LVGL_DIR}/demos/benchmark/assets/lv_font_benchmark_montserrat_16_compr_az.c.c
75+
${LVGL_DIR}/demos/benchmark/assets/lv_font_benchmark_montserrat_28_compr_az.c.c
76+
${LVGL_DIR}/demos/benchmark/lv_demo_benchmark.c
77+
)
78+
79+
target_sources_ifdef(CONFIG_LV_USE_DEMO_STRESS app PRIVATE
80+
${LVGL_DIR}/demos/stress/lv_demo_stress.c
81+
)
82+
83+
target_sources_ifdef(CONFIG_LV_USE_DEMO_WIDGETS app PRIVATE
84+
${LVGL_DIR}/demos/widgets/assets/img_clothes.c
85+
${LVGL_DIR}/demos/widgets/assets/img_demo_widgets_avatar.c
86+
${LVGL_DIR}/demos/widgets/assets/img_demo_widgets_needle.c
87+
${LVGL_DIR}/demos/widgets/assets/img_lvgl_logo.c
88+
${LVGL_DIR}/demos/widgets/lv_demo_widgets.c
89+
)
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Copyright (c) 2023 Fabian Blatz <fabianblatz@gmail.com>
2+
# Copyright (c) 2025 Abderrahmane JARMOUNI
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
choice LV_Z_DEMO_FIRST_DISP
6+
prompt "LVGL demo to build for 1st display"
7+
default LV_Z_DEMO_MUSIC_FIRST_DISP
8+
help
9+
Demo application to build for 1st display.
10+
11+
config LV_Z_DEMO_MUSIC_FIRST_DISP
12+
bool "LVGL music demo"
13+
select LV_USE_DEMO_MUSIC
14+
help
15+
Build music player demo application.
16+
17+
config LV_Z_DEMO_BENCHMARK_FIRST_DISP
18+
bool "LVGL benchmark demo"
19+
select LV_USE_DEMO_BENCHMARK
20+
select LV_USE_SYSMON
21+
select LV_USE_PERF_MONITOR
22+
help
23+
Build benchmarking demo application.
24+
25+
config LV_Z_DEMO_STRESS_FIRST_DISP
26+
bool "LVGL stress demo"
27+
select LV_USE_DEMO_STRESS
28+
select LV_USE_SYSMON
29+
select LV_USE_PERF_MONITOR
30+
help
31+
Build stress testing demo application.
32+
33+
config LV_Z_DEMO_WIDGETS_FIRST_DISP
34+
bool "LVGL widgets demo"
35+
select LV_USE_DEMO_WIDGETS
36+
help
37+
Build widgets demo application.
38+
39+
endchoice
40+
41+
choice LV_Z_DEMO_OTHER_DISPS
42+
prompt "LVGL demo to build for other displays"
43+
default LV_Z_DEMO_WIDGETS_OTHER_DISPS
44+
help
45+
Demo application to build for other displays.
46+
47+
config LV_Z_DEMO_MUSIC_OTHER_DISPS
48+
bool "LVGL music demo"
49+
select LV_USE_DEMO_MUSIC
50+
help
51+
Build music player demo application.
52+
53+
config LV_Z_DEMO_BENCHMARK_OTHER_DISPS
54+
bool "LVGL benchmark demo"
55+
select LV_USE_DEMO_BENCHMARK
56+
select LV_USE_SYSMON
57+
select LV_USE_PERF_MONITOR
58+
help
59+
Build benchmarking demo application.
60+
61+
config LV_Z_DEMO_STRESS_OTHER_DISPS
62+
bool "LVGL stress demo"
63+
select LV_USE_DEMO_STRESS
64+
select LV_USE_SYSMON
65+
select LV_USE_PERF_MONITOR
66+
help
67+
Build stress testing demo application.
68+
69+
config LV_Z_DEMO_WIDGETS_OTHER_DISPS
70+
bool "LVGL widgets demo"
71+
select LV_USE_DEMO_WIDGETS
72+
help
73+
Build widgets demo application.
74+
75+
endchoice
76+
77+
source "Kconfig.zephyr"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.. zephyr:code-sample:: lvgl-multi-display
2+
:name: LVGL Multi-display
3+
:relevant-api: display_interface
4+
5+
Run different LVGL demos on multiple displays.
6+
7+
Overview
8+
********
9+
10+
A sample showcasing LVGL multi-display support in Zephyr.
11+
12+
By default, it runs Benchmark demo on the first display, and Widgets demo on the other ones (order
13+
as defined in the "displays" property of "zephyr,displays" compatible node in deviceTree).
14+
Which demos are run can be changed by modifying the value of CONFIG_LV_Z_DEMO_FIRST_DISP## and
15+
CONFIG_LV_Z_DEMO_OTHER_DISPS## Kconfig symbols.
16+
17+
* Music
18+
The music player demo shows what kind of modern, smartphone-like user interfaces can be
19+
created on LVGL.
20+
* Benchmark
21+
The benchmark demo tests the performance in various cases. For example rectangle, border,
22+
shadow, text, image blending, image transformation, blending modes, etc.
23+
* Stress
24+
A stress test for LVGL. It contains a lot of object creation, deletion, animations, styles
25+
usage, and so on. It can be used if there is any memory corruption during heavy usage or any
26+
memory leaks.
27+
* Widgets
28+
Shows how the widgets look like out of the box using the built-in material theme.
29+
30+
More details on the demos can be found in `LVGL demos Readme`_.
31+
32+
Requirements
33+
************
34+
35+
* A board with two displays or more, ideally with 480x272 resolution or higher.
36+
37+
Building and Running
38+
********************
39+
40+
This sample can be built for simulated display environment on Linux as follows:
41+
42+
.. zephyr-app-commands::
43+
:zephyr-app: samples/modules/lvgl/multi_display
44+
:host-os: unix
45+
:board: native_sim/native/64
46+
:goals: run
47+
:compact:
48+
49+
References
50+
**********
51+
52+
.. target-notes::
53+
54+
.. _LVGL demos Readme: https://github.com/zephyrproject-rtos/lvgl/blob/zephyr/demos/README.md
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2025, Abderrahmane JARMOUNI
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
/delete-property/ zephyr,display;
9+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2025, Abderrahmane JARMOUNI
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
lvgl_displays: my-displays {
9+
compatible = "zephyr,displays";
10+
displays = <&sdl_dc &sdl_dc2>;
11+
status = "okay";
12+
};
13+
14+
sdl_dc {
15+
width = <800>;
16+
height = <600>;
17+
status = "okay";
18+
};
19+
20+
input_sdl_touch: input-sdl-touch {
21+
compatible = "zephyr,input-sdl-touch";
22+
display = <&sdl_dc>;
23+
};
24+
25+
lvgl_pointer {
26+
compatible = "zephyr,lvgl-pointer-input";
27+
input = <&input_sdl_touch>;
28+
display = <&sdl_dc>;
29+
status = "okay";
30+
};
31+
32+
sdl_dc2: sdl-dc2 {
33+
compatible = "zephyr,sdl-dc";
34+
width = <800>;
35+
height = <600>;
36+
status = "okay";
37+
};
38+
39+
input_sdl_touch2: input-sdl-touch2 {
40+
compatible = "zephyr,input-sdl-touch";
41+
display = <&sdl_dc2>;
42+
};
43+
44+
lvgl_pointer2 {
45+
compatible = "zephyr,lvgl-pointer-input";
46+
input = <&input_sdl_touch2>;
47+
display = <&sdl_dc2>;
48+
status = "okay";
49+
};
50+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Copyright 2025 Abderrahmane JARMOUNI
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_LV_COLOR_DEPTH_32=y
5+
CONFIG_LV_Z_MEM_POOL_SIZE=150536
6+
7+
CONFIG_INPUT=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CONFIG_MAIN_STACK_SIZE=4096
2+
CONFIG_LOG=y
3+
4+
CONFIG_DISPLAY=y
5+
6+
CONFIG_LVGL=y
7+
CONFIG_LV_USE_LOG=y
8+
CONFIG_LV_Z_MEM_POOL_SIZE=116736
9+
CONFIG_SYS_HEAP_RUNTIME_STATS=y
10+
11+
CONFIG_LV_FONT_MONTSERRAT_12=y
12+
CONFIG_LV_FONT_MONTSERRAT_14=y
13+
CONFIG_LV_FONT_MONTSERRAT_16=y
14+
CONFIG_LV_FONT_MONTSERRAT_18=y
15+
CONFIG_LV_FONT_MONTSERRAT_24=y
16+
17+
# Benchmark Demo
18+
CONFIG_LV_USE_FONT_COMPRESSED=y
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sample:
2+
description: LVGL multi-display sample
3+
name: LVGL Multi-display
4+
common:
5+
modules:
6+
- lvgl
7+
filter: dt_comp_enabled("zephyr,displays")
8+
tags:
9+
- samples
10+
- display
11+
- lvgl
12+
- gui
13+
harness_config:
14+
fixture: fixture_display
15+
tests:
16+
sample.modules.lvgl.multi_display:
17+
integration_platforms:
18+
- native_sim/native/64

0 commit comments

Comments
 (0)