Skip to content

Commit 44a1a39

Browse files
committed
[update]将lvgl官方的demo也加入到构建中
1 parent c557ee1 commit 44a1a39

80 files changed

Lines changed: 28998 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎L3_Middlewares/CMakeLists.txt‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ if(USE_LVGL)
2222

2323
add_library(lvgl_config INTERFACE)
2424
target_include_directories(lvgl_config INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/LVGL)
25-
target_compile_definitions(lvgl_config INTERFACE
26-
LV_CONF_BUILD_DISABLE_DEMOS=1
27-
)
25+
target_compile_definitions(lvgl_config INTERFACE)
2826
target_link_libraries(lvgl PUBLIC l1_mcu)
2927
endif()
3028

@@ -38,7 +36,7 @@ if(USE_FATFS)
3836
endif()
3937

4038
if(USE_LVGL)
41-
target_link_libraries(l3_middlewares INTERFACE lvgl lvgl::examples lvgl_config)
39+
target_link_libraries(l3_middlewares INTERFACE lvgl lvgl::examples lvgl::demos lvgl_config)
4240
endif()
4341

4442
target_link_libraries(l3_middlewares INTERFACE l2_core global_macros global_options)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Demos for LVGL
2+
3+
## Add the examples to your projects
4+
1. demos can be found in the 'demos' folder once you clone the lvgl.
5+
6+
2. In the ***lv_conf.h*** or equivalent places, you can find demo related macros, change its value to enable or disable specified demos:
7+
8+
```c
9+
...
10+
/*===================
11+
* DEMO USAGE
12+
====================*/
13+
14+
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
15+
#define LV_USE_DEMO_WIDGETS 0
16+
#if LV_USE_DEMO_WIDGETS
17+
#define LV_DEMO_WIDGETS_SLIDESHOW 0
18+
#endif
19+
20+
/*Demonstrate the usage of encoder and keyboard*/
21+
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
22+
23+
/*Benchmark your system*/
24+
#define LV_USE_DEMO_BENCHMARK 0
25+
26+
/*Stress test for LVGL*/
27+
#define LV_USE_DEMO_STRESS 0
28+
29+
/*Music player demo*/
30+
#define LV_USE_DEMO_MUSIC 0
31+
#if LV_USE_DEMO_MUSIC
32+
# define LV_DEMO_MUSIC_SQUARE 0
33+
# define LV_DEMO_MUSIC_LANDSCAPE 0
34+
# define LV_DEMO_MUSIC_ROUND 0
35+
# define LV_DEMO_MUSIC_LARGE 0
36+
# define LV_DEMO_MUSIC_AUTO_PLAY 0
37+
#endif
38+
...
39+
```
40+
41+
3. If your development environment or toolchain does not add source files inside '***lvgl***' folder automatically, ensure the `demos` folder is included for compilation.
42+
4. Include "***demos/lv_demos.h***" in your application source file, for example:
43+
44+
```c
45+
//! main.c
46+
#include "lvgl.h"
47+
#include "demos/lv_demos.h"
48+
...
49+
```
50+
51+
52+
53+
## Demos
54+
55+
### Widgets
56+
Shows how the widgets look like out of the box using the built-in material theme.
57+
58+
See in [widgets](https://github.com/lvgl/lvgl/tree/master/demos/widgets) folder.
59+
60+
<img src="https://github.com/lvgl/lvgl/tree/master/demos/widgets/screenshot1.png?raw=true" width=600px alt="Basic demo to show the widgets of LVGL">
61+
62+
For running this demo properly, please make sure **LV_MEM_SIZE** is at least **38KB** (and **48KB** is recommended):
63+
64+
```c
65+
#define LV_MEME_SIZE (38ul * 1024ul)
66+
```
67+
68+
69+
70+
### Music player
71+
The music player demo shows what kind of modern, smartphone-like user interfaces can be created on LVGL. It works the best with display with 480x272 or 272x480 resolution.
72+
73+
See in [music](https://github.com/lvgl/lvgl/tree/master/demos/music) folder.
74+
75+
<img src="https://github.com/lvgl/lvgl/tree/master/demos/music/screenshot1.gif?raw=true" width=600px alt="Music player demo with LVGL">
76+
77+
### Keypad and encoder
78+
LVGL allows you to control the widgets with a keypad and/or encoder without a touchpad. This demo shows how to handle buttons, drop-down lists, rollers, sliders, switches, and text inputs without touchpad.
79+
Learn more about the touchpad-less usage of LVGL [here](https://docs.lvgl.io/master/overview/indev.html#keypad-and-encoder).
80+
81+
See in [keypad_encoder](https://github.com/lvgl/lvgl/tree/master/demos/keypad_encoder) folder.
82+
83+
<img src="https://github.com/lvgl/lvgl/tree/master/demos/keypad_encoder/screenshot1.png?raw=true" width=600px alt="Keypad and encoder navigation in LVGL embedded GUI library">
84+
85+
### Benchmark
86+
A demo to measure the performance of LVGL or to compare different settings.
87+
See in [benchmark](https://github.com/lvgl/lvgl/tree/master/demos/benchmark) folder.
88+
<img src="https://github.com/lvgl/lvgl/tree/master/demos/benchmark/screenshot1.png?raw=true" width=600px alt="Benchmark demo with LVGL embedded GUI library">
89+
90+
### Stress
91+
A stress test for LVGL. It contains a lot of object creation, deletion, animations, style usage, and so on. It can be used if there is any memory corruption during heavy usage or any memory leaks.
92+
See in [stress](https://github.com/lvgl/lvgl/tree/master/demos/stress) folder.
93+
<img src="https://github.com/lvgl/lvgl/tree/master/demos/stress/screenshot1.png?raw=true" width=600px alt="Stress test for LVGL">
94+
95+
## Contributing
96+
For contribution and coding style guidelines, please refer to the file docs/CONTRIBUTING.md in the main LVGL repo:
97+
  https://github.com/lvgl/lvgl
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Benchmark demo
2+
3+
## Overview
4+
5+
The benchmark demo tests the performance in various cases.
6+
For example rectangle, border, shadow, text, image blending, image transformation, blending modes, etc.
7+
All tests are repeated with 50% opacity.
8+
9+
The size and position of the objects during testing are set with a pseudo random number to make the benchmark repeatable.
10+
11+
On to top of the screen the title of the current test step, and the result of the previous step is displayed.
12+
13+
## Run the benchmark
14+
- In `lv_conf.h` or equivalent places set `LV_USE_DEMO_BENCHMARK 1`
15+
- After `lv_init()` and initializing the drivers call `lv_demo_benchmark()`
16+
- If you only want to run a specific scene for any purpose (e.g. debug, performance optimization etc.), you can call `lv_demo_benchmark_run_scene()` instead of `lv_demo_benchmark()`and pass the scene number.
17+
- If you enabled trace output by setting macro `LV_USE_LOG` to `1` and trace level `LV_LOG_LEVEL` to `LV_LOG_LEVEL_USER` or higher, benchmark results are printed out in `csv` format.
18+
- If you want to know when the testing is finished, you can register a callback function via `lv_demo_benchmark_register_finished_handler()` before calling `lv_demo_benchmark()` or `lv_demo_benchmark_run_scene()`.
19+
- If you want to know the maximum rendering performance of the system, call `lv_demo_benchmark_set_max_speed(true)` before `lv_demo_benchmark()`.
20+
21+
## Interpret the result
22+
23+
The FPS is measured like this:
24+
- load the next step
25+
- in the display driver's `monitor_cb` accumulate the time-to-render and the number of cycles
26+
- measure for 1 second
27+
- calculate `FPS = time_sum / render_cnt`
28+
29+
Note that it can result in very high FPS results for simple cases.
30+
E.g. if some simple rectangles are drawn in 5 ms, the benchmark will tell it's 200 FPS.
31+
So it ignores `LV_DISP_REFR_PERIOD` which tells LVGL how often it should refresh the screen.
32+
In other words, the benchmark shows the FPS from the pure rendering time.
33+
34+
By default, only the changed areas are refreshed. It means if only a few pixels are changed in 1 ms the benchmark will show 1000 FPS. To measure the performance with full screen refresh uncomment `lv_obj_invalidate(lv_scr_act())` in `monitor_cb()` in `lv_demo_benchmark.c`.
35+
36+
![LVGL benchmark running](screenshot1.png)
37+
38+
If you are doing performance analysis for 2D image processing optimization, LCD latency (flushing data to LCD) introduced by `disp_flush()` might dilute the performance results of the LVGL drawing process, hence make it harder to see your optimization results (gain or loss). To avoid such problem, please:
39+
40+
1. Use a flag to control the LCD flushing inside `disp_flush()`. For example:
41+
42+
```c
43+
volatile bool disp_flush_enabled = true;
44+
45+
/* Enable updating the screen (the flushing process) when disp_flush() is called by LVGL
46+
*/
47+
void disp_enable_update(void)
48+
{
49+
disp_flush_enabled = true;
50+
}
51+
52+
/* Disable updating the screen (the flushing process) when disp_flush() is called by LVGL
53+
*/
54+
void disp_disable_update(void)
55+
{
56+
disp_flush_enabled = false;
57+
}
58+
59+
static void disp_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
60+
{
61+
if(disp_flush_enabled) {
62+
GLCD_DrawBitmap(area->x1, //!< x
63+
area->y1, //!< y
64+
area->x2 - area->x1 + 1, //!< width
65+
area->y2 - area->y1 + 1, //!< height
66+
(const uint8_t *)color_p);
67+
}
68+
69+
/*IMPORTANT!!!
70+
*Inform the graphics library that you are ready with the flushing*/
71+
lv_disp_flush_ready(disp_drv);
72+
}
73+
```
74+
75+
2. Disable flushing before calling `lv_demo_benchmark()` or `lv_demo_benchmark_run_scene()`, for example:
76+
77+
```c
78+
extern void disp_enable_update(void);
79+
extern void disp_disable_update(void);
80+
81+
static void on_benchmark_finished(void)
82+
{
83+
disp_enable_update();
84+
}
85+
86+
int main(void)
87+
{
88+
lv_init();
89+
lv_port_disp_init();
90+
lv_port_indev_init();
91+
92+
LV_LOG("Running LVGL Benchmark...");
93+
LV_LOG("Please stand by...");
94+
LV_LOG("NOTE: You will NOT see anything until the end.");
95+
96+
disp_disable_update();
97+
98+
lv_demo_benchmark_set_finished_cb(&on_benchmark_finished);
99+
lv_demo_benchmark_set_max_speed(true);
100+
lv_demo_benchmark();
101+
102+
//lv_demo_benchmark_run_scene(43); // run scene no 31
103+
104+
...
105+
while(1){
106+
lv_timer_handler(); //! run lv task at the max speed
107+
}
108+
}
109+
```
110+
111+
112+
113+
3. Alternatively, you can use trace output to get the benchmark results in csv format by:
114+
- Setting macro `LV_USE_LOG` to `1`
115+
- Setting trace level `LV_LOG_LEVEL` to `LV_LOG_LEVEL_USER` or higher.
116+
117+
118+
119+
120+
## Result summary
121+
In the end, a table is created to display measured FPS values.
122+
123+
On top of the summary screen, the "Weighted FPS" value is shown.
124+
In this, the result of the more common cases are taken into account with a higher weight.
125+
126+
"Opa. speed" shows the speed of the measurements with opacity compared to full opacity.
127+
E.g. "Opa. speed = 90%" means that rendering with opacity is 10% slower.
128+
129+
In the first section of the table, "Slow but common cases", those cases are displayed which are considered common but were slower than 20 FPS.
130+
131+
Below this in the "All cases section" all the results are shown. The < 10 FPS results are shown with red, the >= 10 but < 20 FPS values are displayed with orange.
132+
133+
134+
![LVGL benchmark result summary](https://github.com/lvgl/lvgl/tree/master/demos/benchmark/screenshot2.png?raw=true)

0 commit comments

Comments
 (0)