bigtreetech / TFT35-SPI

45 stars 5 forks source link

Screen rotation #7

Closed bthubs closed 1 year ago

bthubs commented 1 year ago

Hello all!

Anyone with an idea on how to rotate the screen 180 degrees (or any rotation)? I've tried different ways to rotate but none have worked as many other screen use pi instead of SPI (I'm using Manta M8p +CB1). Any help would be appreciated.

bthubs commented 1 year ago

I've got something. The screen rotates but now asks me for a login. Can't figure it out from here.

I got it to rotate by running

sudo nano /etc/X11/Xwrapper.config

and adding lcd_rotate=2 or extraargs=fbcon=rotate:2

HOWEVER, restarting KlipperScreen then asks for a login and only shows console.

I suspect the software that runs the rotation requires root, which I'm not sure how to do at this point. The strange thing is however... if I run 'systemctl status KlipperScreen', one of the lines I receive states '***** KlipperScreen-start.sh[8652]: extraargs: Invalid key '/usr/lib/xorg/Xorg.wrap' at /etc/X11/Xwrapper.config line 16'. Not sure what this means, but maybe why it's requiring a login.

cobrettee commented 1 year ago

Hello all!

Anyone with an idea on how to rotate the screen 180 degrees (or any rotation)? I've tried different ways to rotate but none have worked as many other screen use pi instead of SPI (I'm using Manta M8p +CB1). Any help would be appreciated.

I don't need screen rotation but I successfully tested it out right now on my M8P/CB1 using this video: https://www.youtube.com/watch?v=tA7uRC17F6U

Note though I had to alter the steps a bit for it to work in my case. He noted using the dts file from the BTT CB1 github but this just caused a whitescreen for me so instead I used a copy of the dtbo file directly and converted it to dts then edited that file and converted it back to dtbo

cp /boot/dtb/allwinner/overlay/sun50i-h616-tft35_spi.dtbo dtc -I dtb -O dts -f sun50i-h616-tft35_spi.dtbo -o sun50i-h616-tft35_spi.dts nano sun50i-h616-tft35_spi.dts

after that you can follow his instructions again.

bthubs commented 1 year ago

Hello all! Anyone with an idea on how to rotate the screen 180 degrees (or any rotation)? I've tried different ways to rotate but none have worked as many other screen use pi instead of SPI (I'm using Manta M8p +CB1). Any help would be appreciated.

I don't need screen rotation but I successfully tested it out right now on my M8P/CB1 using this video: https://www.youtube.com/watch?v=tA7uRC17F6U

Note though I had to alter the steps a bit for it to work in my case. He noted using the dts file from the BTT CB1 github but this just caused a whitescreen for me so instead I used a copy of the dtbo file directly and converted it to dts then edited that file and converted it back to dtbo

cp /boot/dtb/allwinner/overlay/sun50i-h616-tft35_spi.dtbo dtc -I dtb -O dts -f sun50i-h616-tft35_spi.dtbo -o sun50i-h616-tft35_spi.dts nano sun50i-h616-tft35_spi.dts

after that you can follow his instructions again.

Thank you! This worked! The video's instruction were in German but youtube's translator worked pretty well.

For future reference, this is how to get the display to rotate (note: you will also need to rotate the touchscreen)

  1. SSH into CB1
  2. Download source dts file from CB-1 Kernel https://github.com/bigtreetech/CB1-Kernel/blob/kernel-5.16/kernel/arch/arm64/boot/dts/allwinner/overlay/sun50i-h616-tft35_spi.dts
  3. As per cobrettee's recommendations, run
    cp /boot/dtb/allwinner/overlay/sun50i-h616-tft35_spi.dtbo
    dtc -I dtb -O dts -f sun50i-h616-tft35_spi.dtbo -o sun50i-h616-tft35_spi.dts
    nano sun50i-h616-tft35_spi.dts
  4. Copy contents of source file to new file in putty as per previous step, then save.
  5. Run
    sudo mv /boot/dtb/allwinner/overlay/sun50i-h616-tft35_spi.dtbo /boot/dtb/allwinner/overlay/sun50i-h616-tft35_spi.dtbo_
    dtc -@ -I dts -O dtb -o sun50i-h616-tft35_spi.dtbo sun50i-h616-tft35_spi.dts
  6. Enter under fragment 3 the rotation angle. It should look like:
    fragment@3 {
                target = <&tft_35>;
                __overlay__ {
            status = "okay";
            spi-max-frequency = <12500000>;
            rotate = <180>;
                };
        };
  7. Save
  8. Run sudo chown root:root ./sun50i-h616-tft35_spi.dtbo
  9. Run sudo chmod u+x ./sun50i-h616-tft35_spi.dtbo
  10. Run sudo mv sun50i-h616-tft35_spi.dtbo /boot/dtb/allwinner/overlay/
  11. Run ls /boot/dtb/allwinner/overlay/
  12. Reboot

This completes the display rotation. Refer to KlipperScreen documentation to change the touchscreen rotation (Transformation Matrix).

unarmedrob commented 10 months ago

@bthubs Thank you for this helped a lot, just want to mention that step 6 modifying the file should be done as part of step 4 when the contents of the file are copied,.

bthubs commented 10 months ago

@bthubs Thank you for this helped a lot, just want to mention that step 6 modifying the file should be done as part of step 4 when the contents of the file are copied,.

Yes that would be more efficient! Thank you

awiltschek commented 6 months ago

Does anyone know whats the difference between the sun50i-h616-tft35_spi and the sun50i-h616-tft35_spi25 files ?