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

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’ …


1 Like

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 . . .



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 !!!


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 . . .


  1. place script output to


1 Like

Wonderful guys!! Really brave!!

We have this issue opened:

and it would be nice to close it.

Some volunteer to integrate this procedure in the UI’s admin menu? :wink:


I will when I get a little time. Work has me in a bit of a death grip at the moment.

I have a strange feeling that I will not avoid :face_with_monocle: this time.

Makes note . . . .
opens wicker basket,
pulls out raven,
puts hood over it’s head marked https…,
attaches note to birds leg, badly …
it falls of…
reaches back into basket and takes out staple gun . . .
staples note to ravens leg a lets it flap off asymmetrical down the corridor. . .

1 Like

Have you read Iain Banks??? :rofl:

Do you wanna buy a wasp . … . ?

I’ll have to make it first . . .