Calibrate Touchscreen

Started by Klaus, March 30, 2020, 03:28:15 pm

Previous topic - Next topic

Klaus

March 30, 2020, 03:28:15 pm Last Edit: March 31, 2020, 11:11:17 am by Klaus
Hi folks,

I'm using a T2-OLinuXino-MICRO-e8Gs16M-IND with a LCD-OLINUXINO-4.3"TS rev.B Display and the Armbian_5.92.4_Olinuxino-a20_Debian_buster_next_5.2.21.7z image.

I also installed the Xorg X-server and some X Applications (e.g. xinput-calibrator).

Now I need to to calibrate the touchscreen of the LCD display and therefore start

    $ export DISPLAY=:0
    $ xinput-calibrator

At the end of the routine the application provides some information which should be placed into /etc/X11/xorg.conf.d/99-calibration.conf.

There is already a 98-screen-calibration.conf file in that directory, which is created during each system start by /usr/bin/olinuxino_ts.sh and targeting the same input device.

If I now replace the current content of 98-screen-calibration.conf
Section "InputClass"
 Identifier "calibration"
 MatchProduct "1c25000.rtp"
 Option "TransformationMatrix" "1.08 0.0 -0.04 0.0 1.14 -0.10 0.0 0.0 1.0"
EndSection
with the Information provided by xinput-calibrator
Section "InputClass"
 Identifier "calibration"
 MatchProduct "1c25000.rtp"
 Option "MinX" "65137"
 Option "MaxX" "57"
 Option "MinY" "-161"
 Option "MaxY" "63768"
 Option "SwapXY" "0" # unless it was already set to 1
 Option "InvertX" "0"  # unless it was already set
 Option "InvertY" "0"  # unless it was already set
EndSection
and restart the X-server, I can't see any difference in the calibration.  :(

If I read through the /var/log/Xorg.0.log I find the following entries for the touchscreen:

...
[ 00039.827] (II) config/udev: Adding input device 1c25000.rtp (/dev/input/event4)
[ 00039.827] (**) 1c25000.rtp: Applying InputClass "libinput touchscreen catchall"
[ 00039.827] (**) 1c25000.rtp: Applying InputClass "calibration"
[ 00039.827] (II) Using input driver 'libinput' for '1c25000.rtp'
[ 00039.827] (**) 1c25000.rtp: always reports core events
[ 00039.827] (**) Option "Device" "/dev/input/event4"
[ 00039.827] (**) Option "_source" "server/udev"
[ 00039.833] (II) event4  - 1c25000.rtp: is tagged by udev as: Touchscreen
[ 00039.835] (II) event4  - 1c25000.rtp: device is a touch device
[ 00039.835] (II) event4  - 1c25000.rtp: device removed
[ 00039.864] (**) Option "config_info" "udev:/sys/devices/platform/soc/1c25000.rtp/input/input4/event4"
[ 00039.864] (II) XINPUT: Adding extended input device "1c25000.rtp" (type: TOUCHSCREEN, id 9)
[ 00039.865] (**) Option "AccelerationScheme" "none"
[ 00039.865] (**) 1c25000.rtp: (accel) selected scheme none/0
[ 00039.865] (**) 1c25000.rtp: (accel) acceleration factor: 2.000
[ 00039.865] (**) 1c25000.rtp: (accel) acceleration threshold: 4
[ 00039.871] (II) event4  - 1c25000.rtp: is tagged by udev as: Touchscreen
[ 00039.872] (II) event4  - 1c25000.rtp: device is a touch device
...
which seems that the input device is
- added by/with config/udev
- the calibration is applied
- the device is removed
- the device is added by by/with/as XINPUT but no calibration is applied.  :o

Is there anything I'm missing out of, or how do I get the touchscreen calibrated?

BTW. Is there any information available on how to transform the output of xinput-calibrator into a TransformationMatrix used by the olinuxino_ts script?

kalata23

If the following packages are missing, please install them with:
sudo apt install xrandr xinput-calibrator xinput
Then:

export DISPLAY=:0
You must get LCD resolution:

xrandr | grep current:
The output will look like this:

Screen 0: minimum 320 x 200, current 480 x 272, maximum 8192 x 8192
Of course, the values will be different depending on the lcd type that you are using.

From the output above, you take the screen width and screen height, i.e:

screen_width = 480
screen_height = 272


and write them somewhere

Execute the following command:

xinput_calibrator -v
On the screen you will see some crosses, that you must press. Then you will see output like this:

