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

Touch the Title Bar for “back”.

…but not the text in the title bar nor the status area on the far right hand side, unless you are in the sequencer in which case touching the titlebar (including text but not including status area) will show a menu with BACK option. Yes, it is sub-optimal but we are improving this…

Ah… I did wonder why it was unresponsive sometimes… Thanks for letting me know what “the rules” are!

Just went through all the steps and wow… my screen calibration is super accurate now.
Excellent. Thank you.

It survives reboots, but not software updates. No real fuss though. It’s easy to SSH back in and update the /zynthian/config/zynthian_custom_config.sh file.

Seems to be the only file I can find that makes any difference.

Would be amazing if this was part of the Zynthian OS to help those doing custom builds.

Kind regards
James.

Needs a menu entry to solve the ash and then it’s gold

Hi again,

after browsing some discussion forums, I think I have found a solution for the non-persistent calibration values.

As I understand it, there are two interface layers for touch screen devices, evdev (older) and libinput (newer, but also uses evdev). The calibration procedure (calib, xinput_calibrator) relies on evdev and thus there can be cases where the calibration is in conflict with libinput.

Here is what I did to make it work, i.e. to make changes persistent. It survives reboot and software update.

ssh -X root@yourraspberry

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

export DISPLAY=:0.0
xinput set-prop “ADS7846 Touchscreen” ‘Coordinate Transformation Matrix’ -1 0 1 0 -1 1 0 0 1

Do the actual calibration:

xinput_calibrator

Rename 10-evdev.conf in /usr/share/X11/xorg.conf.d/ such that it is executed after 40-libinput.conf

mv /usr/share/X11/xorg.conf.d/10-evdev.conf /usr/share/X11/xorg.conf.d/45-evdev.conf

Open 45-evdev.conf and add the two lines from the output of the xinput_calibrator at the section which has “evdev touchscreen catchall” in it.
These are values that work fine for my touchscreen:

Section "InputClass"
    Identifier "evdev touchscreen catchall"
    MatchIsTouchscreen "on"
    MatchDevicePath "/dev/input/event*"
    Driver "evdev"
	#Custom Options below
	Option	"Calibration"	"135 3804 207 3867"
	Option	"SwapAxes"	"0"
EndSection

Additionally, rename any (calibration.)conf file in \etc\X11\xorg.conf.d\ to *.conf~.
Also, deactivate 98-screen-calibration.conf in \usr\share\X11\xorg.conf.d\ by renaming conf to conf~ (or whatever you prefer).

I have tested it on my zynthian (image from 2020-05-25) where I already tried some other attempts described in this thread. Could someone confirm if it works with a fresh image?
Good luck :wink:

As I undesrtand, evdev is phasing out replaced with libinput. Though helped in your case, I would see this as risk for future compatibility and display infrastructure maintenance in the future. I guess there should be way how to make it work with libinput transform matrix without this evdev tricks. I dont know how, but any chance you could log complete xorg init and maybe search there for configuration steps finding those which are conflicting? But I’m not expert on this in any way.

Yes, I agree, it would be better to stick with the future-proof libinput driver.
When following your original recipe, I can read in Xorg.0.log that the transformation matrix is applied but the last lines in the log file are error messages regarding ADS7846 Touchscreen. But I’m no expert on that either…
I’m posting my /var/log/Xorg.0.log.

Xorg.0.log (10.6 KB)

It would be really helpful if someone with Kit V2 and PiScreen 3.5 (V2) and working touchscreen calibration could post his/her Xorg.0.log file, too.

The matrix itself is working, it can be applied with:

ssh -X root@yourraspberry
export DISPLAY=:0.0
xinput set-prop “ADS7846 Touchscreen” --type=float “Coordinate Transformation Matrix” -1.11 0 1.04 0 -1.12 1.05 0 0 1

OK, I reread your posts and as I understand it, your issue is that calibration doesn’t survive updates when transform matrix is entered into zynthian_custom_config.sh. You’ve created /usr/share/X11/xorg.conf.d/98-screen-calibration.conf which seems to be part of standard files updates. What if you instead put script output into !!99!!-screen-calibration.conf? Maybe this won’t be overwritten by update and as higher numbered config will supersede overwritten 98-screen-calibration.conf. I’m using PiScreeen (V1), which doesn’t have any zynthian_custom_config.sh, so there is not conflict with 9(8/9)-screen-calibration. Any chance you could try it with your setup (from fresh image)?
[use PiScreen 3.5 (V1) and calibration script output into 99-screen-calibration.conf, chceck if survives reboot, then if survives update]

