a color of st7789 lcd is not correct

hyu7000
Posts: 12
Joined: Fri Oct 07, 2022 6:20 am

a color of st7789 lcd is not correct

Postby hyu7000 » Thu Dec 29, 2022 7:07 am

board : esp32s3 - wroom - 1
esp-idf 5.0

hi. im testing spi lcd example : lcd_tjpgd_example_main

my issue is that the color is not display on the LCD, but other color are displayed.

ex) i set Blue(0x001F, RGB565), but lcd displayed Green.

Code: Select all

uint16_t num[100];
for(int i = 0; i < 100; i++)
{
    num[i] = 0x001F;
}
esp_lcd_panel_draw_bitmap(panel_handle, 0, 140, 24, 143, &num);
when i set Blue(0x001F), lcd show Green.
when i set Red(0xF800), lcd show Blue.
when i set Green(0x07E0), lcd show Red.

I tried changing .rgb_endian of a panel_config and add esp_lcd_panel_invert_color() , but it didn't work. (LCD_RGB_ENDIAN_RGB <-> LCD_RGB_ENDIAN_BGR)

What should I try?

kenneth
Posts: 3
Joined: Thu Jan 19, 2023 3:16 am

Re: a color of st7789 lcd is not correct

Postby kenneth » Thu Jan 19, 2023 6:25 am

You could try changing the endianess of the color values. Even though esp-idf calls the pixel format "endian" when changing between RGB and BGR, it's not the same as swapping the byte order, at least not on 565 format. A RGB uint16 with

Code: Select all

RRRR RGGG GGGB BBBB
becomes

Code: Select all

GGGB BBBB RRRR RGGG
after swapping byte format which is not the same as BGR order.

I'm using a TTGO T-Display (clone) and on my LCD I have the pixel format set to RGB like so:

Code: Select all

esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = EXAMPLE_PIN_NUM_RST,
        .rgb_endian = LCD_RGB_ENDIAN_RGB,
        .bits_per_pixel = 16,
    };
colors inverted with

Code: Select all

esp_lcd_panel_invert_color(panel_handle, true)
and everytime I set a color I change the endianess with bswap16(x) that is included in endian.h or with a simple macro:

Code: Select all

#define BYTE_SWAP(v) ((v >> 8) | (v << 8))
In the tjpgd example project the byte order is swapped by the jpeg decoder since the .swap_color_bytes flag is set:

Code: Select all

esp_jpeg_image_cfg_t jpeg_cfg = {
        .indata = (uint8_t *)image_jpg_start,
        .indata_size = image_jpg_end - image_jpg_start,
        .outbuf = (uint8_t*)(*pixels),
        .outbuf_size = IMAGE_W * IMAGE_H * sizeof(uint16_t),
        .out_format = JPEG_IMAGE_FORMAT_RGB565,
        .out_scale = JPEG_IMAGE_SCALE_0,
        .flags = {
            .swap_color_bytes = 1,
        }
    };
but any color set manually needs to be swapped by yourself.

Who is online

Users browsing this forum: BivvyCoder and 95 guests