Official 7' touchscreen, rotate touch
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.
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
Re: Official 7' touchscreen, rotate touch
If you use display_lcd_rotate instead, is that better?
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.
Working in the Applications Team.
Re: Official 7' touchscreen, rotate touch
Same thing.... display_lcd_rotate=2 gives this:
https://youtu.be/ZcdE97d9NI8
Any idea what else could be done?
https://youtu.be/ZcdE97d9NI8
Any idea what else could be done?
http://lprzenioslo.zut.edu.pl
Re: Official 7' touchscreen, rotate touch
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.
Working in the Applications Team.
-
- Posts: 7343
- Joined: Tue Jun 30, 2015 1:35 pm
Re: Official 7' touchscreen, rotate touch
Sounds like your coordinate transformation matrix is wrong and needs to be adjusted to match your display rotation.
This will list your input devices. FT5406 is your touch controller .
Now see what your coordinate transformation matrix is:
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
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!)
Now add the content with the coordinate transformation matrix of your choice (example rotates 90° clockwise)
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)]
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
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>
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
Code: Select all
ACTION=="add", ATTRS{name}=="FT5406 memory based driver", ENV{LIBINPUT_CALIBRATION_MATRIX}="-0 -1 1 1 0 0 0 0 1"
Re: Official 7' touchscreen, rotate touch
You could try this change to config.txt
See /boot/overlays/README for other touchscreen parameters
Code: Select all
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.
Working in the Applications Team.
Re: Official 7' touchscreen, rotate touch
Thanks for answers. First I tried out jamesh solution. Unfortunately it doesnt work. At first I tried out this:
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:
So I started with:
And it worked, the x axis was now rotated by 180 degrees. Then I added second line:
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.
Code: Select all
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
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);
Code: Select all
dtoverlay=rpi-ft5406,touchscreen-inverted-x=1
Code: Select all
dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
http://lprzenioslo.zut.edu.pl
Re: Official 7' touchscreen, rotate touch
aBUGSworstnightmare, Your solution did the trick fully. Thank you.
http://lprzenioslo.zut.edu.pl
Re: Official 7' touchscreen, rotate touch
Odd, they should not be exclusive according to the code, and my tests when I wrote it! Not sure what is going on there.Bremenpl wrote: ↑Fri Aug 03, 2018 5:23 amThanks for answers. First I tried out jamesh solution. Unfortunately it doesnt work. At first I tried out this:
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
dtoverlay=rpi-ft5406,touchscreen-swapped-x-y=1
So I started with: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);
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-x=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.Code: Select all
dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.
Working in the Applications Team.
Re: Official 7' touchscreen, rotate touch
Please let me know if you will need me to test anything regarding this.
http://lprzenioslo.zut.edu.pl
Re: Official 7' touchscreen, rotate touch
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.
Working in the Applications Team.
Re: Official 7' touchscreen, rotate touch
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.
Working in the Applications Team.
Re: Official 7' touchscreen, rotate touch
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?
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
-
- Posts: 7343
- Joined: Tue Jun 30, 2015 1:35 pm
Re: Official 7' touchscreen, rotate touch
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?
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?
Re: Official 7' touchscreen, rotate touch
Thank for answer,
Could you elaborate more? Do you mean in general or just in this example application from youtube video?
Could you elaborate more? Do you mean in general or just in this example application from youtube video?
http://lprzenioslo.zut.edu.pl
-
- Posts: 7343
- Joined: Tue Jun 30, 2015 1:35 pm
Re: Official 7' touchscreen, rotate touch
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
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
Re: Official 7' touchscreen, rotate touch
Could you try a qml based app with -platform eglfs arguments?
http://lprzenioslo.zut.edu.pl
-
- Posts: 7343
- Joined: Tue Jun 30, 2015 1:35 pm
Re: Official 7' touchscreen, rotate touch
sorry, no!Bremenpl wrote: Could you try a qml based app with -platform eglfs arguments?
Re: Official 7' touchscreen, rotate touch
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
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
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
-
- Posts: 1
- Joined: Mon Jan 28, 2019 11:04 pm
Re: Official 7' touchscreen, rotate touch
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.Bremenpl wrote: ↑Fri Aug 03, 2018 5:23 am
So I started with:
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-x=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.Code: Select all
dtoverlay=rpi-ft5406,touchscreen-inverted-y=1
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
-
- Posts: 21
- Joined: Mon May 07, 2018 7:12 pm
- Location: Vermont, US
Re: Official 7' touchscreen, rotate touch
Thanks, eatmyvolts. Your version worked!
Re: Official 7' touchscreen, rotate touch
I am using Raspi 3, Raspbian Stretch and the official 7"touch screen.
This worked for me in /boot/config.txt:
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
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
jlinkels
Re: Official 7' touchscreen, rotate touch
After much research and change the 3 parameters for the position
I have found that it only works fine if I set:
But don't work if I set:
In case it serves to someone.
Code: Select all
display_rotate=3
Code: Select all
dtoverlay=rpi-ft5406, touchscreen-swapped-x-y=1, touchscreen-inverted-y=1
Code: Select all
dtoverlay=rpi-ft5406, touchscreen-swapped-x-y=1, touchscreen-inverted-x=0, touchscreen-inverted-y=1