User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Official 7' touchscreen, rotate touch

Mon Jul 30, 2018 12:24 pm

Hello there,
I am using the latest Rasbian image with Rpi 3. I am using the official 7' Rpi touch screen. I can rotate the screen by editing /boot/config.txt (adding display_rotate=x). The problem is, after I rotate the screen, the touch panel doesnt seem to notice that, and it works as it would if the screen was not rotated (mirror when rotated by 180 degrees for example).

How to rotate the touch functionality as well?
I would appreciate all help.
http://lprzenioslo.zut.edu.pl

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Mon Jul 30, 2018 1:16 pm

If you use display_lcd_rotate instead, is that better?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Tue Jul 31, 2018 5:50 am

Same thing.... display_lcd_rotate=2 gives this:

https://youtu.be/ZcdE97d9NI8

Any idea what else could be done?
http://lprzenioslo.zut.edu.pl

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Wed Aug 01, 2018 3:21 am

Anyone please?
http://lprzenioslo.zut.edu.pl

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Wed Aug 01, 2018 8:30 am

I'll try and have a look at this today. It should 'just work', so will need to check if something has gone awry.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

aBUGSworstnightmare
Posts: 7343
Joined: Tue Jun 30, 2015 1:35 pm

Re: Official 7' touchscreen, rotate touch

Thu Aug 02, 2018 11:58 am

Sounds like your coordinate transformation matrix is wrong and needs to be adjusted to match your display rotation.

Code: Select all

pi@raspberrypi:~ $ xinput list
⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ PixArt USB Optical Mouse                	id=8	[slave  pointer  (2)]
⎜   ↳ FT5406 memory based driver              	id=9	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳   USB Keyboard                          	id=6	[slave  keyboard (3)]
    ↳   USB Keyboard                          	id=7	[slave  keyboard (3)]
 
This will list your input devices. FT5406 is your touch controller .
Now see what your coordinate transformation matrix is:

Code: Select all

pi@raspberrypi:~ $ xinput list-props 'FT5406 memory based driver' | grep "Coordinate Transformation Matrix"
	Coordinate Transformation Matrix (114):	1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
This shows results for default (off the shelf) settings.
Default matrix is:
⎡ 1 0 0 ⎤
⎜ 0 1 0 ⎥
⎣ 0 0 1 ⎦

If you now want/need to change your touch input (i.e. because your using the display upside down or in portrait mode) you will have to change the coordinate transformation matrix.
Rotate clockwise 90° ((from left) to the right) transformation matrix should be:
⎡ 0 -1 1 ⎤
⎜ 1 0 0 ⎥
⎣ 0 0 1 ⎦

90° counterclockwise:
⎡ 0 1 0 ⎤
⎜ -1 0 1 ⎥
⎣ 0 0 1 ⎦

invert rotate (180° either clock- or counterclockwise):
⎡ -1 0 1 ⎤
⎜ 0 -1 1 ⎥
⎣ 0 0 1 ⎦

For setting the coordinate transformation matrix you can use

Code: Select all

$ xinput set-prop '<device name>' 'Coordinate Transformation Matrix' <matrix in row-order>
You can also make your own udev-rule:
i.e. (note: not tested with the offical 7in DSI screen; only used this method with other screen!)

Code: Select all

sudo nano /etc/udev/rules.d/99-7inDSI.rules
Now add the content with the coordinate transformation matrix of your choice (example rotates 90° clockwise)

Code: Select all

ACTION=="add", ATTRS{name}=="FT5406 memory based driver", ENV{LIBINPUT_CALIBRATION_MATRIX}="-0 -1 1 1 0 0 0 0 1"

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Thu Aug 02, 2018 1:03 pm

You could try this change to config.txt

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
See /boot/overlays/README for other touchscreen parameters
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Fri Aug 03, 2018 5:23 am

Thanks for answers. First I tried out jamesh solution. Unfortunately it doesnt work. At first I tried out this:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
But it didnt help at all, it only flipped x and y with placed making it still work wrong. I went to the README file in /boot/overlays/ directory and checked out this:

Code: Select all

Name:   rpi-ft5406

Info:   Official Raspberry Pi display touchscreen

Load:   dtoverlay=rpi-ft5406,<param>=<val>

