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

Hi @riban!

Using several touch devices simultaneously on zynthian is a really rare case, my friend. I would say “OK” if it didn’t add extra complexity, but …

… different displays can use the same TouchDevice, while having different default TransformationMatrix. This is specially true for the ubiquitous ADS7846, that is used for several WaveShare displays and also Piscreen & Zynscreen.

I would suggest to go the way i paved, that solves the problem of having a single touch device. For more bizarre multi-touchdevice configurations, a secondary “custom” calibration file should solve the problem.

Please, remember zynthian is a synthesizer … not a PC!!

Thanks!

1 Like

I don’t anticipate more than one touch interface but it seems the ADS7846 driver is enabled by default hence a device appears in the list even when not installed which is why I have to detect which interface is actually being calibrated on first press.

All the ADS7846 customisation scripts I have found in Zynthian codebase use the same transformation. There is the chance that someone puts the screen in a different orientation than expected (like Zynscreen, upside down :stuck_out_tongue:) but that just requires one calibration.

Using a (fully) populated xorg configuration file allows out-of-the-box correct operation of touchscreen without requiring webconf.

I continue to think my suggestion is the right way but you are the boss, so…

I don’t understand why you suggest updating two files. Surely updating the live file is what we want with the ability to reset that via webconf if the display is changed, in which case my code will work (and remains compatible with my alternative scheme :wink:).

We don’t want people configuring a Waveshare have axis swaped by default …

Webconf is needed for configuring the display itself. Zynthian SD images comes with a pre-configured display and touchscreen. If you are using a different one, you must use the webconf.

My proposal is that Zynthian (can) have a default calibration matrix for every display model and it remembers the generated calibration for every display model too. When the display model is changed from webconf, the saved calibration config is loaded, if it doesn’t exist, the default calibration is loaded instead.

The limitation is that only one touchdevice is configured in the 99-calibration.conf.

You proposal has 2 problems:

  • Adding new display calibration defaults or modifying existing defaults is not easy.
  • Managing displays that use the same TouchDevice but different calibration matrix (ADS7846).

And 1 advantage:

  • It supports multi-touchdevice configurations

Calibration can be modified from UI using the new tool. You write the X11 config file and it works. But next time update_sys script is executed (almost every time you click “save” button on webconf), it will regenerate all config files based on configured values (envars), overwriting existing ones. Saving a copy of the calibration config on the config directory, per-display, is a simple solution that works. :wink:

Regars,

I have done as you ask (even though you are wrong :wink:). I must once more voice my unease at this method. It is quite ridiculous to me to write the same file twice twice. Imagine I have a display that is kinda working but needs calibration. I calibrate and all is good. I then go to webconf and realise I had the wrong screen selected. My previous calibration has written my desired configuration to the live xserver file and the default copy of the wrong screen. I have now corrupted the default data.

Anyway - my concerns are a matter of record. You are the boss. You take responsibility. I guess it is time for a pull request…

1 Like

The default config is not overwrote. Remember that it’s on the zynthian-sys dir. We could easily add a “delete custom calibration” button on the webconf, and the default calibration will be loaded. Or you could simply re-calibrate.

We need a way of updating default calibrations, and having mixed in the same file default and custom calibrations makes things more difficult to manage. Of course, we could parse and replace the calibration file. If you implement a simple CLI tool for managing calibration file (add, update and delete calibrations), then i could use it from the update_sys script. In such a case, i would agree on implementing things as you propose :yum:

all the best!

The calibration file parsing is in the code. I have commented it out for your pleasure!

Yes, but we need this functionality available from the udpate_sys script. Let me merge the current PR, let the community to test the functionality, and we can make a second step like this:

  • Creating a little CLI script allowing to manage the calibration file.
  • Modifying update_sys script for using it.
  • Add the “Delete Custom Calibration” button to webconf

Sorry for not explaining myself very well in my reply above. I really love the calibration tool, but having multi-device configurations is not a priority. We go one step forward and after a second one :wink:

Really Big Thanks @riban !

Hi @zynthianers!

The new calibration tool developed by @riban is already merged on master.
Simply update and enjoy!

zynthian_ui_calibration_01

zynthian_ui_calibration_02

zynthian_ui_calibration_03

It only supports one touch device, but we will improve it for supporting N touch devices :yum: :zynlogo:

Huge Thanks, Mr. @riban! :smiling_face_with_three_hearts:

6 Likes

I have added a section to the wiki describing operation of the calibration screen. Here is a summary:

  • Screen shows target crosshairs that must be touched and released
  • First target does no calibration and only detects the touch interface
  • Display type shown after first touch
  • Consequent touches are measured on release, allowing drag to target for more accuracy
  • After second touch the calibration is written to two files (I disagree!)
  • Each target appears white and changes to red when screen touched
  • Touches too close together are ignored (half a screen)
  • A timeout of 15s after last touch or release will close screen without saving configuration
  • BACK button will close screen without saving configuration

I don’t think we need support for multiple simultaneous touchscreens, at least not until we provide extended (second / third) screen support. The robust discussion @jofemodo and I had about how to implement persistent storage was not about multiple screens but how best to storeand restore configuration. VHS won over Betamax but we know which was best :wink:.

