• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

benchmark/18-Mar-2025-2,7822,172

ebike/18-Mar-2025-34,13930,876

flex_layout/18-Mar-2025-1,066653

high_res/18-Mar-2025-720,879712,717

keypad_encoder/18-Mar-2025-272162

multilang/18-Mar-2025-12,99311,249

music/18-Mar-2025-8,9958,217

render/18-Mar-2025-1,8751,510

scroll/18-Mar-2025-15374

smartwatch/18-Mar-2025-15,88313,371

stress/18-Mar-2025-521375

transform/18-Mar-2025-348244

vector_graphic/18-Mar-2025-552410

widgets/18-Mar-2025-2,1941,819

README.mdD18-Mar-20254.5 KiB158112

lv_demos.cD18-Mar-20253.1 KiB14186

lv_demos.hD18-Mar-20251.8 KiB10854

README.md

1# Demos for LVGL
2
3## Add the examples to your projects
41. demos can be found in the 'demos' folder once you clone the lvgl.
5
62. 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
17/* Demonstrate the usage of encoder and keyboard */
18#define LV_USE_DEMO_KEYPAD_AND_ENCODER     0
19
20/* Benchmark your system */
21#define LV_USE_DEMO_BENCHMARK   0
22
23/* Stress test for LVGL */
24#define LV_USE_DEMO_STRESS      0
25
26/* Music player demo */
27#define LV_USE_DEMO_MUSIC       0
28#if LV_USE_DEMO_MUSIC
29# define LV_DEMO_MUSIC_SQUARE       0
30# define LV_DEMO_MUSIC_LANDSCAPE    0
31# define LV_DEMO_MUSIC_ROUND        0
32# define LV_DEMO_MUSIC_LARGE        0
33# define LV_DEMO_MUSIC_AUTO_PLAY    0
34#endif
35
36/* Flex layout demo */
37#define LV_USE_DEMO_FLEX_LAYOUT     0
38
39/* Smart-phone like multi-language demo */
40#define LV_USE_DEMO_MULTILANG       0
41
42/* Widget transformation demo */
43#define LV_USE_DEMO_TRANSFORM       0
44
45/* Demonstrate scroll settings */
46#define LV_USE_DEMO_SCROLL          0
47...
48```
49
503. If your development environment or toolchain does not add source files inside '***lvgl***' folder automatically, ensure the `demos` folder is included for compilation.
514. Include "***demos/lv_demos.h***" in your application source file, for example:
52
53```c
54//! main.c
55#include "lvgl.h"
56#include "demos/lv_demos.h"
57...
58```
59
60## Configure Demos Entry
61
62"demos/lv_demos.c" provides `lv_demos_create` and `lv_demos_show_help` to simplify the creation of demos.
63
64If you build your main program named `lv_demos`, then you can run the widgets demo by running `lv_demos widgets` and the benchmark demo by running `lv_demos benchmark 1`.
65
66For example:
67
68```c
69//! main.c
70#include "lvgl.h"
71#include "demos/lv_demos.h"
72
73...
74static lv_display_t* hal_init(void)
75{
76  lv_display_t* disp = NULL;
77
78  ...
79  /* TODO: init display and indev */
80  ...
81
82  return disp;
83}
84
85int main(int argc, char ** argv)
86{
87  lv_init();
88
89  lv_display_t* disp = hal_init();
90  if (disp == NULL) {
91    LV_LOG_ERROR("lv_demos initialization failure!");
92    return 1;
93  }
94
95  if (!lv_demos_create(&argv[1], argc - 1)) {
96    lv_demos_show_help();
97    goto demo_end;
98  }
99
100  while (1) {
101    uint32_t delay = lv_timer_handler();
102    if (delay < 1) delay = 1;
103    usleep(delay * 1000);
104  }
105
106demo_end:
107  lv_deinit();
108  return 0;
109}
110
111```
112
113## Demos
114
115### Widgets
116Shows how the widgets look like out of the box using the built-in material theme.
117
118See in [widgets](https://github.com/lvgl/lvgl/tree/master/demos/widgets) folder.
119
120![Basic demo to show the widgets of LVGL](widgets/screenshot1.png)
121
122For running this demo properly, please make sure **LV_MEM_SIZE** is at least **38KB** (and **48KB** is recommended):
123
124```c
125#define LV_MEM_SIZE    (38ul * 1024ul)
126```
127
128
129
130### Music player
131The 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.
132
133See in [music](https://github.com/lvgl/lvgl/tree/master/demos/music) folder.
134
135![Music player demo with LVGL](music/screenshot1.gif)
136
137### Keypad and encoder
138LVGL 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.
139Learn more about the touchpad-less usage of LVGL [here](https://docs.lvgl.io/master/overview/indev.html#keypad-and-encoder).
140
141See in [keypad_encoder](https://github.com/lvgl/lvgl/tree/master/demos/keypad_encoder) folder.
142
143![Keypad and encoder navigation in LVGL embedded GUI library](keypad_encoder/screenshot1.png)
144
145### Benchmark
146A demo to measure the performance of LVGL or to compare different settings.
147See in [benchmark](https://github.com/lvgl/lvgl/tree/master/demos/benchmark) folder.
148![Benchmark demo with LVGL embedded GUI library](benchmark/screenshot1.png)
149
150### Stress
151A 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.
152See in [stress](https://github.com/lvgl/lvgl/tree/master/demos/stress) folder.
153![Stress test for LVGL](stress/screenshot1.png)
154
155## Contributing
156For contribution and coding style guidelines, please refer to the file docs/CONTRIBUTING.md in the main LVGL repo:
157  https://github.com/lvgl/lvgl
158