Flipped touchscreen X axis on Makerfactory 3.5“ display

Hello,
I connected a Makerfare 3.5“ display to my Raspi 3 with Hifiberry. The display works but the touch only works in principle:
I can navigate in y direction ok, but the x coordinates are mirrored, i.e. I have to touch on the right to operate a control on the left and vice versa.
I already played with some input matrix for X11 however was not able to fix the problem.
Does anyone have a solution for this problem?

Thanks,
Michael

2 Likes

Have you searched the forum? There are some posts dealing with it.
What have you tried?

@mheidt I already had searched the forum but did not find an answer to this problem.

I’m using the metronome for my tests, where the right dial can be operated by touching the left one and vice versa.

I have tried setting the transformation matrix with xinput using the
following commands.
root@zynthian:~# xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ADS7846 Touchscreen id=6 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]

root@zynthian:~# xinput list-props 6
Device ‘ADS7846 Touchscreen’:
Device Enabled (115): 1
Coordinate Transformation Matrix (116): -1.000000, 0.000000, 1.000000, 0.000000, -1.000000, 1.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix (245): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Calibration Matrix Default (246): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Send Events Modes Available (247): 1, 0
libinput Send Events Mode Enabled (248): 0, 0
libinput Send Events Mode Enabled Default (249): 0, 0
Device Node (250): “/dev/input/event0”
Device Product ID (251): 0, 0
libinput Horizontal Scroll Enabled (252): 0

I tried several variations that appeared logical to me, and they changed the behavior, but none to the desired effect.

root@zynthian:~# xinput set-prop 6 “libinput Calibration Matrix” -1 0 0 0 1 0 0 0 1
root@zynthian:~# xinput set-prop 6 “libinput Calibration Matrix” 1 0 0 0 1 0 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -0.1 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -0.5 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” 0.5 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” 0.2 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -0.2 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -2 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -1 0 1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -1 0 0 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -1 0 -1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” 1 0 -1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” -1 0 -1 0 -1 1 0 0 1
root@zynthian:~# xinput set-prop 6 “Coordinate Transformation Matrix” 1 0 -1 0 -1 1 0 0 1

I also had experimented with dtoverlay settings, this is my current config:
dtoverlay=piscreen2r-notouch,rotate=270
dtoverlay=ads7846,speed=50000,cs=1,penirq=17,penirq_pull=2,swapxy=1,xohms=150,pmax=255
#dtoverlay=ads7846,speed=2000000,cs=1,penirq=17,penirq_pull=2,swapxy=1,xohms=100,pmax=255

Best regards,

Michael

I also tried touchscreen calibration, i.e.:
TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_calibrate
xres = 480, yres = 320
Took 43 samples…
Top left : X = 3360 Y = 607
Took 23 samples…
Top right : X = 3331 Y = 3586
Took 25 samples…
Bot right : X = 733 Y = 3570
Took 30 samples…
Bot left : X = 744 Y = 608
Took 28 samples…
Center : X = 2030 Y = 2094
-26.991516 -0.000366 0.127921
333.300720 -0.084384 -0.000569
Calibration constants: -1768916 -23 8383 21843196 -5530 -37 65536

root@zynthian:~# evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: “ADS7846 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 3736
Min 0
Max 4095
Event code 1 (ABS_Y)
Value 714
Min 0
Max 4095
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 65535

I ran:
TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/event0 ts_print
which showed that the 0,0 origin is in the bottom right corner.

I went to the webpage of my screen (waveshare) and followed their instructions.

having a 99-calibration.conf in /etc/X11/xorg.conf.d/

Section "InputClass"
    Identifier      "calibration"
    MatchProduct    "stmpe-ts"
    Option  "Calibration"   "3807 174 244 3872"
    Option  "SwapAxes"      "1"
EndSection

In config.txt

hdmi_drive=1
hdmi_group=2
hdmi_mode=1
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
display_rotate=2

in /etc/X11/xorg.conf.d/40-libinput.conf
besides other sections:

Section "InputClass"
        Identifier "libinput touchscreen catchall"
        MatchIsTouchscreen "on"
	    Option "CalibrationMatrix" "-1 0 1 0 -1 1 0 0 1"
        MatchDevicePath "/dev/input/event*"
        Driver "libinput"
EndSection

I’ve recently had this problem, using a cheap 3.5" screen from AliExpress. In web config, I use ’ PiScreen 3.5 (v2)’.
Seems to work OK, EXCEPT X axis is backwards.

Much Googling only yielded confusing, conflicting and incorrect solutions.

Solution for me:

Create /etc/X11/xorg.conf.d/40-libinput.conf containing:

Section “InputClass”
Identifier “libinput touchscreen catchall”
MatchIsTouchscreen “on”
Option “CalibrationMatrix” “-1 0 1 0 1 0 0 0 1”
MatchDevicePath “/dev/input/event*”
Driver “libinput”
EndSection

On my system, this file didn’t already exist.

Result - touchscreen X and Y axes work correctly. I’m using touchscreen-only, since I haven’t built a proper Zynthian yet. My system:
Pi 3B
Cheap 3.5" display
USB sound using AudioEngine A2+ speakers

My only complaint now is that the touchscreen is very sensitive, everything must be done very carefully, or else I get unwanted results. I don’t know if this is normal for touch-only using an approved display.

Of course, I expect it will stop working correctly, when some unexpected automatic upgrade overwrites my changes.

Those files are not touched by an update

That’s good news. My workaround for stuck notes using USB audio with USB MIDI is a change in /boot/cmdline.txt, which does get undone.

Not anymore, if you check the new checkbox in the audio config panel

More good news, thanks!

I just did update, a few times, and set the checkbox in config for USB audio, and the value (dwc_otg.speed=1) isn’t going into /boot/cmdline.txt, it’s going into /boot/config.txt.

And notes are sticking.

@jofemodo, your call

Worked for me. Just be careful, copying from this forum gives you some weird quotes that make the config parser fail.