Theo1966
Posts: 4
Joined: Mon Dec 14, 2015 11:41 am

Re: Rotate display 90º?

Mon Dec 14, 2015 12:00 pm

Hi All,
I have the same problem here, the touchscreen input can be rotated manually but will not rotate at boot time.

I use the same script as twuelfing.
I confirmed that the startup script runs bij writing some text to a file. :roll:

If I manually run the script, it works and the touchscreen input rotates.

Are there any other suggestions on how to proceed?

Theo1966
Posts: 4
Joined: Mon Dec 14, 2015 11:41 am

Re: Rotate display 90º?

Mon Dec 14, 2015 3:19 pm

As usual, after long try and error post the problem in a forum and find the solution rather quickly after doing so :lol:

I was thinking it must be something about the difference between commandline and gui.
-> so maybe run the bash after the gui is started
-> So I put the command to run the script in " /home/pi/.config/lxsession/LXDE-pi/autostart "
........ and it worked !!!! :o

Now the input of the touchscreen is rotated 270 degrees @ startup

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

Re: Rotate display 90º?

Thu Dec 17, 2015 7:36 pm

I have done everything in this thread multiple times.

here is where I am.

the display is rotated correctly.
the touch works on the vertical axis
the touch is backward on the horizontal axis.

my screenflip.sh script is set to chmod 755 and the code hasnt changed from the code posted earlier in the thread.
i added the code to execute the script in 3 different places now.
1. home/pi/.config/lxsession.LXDE-pi/autostart
2. /etc/xdg/lxsession/LXDE/autostart
3. /etc/xdg/lxsession/LXDE-pi/autostart (this is where the screenflip.sh is)

in boot/config.txt i have the display_rotate set to 3.

if i run the screenflip.sh by right clicking and opening it then select run, the touch screen works fine.
this makes me think that none of the autostart scripts are actually running the screenflip.sh script

what am i missing?
thanks for the help

Theo1966
Posts: 4
Joined: Mon Dec 14, 2015 11:41 am

Re: Rotate display 90º?

Fri Dec 18, 2015 12:03 pm

Hi Twuelfing,

Maybe you could add a line like:

echo "sript runned" > /home/pi/test.txt

This way you can check the script is called during startup.

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

Re: Rotate display 90º?

Fri Dec 18, 2015 12:51 pm

So i should add the following text to the end of the screenflip.sh file?
echo "sript runned" > /home/pi/test.txt

That is easy enough, but what does this part of it do? > /home/pi/test.txt

Theo1966
Posts: 4
Joined: Mon Dec 14, 2015 11:41 am

Re: Rotate display 90º?

Fri Dec 18, 2015 4:22 pm

Hi Twuelfing,

It creates a file named test.txt to your /Home/pi directory and writes "script runned" inside that text.

So you can check that your script actually did run because there is a new file in your directory. ;)

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

Re: Rotate display 90º?

Fri Dec 18, 2015 6:15 pm

I woke up this morning to see about adding the code suggested above. When i booted up the project the touch screen worked!

thanks for your help everyone. I think I may have just needed to reboot a few extra times for good luck.

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

Re: Rotate display 90º?

Sun Dec 20, 2015 11:37 am

twuelfing wrote:did this work to rotate 270 degrees or just 180?

thanks,
This was working on Wheezie, and when I re-installed Jessie, I couldn't get it to work.

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

Re: Rotate display 90º?

Sun Dec 20, 2015 12:12 pm

Theo1966 wrote:As usual, after long try and error post the problem in a forum and find the solution rather quickly after doing so :lol:

I was thinking it must be something about the difference between commandline and gui.
-> so maybe run the bash after the gui is started
-> So I put the command to run the script in " /home/pi/.config/lxsession/LXDE-pi/autostart "
........ and it worked !!!! :o

Now the input of the touchscreen is rotated 270 degrees @ startup
I edited /home/pi/.config/lxsession/LXDE-pi/autostart
and added @/etc/xdg/lxsession/LXDE-pi/screenflip.sh
And my touchscreen works in 270 rotation on Raspbian Jessie.

Thanks for the post.

sushmasattaru
Posts: 5
Joined: Tue Jan 19, 2016 7:32 am

Re: Rotate display 270º?

