Could this be the end of all touch screen calibration issues?

It took hours, that something as essential as touch screen calibration is not incorporated yet in sensible way, but maybe I haven’t tried hard to find. So far I haven’t found authoritative and reliable way how to do that here. Luckily, I have found this: [Talk:Calibrating Touchscreen - ArchWiki]

So here you go:

  1. SSH into zynthian (root/raspberry)

cd /etc/X11/xorg.conf.d

backup your current config

cp 99-calibration.conf 99-calibration.conf.backup

  1. prepare prerequisites:

apt-get install xserver-xorg-input-evdev
apt-get install -y xinput-calibrator
apt-get install -y bc

  1. copy and paste bash script from link above, create this as “calib” script (using vi [grrrr])
    add this as first line on script:

export DISPLAY=:0.0

  1. make it executable

chmod 777 calib

  1. run it

./calib

  1. calibration will popup on screen, follow instructions

  2. calibration script will end up with output which should go into /etc/X11/xorg.conf.d/99-calibration.conf [BEWARE! script recommends different file names, IDK if will work then]

  3. Maintainers, please, please, please, implement this into basic setup. Hours wasted on such essential feature.

Now touch works from corner to corner, no flips on axes, at least here on my 3.5" some AliEx display.

Good luck.

5 Likes

Will people with touchscreens that required calibration please test whether this is a universal solution?
Will @sailort please create a feature request in the issue tracker?

I know we run everything as root in zynth but this still makes me wince a bit. :sweat_smile:

chmod 755 calib

My daughter asked why we used root. I explained that it is a synth, not a secure server in a bank and we just want just a single user who can do everything. But yes- it makes me wince too!

1 Like

Now I’m scared that some hacker will hack into my “just now played its first sound” kitchen table zynthian box as guest and will run screen calibration while I’m fiddling with it.
Ok, seriously. This ain’t a Linux class, or is it? I don’t know which version of zynthian software is circulating around, what is the security concept, if in some version thing aren’t laid differently, etc… This just works :wink:

1 Like

It’s fine. It’s one of those things like when you get taught to drive HGV’s you’re absolutely drilled in to about usage of wing mirrors, so that when you see someone not doing it in a car you feel a bit uncomfortable.

From the creator of the script:

  1. It expects only one input device
  2. It expects the xorg output from xinput_calibrator with separate “MinX”, “MaxX”, … variables
  3. I’m only a beginner when it comes to bash, so there are probably some issues with quoting

Point 1 is usually true in the Zynthian use case, point 2. is for me truly unknown, and with point 3., one can except bad surprise:
#reset xinput matrix
xinput set-prop “$device” ‘Coordinate Transformation Matrix’ 1 0 0 0 1 0 0 0 1

making a backup of your “quiet working configuration” (after hours of strong headache) before running the script is a good idea because, by default it will reset it.

I can test on a 5inch HDMI+GPIO touch screen (next week, because I have to prepare my first week-end in the countryside after 2 month of quarantine)

1 Like

It worked here flawlessly here, but got your points. After all, this shouldn’t be “final” solution as this should be properly incorporated into zynthian setup. This is just way how to do that. I’ve seen a lot of discussion here, how to properly calculate that matrix, what I seem is that not resetting it to defaults skew actual readings while calibrating, and that libinput and evdev values aren’t directly compatible, thus could lead to dead-ends.

as you said

  1. no issue, just one display
  2. no issue, xinput_calibration will emit those values
  3. what bad surprise you expect from few lines of code which are clear in steps and used understandable logic?

But backup of config is good advise. Will add backup step to guide.

Well in fact, none, as the script doesn’t overwrite the existing configuration. But as I had some bad surprise in the past with some kind of “miraculous script or recipe”, I do not believe in miracle anymore :laughing:

Fun fact, after install from fresh image, there is no 99-calibration.conf file which could be overwritten :wink:

1 Like

Sure… You do well…

Ok lets see. . .

