LVGL can't render normally with my monochrome UI

What do you want to achieve?

Although the code can run successfully in simulator, it can’t run normally on my board.

What have you tried so far?

I try to modify the UI code snippet, but it still can’t work normally. It seems that it is a problem about the rendering, because of the wrong data point by px_map in disp_flush() at lv_port_disp.c.

Code to reproduce

    lv_theme_t * mono_theme;
    mono_theme = lv_theme_mono_init(lv_display_get_default(), true, &lv_font_montserrat_14);
    lv_display_set_theme(lv_display_get_default(), mono_theme);
    
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_text_color(&style, lv_color_white());
    lv_style_set_bg_color(&style, lv_color_black());

    lv_obj_add_style(lv_screen_active(), &style, LV_PART_MAIN);
       
    lv_obj_t * btn1 = lv_button_create(lv_screen_active());
    lv_obj_set_pos(btn1, 10, 10);                         
    lv_obj_set_size(btn1, 60, 30); 
    
    lv_obj_t * label2 = lv_label_create(btn1);
    lv_label_set_text(label2, "btn1");                    

Screenshot and/or video

Environment

  • MCU/MPU/Board: AT32F403AVGT7(just like STM32F4xxx)
  • Diaplay panel: 0.96’ monochrome OLED(128x64) drivered by SSD1306
  • LVGL version: 9.3

It seems that some precautions need to be considered when write a monochrome UI. Below is another UI code, it work normally:

    lv_theme_t * theme = lv_theme_mono_init(lv_display_get_default(), true, NULL);
    lv_display_set_theme(lv_display_get_default(), theme);
    
    /*Create a list*/
    lv_obj_t * list1 = lv_list_create(lv_screen_active());
    lv_obj_set_size(list1, 100, 60);
    lv_obj_set_style_bg_color(list1, lv_color_hex(0x000000), LV_PART_MAIN);
    lv_obj_center(list1);
    
    lv_obj_t * label1 = lv_list_add_text(list1, "File");
    lv_obj_set_style_text_color(label1, lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_t * label2 = lv_list_add_text(list1, "Setting");
    lv_obj_set_style_text_color(label2, lv_color_hex(0xffffff), LV_PART_MAIN);

Everything seems to be ok.

    lv_theme_t * theme = lv_theme_mono_init(lv_display_get_default(), true, NULL);
    lv_display_set_theme(lv_display_get_default(), theme);
    
    /*Create a list*/
    lv_obj_t * list1 = lv_list_create(lv_screen_active());
    lv_obj_set_size(list1, 100, 60);
    lv_obj_set_style_bg_color(list1, lv_color_hex(0x000000), LV_PART_MAIN);
    lv_obj_center(list1);
    
    lv_obj_t * label1 = lv_list_add_text(list1, "File");
    lv_obj_set_style_text_color(label1, lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_t * label2 = lv_list_add_text(list1, "Setting");
    lv_obj_set_style_text_color(label2, lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_t * label3 = lv_list_add_text(list1, "Music");
    lv_obj_set_style_text_color(label3, lv_color_hex(0xffffff), LV_PART_MAIN);
    lv_obj_t * label4 = lv_list_add_text(list1, "Video");
    lv_obj_set_style_text_color(label4, lv_color_hex(0xffffff), LV_PART_MAIN);