How to rotate the official 7-inch Raspberry Pi touch screen?

1. Install XInput for a Raspberry pi 7-inch touch screen:


sudo apt-get install xinput



2. To rotate the Raspberry screen, edit this file:


^ {pr2} $

Add this line of code at the end:




For the other direction, you can use:




Exit (Ctrl +X) and save.



3. Create a script to flip the touch screen every time Raspbian starts:


sudo nano /home/pi/Desktop/fliptouch.sh


Add this line:

Xinput set-prop 'FT5406 memory based driver' 'Coordinate Transformation Matrix' 0 1 0 0 1 0 0 1

Exit (Ctrl +X) and save.in



4. chmod this script:


sudo chmod 777 /home/pi/Desktop/fliptouch.sh



5. To start the script in the session, edit this file:


sudo nano ~/.config/lxsession/LXDE-pi/autostart


Add the following line at the end:




Exit (Ctrl +X) and save.in



6. Restart:


sudo reboot


At this point, the Raspberry Pi 7 inch touch screen display flip is complete.


Useful links: https://www.raspberrypi.org/forums/viewtopic.php?t=219333