Thank you for your suggestion @sailort, I have some progress now with the following steps:
a) renamed 98- to 99-. The calibration matrix in that file contains -1.11 0 1.04 0 -1.12 1.05 0 0 1.
and b) I entered these floats in /zynthian/config/zynthian_custom_config.sh (there was the sequence -0 1 0 1 0 -1 0 0 1 before).
Now I can reboot and update the software and calibration is still there :ok_hand:.
The strange thing is however, that after the update, numbers in zynthian_custom_config.sh are reset to -0 1 0 1 0 -1 0 0 1. But calibration is still there and also survives successive reboots and updates. And If I just do a) or b) - no success. I mean if the matrix is reset anyway, why does it still make a difference if I enter the precise values in zynthian_custom_config.sh? :thinking: Seems that they are read from that file and stored somewhere else.

And: selecting PiScreen V1 did not work, touch was not working at all and GUI froze. So I changed it back to PiScreen V2.

I’ll retry all these things with a fresh install in the next days. But on the other hand, I had these problems already right after installing image from 2020-05-25.

EDIT: Oh no, problems are back… It survived at least one update but maybe the 3rd or 4th update broke it. Strange that the recipe seems to work for anyone else. What might be the difference, maybe Kit V3 vs. Kit V2?

Lets try this:

  1. select PiScreen 3.5 (V2)
  2. copy configuration settings
  3. select PiScreen 3.5 (V1)
  4. paste configuration settings
  5. do the calibration (as 99-…conf) [ ignore zynthian_custom_script.sh ]
  6. report
1 Like

ah, now I got your point what you meant with PiScreen V1. it works :partying_face: Big thanks!
storing configuration in 98- or 99- does not make a difference.

Maybe it is not exactly what I meant, but if it works as should, then it’s good news. Anyway, if it works this way, it says something about nondeterministic behavior of zynthian_custom_script.h. And that could be a lead for nice and working systematic solution.

For the sake of clarity, could someone reiterate the calibration steps? I’m having trouble following along. Thanks!

(Hmm… should we make a wiki page for this?)

2 Likes

I’ve started something here . . .

https://wiki.zynthian.org/index.php/Aligning_Zynthian_Touchscreens

OK, I’ll commit to prepare bash script which would automate this process if someone knowledgable will make button for invocation from webconfig. Just let me know desired location and name for testing purposes.

  1. chceck if needed x tools are installed, if not, install
  2. run calibration
  3. output to both known working locations
  4. if I will find a way to identify current display name, disable custom…config.sh to avoid interference
4 Likes

That’s great!

Presumably there is a proscribed Xwindows order to the config files?

I’ll set up a branch @mheidt How & Where might this be implemented or is it a GUI feature ?

I think both, webconf for the button and the script might be in sys/scripts?

A button like the ogg functionality but on the IU options page?

Will be better on Display config screen I guess. It just need to invoke sh script somewhere. Meanwhile I have received another display, now 4". Having head in hands since morning. This is a mine-field I regret stepping in.

  1. waveshare4c works as display driver, but reports strange values to libinput, Transform Matrix was very strange, with values like -720, -250, etc. and touch screen was not working, as it was way off and cursor stayed only in corner.
  2. thought that I’ll use separate ads7846 driver overlay for touch screen, but it won’t work as WS4C drivers lock SPI access for itself
  3. realized piscreen2r-notouch (PiScreen 3.5 V2) with ads7846 driver works, but again, touch values seems strange, touch pressure in range of 65000, nothing to work around
  4. now I’m playing with piscreen2r (without notouch option), this works, but have very strange issue, when holding and dragging value widgets sometimes (too often for my taste) it select different item within middle list-box, even when I don’t cross, even far away from it with finger. Values from evtest doesn’t seem to hit middle section according to X/Y coordinates. What it seems to me, that middle list-box control is receiving (and unfortunately processing) events, which doesn’t belong to it’s screen section. I had this strangeness on other driver combinations also, so this is probably zynth issue.