Tue Jan 19, 2016 7:38 am

I am interfacing a 5 inch HDMI LCD(B) with raspberry pi 2. I am able to rotate screen by 270 degrees using 'display_rotate=3'. But, I am unable to achieve the change of axes of touch. I tried all the xinput commands suggested and created a '.sh' file bt touch is not changed. How can I achieve a portrait display along with touch?

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

Re: Rotate display 270º?

Tue Jan 19, 2016 4:14 pm

sushmasattaru wrote:I am interfacing a 5 inch HDMI LCD(B) with raspberry pi 2. I am able to rotate screen by 270 degrees using 'display_rotate=3'. But, I am unable to achieve the change of axes of touch. I tried all the xinput commands suggested and created a '.sh' file bt touch is not changed. How can I achieve a portrait display along with touch?
You have xinput installed? Have you tried running the commands in your shell file straight in the command line? Do they run? Do they work?

If so, did you try running

Code: Select all

xinput --list
to see which ID your touchscreen is? Do they match?

(Basically, take a look at my older post, run through it and see if that helps)

sushmasattaru
Posts: 5
Joined: Tue Jan 19, 2016 7:32 am

Re: Rotate display 90º?

Wed Jan 20, 2016 6:10 am

I installed 'xinput' and got the following result:
[email protected]:~ $ DISPLAY=:0 xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ USB Mouse id=6 [slave pointer (2)]
⎜ ↳ RPI_TOUCH By ZH851 id=7 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Logitech USB Keyboard id=8 [slave keyboard (3)]
↳ Logitech USB Keyboard id=9 [slave keyboard (3)]
Touch controller is RPI_TOUCH By ZH851, touch screen which I was using is 5" HDMI LCD (B) and that doesn't have 'FT5406 memory based driver' . How can I achieve axis inversion?

sushmasattaru
Posts: 5
Joined: Tue Jan 19, 2016 7:32 am

Re: Rotate display 90º?

Wed Jan 20, 2016 7:30 am

I formatted SD card and flashed image. I checked with the following commands:
[email protected]:~ $ DISPLAY=:0.0 xinput set-prop 'RPI_TOUCH By ZH851' 'Evdev Axes Swap' 1
[email protected]:~ $ DISPLAY=:0.0 xinput --set-prop 'RPI_TOUCH By ZH851' 'Evdev Axis Inversion' 1 0
Touch axes got inverted successfully.
I followed the steps mentioned to enable while booting, but the changes are lost

alphanumeric
Posts: 1922
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Rotate display 90º?

Wed Jan 20, 2016 2:27 pm

I do believe if you use lcd_rotate the touch will flip too. lcd_rotate=2 will flip everything 180 degrees. 3 is likely 270 degrees. If somebody already posted this, my apologies. I skimmed through a couple of posts.

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

Re: Rotate display 90º?

Wed Jan 20, 2016 3:59 pm

alphanumeric wrote:I do believe if you use lcd_rotate the touch will flip too. lcd_rotate=2 will flip everything 180 degrees. 3 is likely 270 degrees.
Yes, lcd_rotate=2 does rotate everything 180deg and that's always worked fine. But this post is about rotating 90deg and lcd_rotate=1 or lcd_rotate=3 rotates the screen but not the touch inputs, thus the need for xinput to change the axes of the touch portion.

alphanumeric
Posts: 1922
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Rotate display 90º?

Wed Jan 20, 2016 4:10 pm

OK, I only ever tried lcd_rotate=2 and it also flipped the touch screen upside down to match. What I saw mentioned in the first couple of posts is display_rotate=1. That's not the same thing. display_rotate only rotates the image, it doesn't rotate the touch calibration to match. lcd_rotate flips both. It did for me anyway.

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

Re: Rotate display 90º?

Thu Jan 21, 2016 8:14 pm

alphanumeric wrote:OK, I only ever tried lcd_rotate=2 and it also flipped the touch screen upside down to match. What I saw mentioned in the first couple of posts is display_rotate=1. That's not the same thing. display_rotate only rotates the image, it doesn't rotate the touch calibration to match. lcd_rotate flips both. It did for me anyway.
Interesting. I should change that in the post.

sushmasattaru
Posts: 5
Joined: Tue Jan 19, 2016 7:32 am

