espressif / esp-bsp

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

Screen and touch swap issue with ST7796 esp_lvgl_port (lvgl 9) (BSP-467) #300

Closed sukesh-ak closed 2 months ago

sukesh-ak commented 2 months ago

I have a WT32-SC01 device running ESP32, ST7796 LCD (480x320), FT5x06 touch panel.
ESP-IDF: v5.1.2

I have managed to make it work without esp_lvgl_port using only esp_lcd for LVGL 8 here.
Now I am trying to get it working with esp_lvgl_port for LVGL 9 code here.

Screen and touch points are swapped (or not aligned) here. IMG_3267

3 questions:

  1. Can someone take a look to see why the content is swapped? I don't want to switch back to 8.x now.
  2. I am using esp_lcd_st7796 v1.0.0 since newer versions are not supported on ESP32. Can this be fixed?
  3. I am using code from 5431be8 of (esp-bsp) since its not available on the ESP Component Registry yet. Will this be published soon?

TIA

espzav commented 2 months ago

Hello @sukesh-ak, we wanted to release LVGL port with LVGL9 support, but there is lot of things, which is not good now. We are solving lot of issues now. This is the reason, why the component is not in ESP Component Registry. We decided to wait to next release of the LVGL9.

  1. I think, it should help change this line: esp_lcd_panel_mirror(lcd_panel, true, true); try to set false to X or Y (I don't know, which axis is it right now)
  2. @Lzw655 Can we release esp_lcd_st7796 for ESP32 too?
  3. Answered above.
Lzw655 commented 2 months ago

@espzav Although I don't have hardware for testing, I believe it is feasible.

sukesh-ak commented 2 months ago

Hello @sukesh-ak, we wanted to release LVGL port with LVGL9 support, but there is lot of things, which is not good now. We are solving lot of issues now. This is the reason, why the component is not in ESP Component Registry. We decided to wait to next release of the LVGL9.

  1. I think, it should help change this line: esp_lcd_panel_mirror(lcd_panel, true, true); try to set false to X or Y (I don't know, which axis is it right now)
  2. @Lzw655 Can we release esp_lcd_st7796 for ESP32 too?
  3. Answered above.

I tried changing as below. It fixes the screen on device start.

esp_lcd_panel_mirror(lcd_panel, false, true);

Once I hit rotate button, it gets swapped again in the other orientations.

Touch works on the button only in the portrait rotations but in landscape it's on the opposite side.

At this point, if I can skip esp_lvgl_port (due to delay of completion) and use only esp_lcd like the lvgl 8.x version here it would be enough for me.

For 2nd question what I meant is here esp_lcd_st7796 v 1.0.0 supports all MCU and latest v 1.2.1 only supports ESP32-S2 & ESP32-S3

I have a sample using LVGL 8x with IDF called ESP32-TUX here which supports 4 different TFT using LovyanGFX. I would like to build a better v2 version of it with esp_lcd and lvgl 9.0 in near future.

espzav commented 2 months ago
  1. For rotation, you should set right values into LVGL port configuration here:

    const lvgl_port_display_cfg_t disp_cfg = {
        .io_handle = lcd_io,
        .panel_handle = lcd_panel,
        .buffer_size = HMI_LCD_H_RES * HMI_LCD_DRAW_BUFF_HEIGHT * sizeof(uint16_t),
        .double_buffer = HMI_LCD_DRAW_BUFF_DOUBLE,
        .hres = HMI_LCD_H_RES,
        .vres = HMI_LCD_V_RES,
        .monochrome = false,
        /* Rotation values must be same as used in esp_lcd for initial settings of the screen */
        .rotation = {
            .swap_xy = false, //SET SAME VALUE AS esp_lcd_swap_xy
            .mirror_x = false, //SET SAME VALUE AS esp_lcd_mirror
            .mirror_y = false, //SET SAME VALUE AS esp_lcd_mirror
        },
        .flags = {
            .buff_dma = true,
            .swap_bytes = true,
        }
    };
  2. I will check it. If it is ok on ESP32, I will add it into targets soon.

  3. Your project looks very good. We have new chip ESP32P4 with MIPI-DSI support - we have it in ESP LVGL Port too (now we are testing before release). We have ESP-BSP for it too and I think, that for your project will be best to use our BSP. You can create own BSP with same API for third party boards and you can use all Espressifs boards very easy in your project. BSP: https://github.com/espressif/esp-bsp there is a list supported boards. We will add M5Stack CoreS3 soon (it is on branch now) and we will add ESP32P4 with MIPI-DSI screen till two weeks. You can use our BSP with LVGL or without. Our BSPs now using LVGL8 and switch to LVGL9 will be very easy - it is ready, we are only waiting for some changes in LVGL9.

sukesh-ak commented 2 months ago

@espzav Thank you for the suggestion for rotation.

I have fixed screen and touch issues now. Screen issue was fixed by changing mirror_y values

const lvgl_port_display_cfg_t disp_cfg = {
        .io_handle = lcd_io,
        .panel_handle = lcd_panel,
        .buffer_size = HMI_LCD_H_RES * HMI_LCD_DRAW_BUFF_HEIGHT * sizeof(uint16_t),
        .double_buffer = HMI_LCD_DRAW_BUFF_DOUBLE,
        .hres = HMI_LCD_H_RES,
        .vres = HMI_LCD_V_RES,
        .monochrome = false,
        /* Rotation values must be same as used in esp_lcd for initial settings of the screen */
        .rotation = {
            .swap_xy = false,
            .mirror_x = false,
            .mirror_y = true,
        },
        .flags = {
            .buff_dma = true,
            .swap_bytes = true,
        }
    };

Touch issue was fixed by adding 2 lines

    esp_lcd_touch_set_mirror_y(touch_handle, true);
    esp_lcd_touch_set_mirror_x(touch_handle, true);

Updated working code branch is here Though this will be merged to main soon.

sukesh-ak commented 2 months ago
  1. I will check it. If it is ok on ESP32, I will add it into targets soon.
  2. Your project looks very good. We have new chip ESP32P4 with MIPI-DSI support - we have it in ESP LVGL Port too (now we are testing before release). We have ESP-BSP for it too and I think, that for your project will be best to use our BSP. You can create own BSP with same API for third party boards and you can use all Espressifs boards very easy in your project. BSP: https://github.com/espressif/esp-bsp there is a list supported boards. We will add M5Stack CoreS3 soon (it is on branch now) and we will add ESP32P4 with MIPI-DSI screen till two weeks. You can use our BSP with LVGL or without. Our BSPs now using LVGL8 and switch to LVGL9 will be very easy - it is ready, we are only waiting for some changes in LVGL9.

2) Thank you. It will be easy since the commercial project I am working on might switch to ESP32-S3 version of the display in future (though 8bit parallel display then).

3) I have been drooling over ESP32P4 with MIPI-DSI support from the day it was announced. Good to know it's coming soon. Is there a way to get me a ESP32-P4 devkit early. Hope it will have additional BLE/Wi-Fi support too.