Event: time 1594125797.266497, -------------- SYN_REPORT ------------
Event: time 1594125797.306426, type 3 (EV_ABS), code 0 (ABS_X), value 3400
Event: time 1594125797.306426, type 3 (EV_ABS), code 1 (ABS_Y), value 1740
Event: time 1594125797.306426, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 108
Event: time 1594125797.306426, -------------- SYN_REPORT ------------
Event: time 1594125797.326495, type 3 (EV_ABS), code 0 (ABS_X), value 3399
Event: time 1594125797.326495, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 113
Event: time 1594125797.326495, -------------- SYN_REPORT ------------
Event: time 1594125797.346538, type 3 (EV_ABS), code 0 (ABS_X), value 3382
Event: time 1594125797.346538, type 3 (EV_ABS), code 1 (ABS_Y), value 1739
Event: time 1594125797.346538, -------------- SYN_REPORT ------------
Event: time 1594125797.372984, type 3 (EV_ABS), code 0 (ABS_X), value 3373
Event: time 1594125797.372984, type 3 (EV_ABS), code 1 (ABS_Y), value 1754
Event: time 1594125797.372984, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 107
Event: time 1594125797.372984, -------------- SYN_REPORT ------------
Event: time 1594125797.386496, type 3 (EV_ABS), code 0 (ABS_X), value 3377
Event: time 1594125797.386496, type 3 (EV_ABS), code 1 (ABS_Y), value 1751
Event: time 1594125797.386496, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 99
Event: time 1594125797.386496, -------------- SYN_REPORT ------------
Event: time 1594125797.406539, type 3 (EV_ABS), code 0 (ABS_X), value 3396
Event: time 1594125797.406539, type 3 (EV_ABS), code 1 (ABS_Y), value 1740
Event: time 1594125797.406539, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 41
> !!! -------------------------- !!!
> HERE I THINK PROBLEM IS. X COORDINATE DOESN"T CHANGE TO EXTEND IT SHOULD HIT MIDDLE SECTION
> Event: time 1594125797.406539, -------------- SYN_REPORT ------------
> Event: time 1594125797.426359, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 0
> Event: time 1594125797.426359, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 0
> Event: time 1594125797.426359, -------------- SYN_REPORT ------------
> Event: time 1594125797.456516, type 1 (EV_KEY), code 330 (BTN_TOUCH), value 1
> Event: time 1594125797.456516, type 3 (EV_ABS), code 0 (ABS_X), value 3391
> Event: time 1594125797.456516, type 3 (EV_ABS), code 1 (ABS_Y), value 1925
> Event: time 1594125797.456516, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 35
> !!! -------------------------- !!!
Event: time 1594125797.456516, -------------- SYN_REPORT ------------
Event: time 1594125797.491510, type 3 (EV_ABS), code 0 (ABS_X), value 3415
Event: time 1594125797.491510, type 3 (EV_ABS), code 1 (ABS_Y), value 1935
Event: time 1594125797.491510, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 86
Event: time 1594125797.491510, -------------- SYN_REPORT ------------
Event: time 1594125797.506498, type 3 (EV_ABS), code 0 (ABS_X), value 3423
Event: time 1594125797.506498, type 3 (EV_ABS), code 1 (ABS_Y), value 1939
Event: time 1594125797.506498, type 3 (EV_ABS), code 24 (ABS_PRESSURE), value 87
Event: time 1594125797.506498, -------------- SYN_REPORT ------------
Event: time 1594125797.526532, type 3 (EV_ABS), code 0 (ABS_X), value 3411
Event: time 1594125797.526532, type 3 (EV_ABS), code 1 (ABS_Y), value 1938

For selector class switch_select and click_listbox methods are called withou cb_listbox_push.

EDIT: OK, I’ve got it. Short press on controller value subscreen emits Rotary Encoder push according to position. Time to comment out some lines in cb_canvas_release.
EDIT2: Aaaah. what a relief on UI using touch. No more crazy UI screen switches under fingers.

EDIT3: Ended up with this in zynthian_gui_controller.py. Now onlyquick swipes to sides selects next controller set and if so, origin value of control is restored not accounting eventual swipe in Y axis. Maybe someone could come (I’m sure someone will) with solution with swipe right → down, swipe left → up.

    def cb_canvas_push(self,event):
            self.canvas_push_ts=datetime.now()
            self.canvas_motion_y0=event.y
            self.canvas_motion_x0=event.x
            self.canvas_motion_dy=0
            self.canvas_motion_dx=0
            self.canvas_motion_count=0
            self.ctrl_pvalue=self.value


    def cb_canvas_release(self,event):
            if self.canvas_push_ts:
                    dts=(datetime.now()-self.canvas_push_ts).total_seconds()
                    deltax=event.x-self.canvas_motion_x0
                    if dts<0.5:
                            if abs(deltax)>10:
                                    self.set_value(self.ctrl_pvalue, True)
                                    self.zyngui.zynswitch_defered('S',3)
1 Like