10

I've just bought a Raspberry Pi 3 with a 7" Display touch screen and a casing.

Unfortunately, the casing can't allow me to rotate manually the screen so my apps are running upside down.

I've tried to do it from the console using the following adb commands but with no luck:

adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0

Then

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1

Or

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:3

Is there any way to do it from a config flag directly that screen orientation is handled from boot ?

Prags
  • 2,457
  • 2
  • 21
  • 38
Bibu
  • 1,249
  • 2
  • 17
  • 40
  • I would imagine orientation sensors (and orientation config changes) have been disabled but I can't find anything in the official docs to support that. Have you thought of just turning your screen the other way up? :-) – Blundell Jan 10 '17 at 08:23
  • I did :-) but, as it seems there is no orientation sensor, screen does not change the orientation neither. – Bibu Jan 10 '17 at 08:37

4 Answers4

10

I find out finally how to achieve it.

Solution found there : Android Things with Rasp3 7 inch touchscreen

You have to mount the boot partition from the sdcard on your laptop and edit the /boot/config.txt file and add the following line:

lcd_rotate=2

By adding this line both display and touchscreen will be rotated, compared to display_rotate=2 where only display is rotated and touchscreen remains upside down.

Community
  • 1
  • 1
Bibu
  • 1,249
  • 2
  • 17
  • 40
  • What OS did you use to mount the boot partition? – Quintin Balsdon Jan 10 '17 at 13:20
  • I've used Mac OS 10.11.6 – Bibu Jan 10 '17 at 13:22
  • Wow, cool - how did you mount it? I have tried plugging the SD card in and all I get is some "Cannot be read" error – Quintin Balsdon Jan 10 '17 at 13:23
  • @QuintinBalsdon sometimes SD cards have a tiny little switch on the side to turn on and off write mode – Blundell Jan 10 '17 at 20:08
  • 2
    @QuintinBalsdon, I've used the following command `sudo mount -t msdos /dev/disk4s1 /mnt/sd` where `4`was the number of my SDcard that you can find using Mac OS Disk Utility – Bibu Jan 10 '17 at 20:18
  • I'm having troubles with this, it didnt work for me. On my Android installation, there is a `CONFIG.txt` in the root of the card but not `boot/config.txt`. When I added that config to `CONFIG.txt` with different combinations and positions, I either got the rainbow screen of death or the display would stay in landscape – borislemke Jan 31 '17 at 15:58
  • Did you mount the SD card on your computer ? boot should be present otherwise the OS can't boot. – Bibu Feb 01 '17 at 09:40
  • On 0.2-devpreview and when i mount /dev/disk2s1 I only see the config.txt at the root of the sdcard. No boot directory. https://ibb.co/cUdjyv any ideas? – Robert Estivill Mar 28 '17 at 21:12
  • i kind of get this working on 0.4.0-devpreview by setting display_rotate instead of lcd_rotate(im using hdmi out), the later does nothing. I see that the display is rotated but i get some major graphic bugs and it's not usable as is. But if i remove that and use content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:3 it does rotate my app, not the "system" And as some mentioned, now when you mount the config.txt is in the root not in a boot folder – Edvald Eysteinsson May 23 '17 at 11:45
  • @Bibu how did you set up the touch screen? I couldn't get it to works – adadion Jul 25 '17 at 09:14
1

Try this:

if (Build.DEVICE.equalsIgnoreCase("rpi3"))
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
Milan Jurkulak
  • 557
  • 3
  • 6
0

Google added new APIs in DP6 to control device settings, including display orientation: Android Things uses three different APIs to control settings for the screen (display), system time, and available locales.

Please open a new bug if these APIs do not behave as you expect.

Prags
  • 2,457
  • 2
  • 21
  • 38
  • 1
    The `ScreenManager` API has been [removed in DP8](https://developer.android.com/things/preview/releases) – Noel May 03 '18 at 16:26
  • It would be really great if this could be configured on the display option on the setup screen (similar to wifi) – Stefan Haustein Oct 20 '18 at 19:59
0

Step 1

On the rpi, open terminal and run the following:

sudo nano /boot/config.txt


Step 2

Scroll to the bottom of the file and add this:

display_lcd_rotate=2

Now, to save, press Ctrl+x, then press 'y' and press return.


Step 3

Now run

sudo reboot


Done!

Note, if you want to rotate 90º, not 180º (to go portrait), you need to add the following TWO lines to your config.txt:

display_lcd_rotate=1
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1,touchscreen-inverted-x=1
Albert Renshaw
  • 17,282
  • 18
  • 107
  • 195