Params: touchscreen-size-x      Touchscreen X resolution (default 800)

        touchscreen-size-y      Touchscreen Y resolution (default 600);

        touchscreen-inverted-x  Invert touchscreen X coordinates (default 0);

        touchscreen-inverted-y  Invert touchscreen Y coordinates (default 0);

        touchscreen-swapped-x-y Swap X and Y cordinates (default 0);
So I started with:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-x=1
And it worked, the x axis was now rotated by 180 degrees. Then I added second line:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
And after this Y was properly rotated, but X went back to normal. Thus I figured out that those commands are exclusive and you cannot use them together. This is odd for me, it just doesnt work. I will now try the other solution.
http://lprzenioslo.zut.edu.pl

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Fri Aug 03, 2018 5:37 am

aBUGSworstnightmare, Your solution did the trick fully. Thank you.
http://lprzenioslo.zut.edu.pl

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Fri Aug 03, 2018 6:37 am

Bremenpl wrote:
Fri Aug 03, 2018 5:23 am
Thanks for answers. First I tried out jamesh solution. Unfortunately it doesnt work. At first I tried out this:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
But it didnt help at all, it only flipped x and y with placed making it still work wrong. I went to the README file in /boot/overlays/ directory and checked out this:

Code: Select all

Name:   rpi-ft5406

Info:   Official Raspberry Pi display touchscreen

Load:   dtoverlay=rpi-ft5406,<param>=<val>

Params: touchscreen-size-x      Touchscreen X resolution (default 800)

        touchscreen-size-y      Touchscreen Y resolution (default 600);

        touchscreen-inverted-x  Invert touchscreen X coordinates (default 0);

        touchscreen-inverted-y  Invert touchscreen Y coordinates (default 0);

        touchscreen-swapped-x-y Swap X and Y cordinates (default 0);
So I started with:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-x=1
And it worked, the x axis was now rotated by 180 degrees. Then I added second line:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
And after this Y was properly rotated, but X went back to normal. Thus I figured out that those commands are exclusive and you cannot use them together. This is odd for me, it just doesnt work. I will now try the other solution.
Odd, they should not be exclusive according to the code, and my tests when I wrote it! Not sure what is going on there.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Fri Aug 03, 2018 6:45 am

Please let me know if you will need me to test anything regarding this.
http://lprzenioslo.zut.edu.pl

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Fri Aug 03, 2018 6:47 am

Bremenpl wrote:
Fri Aug 03, 2018 6:45 am
Please let me know if you will need me to test anything regarding this.
I'll check the code when I get into office, and let you know.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Mon Aug 06, 2018 5:52 pm

Anything new?
http://lprzenioslo.zut.edu.pl

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 32227
Joined: Sat Jul 30, 2011 7:41 pm

Re: Official 7' touchscreen, rotate touch

Mon Aug 06, 2018 7:12 pm

Sorry, not had a chance t ocheck this stuff out. I'm working on the panel, but with lots of custom changes, and its a PITA to swap stuff around. Will try and check in next couple of days.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Wed Aug 15, 2018 4:54 am

Hello there,
I am posting to let know that the solution provided by @aBUGSworstnightmare earlier doesnt seem to solve my problem fully. Even though When in the "desktop" the pointer works correctly, it stops when used with a Qt application with eglfs platform. Here is a video: https://www.youtube.com/watch?v=zFPPxua4l_M
It shows that comparing to the same application working on an x86 machine, the touch direction is flipped by 180 degrees. I wonder either your solution @jamesh would help?
http://lprzenioslo.zut.edu.pl

aBUGSworstnightmare
Posts: 7343
Joined: Tue Jun 30, 2015 1:35 pm

Re: Official 7' touchscreen, rotate touch

Wed Aug 15, 2018 6:08 am

Well...you did not mention 'Qt application with eglfs platform' in your initial post...

My uneducated guess is problem is related to EGLFS (as touch works with normal Qt application here).
BTW: what should happen when you use the touch?

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Wed Aug 15, 2018 6:24 am

Thank for answer,
Could you elaborate more? Do you mean in general or just in this example application from youtube video?
http://lprzenioslo.zut.edu.pl

aBUGSworstnightmare
Posts: 7343
Joined: Tue Jun 30, 2015 1:35 pm

Re: Official 7' touchscreen, rotate touch

Thu Aug 16, 2018 1:09 pm

I'm running a Standard Qt app where touch is working as expected (official 7in DSI Screen, as well as Manga Screen 2 touch).
Qt is installed by using command below