And yes, I am planning to use esp-bsp in future. If there are enough samples for all the peripherals it will make life easier.

espzav commented 2 months ago

@igrr and @tore-espressif please, can we share any HW for support this project?

sukesh-ak commented 2 months ago

Thanks @espzav

@igrr and @tore-espressif

Its for the next version of ESP32-TUX https://github.com/sukesh-ak/ESP32-TUX

sukesh-ak commented 2 months ago

@espzav Can you explain what you mean by this? We decided to wait to next release of the LVGL9.

espzav commented 2 months ago

@espzav Can you explain what you mean by this? We decided to wait to next release of the LVGL9.

We are waiting for some fixes and changes in LVGL. Each LVGL release is pushed into ESP Component Registry. Now there is LVGL 9.0 and we are waiting for LVGL 9.1 Is it clear?

sukesh-ak commented 2 months ago

@espzav Can you explain what you mean by this? We decided to wait to next release of the LVGL9.

We are waiting for some fixes and changes in LVGL. Each LVGL release is pushed into ESP Component Registry. Now there is LVGL 9.0 and we are waiting for LVGL 9.1 Is it clear?

ok Thanks. Waiting for the changes then.

tore-espressif commented 2 months ago

Hi @sukesh-ak , current status of ESP32-P4 is that we have only limited amount of engineering samples, so we can't share them with broader audience.

We expect new batch of revised silicon in June 2024. You can contact our sales department if you want to inquiry about pre-massproduction samples https://www.espressif.com/en/contact-us/sales-questions

sukesh-ak commented 2 months ago

Hi @sukesh-ak , current status of ESP32-P4 is that we have only limited amount of engineering samples, so we can't share them with broader audience.

We expect new batch of revised silicon in June 2024. You can contact our sales department if you want to inquiry about pre-massproduction samples https://www.espressif.com/en/contact-us/sales-questions

Thanks for the response @tore-espressif No hurry. Will wait for a product with a TFT with P4.

sukesh-ak commented 2 months ago

@espzav Can you explain what you mean by this? We decided to wait to next release of the LVGL9.

We are waiting for some fixes and changes in LVGL. Each LVGL release is pushed into ESP Component Registry. Now there is LVGL 9.0 and we are waiting for LVGL 9.1 Is it clear?

The lvgl 9.1 update is planned for 19th March as per this. Are the concerns addressed in lvgl 9.1 already? https://github.com/lvgl/lvgl/issues/5843

sukesh-ak commented 2 months ago

@espzav I noticed the update for esp_lvgl_port 2.0 and have updated my sample here. https://github.com/sukesh-ak/IDF5-ESP_LCD-LVGL9

With #define HMI_LVGL_TASK_MIN_DELAY_MS 5 the display is very slow with 1 fps. Value of 5 works well with 28 fps.

I will go ahead and close this. I like how the ESP Registry is working and hope to write few esp-bsp for some popular display boards soon.