Inverts Text on a Monochrom display

Description

I have an ESP32 with a monochrome display with an SSD1603 controller.
I would like create kind of status bar on the top part of the display where I would like to draw the text “inverted” (so the background is the filled, and the text just leaves out the pixels).

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

esp32, monochrome OLED 128x64 with an SSD1603

What LVGL version are you using?

7.9.0

What do you want to achieve?

I would like create kind of status bar on the top part of the display where I would like to draw the text “inverted” (so the background is the filled, and the text just leaves out the pixels).

What have you tried so far?

Tried to create a new style for an label and add that style to the label, but that did not really make any difference.

Code to reproduce

    lv_obj_t * label1 =  lv_label_create(scr, NULL);
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_text_color (& style, LV_STATE_DEFAULT, LV_COLOR_WHITE);
    lv_style_set_bg_color   (& style, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_obj_add_style(label1, LV_LABEL_PART_MAIN, &style);
    lv_label_set_text(label1, "Status Bar");
    lv_obj_set_pos (label1, 10, 1);

I assume you have tried flipping the colors (so the text is black, and the background is white)?

Hi, I tried to reverse the colors, but that I don’t see anything drawn.
So maybe it will draw the test by “removing” the pixels, but I have no idea how to draw the background “filled” before I draw the text.

Are you using lv_port_esp32 or your own driver?

I’m using the lv_port_esp32.

I have managed to achive what I want by:

  • using BLACK as text color and WHITE as background colot
  • set the by opacity to 255 (lv_style_set_bg_opa (& style,LV_STATE_DEFAULT, 255):wink:
  • setting the site of the label to the full with of the screen
  • setting the long mode of the label to LV_LABEL_LONG_CROP

That way, the whole top area of the screen is drawn in inverse!

Thanks for your help!
Martin