Way to Rotate lvgl example?

Hi,

I have been working on a project involving an LCD screen using the LVGL sample as a base. However, it would be nice if I could rotate either the text itself or the screen by 90 degrees. I tried the lv_disp_set _rotation command found in lv_hal_disp.c but rather than rotating the screen it just broke the display. The same thing happens if I flip the width and height in the overlay. 1) is this error some how caused by the lv_disp library and 2) is there a fix for this? I am using the SH1107 OLED which is compatible with the ssd1306 drivers and I am using an unedited version of the lvgl example. Any help would be appreciated.

Thanks!

Parents Reply Children
  • Hi 

    Have you tried to change the rotation property in the device tree node for the display driver? 

    I believe this is the recommended way to set the orientation of the display. 

    Best regards
    Torbjørn

  • I tried to but I was under them impression from research that there wasn't a rotation property. Can I just set that in the overlay?

  • Hi 

    Can you check the zephyr.dts file in the build/zephyr directory? 

    This file will contain the complete device tree configuration, after all board files, overlays etc has been compiled. 

    As an example, if I build the display/lvgl sample I can find the display node under spi3, and see that it includes the rotation property:

    ili9340: ili9340@0 {
    		compatible = "ilitek,ili9340";
    		spi-max-frequency = < 0xe7319b >;
    		reg = < 0x0 >;
    		cmd-data-gpios = < &arduino_header 0xf 0x1 >;
    		width = < 0x140 >;
    		height = < 0xf0 >;
    		pixel-format = < 0x1 >;
    		rotation = < 0x5a >;
    		frmctr1 = [ 00 18 ];
    		pwctrl1 = [ 23 00 ];
    		vmctrl1 = [ 3E 28 ];
    		vmctrl2 = [ 86 ];
    		pgamctrl = [ 0F 31 2B 0C 0E 08 4E F1 37 07 10 03 0E 09 00 ];
    		ngamctrl = [ 00 0E 14 03 11 07 31 C1 48 08 0F 0C 31 36 0F ];
    	};

    You should be able to change this property through the overlay, yes. 

    Once the project gets more mature I would recommend making your own board definition, rather than relying on overlays. 

    Best regards
    Torbjørn

  • Ah, I see. Unfortunately I am using I2C rather than SPI.

    i2c1: arduino_i2c: i2c@9000 {
                    compatible = "nordic,nrf-twim";
                    #address-cells = < 0x1 >;
                    #size-cells = < 0x0 >;
                    reg = < 0x9000 0x1000 >;
                    clock-frequency = < 0x61a80 >;
                    interrupts = < 0x9 0x1 >;
                    status = "okay";
                    pinctrl-0 = < &i2c1_default >;
                    pinctrl-1 = < &i2c1_sleep >;
                    pinctrl-names = "default", "sleep";
                    zephyr,concat-buf-size = < 0x1000 >;
                    ssd1306_ssd1306_128x64: ssd1306: ssd1306@3c {
                        compatible = "solomon,ssd1306fb";
                        reg = < 0x3c >;
                        width = < 0x40 >;
                        height = < 0x80 >;
                        segment-offset = < 0x0 >;
                        page-offset = < 0x0 >;
                        display-offset = < 0x1f >;
                        multiplex-ratio = < 0x3f >;
                        segment-remap;
                        com-invdir;
                        prechargep = < 0x22 >;
                        com-sequential;
                    };
                };

    As you can see there is no rotation here.

  • Hi 

    My bad, you are correct that there is no rotation property for the ssd1306 driver. 

    Looking at the driver implementation in ssd1306.c I see that the set_orientation function will just return the not supported error:
    https://github.com/nrfconnect/sdk-zephyr/blob/main/drivers/display/ssd1306.c#L365-L371

    As far as I can tell from the SSD1306 datasheet the driver doesn't provide any kind of rotation register, which is why it is not supported in the driver. 

    What happens if you remove the segment-remap or com-invdir properties from the ssd1306 node? 

    Possibly you can invert the display horizontally or vertically this way, but I am not sure that will solve your issue or not. 

    Best regards
    Torbjørn

Related