How to create custom themes in LVGL v8?

How to create custom themes in LVGL v8?

The very only LVGL example of custom theme was the Printer Demo, but it was not ported to LVGL v8.

I have already developed projects using LVGL v7 and now I’m trying to develop with LVGL v8 (current version), but I am struggling with the very start, creating a theme.

A lot has changed in this subject from LVGL v7 to LVGL v8, but I couldn’t find any proper documentation explaining how to port something like that project to LVGL v8. I am wasting a lot of time studying the library source code instead of programming and about to consider keep developing with LVGL v7.

Please help.

In one of my recent experience, with a project that was started with v7 we decide to rewrite almost from scratch the things with lvgl v8. It was easier than try to understand how to exactly map v7 setup to v8.

The source code for Default, Basic and Mono themes show how to implement themes in LVGL v8.

The Example Style 14 shows how to extend the current theme.

Example Style 14: It looks like it is initializing a default theme and then overwriting/extending it, and if so, how to use a custom theme as default?

After the driver setup, the desired theme needs to be set to the disp variable.

For instance, this is how the default theme is set:

    if(lv_theme_default_is_inited() == false) {
        disp->theme = lv_theme_default_init(disp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED),
                                            LV_THEME_DEFAULT_DARK, LV_FONT_DEFAULT);
    else {
        disp->theme = lv_theme_default_get();

Or via the function

void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)