Template:Touch Rotating
Rotation(Working with Raspberry Pi)
Display Rotating Add this statement in the config.txt file (the config file is located in the root directory of the TF card, which is named /boot):
display_rotate=1 #1:90;2: 180; 3: 270
Note: For Raspberry Pi 4, you need to comment out dtoverlay=vc4-fkms-V3D.
#dtoverlay=vc4-fkms-V3D.
And then restart the Raspberry Pi after saving.
sudo reboot
Touch Rotating After the display is rotated, the position of touch is incorrect because the touch doesn’t change with the display angle. So the touch also needs to be modified. 1.Install libinput.
sudo apt-get install xserver-xorg-input-libinput
If the system you installed is Ubuntu or Jetson Nano. The installation code is:
sudo apt install xserver-xorg-input-synaptics
2.Create the xorg.conf.d directory under /etc/X11/ (if the directory already exists, proceed directly to step 3).
sudo mkdir /etc/X11/xorg.conf.d
3.Copy the 40-libinput-conf file to the directory you created just now.
sudo cp /usr/share/X11/xorg.conf.d/40-libinput.conf /etc/X11/xorg.conf.d/
4.Edit this file.
sudo nano /etc/X11/xorg.conf.d/40-libinput.conf
Find the part of the touchscreen, add the following statement inside, and then save the file.
Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1"
Similar to the picture below:
5. save and reboot your Pi
sudo reboot
After completing these steps. The LCD could rotate 90 degrees both display and touch function. Note: 90 degree: Option "CalibrationMatrix" "0 1 0 -1 0 1 0 0 1" 180 degree: Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1" 270 degree: Option "CalibrationMatrix" "0 -1 1 1 0 0 0 0 1"