Description
I try to rotate the display in the same orientation as the touchscreen. When I use the lv_display_set_rotation() function, my display is rotated, but the screen width is truncated to 240 pixels, while it should be 320 pixels. In fact, I’m getting a 240 x 240 display. When I use the corresponding TF_eSPI function tft.setRotation(), the display rotation is performed as expected.
I tried different rotation settings. The content of the display is rotated as required, but the display is always 240x240.
What MCU/Processor/Board and compiler are you using?
CYD = ESP32 with XPT2046 touch controler and ILI9341 display controller
What LVGL version are you using?
9.2
What do you want to achieve?
support rotation in all 4 orientations
What have you tried so far?
see description section
I also tried without swapping height and width in the #define section, but the result is the same.
Code to reproduce
Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.
The code block(s) should be formatted like:
/*You code here*/
#define LV_DISPLAY_ROTATION_0 0 // portrait, USB bottom side
#define LV_DISPLAY_ROTATION_90 1 // landscape, USB right side
#define LV_DISPLAY_ROTATION_180 2 // portrait, USB top side
#define LV_DISPLAY_ROTATION_270 3 // landscape USB left side
#define TFT_ROTATION LV_DISPLAY_ROTATION_90 // landscape, USB right side
// swap height and width according to rotation setting
#if (TFT_ROTATION == LV_DISPLAY_ROTATION_0) || (TFT_ROTATION == LV_DISPLAY_ROTATION_180)
#define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 320
#else
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#endif
… some more code
in setup function:
touchscreen.begin(touchscreenSPI);
touchscreen.setRotation(TFT_ROTATION);
… some more code …
disp = lv_tft_espi_create(SCREEN_WIDTH, SCREEN_HEIGHT, draw_buf, sizeof(draw_buf));
// lv_display_set_rotation(disp, (lv_display_rotation_t)TFT_ROTATION); // use LVGL lib to set rotation doesn’t work!
tft.setRotation(TFT_ROTATION); // use TFT lib to set rotation
Screenshot and/or video
If possible, add screenshots and/or videos about the current state.