LVGL 9.1.0 rotation with ILI9225 screen

Description

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

ESP32 Wroom + Screen ILI9225 + Arduino IDE

What LVGL version are you using?

9.1.0

What do you want to achieve?

Rotate my screen in portrait

What have you tried so far?

lv_display_set_rotation(disp,LV_DISPLAY_ROTATION_270);

Code to reproduce

INO file (draw a button and a text):

#include <lvgl.h>
#if LV_USE_TFT_ESPI
  #include <TFT_eSPI.h>
#endif

#define TFT_HOR_RES   220
#define TFT_VER_RES   176

#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 10 * (LV_COLOR_DEPTH / 8))
uint32_t draw_buf[DRAW_BUF_SIZE / 4];

lv_obj_t *label_time;
uint8_t xxx = 0;

void setup()
{
    Serial.begin(115200);
    lv_init();
    lv_tick_set_cb(millis);
    lv_display_t *disp;
    disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf, sizeof(draw_buf));

    lv_obj_t * btn = lv_button_create(lv_screen_active());     /*Add a button the current screen*/
    lv_obj_set_pos(btn, 10, 10);                            /*Set its position*/
    lv_obj_set_size(btn, 120, 50);                          /*Set its size*/

    static lv_style_t style;

    lv_style_init(&style);
    lv_style_set_text_color(&style, lv_color_black());

    label_time = lv_label_create(lv_scr_act());
    lv_obj_add_style(label_time, &style, 0);
    lv_obj_align(label_time, LV_ALIGN_BOTTOM_MID, 0, -20);

    lv_display_set_rotation(disp,LV_DISPLAY_ROTATION_270);
}

void loop()
{
    lv_task_handler(); 

    if(xxx==0){
      xxx=1;
      unsigned long elapsedMillis = millis();
      String timeText = "Millisecondes ecoulees: " + String(elapsedMillis);
      lv_label_set_text(label_time, timeText.c_str());
      Serial.println(timeText.c_str());
    }
}

Screenshot and/or video

→ the 4 rotations (0, 90, 180, 270) have the same orientation, landscape, 90° more than what I want
–>0 and 180°: the objects are dispatched correctly (excepted the orientation)
–>90 and 270: the objects are cut (I guess it cuts the width of the screen to the heith value)

Note: they were drawn under squareline in portrait but display in landscape

Note: I am experienced in C and C++ but new to LVGL. I read blogs from 2022 with similar issue but I don’t know if it is partially corrected (needing an adaptation for my screen) or still unsolved (meaning that I must go down to LVGL 8). Thanks!

Rotation 0 or 180:

Rotation 90:

Rotation 270:

Also for me screen rotation not work with lv_display_set_rotation(disp,LV_DISPLAY_ROTATION_270);

you need declare TFT_eSPI in variables, so
TFT_eSPI tft = TFT_eSPI();
and in SETUP you can change rotation with:
tft.setRotation(3);// 0-3

and remember that also touch need rotation if you use em

Thank you.

Unfortunatelly, tft.setRotation(1) and tft.setRotation(3) work fine (landscape to the left and to the right), but the 2 others are completly illisible.

I checked wit the original TFT_eSPI library (because mine is deeply personnalised), but I get the same result.

Note that the problem is only for the LVGL graphic objects. The TFT_eSPI objects are drawn correctly and rotate fine.