Step Action Result
1. SSH into zynthian (root/raspberry) Ok
2. > cd /etc/X11/xorg.conf.d Ok, files in there … 99-calibration.conf, 99-fbdev.conf
3. > cp 99-calibration.conf 99-calibration.conf.backup backup your current config
4. > apt-get install xserver-xorg-input-evdev This package provides the driver for input devices using evdev, the Linux kernel’s event delivery mechanism. This driver allows for multiple keyboards and mice to be treated as separate input devices.—I appear to already have this
5. > apt-get install -y xinput-calibrator A generic touchscreen calibration program for X.Org —I’ve already got it but I’ve played around a bit
6. > apt-get install -y bc GNU bc arbitrary precision calculator language, and I’ve got that :smiley:
7. 3. copy and paste bash script from link above, create this as “calib” script (using vi [grrrr]… nano is a much easier windows like tool for people who have issues with vi . . . :-). Type nano calib, cut and paste the code into it. Cntrl O to write it Cntrl X to exit …)add this as first line on script:
8. add export DISPLAY=:0.0 to script first line Easy withing nano . . . :slight_smile:
9. chmod 755 calib make it executable; I agree with @Baggypants
10. > ./calib 6. calibration will popup on screen, follow instructions and Play tap the dot :smiley:
11. nano 99-calibration.conf 7. calibration script will end up with output which should go into /etc/X11/xorg.conf.d/99-calibration.conf [BEWARE! script recommends different file names, IDK if will work then] i already had details for this in the file so I overwrote them

Directly after calibration all seems good !!!

echo setting up the touchscreen
export DISPLAY=:0.0
xinput set-prop ‘ADS7846 Touchscreen’ ‘Coordinate Transformation Matrix’ 1.06666775175377203405 0 -.04500398769511222513 0 -1.09588468420260530760 1.05137037842176552231 0 0 1

So I reboot …

Sadly E & W are still reversed . . .but I will retry with a clean build as this is a fairly corrupted zynthian-touch.local . . . .

same with calling the file 98-calibration.conf . . . sadly … :frowning:

My script fixes it but presumably renders up the not quite accurate scaling factors. . .
So I’ve copied these values into my touch script and they do renerder up a pretty accurate step sequence grid … :smiley: So from my perspective, it generates a decent matrix but I haven’t found where this should be applied.

Almost right :smiley:

So in my case it sets the mechanism u correctly but it’s getting it’s start up settings from somewhere else. . .

I will try with a clean image, as this is a zynthian-touch.local that has had a certain amount of ‘persuasion’ …

Blockquote

2 Likes

Wow, guide check nicely done. Configuration survive reboots on my box. Haven’t investigating further, but it seems there are at least two ways for x server input, libinput and evdev and those works on different values, properties and config files. Could it happen that during tinkering with it you have switched to evdev? Seems that image I have used (downloaded yesterday from nightlies) using libinput. Also those MinX, MaxY, SwapXY options are aplied with Transform matrix. My understanding is, with proper Transformation matrix these should be removed. Please post follow up after fresh image. Thanks.

I’ll write another clean image. Something is just not right here . . .

GOT IT !!!

The file the results need to be copied into is . . .

/usr/share/X11/xorg.conf.d/98-screen-calibration.conf

image

I’m using.

Which is default except for a rotate=270

I’ll delete a lot of the previous entries as being fairly irrelevant. Thanks so much for the help @sailort :smiley: Apologies if these deletions make you look as thou’ you are talking to yourself !!!

3 Likes

How did you figured out that location?

Too late! From the point of view of the thread it’s a little bit clearer as to what we were trying to achieve, which was proving your fix !! :smiley:

It’s one of the locations listed in the output from the script !!!

Yes, it is, but here it works in /etc/X11/xorg.conf.d/99-calibration.conf. That’s odd.

Yes peculiar, you’d have thought all zynths were created equal . . .

GUIDE UPDATE:

  1. place script output to

/etc/X11/xorg.conf.d/98-screen-calibration.conf

1 Like