How to switch between Dark and Light Mode in V8.0 - Possible error in Documentation

Description

I would like to Switch between Dark Mode and Light Mode using the lv_theme_default in V8.1.0

In the LVGL Master Branch Documentation:
https://docs.lvgl.io/master/overview/style.html

Under the Paragraph: Themes
The following is stated:

lv_theme_t * th = lv_theme_default_init(display,  /*Use the DPI, size, etc from this display*/ 
                                        LV_COLOR_PALETTE_BLUE, LV_COLOR_PALETTE_CYAN,   /*Primary and secondary palette*/
                                        false,    /*Light or dark mode*/ 
                                        &lv_font_montserrat_10, &lv_font_montserrat_14, &lv_font_montserrat_18); /*Small, normal, large fonts*/
                                        
lv_disp_set_theme(display, th); /*Assign the theme to the display*/

In this code excerpt from the documentation, as you can see they expect three font parameters i.e.
Small, Normal and Large Fonts.

However, in lv_theme_default.c the function is defined as:

lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)

and thus only takes one font parameter, and thus it fails to compile.
But in the code in lv_theme_default.c it does initialize all three fonts:

theme.disp = disp;
theme.color_primary = color_primary;
theme.color_secondary = color_secondary;
theme.font_small = font;
theme.font_normal = font;
theme.font_large = font;
theme.apply_cb = theme_apply;
theme.flags = dark ? MODE_DARK : 0;
  • I can probably assume that that would be the Normal font, but would like clarification please?

  • Can the documentation be updated to reflect the proper use case?.

  • I also note that the function is not included later on in the API functions section.

What MCU/Processor/Board and compiler are you using?

VSCode 1.58.0-insider, ESP32-WROOM-32E Devkit 4.0
Espressif plugin 1.1.0
ESP-IDF release/4.2
Win 10
KConfig used.

What LVGL version are you using?

LVGL 8.1.0 (dev) i.e master.

What do you want to achieve?

Trying to switch between Dark and Light themes.

What have you tried so far?

/**

 * @brief Sets the current theme Dark or Light

 * Called from packhouse_config too.

 */

void packhouse_set_theme(packhouse_config_t *ph)

{

  lv_theme_t * th = lv_disp_get_theme(NULL);

  //lv_disp_t * disp = obj ? lv_obj_get_disp(obj) : lv_disp_get_default();

  lv_disp_t * disp = lv_disp_get_default();

   bool flag = ph->ph_dark_mode ? 1 : 0;

    //theme.flags = dark ? MODE_DARK : 0;

    lv_theme_default_init(disp, th->color_primary, th->color_secondary,

                          flag,

                          th->font_small, th->font_normal, th->font_large);

}

Comment

This is probably not the best way of achieving my goal. I have purposely left in some of my comments in the code excerpt so others can see how I came to my conclusions when converting from V7 to V8.1.0
I’ll be thankful for any help.