[Solved] Touch screen is reversed

Post Reply
User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

[Solved] Touch screen is reversed

Unread post by mad_ady » Thu Mar 21, 2019 5:08 pm

Hello all,
I've migrated my C2 which runs the 3.5" LCD from 16.04 to 18.04 and after re-enabling the LCD (following the wiki guide), all is well except the touch screen. Let me explain.

The LCD is loaded with rotation=90 (that's the way it should be):

Code: Select all

adrianp@uy-scuti:~$ cat /etc/modprobe.d/odroid-lcd35.conf 
options fbtft_device name=flexpfb rotate=90
options flexfb chip=ili9488
And the image is fine.

When I touch the top left region of the LCD, X11 registers a click (I can see the cursor and also the click) in the bottom right corner (diametrally opposed). When I click bottom left, I get a click top right.
Here is my Xorg config:

Code: Select all

adrianp@uy-scuti:~$ cat /usr/share/X11/xorg.conf.d/99-odroidc2.conf 
# This is a minimal sample config file, which can be copied to
# /etc/X11/xorg.conf in order to make the Xorg server pick up
# and load xf86-video-fbturbo driver installed in the system.
#
# When troubleshooting, check /var/log/Xorg.0.log for the debugging
# output and error messages.
#
# Run "man fbturbo" to get additional information about the extra
# configuration options for tuning the driver.

Section "Device"
        Identifier      "FBTURBO"
        Driver          "fbturbo"
        Option          "fbdev" "/dev/fb2"

        Option          "SwapbuffersWait" "true"
        Option          "alpha_swap" "true"
EndSection
I also ran xinput_calibrator and pressed where I saw the indicated spot to press and it generated this config:

Code: Select all

Section "InputClass"                               
        Identifier      "calibration"
        MatchProduct    "SX865X Touchscreen"              
        Option  "MinX"  "61951"                                  
        Option  "MaxX"  "1604"                    
        Option  "MinY"  "60159"                     
        Option  "MaxY"  "5683"                         
        Option  "SwapXY"        "0" # unless it was already set to 1
        Option  "InvertX"       "0"  # unless it was already set
        Option  "InvertY"       "0"  # unless it was already set
EndSection
I added those to /usr/share/X11/xorg.conf.d/99-calibration.conf and restarted lightdm, but touch behaved the same way.
I also tried with InvertX = 1 and InvertY = 1, but there was no change.

Any ideas what I'm doing wrong or how to debug it further? I'd prefer not to have to rotate the odroid physically because the wires would get in the way...

User avatar
odroid
Site Admin
Posts: 30282
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 3 times
Been thanked: 26 times
Contact:

Re: Touch screen is reversed

Unread post by odroid » Thu Mar 21, 2019 5:18 pm


User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Touch screen is reversed

Unread post by mad_ady » Thu Mar 21, 2019 6:05 pm

It worked fine in 90 degrees mode under 16.04/kernel 3.14. I can try to revert to kernel 3.14 in case it's a kernel issue, but I think it may be Xorg related. Any ideas how I can test the LCD touch in console mode?

User avatar
odroid
Site Admin
Posts: 30282
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 3 times
Been thanked: 26 times
Contact:

Re: Touch screen is reversed

Unread post by odroid » Thu Mar 21, 2019 6:36 pm

I have no idea.
Can you find any device node in /dev/input/ directory?

User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Touch screen is reversed

Unread post by mad_ady » Thu Mar 21, 2019 8:46 pm

I do have it, yes:

Code: Select all

$ sudo evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      cec_input
/dev/input/event1:      vt-input
/dev/input/event2:      C-Media USB Headphone Set
/dev/input/event3:      SX865X Touchscreen
/dev/input/event4:      meson-ir
/dev/input/event5:      MCE IR Keyboard/Mouse (meson-ir)
/dev/input/event6:      lircd-uinput
Select the device event number [0-6]: 3
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
Input device name: "SX865X Touchscreen"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 330 (BTN_TOUCH)
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)
      Value    380
      Min        0
      Max     4095
    Event code 1 (ABS_Y)
      Value    417
      Min        0
      Max     4095
    Event code 24 (ABS_PRESSURE)
      Value      0
      Min        0
      Max     4095
