Like many things in the Raspberry Pi ecosystem, functions such as rotating the display output can be a little unintuitive at first. Or perhaps you’re not sure how to get rid of that annoying black outline on your screen. So, we’ve put together a handy quick-reference tutorial for you. The methods used here were tested on a Pi 3, however, they’ll be applicable to any model Pi and any of the Raspberry Pi displays.
Everything that we’re doing will be done by editing the config.txt file. You can do this by viewing the contents of your micro SD card on a computer and opening the config.txt file from the boot directory in a text editor. Our preferred method though is just by editing it directly in the terminal on your Pi. It’s easier and much cleaner. To do this, open a new terminal window and enter the following:
sudo nano /boot/config.txt
Rotating the Display
You can rotate the display by using the display_rotate and lcd_rotate commands. They both rotate the display, however, lcd_rotate also rotates the touch interface. A common issue when using the Official Raspberry Pi Touchscreen is that most of the stands for it, such as the Pimoroni Touchscreen Case, mount the screen upside down. If you only used display_rotate, it would look rotated, but your touch inputs wouldn’t match up.
To rotate your display, simply enter display_rotate or lcd_rotate at the bottom of your config file:
#rotate 0 degrees display_rotate=0
#rotate 90 degrees clockwise display_rotate=1
#rotate 180 degrees display_rotate=2
#rotate 270 degrees display_rotate=3
It’s that easy! You can also flip your display by adding the following:
#flips the display vertically display_rotate=0x20000
#flips the display horizontally display_rotate=0x10000
Once you've made those changes, hit Ctrl+X and then Y to save, and you’ll need to reboot in order for any of those changes to take effect, so just use:
Removing the Black Border
If you see a black border around your screen, then you need to adjust the underscan settings. This can be changed in the GUI config editor (available via the main menu), however, given that we’ve been working in the terminal, it’s easier just to stay there.
Look for the line #disable_overscan=1 and remove the ‘#’ symbol which changes it from a comment to a line of code. Once you reboot your system, that pesky, black border will be gone! You can always re-enable it by putting the ‘#’ symbol back in front and reboot for the change to take effect.
And that's all there is to it folks. As always, be sure to leave a comment if you have any questions. Happy Making!