2 Likes

The second screen support will arrive sooner than later :wink:

Regarding the Betamax, in its current status has some limitations:

Example 1.) You have a 2 zynthians, one official kit with the Zynscreen and a second one with a Waveshare. Both displays use the same touch device “ADS7846”. You want to move the SD card from one zynthian to the other one. The Betamax can’t manage (in its current status) this situation and you need to recalibrate the touchscreen every time you move the SD card . If you don’t recalibrate, axis will be swapped and touch interface will be completely unusable. In the other hand, the poor VHS will manage the situation smoothly.

Example 2.) We add a new touch display to the config list. The Betamax (in its current status) can’t manage this situation and users wanting to test the new display with a working SD-card will need to use the terminal for fixing the configuration. The poor VHS will manage the situation smoothly.

Anyway, i must say that Betamax is a better system, but we need to address these little issues before jumping to it. Step by step.

All the best!

Argh! VHS epic fail!!! I updated my official Zynthian V4.1 and touchscreen calibration is inverted.

VHS 0 - Betamax 1

This is the scenario that VHS is supposed to avoid! What is going on???

Even after calibration it is still wrong. Something is awry.

Reverting to feature branch resolves issue so something wrong with the merge to master>

It could be a trace from some development bug that have corrupted the calibration file. Try to run update_zynthian_sys.sh script. Or click “save” from webconf.

Regards,

BTW, are you sure the update is pulling correctly everything? When developing and copying files by hand to the zynthian, sometimes you have to delete some of the files added by hand for allowing “git pull” to work.

I did this on my production unit which is separate to my development machine. I mostly develop and test on one machine and now that I have a pucker V4.1 I test on that after committing to GitHub.

Could you check if this file:

$ZYNTHIAN_CONFIG_DIR/zynthian_custom_config.sh

does exist? It should be removed …

Regards,

That file does not exist.

I swapped back to feature branch, calibrated fine. I swapped back to master and it remembered the calibration and consequent calibration is working fine.

I am worried that I experienced the issue I was worried about, i.e. that overwritting the live xserver config file and also updating the backup file is prone to unexpected behaviour. I understand your approach of having configurations for each screen type but don’t think we should update the backup / default. We should avoid overwritting the xserver file unless we have specifically chosen a different screen.

I can’t really comment on how your update and save mechanism works as I don’t fully understand it. I do know it causes me (and others) occasional issues when we try to circumvent it (which is to be expected) but in some cases (including this one) I think it may be overly complicated and hence getting in the way of a simple task. But I will go away now and leave it to the wider community to update, test and comment.

I never had a Betamax! I do still have many VHS cassettes but my player died some time ago!

And we don’t. We only save the custom calibration for each display in a separated file.
The display’s default calibration is always on the zynthian-sys/custom dir.

The update_zynthian_sys.sh script always regenerate almost all the relevant system files, and it’s good because it allows to fix a lot of problems. Generating the X11 calibration file shouldn’t be a problem. It’s the way zynthian configuration script works normally.

BTW, i just updated with a “virgin” V4 and it worked nicely. I think you v4 was polluted with some trace of your development process.

Simply burn a SD with the lated RC3 and update.

Regards,

To fulfill a promise made a long time ago…

My :zynface: became very ticklish :rofl:

Edit: Many thanks for this great improvement ! :+1:

8 Likes

The thin light of dawn cuts across the top of the rookery and is met by a gentle stirring, increasing to a aggrieved muttering, punctured with the occasion swiftly exchanged peck and answering shriek.

They start to take to the air, circling the tight confines, with an increasing noise and their cries take on a rhythmic pace against the intense swirling of wings like many ships sails in a strong gale.

As one, as if signaled , the spear like a dart through the exits and reform in a purposely driven whirling pillar of motion. They rise, high above the castle walls, and once again, with one mind speed of towards one isolated cottage on the edge of town.

They career down with a bloody curdling whistle and be-splatter the croft till the windows and doors are white against the old brick.

As suddenly as they appear they disappear toward the horizon . .

The door stiffly opens and @MrDham shakes his fist at their fast disappearing shapes against the sky. . .

"Ok I’ll get your bloody :face_with_monocle: . . . "

3 Likes

Hi,
i got a Waveshare 5inch HDMI LCD (B) with USB connection.
I read half of this thread and tried the calibration from the admin menu.
first thing: i have actually no encoders. hitting the menu with an uncalibrated touchscreen is a challenge. But i had a keyboard :wink:

you have implemented a 3 point calibration. For this screen its maybe not enough. I had a difference between stylus and cross on the screen. The difference changed between top and lower area of the screen.

I did the calibration from the waveshare Wiki.

apt-get install -y xinput-calibrator
DISPLAY=:0.0 xinput_calibrator

With this i got a 4 point calibration. Don’t know if this is really a difference.
I put the codesnipped into /usr/share/X11/xorg.conf.d/40-libinput.conf
After a reboot the touchscreen reacts exact.

Maybe this helps someone.