-
Notifications
You must be signed in to change notification settings - Fork 7.5k
samples/modules: Add LVGL demo sample #62904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Copyright (c) 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(lvgl_sample) | ||
|
||
set(LVGL_DIR ${ZEPHYR_LVGL_MODULE_DIR}) | ||
|
||
FILE(GLOB app_sources src/*.c) | ||
target_sources(app PRIVATE ${app_sources}) | ||
|
||
target_include_directories(app PRIVATE | ||
${LVGL_DIR}/demos/ | ||
) | ||
|
||
target_sources_ifdef(CONFIG_LV_USE_DEMO_MUSIC app PRIVATE | ||
${LVGL_DIR}/demos/music/lv_demo_music_list.c | ||
${LVGL_DIR}/demos/music/lv_demo_music.c | ||
${LVGL_DIR}/demos/music/lv_demo_music_main.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_next.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_top_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_4_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_4.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_right.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_1.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_slider_knob_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_3.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_pause.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_pause_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_bottom_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_2_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_play_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_top.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_play_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_1_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_wave_bottom.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_left_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_play.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_list_border.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_2.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_next_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_play.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_list_border_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_rnd.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_3.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_prev_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_loop.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_1.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_slider_knob.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_right_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_corner_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_corner_left.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_2_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_3_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_icon_1_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_2.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_prev.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_rnd_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_pause_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_cover_3_large.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_list_pause.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_logo.c | ||
${LVGL_DIR}/demos/music/assets/img_lv_demo_music_btn_loop_large.c | ||
) | ||
|
||
target_sources_ifdef(CONFIG_LV_USE_DEMO_BENCHMARK app PRIVATE | ||
${LVGL_DIR}/demos/benchmark/lv_demo_benchmark.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_indexed16.c | ||
${LVGL_DIR}/demos/benchmark/assets/lv_font_bechmark_montserrat_28_compr_az.c.c | ||
${LVGL_DIR}/demos/benchmark/assets/lv_font_bechmark_montserrat_16_compr_az.c.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_argb.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_alpha16.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_rgb.c | ||
${LVGL_DIR}/demos/benchmark/assets/lv_font_bechmark_montserrat_12_compr_az.c.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_chroma_keyed.c | ||
${LVGL_DIR}/demos/benchmark/assets/img_benchmark_cogwheel_rgb565a8.c | ||
) | ||
|
||
target_sources_ifdef(CONFIG_LV_USE_DEMO_STRESS app PRIVATE | ||
${LVGL_DIR}/demos/stress/lv_demo_stress.c | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
choice LV_Z_DEMO | ||
prompt "LVGL demo to build" | ||
default LV_Z_DEMO_MUSIC | ||
help | ||
Demo application to build. | ||
|
||
config LV_Z_DEMO_MUSIC | ||
bool "LVGL music demo" | ||
select LV_USE_DEMO_MUSIC | ||
help | ||
Build music player demo application. | ||
|
||
config LV_Z_DEMO_BENCHMARK | ||
bool "LVGL benchmark demo" | ||
select LV_USE_DEMO_BENCHMARK | ||
help | ||
Build benchmarking demo application. | ||
|
||
config LV_Z_DEMO_STRESS | ||
bool "LVGL stress demo" | ||
select LV_USE_DEMO_STRESS | ||
help | ||
Build stress testing demo application. | ||
|
||
endchoice | ||
|
||
source "Kconfig.zephyr" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.. zephyr:code-sample:: lvgl-demos | ||
:name: LVGL demos | ||
:relevant-api: display_interface | ||
|
||
Run LVGL built-in demos. | ||
|
||
Overview | ||
******** | ||
|
||
A sample showcasing upstream LVGL demos. | ||
|
||
* Music | ||
The music player demo shows what kind of modern, smartphone-like user interfaces can be created on LVGL. | ||
* Benchmark | ||
The benchmark demo tests the performance in various cases. For example rectangle, border, shadow, text, image blending, image transformation, blending modes, etc. | ||
* Stress | ||
A stress test for LVGL. It contains a lot of object creation, deletion, animations, styles usage, and so on. It can be used if there is any memory corruption during heavy usage or any memory leaks. | ||
|
||
Requirements | ||
************ | ||
|
||
* A board with display, ideally with 480x272 resolution or higher. | ||
|
||
Building and Running | ||
******************** | ||
|
||
These demos can be built as follows: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/modules/lvgl/demos | ||
:host-os: unix | ||
:board: native_posix | ||
:gen-args: -DCONFIG_LV_Z_DEMO_MUSIC=y | ||
:goals: run | ||
:compact: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/modules/lvgl/demos | ||
:host-os: unix | ||
:board: native_posix | ||
:gen-args: -DCONFIG_LV_Z_DEMO_BENCHMARK=y | ||
:goals: run | ||
:compact: | ||
|
||
.. zephyr-app-commands:: | ||
:zephyr-app: samples/modules/lvgl/demos | ||
:host-os: unix | ||
:board: native_posix | ||
:gen-args: -DCONFIG_LV_Z_DEMO_STRESS=y | ||
:goals: run | ||
:compact: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_MAIN_STACK_SIZE=4096 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Enable PXP DMA engine and set rotation angle to 0 degrees. | ||
# This allows us to verify the DMA driver functions without altering | ||
# the output image | ||
CONFIG_DMA=y | ||
CONFIG_MCUX_ELCDIF_PXP=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Enable PXP DMA engine and set rotation angle to 0 degrees. | ||
# This allows us to verify the DMA driver functions without altering | ||
# the output image | ||
CONFIG_DMA=y | ||
CONFIG_MCUX_ELCDIF_PXP=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_LV_COLOR_DEPTH_32=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2023, Fabian Blatz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
&sdl_dc { | ||
compatible = "zephyr,sdl-dc"; | ||
height = <272>; | ||
width = <480>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_LV_COLOR_DEPTH_32=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright (c) 2023, Fabian Blatz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "native_posix.overlay" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_LV_COLOR_DEPTH_32=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright (c) 2023, Fabian Blatz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "native_posix.overlay" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2023 Fabian Blatz <[email protected]> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
CONFIG_LV_COLOR_DEPTH_32=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright (c) 2023, Fabian Blatz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "native_sim.overlay" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CONFIG_MAIN_STACK_SIZE=2048 | ||
CONFIG_LOG=y | ||
CONFIG_SHELL=y | ||
faxe1008 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
CONFIG_LVGL=y | ||
CONFIG_LV_Z_MEM_POOL_NUMBER_BLOCKS=8 | ||
CONFIG_LV_Z_SHELL=y | ||
CONFIG_LV_USE_MONKEY=y | ||
|
||
CONFIG_DISPLAY=y | ||
CONFIG_INPUT=y | ||
|
||
CONFIG_LV_FONT_MONTSERRAT_12=y | ||
CONFIG_LV_FONT_MONTSERRAT_14=y | ||
CONFIG_LV_FONT_MONTSERRAT_16=y | ||
|
||
# Benchmark Demo | ||
CONFIG_LV_USE_FONT_COMPRESSED=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
sample: | ||
description: LVGL sample, containing all upstream demos | ||
name: LVGL demos | ||
common: | ||
modules: | ||
- lvgl | ||
harness: none | ||
filter: dt_chosen_enabled("zephyr,display") | ||
tags: samples lvgl display gui | ||
tests: | ||
sample.modules.lvgl.demo_music: | ||
extra_configs: | ||
- CONFIG_LV_Z_DEMO_MUSIC=y | ||
sample.modules.lvgl.demo_benchmark: | ||
extra_configs: | ||
- CONFIG_LV_Z_DEMO_BENCHMARK=y | ||
sample.modules.lvgl.demo_stress: | ||
extra_configs: | ||
- CONFIG_LV_Z_DEMO_STRESS=y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2023 Fabian Blatz <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/drivers/display.h> | ||
#include <lvgl.h> | ||
#include <lv_demos.h> | ||
|
||
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL | ||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(app); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can just do |
||
|
||
int main(void) | ||
{ | ||
const struct device *display_dev; | ||
|
||
display_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display)); | ||
if (!device_is_ready(display_dev)) { | ||
LOG_ERR("Device not ready, aborting test"); | ||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changes nothing in this case but it's odd to catch an error and return 0... |
||
} | ||
|
||
#if defined(CONFIG_LV_USE_DEMO_MUSIC) | ||
lv_demo_music(); | ||
#elif defined(CONFIG_LV_USE_DEMO_BENCHMARK) | ||
lv_demo_benchmark(); | ||
#elif defined(CONFIG_LV_USE_DEMO_STRESS) | ||
lv_demo_stress(); | ||
#else | ||
#error Enable one of the demos CONFIG_LV_USE_DEMO_MUSIC, CONFIG_LV_USE_DEMO_BENCHMARK \ | ||
or CONFIG_LV_USE_DEMO_STRESS. | ||
#endif | ||
|
||
lv_task_handler(); | ||
display_blanking_off(display_dev); | ||
|
||
while (1) { | ||
k_msleep(lv_task_handler()); | ||
} | ||
|
||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should these be wrapping on 80 columns or something? @kartben @gmarull not sure if it's a rule or guideline or just not a thing for doc files but usually everything in the repo is bounded it seems