Lvgl 9.2.2, esp32-c6-lcd-1.47, idf 5.4.1, st7789v3

Hello,

TLDR: Using Square Line Studio UI and my display, I’ve ended up in the situation where black is white and vice-versa.

In detail:

I have an ESP32-C6-LCD-1.47 device, and I wanted to use modern LVGL and IDF frameworks and Square Line Studio for drawing graphics.

I’ve made a setup following the instructions:

Now I have two different examples of how to set up my device.

However, the most recent example somehow ended in inverted mode, but not entirely for the display. It only affects “background”, which is never black.

There are simple repos with all settings:

The working case with all colors set fine, based on the official example with the small addition of Square Line Studio UI: repo

  • LVGL 8.3.11
  • IDF 5.4.1

And my custom implementation with inverted background, where I’ve tried to use the modern approach repo

  • LVGL 9.2.2
  • IDF 5.4.1

I want to fix the inversion of the background in the second example.

What I’ve tried already:

  • I used lv_draw_sw_rgb565_swap(px_map, (x2 + 1 - x1) * (y2 + 1 - y1)); with or without it does not help, or invert all colours of the display blue-to-pink and black-to-green when the black here is black theme from Square Line Studio, which is showing as white background so that it might convert like white-to-green.

  • I used esp_lcd_panel_invert_color(panel_handle, true); it shows a similar result to the previous method: blue-to-orange but now the white background becomes black, as intended from Square Line UI, however, the Arc object becomes orange…

  • I also checked the example setup, and I’ve tried to implement a similar approach of panel_config, but it does not help either: .data_endian = LCD_RGB_ENDIAN_BGR, // From example

  • The last approach I’ve tried is to find a particular directive which can be related to this inversion at the very beginning of LCD initialization, but still no luck: esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_INVON, NULL, 0); - does not help, and esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_COLMOD, NULL, 0); - does not help either.
    `

The example driver for the current LCD is pretty simple; it only calls one method, esp_lcd_new_panel_st7789t with a finite amount of options code, but I cannot get what is wrong with my setup, and why is the background inverted?

Correction: As I see, the white text is also black on the display, which means not only the background but also two colours are switched: black-to-white and white-to-black.

Adding the control example, when BG color = FFFFFF

Maybe I need to switch some bits, but I can’t see where this option is in the example setup - to recreate the approach and understand the root cause.

Thanks!

Solved.

Trying to reproduce, I’ve made R G B and White panel UI elements to see what color is actually shifted. I saw blue and red switch places after the flash.

So I’ve tried to change two options:

LCD_RGB_ELEMENT_ORDER_RGB
LCD_RGB_ENDIAN_RGB
  • both were BGR, because I thought my display had a different order, but it’s not! It was just reversed from the beginning. So I moved back to basics.
  1. Proper RGB:
esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = DISP_GPIO_RST,
        .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
        .bits_per_pixel = 16,
        .data_endian = LCD_RGB_ENDIAN_RGB, // From example
        .flags = { .reset_active_high = 0 },  // Not in the example
    };
  1. Set panel param to invert bit:
esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_INVON, NULL, 0);
  1. At LVGL driver set rgb565:
    lv_draw_sw_rgb565_swap(px_map, (x2 + 1 - x1) * (y2 + 1 - y1));

Now works!
Photo colours are a bit off, but the colors are matched in real life.

However, there are a few dirty pixels around the Arc starting position, which are green. Don’t know why, but I will play with the setup a bit more.

Solved 2: proper paned config from the beginning and LCD inversion ON - all colours are back and there is no need to further inversions:

    esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = DISP_GPIO_RST,
        .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
        .bits_per_pixel = 16,
        .data_endian = LCD_RGB_ENDIAN_BGR, // From example
        .flags = { .reset_active_high = 0 },  // Not in the example
    };
    esp_lcd_panel_io_tx_param(io_handle, LCD_CMD_INVON, NULL, 0);

No need esp_lcd_panel_invert_color and lv_draw_sw_rgb565_swap

data_endian is the same thing as lv_draw_sw_rgb565_swap

1 Like