espressif / esp-bsp

Board support components for Espressif development boards
Other
141 stars 76 forks source link

Use esp_lcd_ili9341 IPS screen Appears to be a red and yellow reversal (BSP-466) #297

Closed yel-best closed 2 months ago

yel-best commented 2 months ago

Use esp_lcd_ili9341 last version library Use ESP-IDF 5.0.2 version library Use LVGL 8.3.11 version library

The screen used is ILI9341 IPS screen The touch chip is FT6336

Use CONFIG_LV_COLOR_16_SWAP=Y

After I configure all the parameters and initialize LVGL, the colors seem to be inverted when I light up the screen. Red turns to yellow, and yellow turns to red. The effect picture is as follows, but the blue is not inverted. I don’t know what it is. Why, can you give me some help?

84bd755d1f3356a9f0f197fc16bde17


    lv_label_set_text(label, "#FF0000 "LV_SYMBOL_BELL" Hello world Espressif and LVGL "LV_SYMBOL_BELL"\n #FF9400 "LV_SYMBOL_WARNING" For simplier initialization, use BSP "LV_SYMBOL_WARNING" #");
    lv_obj_align(label, LV_ALIGN_CENTER, 0, -30);

#define LVGL_LCD_BL_ON_LEVEL      (1)
gpio_set_level(LVGL_LCD_GPIO_BL, LVGL_LCD_BL_ON_LEVEL)

"#FF0000 " It should be red, “#FF9400” it should be yellow

Introduction to the screen I use: http://www.lcdwiki.com/3.2inch_IPS_SPI_Module_ILI9341

thx

espzav commented 2 months ago

@yel-best Please try to enable or disable option: CONFIG_LV_COLOR_16_SWAP=y in menuconfig

yel-best commented 2 months ago

@yel-best Please try to enable or disable option: CONFIG_LV_COLOR_16_SWAP=y in menuconfig

Thanks, I have updated the description of the question, can you help me take a look?

yel-best commented 2 months ago

@yel-best Please try to enable or disable option: CONFIG_LV_COLOR_16_SWAP=y in menuconfig

CONFIG_LV_COLOR_16_SWAPis even weirder when disabled, so I enabled CONFIG_LV_COLOR_16_SWAP=yby default

d435759a5edeee06c9763108c23e291

yel-best commented 2 months ago

Updates

Since ILI9341 IPS LCD is used

I adjusted it to disable CONFIG_LV_COLOR_16_SWAP

Add code: esp_lcd_panel_invert_color(lcd_panel, true);

Because we see that the inverted color address is 0x21, it should be sufficient.

static esp_err_t panel_ili9341_invert_color(esp_lcd_panel_t *panel, bool invert_color_data)
{
     ili9341_panel_t *ili9341 = __containerof(panel, ili9341_panel_t, base);
     esp_lcd_panel_io_handle_t io = ili9341->io;
     int command = 0;
     if (invert_color_data) {
         command = LCD_CMD_INVON;
     } else {
         command = LCD_CMD_INVOFF;
     }
     ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, command, NULL, 0), TAG, "send command failed");
     return ESP_OK;
}

4aebe187ae46ef8fe5d6ddf7dea7ffe

After selecting the result, the color should be normal according to the fuzzy judgment, but the interface will be blurry. How to solve this problem of fuzzy interface? what is the reason?

espzav commented 2 months ago

This is still not right color settings. It seems, that you should change vendor initialization data: https://github.com/espressif/esp-bsp/blob/05d471ac4a65ea84c6d8bf1c83250b58f1a53beb/components/lcd/esp_lcd_ili9341/include/esp_lcd_ili9341.h#L37 these data can be different for each vendor.

You can try this change: https://github.com/espressif/esp-bsp/commit/b35a400e47cf8a0034cf769c32cbf12fbafdc90a

Lzw655 commented 2 months ago

@yel-best Please try to enable or disable option: CONFIG_LV_COLOR_16_SWAP=y in menuconfig

CONFIG_LV_COLOR_16_SWAPis even weirder when disabled, so I enabled CONFIG_LV_COLOR_16_SWAP=yby default

d435759a5edeee06c9763108c23e291

Hi @yel-best, in this situation (without using invert_color()), I think you can try to change the RGB elements' order as the following code:

    const esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,      // Set to -1 if not use
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)      // Implemented by LCD command `36h`
        .color_space = ESP_LCD_COLOR_SPACE_BGR,
#else
        .rgb_endian = LCD_RGB_ENDIAN_BGR,
#endif
        .bits_per_pixel = 16,                           // Implemented by LCD command `3Ah` (16/18)
        // .vendor_config = &vendor_config,            // Uncomment this line if use custom initialization commands
    };
yel-best commented 2 months ago

@yel-best Please try to enable or disable option: CONFIG_LV_COLOR_16_SWAP=y in menuconfig

CONFIG_LV_COLOR_16_SWAPis even weirder when disabled, so I enabled CONFIG_LV_COLOR_16_SWAP=yby default d435759a5edeee06c9763108c23e291

Hi @yel-best, in this situation (without using invert_color()), I think you can try to change the RGB elements' order as the following code:

    const esp_lcd_panel_dev_config_t panel_config = {
        .reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,      // Set to -1 if not use
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)      // Implemented by LCD command `36h`
        .color_space = ESP_LCD_COLOR_SPACE_BGR,
#else
        .rgb_endian = LCD_RGB_ENDIAN_BGR,
#endif
        .bits_per_pixel = 16,                           // Implemented by LCD command `3Ah` (16/18)
        // .vendor_config = &vendor_config,            // Uncomment this line if use custom initialization commands
    };

thanks , ok

However, in this case, after using inversion, the colors will appear to be correct, but the text content on the screen will be blurred.

4aebe187ae46ef8fe5d6ddf7dea7ffe

Lzw655 commented 2 months ago

This is still not right color settings. It seems, that you should change vendor initialization data:

https://github.com/espressif/esp-bsp/blob/05d471ac4a65ea84c6d8bf1c83250b58f1a53beb/components/lcd/esp_lcd_ili9341/include/esp_lcd_ili9341.h#L37

these data can be different for each vendor. You can try this change: b35a400

@yel-best Ok, looks like this step should be necessary.

yel-best commented 2 months ago

This is still not right color settings. It seems, that you should change vendor initialization data: https://github.com/espressif/esp-bsp/blob/05d471ac4a65ea84c6d8bf1c83250b58f1a53beb/components/lcd/esp_lcd_ili9341/include/esp_lcd_ili9341.h#L37

these data can be different for each vendor. You can try this change: b35a400

@yel-best Ok, looks like this step should be necessary.

yes,you are right. The LCD driver I am currently using should beILI9341v, not the ordinaryILI9341 protocol, so I need to make some modifications. Directly using the cmd in the package will not display properly.

I modified the configuration and used CONFIG_LV_COLOR_16_SWAP=y, and finally I got the desired result

Check out my latest results

5b5d3ae2da81eb60e2de088778da82d

Thank you all for your help, thank you very much 👏

kisvegabor commented 2 months ago

FYI, in LVGL v9 LV_COLOR_16_SWAP is removed and you can call lv_draw_sw_rgb565_swap in the flush_cb.

yel-best commented 2 months ago

FYI, in LVGL v9 LV_COLOR_16_SWAP is removed and you can call lv_draw_sw_rgb565_swap in the flush_cb.

oh..thank you for your reminder, I will pay attention to this option when upgrading lvgl 9. 😃