-
demos can be found in the 'demos' folder once you clone the lvgl.
-
In the lv_conf.h or equivalent places, you can find demo related macros, change its value to enable or disable specified demos:
...
/*===================
* DEMO USAGE
====================*/
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
#define LV_USE_DEMO_WIDGETS 0
/*Demonstrate the usage of encoder and keyboard*/
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
/*Benchmark your system*/
#define LV_USE_DEMO_BENCHMARK 0
/*Stress test for LVGL*/
#define LV_USE_DEMO_STRESS 0
/*Music player demo*/
#define LV_USE_DEMO_MUSIC 0
#if LV_USE_DEMO_MUSIC
# define LV_DEMO_MUSIC_SQUARE 0
# define LV_DEMO_MUSIC_LANDSCAPE 0
# define LV_DEMO_MUSIC_ROUND 0
# define LV_DEMO_MUSIC_LARGE 0
# define LV_DEMO_MUSIC_AUTO_PLAY 0
#endif
/*Flex layout demo*/
#define LV_USE_DEMO_FLEX_LAYOUT 0
/*Smart-phone like multi-language demo*/
#define LV_USE_DEMO_MULTILANG 0
/*Widget transformation demo*/
#define LV_USE_DEMO_TRANSFORM 0
/*Demonstrate scroll settings*/
#define LV_USE_DEMO_SCROLL 0
...
- If your development environment or toolchain does not add source files inside 'lvgl' folder automatically, ensure the
demos
folder is included for compilation. - Include "demos/lv_demos.h" in your application source file, for example:
//! main.c
#include "lvgl.h"
#include "demos/lv_demos.h"
...
"demos/lv_demos.c" provides lv_demos_create
and lv_demos_show_help
to simplify the creation of demos.
If 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
.
For example:
//! main.c
#include "lvgl.h"
#include "demos/lv_demos.h"
...
static lv_display_t* hal_init(void)
{
lv_display_t* disp = NULL;
...
/* TODO: init display and indev */
...
return disp;
}
int main(int argc, char ** argv)
{
lv_init();
lv_display_t