Properties:
Testing ... (interrupt to exit)

When I'm at home I'll try some touches, to see what coordinates it generates.

User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Touch screen is reversed

Unread post by mad_ady » Fri Mar 22, 2019 3:47 am

Ok, I managed to record some keypresses via evtest:

Code: Select all

Bottom right:
Event: time 1553192419.627161, type 3 (EV_ABS), code 0 (ABS_X), value 347                                               
Event: time 1553192419.627161, type 3 (EV_ABS), code 1 (ABS_Y), value 549                                               

Bottom left:
Event: time 1553192400.607148, type 3 (EV_ABS), code 0 (ABS_X), value 3689                                              
Event: time 1553192400.607148, type 3 (EV_ABS), code 1 (ABS_Y), value 589                                               

Top right:
Event: time 1553192380.307246, type 3 (EV_ABS), code 0 (ABS_X), value 276                                              
Event: time 1553192380.307246, type 3 (EV_ABS), code 1 (ABS_Y), value 3751                                             

Top left:
Event: time 1553192347.387244, type 3 (EV_ABS), code 0 (ABS_X), value 3773                                             
Event: time 1553192347.387244, type 3 (EV_ABS), code 1 (ABS_Y), value 3707                                             


User avatar
odroid
Site Admin
Posts: 30282
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 3 times
Been thanked: 26 times
Contact:

Re: Touch screen is reversed

Unread post by odroid » Fri Mar 22, 2019 9:36 am

It looks fine.

Did you try "SwapAxes" option in /usr/share/X11/xorg.conf.d/99-calibration.conf file?
https://wiki.odroid.com/accessory/displ ... calibrator

User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Touch screen is reversed

Unread post by mad_ady » Fri Mar 22, 2019 2:48 pm

SwapAxes set to 1 doesn't change anything, but I stumbled over this:

Code: Select all

 Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"  
which rotates touch by 90 degrees in my case. So when I press top left, it registers bottom left. I need to research what the parameters do and come up with the right transformation matrix for my case.

Thanks!

Codey8
Posts: 27
Joined: Sat Dec 15, 2018 4:41 am
languages_spoken: english
ODROIDs: Odroid GO
Has thanked: 0
Been thanked: 0
Contact:

Re: Touch screen is reversed

Unread post by Codey8 » Sat Mar 23, 2019 1:44 am

mad_ady wrote:
Fri Mar 22, 2019 2:48 pm
SwapAxes set to 1 doesn't change anything, but I stumbled over this:

Code: Select all

 Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"  
which rotates touch by 90 degrees in my case. So when I press top left, it registers bottom left. I need to research what the parameters do and come up with the right transformation matrix for my case.

Thanks!
I agree! :lol:

User avatar
mad_ady
Posts: 5676
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 18 times
Been thanked: 18 times
Contact:

Re: Touch screen is reversed

Unread post by mad_ady » Sat Mar 23, 2019 3:11 am

I report success!
I found the documentation for transformation matrix here: https://wiki.ubuntu.com/X/InputCoordinateTransformation

I added the 180 degrees example in my /usr/share/X11/xorg.conf.d/99-calibration.conf (luckly I didn't have to remember matrix multiplication rules!):

Code: Select all

Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"
Restarted lightdm and clicks are where they're supposed to be. All is well again in my household - till the next big upgrade :)

@odroid: can you add a note in the wiki that this might be needed for 18.04?

User avatar
odroid
Site Admin
Posts: 30282
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 3 times
Been thanked: 26 times
Contact:

Re: [Solved] Touch screen is reversed

Unread post by odroid » Mon Mar 25, 2019 10:06 am


Post Reply

Return to “3.5inch LCD Shield”

Who is online

Users browsing this forum: No registered users and 1 guest