Code: Select all

sudo apt install qtcreator qttools5-dev qtbase5-dev qt5-default qtdeclarative5-dev libqt5svg5-dev libqtwebkit-dev libqt5webkit5-dev libsdl1.2-dev build-essential libudev-dev qtmultimedia5-dev

User avatar
Bremenpl
Posts: 85
Joined: Thu Feb 02, 2012 9:32 am
Location: Poland

Re: Official 7' touchscreen, rotate touch

Thu Aug 16, 2018 2:58 pm

Could you try a qml based app with -platform eglfs arguments?
http://lprzenioslo.zut.edu.pl

aBUGSworstnightmare
Posts: 7343
Joined: Tue Jun 30, 2015 1:35 pm

Re: Official 7' touchscreen, rotate touch

Thu Aug 16, 2018 4:51 pm

Bremenpl wrote: Could you try a qml based app with -platform eglfs arguments?
sorry, no!

XDSFyP
Posts: 15
Joined: Mon Aug 27, 2018 1:06 am

Re: Official 7' touchscreen, rotate touch

Mon Aug 27, 2018 1:28 am

Thanks to everyone in this thread, I got the touches to map correctly to the image rotation. Adding my solution for future reference.

I am using raspbian lite Linux raspberrypi 4.14.62-v7+ #1134 SMP Tue Aug 14 17:10:10 BST 2018 armv7l without (Pixel?) desktop environment.
RPI3B+

I rotated the official 7 inch touchscreen 90 degrees appending the following to my /boot/config.txt

Code: Select all

display_lcd_rotate=1 # rotates image
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1,touchscreen-inverted-x=1 # rotates touches

I am using the pi to run a Qt C++ program from bash with sudo startx ./qtApp after I have installed apt-get install xserver-xorg x11-xserver-utils xinit

eatmyvolts
Posts: 1
Joined: Mon Jan 28, 2019 11:04 pm

Re: Official 7' touchscreen, rotate touch

Mon Jan 28, 2019 11:15 pm

Bremenpl wrote:
Fri Aug 03, 2018 5:23 am

So I started with:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-x=1
And it worked, the x axis was now rotated by 180 degrees. Then I added second line:

Code: Select all

dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
And after this Y was properly rotated, but X went back to normal. Thus I figured out that those commands are exclusive and you cannot use them together. This is odd for me, it just doesnt work. I will now try the other solution.
Thank you for putting me on the right track for what I needed to do. Which was rotate the screen 180 degrees while using both touchscreen and mouse.
By chance I tried this and the commands are not mutually exclusive, they just have to be combined on one line

Code: Select all

display_lcd_rotate=2
dtoverlay=rpi-ft5406,touchscreen-inverted-x=1,touchscreen-inverted-y=1
Works for me, thanks again.

moderatelyfunky
Posts: 21
Joined: Mon May 07, 2018 7:12 pm
Location: Vermont, US

Re: Official 7' touchscreen, rotate touch

Tue Feb 26, 2019 12:27 am

Thanks, eatmyvolts. Your version worked!

jlinkels
Posts: 5
Joined: Sun Jun 09, 2019 3:01 pm

Re: Official 7' touchscreen, rotate touch

Fri Aug 02, 2019 4:31 pm

I am using Raspi 3, Raspbian Stretch and the official 7"touch screen.

This worked for me in /boot/config.txt:

Code: Select all

display_rotate=1
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1,touchscreen-inverted-x=1,touchscreen-inverted-y=1
I am using a Tcl/Tk graphical application. It works as expected in both the desktop and the application. Thanks to y'all for posting their solutions and reports.

jlinkels

zapping
Posts: 1
Joined: Tue Sep 03, 2019 7:33 pm

Re: Official 7' touchscreen, rotate touch

Tue Sep 03, 2019 7:42 pm

After much research and change the 3 parameters for the position

Code: Select all

display_rotate=3
I have found that it only works fine if I set:

Code: Select all

dtoverlay=rpi-ft5406, touchscreen-swapped-x-y=1, touchscreen-inverted-y=1
But don't work if I set:

Code: Select all

dtoverlay=rpi-ft5406, touchscreen-swapped-x-y=1, touchscreen-inverted-x=0, touchscreen-inverted-y=1
In case it serves to someone.

Return to “Official Display”