This is my work in progress, not a tutorial! But someone might find it hlepful.
Because it’s not a good approach to directly write changes to themes defined int the lvgl library (lvgl/src/lv_themes), I’m working on “how to” make my own theme completely. My IDE is STM32CubeIde, LVGL is 7.x.x. I assume having working LVGL project.
1)
Copy lv_theme_template.c from project_root/lvgl/src/lv_themes/ into project_root/Core/Src/
Copy lv_theme_template.h from project_root/lvgl/src/lv_themes/ into project_root/Core/Src/
Rename copied files them to own names (lv_theme_myown.c, lv_theme_myown.h)
2)
In the lv_conf.h file find this line:
#define LV_THEME_DEFAULT_INCLUDE <stdint.h> /*Include a header for the init. function*/
And change it to:
#define LV_THEME_DEFAULT_INCLUDE <lv_theme_myown.h>
3)
In the lv_conf.h find line:
#define LV_THEME_DEFAULT_INIT lv_theme_template_init
And change it to:
#define LV_THEME_DEFAULT_INIT lv_theme_myown_init
4)
Also in lv_conf.h change these defines to 0:
/*================ * THEME USAGE *================*/ ... #define LV_USE_THEME_EMPTY 0 ... #define LV_USE_THEME_TEMPLATE 0 ... #define LV_USE_THEME_MATERIAL 0 ... #define LV_USE_THEME_MONO 0
5)
In file lv_theme_myown.c change name of the function lv_theme_template_init(….) and change it to lv_theme_myown_init(….)
lv_theme_t * lv_theme_template_init(....) //change it to: lv_theme_t * lv_theme_myown_init(....) //Do the same in lv_theme_myown.h
Do the same in lv_theme_myown.h
6)
In lv_theme_myown.c find:
/********************* * INCLUDES *********************/ #include "../../lvgl.h" /*To see all the widgets*/ #if LV_USE_THEME_TEMPLATE #include "../lv_misc/lv_gc.h"
and change it to:
/********************* * INCLUDES *********************/ #include "lvgl/lvgl.h" /*To see all the widgets*/ //#if LV_USE_THEME_TEMPLATE #include "lvgl/src/lv_misc/lv_gc.h"
Don’t forget #endif at the end of file!
Now you can edit your own LVGL theme based on the template theme.
Leave a Reply