DEBUG: XInputExtension version is 2.3
DEBUG: Skipping virtual master devices and devices without axis valuators.
DEBUG: Skipping device 'Virtual core XTEST pointer' id=4, does not report Absolute events.
DEBUG: Selected device: 1c25000.rtp
DEBUG: Not usbtouchscreen calibrator: Not a usbtouchscreen device
DEBUG: Not evdev calibrator: Evdev: invalid "Evdev Axis Calibration" property format
Calibrating standard Xorg driver "1c25000.rtp"
        current calibration values: min_x=0, max_x=65535 and min_y=0, max_y=65535
        If these values are estimated wrong, either supply it manually with the --precalib option, or run the 'get_precalib.sh' script to automatically get it (through HAL).
DEBUG: Found that '1c25000.rtp' is a sysfs name.
DEBUG: Adding click 0 (X=67, Y=48)
DEBUG: Adding click 1 (X=408, Y=46)
DEBUG: Adding click 2 (X=76, Y=227)
DEBUG: Adding click 3 (X=413, Y=227)
Теб те интересува това :
DEBUG: Adding click 0 (X=67, Y=48)
DEBUG: Adding click 1 (X=408, Y=46)
DEBUG: Adding click 2 (X=76, Y=227)
DEBUG: Adding click 3 (X=413, Y=227)

* Note: All the values in this post are just example, in your case they will be different.

Then you calculate the transformation matrix:
a = (screen_width * 6 / 8) / (click_3_X - click_0_X)
c = ((screen_width / 8) - (a * click_0_X)) / screen_width
e = (screen_height * 6 / 8) / (click_3_Y - click_0_Y)
f = ((screen_height / 8) - (e * click_0_Y)) / screen_height

Then enter:
xinputAnd find  out your TS device name, then copy it, you will need it in the next step.

Execute:
xinput set-prop "YOUR_DEVICE" "libinput Calibration Matrix" "libinput Calibration Matrix" a, 0.0, c, 0.0, e, f, 0.0, 0.0, 1.0

where:
a,c,e,f - you must replace them with values from the calculations above
"YOUR_DEVICE" - this is the name of the TS device that you got from xinput command.

If you are satisfied, you can save the values of the transformation matrix into that .conf file, so no need to execute the command above on each boot.

tropek

Quote from: kalata23 on April 01, 2020, 08:57:00 amIf you are satisfied, you can save the values of the transformation matrix into that .conf file, so no need to execute the command above on each boot.
Hello

Which .conf file is it exactly ?
The values a, c, e and f written in /etc/X11/xorg.conf.d/98-screen-calibration.conf are taken into account after a reconnection to XFCE.
But on a reboot they are replaced by "default" values (I don't know where they come from).

Merci
DeepL translation

kalata23

Quote from: tropek on March 23, 2021, 11:57:42 am
Quote from: kalata23 on April 01, 2020, 08:57:00 amIf you are satisfied, you can save the values of the transformation matrix into that .conf file, so no need to execute the command above on each boot.
Hello

Which .conf file is it exactly ?
The values a, c, e and f written in /etc/X11/xorg.conf.d/98-screen-calibration.conf are taken into account after a reconnection to XFCE.
But on a reboot they are replaced by "default" values (I don't know where they come from).

Merci
The calibration values are written in /etc/X11/xorg.conf.d/98-screen-calibration.conf However olinuxino-ts.service executes /usr/bin/olinuxino_ts.sh on every boot. This overrides the .conf file after reboot, that's why I can suggest you to change default values in /usr/bin/olinuxino_ts.sh

tropek

DeepL translation

tropek

DeepL translation

tropek

April 05, 2021, 03:36:19 pm #6 Last Edit: April 05, 2021, 03:47:17 pm by tropek
Hello
I forgot to mention that I use an A10 with an updated buster, because I didn't get an answer on the A10 forum ...
In this configuration there is no olinuxino_ts.sh file, nor anything like it.

In which directory should something be found ?
DeepL translation

LubOlimex

The instructions kalata23 apply only for A10 Olimage images that are downloaded from here:

http://images.olimex.com/release/a10/

What image exactly are you using and where did you download it from (share link of place where you got it)?

Also if you use A10 board, please post in the A10 sub-forum, not in the A20 sub-forum, thanks.
Technical support and documentation manager at Olimex

tropek

My image comes from the page you indicate
A10-OLinuXino-buster-base-20210318-122357.img.7z
and the card A10 works.

I posted here -> https://www.olimex.com/forum/index.php?topic=8136.0
and Olimex advises me to continue here !

Thanks
DeepL translation