Re: Rotate display 90º?

Fri Jan 22, 2016 9:32 am

I tried the following to run xinput commands while booting:

I 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
DISPLAY=:0.0 xinput set-prop 'RPI_TOUCH By ZH851' 'Evdev Axes Swap' 1
DISPLAY=:0.0 xinput --set-prop 'RPI_TOUCH By ZH851' 'Evdev Axis Inversion' 1 0
After booting nothing happened, changes were lost. How can I enable above commands while booting? Any alternative?

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

Re: Rotate display 90º?

Fri Jan 22, 2016 11:29 am

sushmasattaru wrote:I tried the following to run xinput commands while booting:

I 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
If you're running Jessie you need to start it with the users autostart at

Code: Select all

~/.config/lxsession/LXDE-pi/autostart
It's a good practice to put all your scripts in one place, first it keeps them all together rather than scattered around the filesystem. If you have to edit a script 6 months from now you won't have to figure out where you put it. And second it keeps them from possibly being overwritten by a future upgrade if you've put them in a system directory. Use somewhere like "/usr/bin/", or I create a "scripts" folder in the home directory and all my scripts are found at "~/scripts". When I backup the /home/ directory it also backs up all the scripts I'm using.

hen3bosch
Posts: 2
Joined: Sun Feb 21, 2016 9:38 pm

Re: Rotate display 90º?

Sun Feb 21, 2016 9:46 pm

I found a solution at this site: http://www.circuitbasics.com/raspberry- ... omment-142

This worked for me, i just had to change the

Code: Select all

Option “InvertY” “true”
with

Code: Select all

Option “InvertX” “true”
Here's the text:
I fixed the inverted Y axes on touch screen.

downloaded the needed module with these commands:

sudo pip install evdev
sudo pip install xinput

I added this code on the /usr/share/X11/xorg.conf.d/99-fbturbo.conf

Section “InputClass”
Identifier “evdev touchscreen catchall”
MatchIsTouchscreen “on”
MatchDevicePath “/dev/input/event*”
Driver “evdev”
Option “InvertY” “true”
Option “GrabDevice” “True”
EndSection

Also in the section you can add these lines in case you need:

Option “SwapAxes” “True”
Option “InvertX” “true”
--
hen3bosch

sushmasattaru
Posts: 5
Joined: Tue Jan 19, 2016 7:32 am

Re: Rotate display 90º?

Tue Mar 15, 2016 10:47 am

I tried editing config file as I am using jessie, but changes were lost after reboot

lincolnberryiii
Posts: 2
Joined: Sun May 15, 2016 4:43 pm

Re: Rotate display 90º?

Sun May 15, 2016 5:12 pm

A couple things: For one, I am unable to get my shell script to take effect after startx. I can manually run the shell script once booted to the desktop, but all bets are off using the autostart method above.

Also, once the display goes to sleep, I notice that I have to run my touch calibration shell script again once it wakes. Any clues as to why this might be?
Last edited by lincolnberryiii on Sun May 15, 2016 7:39 pm, edited 1 time in total.

alphanumeric
Posts: 1922
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Rotate display 90º?

Sun May 15, 2016 7:36 pm

sushmasattaru wrote:I tried editing config file as I am using jessie, but changes were lost after reboot
You did the ctrl x to save right?

alphanumeric
Posts: 1922
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Rotate display 90º?

Sun May 15, 2016 7:42 pm

lincolnberryiii wrote:A couple things: For one, I am unable to get my shell script to run after startx. I can manually run the shell script once booted to the desktop, but all bets are off using the autostart method above.

Also, once the display goes to sleep, I notice that I have to run my touch calibration shell script again once it wakes. Any clues as to why this might be?
Did you try the lcd_rotate=1 config.txt edit? It's a lot easier. It works for me.

lincolnberryiii
Posts: 2
Joined: Sun May 15, 2016 4:43 pm

Re: Rotate display 90º?

Sun May 15, 2016 8:01 pm

alphanumeric wrote:Did you try the lcd_rotate=1 config.txt edit? It's a lot easier. It works for me.
Thanks, but I need my display rotated at 270° and lcd_rotate=3 doesn't work for me. I'm running Raspbian Jessie on the Pi 2 B.

Return to “Official Foundation Display”