lanewinfield
Posts: 22
Joined: Tue Apr 07, 2015 2:12 am

Rotate display 90º?

Wed Sep 16, 2015 3:34 am

Hey there,

I had a previous project working with an Adafruit piTFT that I had with the display rotated (so that it's viewed like a smartphone vs. like a laptop screen_.

Any ideas on how to rotate 90º (not 180, like the config.txt commands do)?

Thanks!

lanewinfield
Posts: 22
Joined: Tue Apr 07, 2015 2:12 am

Re: Rotate display 90º?

Wed Sep 16, 2015 4:20 am

Nevermind. Figured it out.

Code: Select all

sudo nano /boot/config.txt
Add one of these to the bottom:

display_rotate=0 Normal
display_rotate=1 90 degrees
display_rotate=2 180 degrees
NOTE: You can rotate both the image and touch interface 180º by entering lcd_rotate=2 instead
display_rotate=3 270 degrees
display_rotate=0x10000 horizontal flip
display_rotate=0x20000 vertical flip
Last edited by lanewinfield on Thu Jan 21, 2016 8:15 pm, edited 1 time in total.

lanewinfield
Posts: 22
Joined: Tue Apr 07, 2015 2:12 am

Re: Rotate display 90º?

Wed Sep 16, 2015 4:37 am

I spoke too soon. Now all the touch events are opposite where they should be. Anybody have any thoughts?

lanewinfield
Posts: 22
Joined: Tue Apr 07, 2015 2:12 am

Re: Rotate display 90º?

Wed Sep 16, 2015 4:56 am

Don't mind me, just talking to myself.

Figured out how to make it work. First you have to install xinput.

Code: Select all

$ sudo apt-get install xinput
Then list your displays:

(if you're on the Pi)

Code: Select all

xinput --list
(if you're on the Rasp Pi via SSH)

Code: Select all

DISPLAY=:0 xinput --list
I'd guess that every display is the same name, which is "FT5406 memory based driver."

Using the name of the device, use this command (add DISPLAY=:0 if you're SSHing!)

Code: Select all

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
That'll swap the two axes, but now you have to screw with each individual axis. Depending on your rotation, it's either going to be

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
or

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
I'm gonna go ahead and add these to rc.local and hope for the best!

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Tue Sep 22, 2015 6:37 pm

I was referred to this thread while attempting to get my raspberry pi with the 7 inch official touch screen to rotate the display AND touch screen 90 or 270 degrees.
I am very inexperienced with raspberry pi, Linux, etc. and could use some help.

I followed the directions until I ran the command in the image below and the results confused me.
I would greatly appreciate any expertise or ideas anyone may have.

Thanks,
image.jpeg
image.jpeg (62.79 KiB) Viewed 316925 times

lanewinfield
Posts: 22
Joined: Tue Apr 07, 2015 2:12 am

Re: Rotate display 90º?

Tue Sep 22, 2015 7:18 pm

twuelfing wrote:I was referred to this thread while attempting to get my raspberry pi with the 7 inch official touch screen to rotate the display AND touch screen 90 or 270 degrees.
I am very inexperienced with raspberry pi, Linux, etc. and could use some help.

I followed the directions until I ran the command in the image below and the results confused me.
I would greatly appreciate any expertise or ideas anyone may have.

Thanks,
image.jpeg
Cool! You're doing a great job. I started playing around with Rasp Pi knowing nothing and now—well, I know a little bit.

The first step is actually rotating the screen—I can't tell if you've done that already. To do that, run this command:

Code: Select all

sudo nano /boot/config.txt
And add either

Code: Select all

display_rotate=1
or

Code: Select all

display_rotate=3
at the end of the file. CTRL-X + say Y to save that file once you've added that.

Code: Select all

sudo reboot
and you'll see that the monitor is now rotated.

Now we're at where you're at in that picture.

If I'm not mistaken, what you're seeing there is a list of the pointers (like mice or touchscreens) and keyboard inputs. What we're looking for there is the name of the touchscreen input. In this case, it's

Code: Select all

FT5406 memory based driver
So, now that we've found that, you should do a command that will tell that touchscreen input to swap axes for the touch interface. Use this command:

Code: Select all

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
Then, after that, we'll do a command that'll swap the other direction. But, it depends on which direction you rotated the screen (90º or 270º), so try each one until the touchscreen works:

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1

Code: Select all

xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
Try out the screen now—it should work fine.

NOW the next step is getting this working automatically when the rasp pi boots up.

Code: Select all

sudo nano /etc/rc.local
Editing rc.local will allow you to add commands that will run as soon as the Pi boots up. We want to add those two lines that we used above to get this running automatically.

Add the first line and then whichever second line worked in the last step. Either:

Code: Select all

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
OR

Code: Select all

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
Once that's in the bottom of the file, CTRL-X, Y to save, and sudo reboot again.

That should work!

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Wed Sep 23, 2015 11:03 pm

i got everything to work, except the part where adding the lines to rc.local would cause the changes to be present at boot.

When i typed them in manually it worked, when i added the lines and saved the file out and reboot the touch screen is still backward as if nothing was done.

I added the lines directly above the last line and modified nothing else.
Do i need to enable this script somewhere for it to work?
the comments in the file say that by default it does nothing and to change some setting to enable or disable it, but it didnt make sense to me. If you need i can get the exact text from the file.

thanks,

ritter4242
Posts: 11
Joined: Fri Sep 25, 2015 4:07 am

Re: Rotate display 90º?

Fri Sep 25, 2015 4:12 am

I've gotten as far as twuelfing, but when I add the command to rc.local (after the comments) I reboot and get:
[....] startpar: service(s) returned failure: rc.local
[FAI failed!

any thoughts?

House-Audio
Posts: 1
Joined: Fri Sep 25, 2015 9:22 am

Re: Rotate display 90º?

Fri Sep 25, 2015 9:24 am

The issue is that rc.local runs to early (my basic understanding). instead:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

add the lines

@DISPLAY=:0 xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1

and
@DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
or
@DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0

Depending which one worked for you above. This adds them to the autostart file for the GUI.

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Fri Sep 25, 2015 8:28 pm

I have added these lines to the specified file. It still does not work as intended.

thanks again for all the help!

Marques de Monsas
Posts: 11
Joined: Tue Sep 29, 2015 4:34 pm

Re: Rotate display 90º?

Tue Sep 29, 2015 7:46 pm

Hello.
I got it working by using script and running it from "/etc/xdg/lxsession/LXDE-pi/autostart".

Add

Code: Select all

@/your/script.sh
to /etc/xdg/lxsession/LXDE-pi/autostart

Script that I use:

Code: Select all

#!/bin/bash
#script to set correct touchscreen orientation after x start
#this won't rotate the displayed image, only the touchscreen input
#to rotate the displayed image add the following to /boot/config.txt
#"display_rotate=1" to rotate display 90 degrees
#"display_rotate=3" to rotate display 270 degrees

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1

#Uncomment this for 90 rotation
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1

#Uncomment this for 270 rotation
#xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
This is kind of a workaround. I hope some one makes proper fix for this issue. Would be nice to simply use lcd_rotate in config.txt for 90 and 270 degrees also.

Hope this helps in the mean time.

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Thu Oct 01, 2015 8:42 pm

I have tried all of this, when i type the commands in manually the touch screen does what I want. when i add it to the various scripts and files it does not adjust the touch input.
the monitor is rotated as i want it at 270 degrees.

here are the specific inputs. When i type these into the command window it works.

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0

thanks again for the patience and help sorting this out.
its kind of hard to believe that after so much time was spent preparing this display for resale that it doesn't seem to have been considered that users may not want the default orientation.

mjlush
Posts: 5
Joined: Wed Dec 19, 2012 12:16 pm

Re: Rotate display 90º?

Sun Oct 04, 2015 1:59 pm

lanewinfield wrote:

Code: Select all

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0
Really helpful post thanks!
In my hands I ended up doing

Code: Select all

added "display_rotate=2" to /boot/config.txt
(run via ssh so) 
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 0
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 1
Quite why our Pi's would differ like that I really don't know (am running up to date rasbian and rpi-update)

Marques de Monsas
Posts: 11
Joined: Tue Sep 29, 2015 4:34 pm

Re: Rotate display 90º?

Mon Oct 05, 2015 3:04 am

I am sorry I forgot to mention that I am using Raspberry Pi 2 B and the official 7" touch screen. Also the OS (rasbian) and FW where up to date at the time of writing the post.

I don't really know how to debug the desktop environment or the autostart script. There is probably some log file somewhere.
As I said before, in my mind this should really be set up in the config.txt file and I don't even have a clue why the xinput commands won't work straight from the autostart script and why is the user script required in between, but it works for me and I thought to share it here if it is any use to anybody.
Sorry that I can not be any more of assistance. :|

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Fri Oct 09, 2015 1:27 am

Forgive my ignorance here,
I have just been following the directions provided here and dont really understand what all of it is doing or why it does it, so I am going to ask.

What do the two hyphens or minus signs before the set-prop part of the command?
DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 0

Marques de Monsas
Posts: 11
Joined: Tue Sep 29, 2015 4:34 pm

Re: Rotate display 90º?

Fri Oct 09, 2015 2:16 am

twuelfing wrote:Forgive my ignorance here,
I have just been following the directions provided here and dont really understand what all of it is doing or why it does it, so I am going to ask.

What do the two hyphens or minus signs before the set-prop part of the command?
DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 0
They are for the xinput program to identify the ASCII characters are meant as a command, many of command line programs use the minus sign (or two) to identify user argument or command. Try several commands with --help and see what you get. e.g.

Code: Select all

ls --help

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Fri Oct 09, 2015 3:31 pm

thanks for the info.
I noticed that if i include the two dashes when i do the command manually it does not work. The commands only seem to work if i omit those.
any reason that would be the case?

Marques de Monsas
Posts: 11
Joined: Tue Sep 29, 2015 4:34 pm

Re: Rotate display 90º?

Sat Oct 10, 2015 10:17 am

twuelfing wrote:thanks for the info.
I noticed that if i include the two dashes when i do the command manually it does not work. The commands only seem to work if i omit those.
any reason that would be the case?
This is weird. I am not a Linux guru so take my writings with grain of salt.
What I understand is if you have the same hardware and software you should get the same results. I have absolutely no clue why you are having the behaviour you are describing with the "--" and commands, as I don't have my setup that I made the script for, nor do I have a Linux machine at hand to test there either, so I am very sorry, but I am unable to help you further. Some one with better Linux knowledge can maybe explain this behaviour. To my knowledge what you describe should not be possible, but I can be mistaken as I said I am no guru nor can I test these commands at the moment.
Sorry for not being able to help you further.

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Sat Oct 10, 2015 5:51 pm

Is it possible your rotating your display 180 degrees?
That seems to be relatively easy to accomplish compared to the 270 degree rotation i need.
Perhaps this explains the differences we are seeing as we are not trying to do the same thing.
mjlush wrote:
lanewinfield wrote:
In my hands I ended up doing

Code: Select all

added "display_rotate=2" to /boot/config.txt
(run via ssh so) 
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 0
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 1
Quite why our Pi's would differ like that I really don't know (am running up to date rasbian and rpi-update)

JimmyN
Posts: 1109
Joined: Wed Mar 18, 2015 7:05 pm
Location: Virginia, USA

Re: Rotate display 90º?

Sat Oct 10, 2015 6:22 pm

mjlush wrote:
Really helpful post thanks!
In my hands I ended up doing

Code: Select all

added "display_rotate=2" to /boot/config.txt
(run via ssh so) 
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 0
 DISPLAY=:0 xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 1
Quite why our Pi's would differ like that I really don't know (am running up to date rasbian and rpi-update)
If you're going to rotate it 180deg then you should use lcd_rotate=2 in config.txt rather than display_rotate. That will rotate the touchscreen along with the display and you don't need any xinput commands. The problem being discussed is rotating the screen 90deg (1) or 270deg (3) which requires the xinput commands to orient the touchscreen correctly.

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Sat Oct 10, 2015 7:26 pm

I understand how to rotate the display and touch 180 degrees.

I have checked everything 3 times and here is where i am at.

the screen is rotated 270 degrees by using display_rotate=3 in the config.txt file located in \boot

I have added to /etc/xdg/lxsession/LXDE-pi/autostart the following line as the first line in the file
@/etc/xdg/lxsession/LXDE-pi/screenflip.sh

I created a file screenflip.sh here: /etc/xdg/lxsession/LXDE-pi/
in this file i have the following lines of code

#!/bin/bash
#script to set correct touchscreen orientation after x start
#this won't rotate the displayed image, only the touchscreen input
#to rotate the displayed image add the following to /boot/config.txt
#"display_rotate=1" to rotate display 90 degrees
#"display_rotate=3" to rotate display 270 degrees

xinput set-prop 'FT5406 memory based driver' 'Evdev Axes Swap' 1

#Uncomment this for 90 rotation
#xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 0 1

#Uncomment this for 270 rotation
xinput --set-prop 'FT5406 memory based driver' 'Evdev Axis Inversion' 1 0


i really appreciate everyones help with this, its greatly appreciated.
if your curious what i am working toward, you can check out my blog at http://troywuelfing.blogspot.com/

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Sat Oct 10, 2015 7:44 pm

I noticed some issues appearing that seem as though they may be relevant to my problems.
below is a picture of the errors I see while the machine is booting.
IMG_2067.jpg
IMG_2067.jpg (50.88 KiB) Viewed 315364 times

mikearnoldsmith
Posts: 4
Joined: Fri Nov 13, 2015 12:17 pm

Re: Rotate display 90º?

Fri Nov 13, 2015 12:38 pm

The script worked for me only after I made the script executable.

Code: Select all

sudo chmod 755 /etc/xdg/lxsession/LXDE-pi/screenflip.sh

twuelfing
Posts: 14
Joined: Mon Sep 21, 2015 1:33 am

Re: Rotate display 90º?

Fri Nov 13, 2015 4:45 pm

did this work to rotate 270 degrees or just 180?

thanks,

mikearnoldsmith
Posts: 4
Joined: Fri Nov 13, 2015 12:17 pm

Re: Rotate display 90º?

Sat Nov 14, 2015 12:09 pm

My display and Touchscreen is working in 270 rotation.

Return to “Official Display”