LVGL Screen Rotation Issue

Hi,

I designed my LVGL UI in 480x800, but my display is 800x480 (landscape). I need to rotate the screen 90 degrees.

I tried:
disp_drv.sw_rotate = 1;
lv_disp_set_rotation(disp, LV_DISP_ROT_90);
but it didn’t work.

**Is there an alternative way to rotate the screen in LVGL?

Thanks!

1 Like

what does it mean? you see ui in landscape orientation ? how did you configured display - 800x480 ?

Hi,
This is my zephyr ltdc configuration, i attached expected and actual image below ,

&ltdc {
    pinctrl-0 = <&ltdc_vsync_pi9 &ltdc_hsync_pi10 &ltdc_g6_pi11 &ltdc_de_pf10
                 &ltdc_b5_pa3 &ltdc_g2_pa6 &ltdc_r3_pb0 &ltdc_r6_pb1
                 &ltdc_g5_pb11 &ltdc_r4_ph10 &ltdc_r5_ph11 &ltdc_r7_pg6
                 &ltdc_clk_pg7 &ltdc_b2_pc9 &ltdc_b3_pa8 &ltdc_b4_pa10
                 &ltdc_g3_ph14 &ltdc_g4_ph15 &ltdc_g7_pi2 &ltdc_b6_pb8
                 &ltdc_b7_pb9>;
// pinctrl-0 = <&pinctrl_ltdc>;
    pinctrl-names = "default";
ext-sdram = <&sdram1>;
    status = "okay";

    width = <800>;  // Horizontal resolution
    height = <480>; // Vertical resolution
   
    pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>; // 32-bit color format
   
    display-timings {
        compatible = "zephyr,panel-timing";
        de-active = <0>;         // Data Enable polarity
        pixelclk-active = <0>;   // Pixel Clock polarity
        hsync-active = <0>;      // Horizontal Sync polarity
        vsync-active = <0>;      // Vertical Sync polarity
        hsync-len = <19>;        // Horizontal Sync pulse width
        vsync-len = <9>;         // Vertical Sync pulse width
        hback-porch = <46>;      // Horizontal Back Porch
        vback-porch = <23>;      // Vertical Back Porch
        hfront-porch = <210>;    // Horizontal Front Porch
        vfront-porch = <22>;     // Vertical Front Porch
       
    };

    def-back-color-red = <0>;
    def-back-color-green = <0xff>; // Green background
    def-back-color-blue = <0>;
};


What version of Zephyr are you using? As far as I remember in versions below 2.7 LVGL resolution defined independent of display resolution.

using zephyr version 4.

are you sure it is called in your appl (in particular after lvgl has been initilized, lvgl_init() call) ?

EDIT: and what is disp ?

Yes, I am calling lv_disp_set_rotation after calling lv_init. And I don’t understand your question about “disp”.

you are using disp variable. what is it ? how is it initilized ?

I think lv_disp_set_rotation() should be called after lv_disp_drv_register() in lvgl_init(), and if you are want to use single display lv_disp_get_default() instead of disp.
I use lv_disp_set_rotation(lv_disp_get_default(), disp_rot); in user application code (not in zephyr code)
lvgl_init() is a part of zephyr module code, and with

SYS_INIT(lvgl_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);

executed just before application code (main).

Thanks for you suggestion, i have one more doubt about screen rotation

my display natually build-in horizontal co-ordination of the framebuffer , but my screen design was vertical co-ordination how to change co-ordination horizontal to verical using frame buffer,
note : I don’t have any specific display driver for rotation.