If you just installed the latest version of Rasbian on your Raspberry Pi, or have a recent version installed, chances are that your 7″ touch screen will be upside down.
This is because they decided to change the standard orientation of the raspberry pi touch screen, in one of the latest updates.
As the official casing for the 7″ touch screen was released before this update, the default orientation of the screen will now be upside down. Whether you want to hang the raspberry pi case on the wall, or put in on a table, the 180 degrees rotation is not optimal.
Fortunately, the fix is very easy, and you can have your raspberry pi flipped back from upside down with a single line of code.
How to flip the Raspberry Pi touch screen
First of all, you should be aware that several methods exists to rotate, flip or mirror the raspberry pi screen. Do NOT use the display_rotate functionality, as this will require unnecessary additional processing of graphics, and will only rotate the display, not the touch input.
To flip the raspberry pi touch screen back from upside down, open a terminal and type in the following command:
sudo bash -c "echo -e '\n#Rotate touch screen 180\nlcd_rotate=2' >> /boot/config.txt"
This should add the line lcd_rotate=2 to your /boot/config.txt file, and if you do a restart, your raspberry pi should now boot up with the right screen orientation in the future.
Of course, you could just add this line to the file yourself, using a text editor.
If this worked for you, consider leaving a comment.
Also, check out this source for other great tips on configuring the 7″ Raspberry Pi touch screen.