Skip to content

Commit 1f4482b

Browse files
committed
samples: subsys: display: Add gui_guider sample
Signed-off-by: Zongchun Yu <zongchun.yu@nxp.com>
1 parent 13daf24 commit 1f4482b

File tree

12 files changed

+477
-0
lines changed

12 files changed

+477
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2025 NXP
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
#
5+
6+
cmake_minimum_required(VERSION 3.20.0)
7+
8+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
9+
project(gui_guider)
10+
11+
FILE(GLOB_RECURSE app_sources src/*.c)
12+
target_include_directories(app PRIVATE src/generated src/custom src/generated/guider_customer_fonts src/generated/guider_fonts src/generated/images)
13+
target_sources(app PRIVATE ${app_sources})
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.. zephyr:code-sample:: gui_guider
2+
:name: GUI Guider basic sample
3+
:relevant-api: display_interface input_interface
4+
5+
Display a slider widget.
6+
7+
Overview
8+
********
9+
10+
This sample application displays a slider in the top left corner of the screen.
11+
12+
Requirements
13+
************
14+
15+
Display shield and a board which provides a configuration
16+
for corresponding connectors, for example:
17+
18+
a simulated display environment in a :zephyr:board:`native_sim <native_sim>` application:
19+
20+
- :zephyr:board:`native_sim`
21+
- `SDL2`_
22+
23+
or
24+
25+
- :zephyr:board:`mimxrt1050_evk`
26+
- `RK043FN02H-CT`_
27+
28+
or
29+
30+
- :zephyr:board:`mimxrt1064_evk`
31+
- `RK043FN02H-CT`_
32+
33+
Building and Running
34+
********************
35+
36+
Example building for :zephyr:board:`mimxrt1064_evk`:
37+
38+
.. zephyr-app-commands::
39+
:zephyr-app: samples/subsys/display/gui_guider
40+
:board: mimxrt1064_evk
41+
:shield: rk043fn02h_ct
42+
:goals: build flash
43+
44+
Example building for :zephyr:board:`native_sim <native_sim>`:
45+
46+
.. zephyr-app-commands::
47+
:zephyr-app: samples/subsys/display/gui_guider
48+
:board: native_sim
49+
:goals: build run
50+
51+
Alternatively, if building from a 64-bit host machine, the previous target
52+
board argument may also be replaced by ``native_sim/native/64``.
53+
54+
References
55+
**********
56+
57+
.. target-notes::
58+
59+
.. _LVGL Web Page: https://lvgl.io/
60+
.. _SDL2: https://www.libsdl.org
61+
.. _RK043FN02H-CT: https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/i.mx-applications-processors/i.mx-rt-series/4.3-lcd-panel:RK043FN02H-CT
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CONFIG_LV_Z_MEM_POOL_SIZE=65536
2+
CONFIG_MAIN_STACK_SIZE=4096
3+
4+
CONFIG_DISPLAY=y
5+
6+
CONFIG_LOG=y
7+
8+
CONFIG_LVGL=y
9+
CONFIG_LV_USE_LOG=y
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
sample:
2+
description: GUI Guider sample application
3+
name: gui guider sample
4+
common:
5+
tags:
6+
- display
7+
- gui
8+
- gui_guider
9+
- samples
10+
modules:
11+
- lvgl
12+
tests:
13+
sample.display.gui_guider.gui:
14+
filter: dt_chosen_enabled("zephyr,display")
15+
# flash usage varies depending on the platform, but ~200K are the bare
16+
# minimum, give some room by adding 50K more. RAM usage depends largerly on
17+
# the display buffer, but a minimum is also required for the system itself.
18+
# ~25K seem to be sufficient for most cases, rounded to 32K.
19+
min_flash: 250
20+
min_ram: 32
21+
harness: none
22+
integration_platforms:
23+
- native_sim/native/64
24+
sample.display.gui_guider.rk055hdmipi4m:
25+
tags: shield
26+
# This sample is intended to test the RT1170 and RT595, which require
27+
# a display shield to work with LVGL
28+
min_flash: 250
29+
# The minimum RAM needed for this display is actually around 8MB,
30+
# but the RT595 uses external PSRAM for the display buffer
31+
min_ram: 32
32+
harness: none
33+
extra_args: SHIELD="rk055hdmipi4ma0"
34+
platform_allow:
35+
- mimxrt1170_evk/mimxrt1176/cm7
36+
- mimxrt595_evk/mimxrt595s/cm33
37+
integration_platforms:
38+
- mimxrt1170_evk/mimxrt1176/cm7
39+
harness_config:
40+
fixture: fixture_display_rk055hdmipi4m
41+
sample.subsys.display.gui_guider.rk043fn66hs_ctg:
42+
tags: shield
43+
platform_allow:
44+
- mimxrt1064_evk
45+
- mimxrt1060_evk/mimxrt1062/qspi
46+
- mimxrt1050_evk/mimxrt1052/hyperflash
47+
- mimxrt1040_evk
48+
integration_platforms:
49+
- mimxrt1040_evk
50+
harness: console
51+
extra_args: SHIELD=rk043fn66hs_ctg
52+
harness_config:
53+
fixture: fixture_display_rk043fn66hs_ctg
54+
sample.subsys.display.gui_guider.rk043fn02h_ct:
55+
tags: shield
56+
platform_allow:
57+
- mimxrt1064_evk
58+
- mimxrt1060_evk@C/mimxrt1062/qspi
59+
- mimxrt1050_evk/mimxrt1052/hyperflash
60+
- mimxrt1040_evk
61+
integration_platforms:
62+
- mimxrt1040_evk
63+
harness: console
64+
extra_args: SHIELD=rk043fn02h_ct
65+
harness_config:
66+
fixture: fixture_display_rk043fn02h_ct
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
8+
/*********************
9+
* INCLUDES
10+
*********************/
11+
#include <stdio.h>
12+
#include "lvgl.h"
13+
#include "custom.h"
14+
15+
/*********************
16+
* DEFINES
17+
*********************/
18+
19+
/**********************
20+
* TYPEDEFS
21+
**********************/
22+
23+
/**********************
24+
* STATIC PROTOTYPES
25+
**********************/
26+
27+
/**********************
28+
* STATIC VARIABLES
29+
**********************/
30+
31+
/**
32+
* Create a demo application
33+
*/
34+
35+
void custom_init(lv_ui *ui)
36+
{
37+
/* Add your codes here */
38+
}
39+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef CUSTOM_H
8+
#define CUSTOM_H
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#include "gui_guider.h"
14+
15+
void custom_init(lv_ui *ui);
16+
17+
#ifdef __cplusplus
18+
}
19+
#endif
20+
#endif /* CUSTOM_H */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "events_init.h"
8+
#include <stdio.h>
9+
#include "lvgl.h"
10+
11+
void events_init(lv_ui *ui)
12+
{
13+
14+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
8+
#ifndef EVENTS_INIT_H
9+
#define EVENTS_INIT_H
10+
#ifdef __cplusplus
11+
extern "C" {
12+
#endif
13+
14+
#include "gui_guider.h"
15+
16+
void events_init(lv_ui *ui);
17+
18+
19+
#ifdef __cplusplus
20+
}
21+
#endif
22+
#endif /* EVENTS_INIT_H */
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "lvgl.h"
8+
#include <stdio.h>
9+
#include "gui_guider.h"
10+
11+
void ui_init_style(lv_style_t * style)
12+
{
13+
if (style->prop_cnt > 1)
14+
lv_style_reset(style);
15+
else
16+
lv_style_init(style);
17+
}
18+
19+
void ui_load_scr_animation(lv_ui *ui, lv_obj_t ** new_scr, bool new_scr_del, bool * old_scr_del, ui_setup_scr_t setup_scr,
20+
lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay, bool is_clean, bool auto_del)
21+
{
22+
lv_obj_t * act_scr = lv_screen_active();
23+
24+
if (auto_del && is_clean) {
25+
lv_obj_clean(act_scr);
26+
}
27+
if (new_scr_del) {
28+
setup_scr(ui);
29+
}
30+
lv_screen_load_anim(*new_scr, anim_type, time, delay, auto_del);
31+
*old_scr_del = auto_del;
32+
}
33+
34+
void ui_animation(void * var, uint32_t duration, int32_t delay, int32_t start_value, int32_t end_value, lv_anim_path_cb_t path_cb,
35+
uint32_t repeat_cnt, uint32_t repeat_delay, uint32_t playback_time, uint32_t playback_delay,
36+
lv_anim_exec_xcb_t exec_cb, lv_anim_start_cb_t start_cb, lv_anim_completed_cb_t ready_cb, lv_anim_deleted_cb_t deleted_cb)
37+
{
38+
lv_anim_t anim;
39+
lv_anim_init(&anim);
40+
lv_anim_set_var(&anim, var);
41+
lv_anim_set_exec_cb(&anim, exec_cb);
42+
lv_anim_set_values(&anim, start_value, end_value);
43+
lv_anim_set_time(&anim, duration);
44+
lv_anim_set_delay(&anim, delay);
45+
lv_anim_set_path_cb(&anim, path_cb);
46+
lv_anim_set_repeat_count(&anim, repeat_cnt);
47+
lv_anim_set_repeat_delay(&anim, repeat_delay);
48+
lv_anim_set_playback_time(&anim, playback_time);
49+
lv_anim_set_playback_delay(&anim, playback_delay);
50+
if (start_cb) {
51+
lv_anim_set_start_cb(&anim, start_cb);
52+
}
53+
if (ready_cb) {
54+
lv_anim_set_completed_cb(&anim, ready_cb);
55+
}
56+
if (deleted_cb) {
57+
lv_anim_set_deleted_cb(&anim, deleted_cb);
58+
}
59+
lv_anim_start(&anim);
60+
}
61+
62+
void init_scr_del_flag(lv_ui *ui)
63+
{
64+
65+
ui->screen_del = true;
66+
}
67+
68+
void setup_bottom_layer(void)
69+
{
70+
lv_theme_apply(lv_layer_bottom());
71+
}
72+
73+
void setup_ui(lv_ui *ui)
74+
{
75+
setup_bottom_layer();
76+
init_scr_del_flag(ui);
77+
setup_scr_screen(ui);
78+
lv_screen_load(ui->screen);
79+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2025 NXP
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef GUI_GUIDER_H
8+
#define GUI_GUIDER_H
9+
#ifdef __cplusplus
10+
extern "C" {
11+
#endif
12+
13+
#include "lvgl.h"
14+
15+
16+
typedef struct
17+
{
18+
19+
lv_obj_t *screen;
20+
bool screen_del;
21+
lv_obj_t *screen_slider_1;
22+
}lv_ui;
23+
24+
typedef void (*ui_setup_scr_t)(lv_ui * ui);
25+
26+
void ui_init_style(lv_style_t * style);
27+
28+
void ui_load_scr_animation(lv_ui *ui, lv_obj_t ** new_scr, bool new_scr_del, bool * old_scr_del, ui_setup_scr_t setup_scr,
29+
lv_screen_load_anim_t anim_type, uint32_t time, uint32_t delay, bool is_clean, bool auto_del);
30+
31+
void ui_animation(void * var, uint32_t duration, int32_t delay, int32_t start_value, int32_t end_value, lv_anim_path_cb_t path_cb,
32+
uint32_t repeat_cnt, uint32_t repeat_delay, uint32_t playback_time, uint32_t playback_delay,
33+
lv_anim_exec_xcb_t exec_cb, lv_anim_start_cb_t start_cb, lv_anim_completed_cb_t ready_cb, lv_anim_deleted_cb_t deleted_cb);
34+
35+
36+
void init_scr_del_flag(lv_ui *ui);
37+
38+
void setup_bottom_layer(void);
39+
40+
void setup_ui(lv_ui *ui);
41+
42+
extern lv_ui guider_ui;
43+
44+
45+
void setup_scr_screen(lv_ui *ui);
46+
47+
48+
49+
#ifdef __cplusplus
50+
}
51+
#endif
52+
#endif /* GUI_GUIDER_H */

0 commit comments

Comments
 (0)