2022/05/05 updated｜By G Editor
When Raspberry Pi players need to do touch screen rotation for portrait application, they often encounter the problem that the display image has been changed to portrait mode, but the touch position has not been rotated synchronously. This is because the touch position of the Raspberry Pi touch screen must be redefined by Transformation Matrix . If the correct transformation matrix value is not defined in Xinput, the touch screen cannot respond correctly.
Here we will explain in detail how to rotate the screen as Portrait (90 degrees) or Portrait flipped (270 degrees) in Raspberry Pi operating system, and rotate the M505T touch monitor to portrait or portrait flipped by specifying the position of the Transformation Matrix, in order to fulfil the touch demand of Kiosk, navigation system or industrial control.
There are only standard landscape display options inside Raspberry Pi Operation System (Raspi-Config). For example, you shall select [ DMT Mode 82 1920x1080 60Hz 16:9 ] for M505T touch monitor, which is 16:9 landscape display mode. ( Read more details of Raspi-Config )
To set M505T as a portrait display application, please follow the steps below.
Click the Terminal icon to run Terminal
Key in 〖 sudo nano /boot/config.txt 〗
Find "HDMI_mode=82" , and add〖display_hdmi_rotate=1〗below it. Press" ctrl+X" >> press" Y ">>press " enter" to save and exit.
Note 1: The angle of rotation is counted clockwise. display_rotate =0 (landscape) display_rotate=1 （90 degress） display_rotate=2 （180 degrees） display_rotate=3 （270 degrees）
Note 2: Due the buttons are on the front right side of M505T, we suggest to choose ９0-degree-portrait display while putting M505T vertical on the desk.
Notice: Debian is upgraded in April 2022. If the screen does not rotate after you enter the display_hdmi_rotate=1 command, please check the config file, disable the default command dtoverlay=vc4-kms-v3d by adding # at the begining, save it and reboot. Then, comman "display_hdmi_rotate" shall work.
Key in〖 sudo reboot 〗
⑤ After booting, the display is portrait mode.
〖 cd /usr/share/X11/xorg.conf.d〗
Key in〖 ls〗 to list all the files in the directory.
Key in〖sudo nano 40-libinput.conf〗
Find the InputClass section of touchscreen 的InputClass.
Key in〖Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1" 〗
List of Transformation Matrix for M505T
90° = Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"
180° = Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
270° = Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
Remark: The XY position of different touch screen's start point may be various, so the transformation matrix values of 90° and 270° may be the opposite. For models other than M505T, please try to adjust it yourself!
Key in〖 sudo reboot〗
⑤ Click the Raspberry menu button to confirm that the touch position is correct.
In order to operate touch control precisely, you may calibrate the touch input of the vertical M505T touch monitor by xinport_calibrator program as well. For detailed process, please refer to this article.