Calibrate Touchscreen

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

Previous topic - Next topic

kalata23

Quote from: alex_u-94 on July 01, 2022, 01:48:58 PMA few problems...
Firstly, I've already done this and it doesn't work at all because the olimex script to generate "98-screen-calibration.conf" uses the section I edited. If you check my post, I have inserted the contents from the source file "98-screen-calibration.conf", which was generated using an unmodified script. You can also check in the script that different sections for a 7-inch LCD display have different values.
The second problem is "98-screen-calibration.conf", which was generated using a modified script, contains the values that I inserted there....

Modified script
$ cat /usr/lib/olinuxino/olinuxino-ts
#!/bin/bash

# Check is LCD is enabled in the device tree
LCD=$(grep -r "lcd-olinuxino-[147]" /proc/device-tree -a -h | tr -d '\0')
[[ -z $LCD ]] && exit 0

overlays=$(cat /boot/uEnv.txt)

# Select transformation matrix
if [[ $overlays == *"micro-i2c2-ar1021"* ]];
then
    case $LCD in
        "olimex,lcd-olinuxino-4.3")
                MATRIX="1.09 0.0 -0.04 0.0 1.17 -0.09 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-7")
                MATRIX="1.05 0.0 -0.03 0.0 1.13 -0.08 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-10")
                MATRIX="1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
                ;;
        *)
                # The LCD is not supported by this script
                exit 0;
    esac

    PRODUCT="ar1021 I2C Touchscreen"

else
    case $LCD in
        "olimex,lcd-olinuxino-4.3")
                MATRIX="1.08 0.0 -0.04 0.0 1.14 -0.10 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-7")
                MATRIX="1.04 0.0 -0.02 0.0 1.12 -0.08 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-10")
                MATRIX="1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
                ;;
        *)
                # The LCD is not supported by this script
                exit 0;
    esac

    PRODUCT="1c25000.rtp"

fi

# Generate configuration file
mkdir -p /etc/X11/xorg.conf.d
tee > /etc/X11/xorg.conf.d/98-screen-calibration.conf << __EOF__
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "$PRODUCT"
        Option          "TransformationMatrix" "$MATRIX"
EndSection
__EOF__

# педалщина
LCD=$(grep -r "lcd-olinuxino-[147]" /proc/device-tree -a -h | tr -d '\0')
[[ -z $LCD ]] && exit 0

overlays=$(cat /boot/uEnv.txt)

# Select transformation matrix
if [[ $overlays == *"-gt911inv"* ]];
then
        /usr/bin/memtool mw -l 0x1C0C010  0x80000000 || :
        /usr/bin/memtool mw -l 0x1C0C044  0xF0000006 || :
fi

Generated "98-screen-calibration.conf"
$ cat /etc/X11/xorg.conf.d/98-screen-calibration.conf
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "1c25000.rtp"
        Option          "TransformationMatrix" "1.04 0.0 -0.02 0.0 1.12 -0.08 0.0 0.0 1.0"
EndSection

If you compare the script and the configuration file, you will find that the transformation matrix is the same.

Do I understand correctly that {MatchProduct "1c25000.rtp"} section should have a different value in the configuration file (98-screen-calibration.conf)?

Checks from the script
Display:

$ grep -r "lcd-olinuxino-[147]" /proc/device-tree -a -h | tr -d '\0'
olimex,lcd-olinuxino-7

Touch:
$ cat /boot/uEnv.txt
#
# Auto-generated on: 2022-04-13 10:12:41.610325
# Generated UUID: 30010994-cd0e-4557-be6d-fb22555be453
#
# Put u-boot environment variables here. Before boot, boot.scr will use these variables:
#
# boot_config - Explicitly specify the boot configuration
# fdtoverlays - List of overlay files
# load_legacy - Don't load FIT image,
# optargs - Optional arguments passed to the kernel

fdtoverlays=/usr/lib/olinuxino-overlays/sun7i-a20/som204-lcd-olinuxino-7.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/som-i2c2-ar1021.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/spi1-spidev.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/spi2-spidev.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-can.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-i2c2.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-spi1.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-spi2.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart3.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart4.dtbo /usr/lib/olinuxino-overlays/sun7i-a20/sun7i-a20-uart7.dtbo

The overlay does not include micro-i2c2-ar1021, so the script uses the second section....

Can you, please attach screenshot of olinuxino-overlay command.

LubOlimex

Umm, something is very wrong at start. I feel you should first run olinuxino-display script and select:

LCD-OLinuXino-7RTS        800x480 panel with resistive TS and I2C interface
Then reboot the board.

I tested same setup and we got the following:
root@a20-olinuxino:~# nano /etc/X11/xorg.conf.d/98-screen-calibration.conf .

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ar1021 I2C Touchscreen"
        Option          "TransformationMatrix" "1.05 0.0 -0.03 0.0 1.13 -0.08 0.0 0.0 1.0"
EndSection


If you compare you'd see you get different touchscreen driver so everything after that point might be wrong.
Technical support and documentation manager at Olimex

alex_u-94

Quote from: kalata23 on July 01, 2022, 03:17:13 PMCan you, please attach screenshot of
Code Select Expand
olinuxino-overlay command.

All options:








kalata23

Can you please, try LubOlimex's advice, to select your LCD with olinuxino-display command and then reboot the board. After that please give us the output of:
cat /etc/X11/xorg.conf.d/98-screen-calibration.conf
For some reason in your 98-screen-calibration.conf  the  MatchProduct field has 1c25000.rtp value, but it should be ar1021 I2C Touchscreen

alex_u-94

Quote from: LubOlimex on July 01, 2022, 03:36:02 PMUmm, something is very wrong at start. I feel you should first run olinuxino-display script and select:

LCD-OLinuXino-7RTS        800x480 panel with resistive TS and I2C interface
Then reboot the board.

I tested same setup and we got the following:
root@a20-olinuxino:~# nano /etc/X11/xorg.conf.d/98-screen-calibration.conf .

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "ar1021 I2C Touchscreen"
        Option          "TransformationMatrix" "1.05 0.0 -0.03 0.0 1.13 -0.08 0.0 0.0 1.0"
EndSection


If you compare you'd see you get different touchscreen driver so everything after that point might be wrong.

To my great regret, I also did this earlier with the same result



alex_u-94

I changed the script and hardcoded the device type. Now the generated configuration works correctly... It not a right way, but I do not know why micro-i2c2-ar1021 is missing from my ftdoverlays list

kalata23

#21
Hi, again. I have tested the same LCD with the same board, and found that the issue is related to olinuxino-ts script. I have fixed it, so in future releases of olimage this problem must be solved.
Here is the solution to your problem.
1. Open /usr/lib/olinuxino/olinuxino-ts file with some editor and change the line
# Select transformation matrix
if [[ $overlays == *"micro-i2c2-ar1021"* ]];

to

# Select transformation matrix
if [[ $overlays == *"i2c2-ar1021"* ]];

After that you can change the calibration values in the same section:

Quote from: undefinedif [[ $overlays == *"i2c2-ar1021"* ]];
then
    case $LCD in
        "olimex,lcd-olinuxino-4.3")
                MATRIX="1.09 0.0 -0.04 0.0 1.17 -0.09 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-7")
                MATRIX="1.05 0.0 -0.03 0.0 1.13 -0.08 0.0 0.0 1.0"

                ;;
        "olimex,lcd-olinuxino-10")
                MATRIX="1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
                ;;
        *)
                # The LCD is not supported by this script
                exit 0;
    esac 
 
    PRODUCT="ar1021 I2C Touchscreen"

Don't forget to reboot your LCD after changing calibration values, to take effect.

alex_u-94


adamor

Hi all,
regarding the calibration topic we were having quite a few issue.
We need to provide our customers with many LCD-OLinuXino-10ts so it's impractical (read impossible) to generate a different /usr/lib/olinuxino/olinuxino-ts script for each of them.

The olinuxino-ts script is conceptually wrong; something forced this way in place of a having a proper conf file can't work for every system, please people at Olimex, revise it or delete it.

Nonetheless using a manual generated configuration can't work when then calibration need to be done by a no-skilled user.

The original issue seems related to broken old xinput_calibrator vs new libinput, this as least with Deb11 Bullseye (same issue didn't happened with Debian8 based images).

First I would suggest to remove/rename/modify olinuxino-ts so that is not executed at startup. (suggests for Olimex people, just put a condition to make the conf file only if it isn't already present, that would work much better).

Second, some program/procedure/script need to be run, and result stored in the proper conf file/folder.

One of the following procedure can be put in place:
- use the manual procedure showed in this thread but put the result value in /etc/X11/xorg.conf.d/98-calibration.conf
(tested, working)

- use a wrapper script, which use Debian provided old xinput_calibrator but with the newer "TransformationMatrix", available here:
https://wiki.archlinux.org/title/Talk:Calibrating_Touchscreen#Wrapper_around_xinput_calibrator
(tested, working, modified to write directly to conf file)

- use a newer version of xinput_calibrator which should take in account the newer libinput, (Deb11 and Deb12 are currently at v0.7.5 vs v0.10 on github),  source available here:
https://github.com/kreijack/xlibinput_calibrator
(not tested)

- use an alternative calibration program, which can deal with the newer libinput, for example the fowllowing in python/tk:
https://github.com/reinderien/xcalibrate
(tested, working, modified to write directly to conf file)

Cheers,
Adamo

akr

Hi! i am facing the same problem with LCD-OLinuXino-10TS. i am using it with A10-OLinuXino-LIME.  i have a huge deviation around all the four corners. and seems to work a little in the middle section of the touchscreen.
This is my olinuxino-ts file  (/usr/lib/olinuxino/olinuxino-ts)

"""
#!/bin/bash

# Check is LCD is enabled in the device tree
LCD=$(grep -r "lcd-olinuxino-[147]" /proc/device-tree -a -h | tr -d '\0')
[[ -z $LCD ]] && exit 0

overlays=$(cat /boot/uEnv.txt)

# Select transformation matrix
if [[ $overlays == *"i2c2-ar1021"* ]];
then
    case $LCD in
        "olimex,lcd-olinuxino-4.3")
                MATRIX="1.09 0.0 -0.04 0.0 1.17 -0.09 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-7")
                MATRIX="1.05 0.0 -0.03 0.0 1.13 -0.08 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-10")
                MATRIX="1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
                ;;

        *)
                # The LCD is not supported by this script
                exit 0;
    esac

    PRODUCT="ar1021 I2C Touchscreen"

else
    case $LCD in
        "olimex,lcd-olinuxino-4.3")
                MATRIX="1.08 0.0 -0.04 0.0 1.14 -0.10 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-7")
                MATRIX="1.06 0.0 -0.03 0.0 1.11 -0.08 0.0 0.0 1.0"
                ;;
        "olimex,lcd-olinuxino-10")
                MATRIX="1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
                ;;

        *)
                # The LCD is not supported by this script
                exit 0;
    esac

    PRODUCT="1c25000.rtp"

fi

# Generate configuration file
mkdir -p /etc/X11/xorg.conf.d
tee > /etc/X11/xorg.conf.d/98-screen-calibration.conf << __EOF__
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "$PRODUCT"
        Option          "TransformationMatrix" "$MATRIX"
EndSection
__EOF__

# педалщина
LCD=$(grep -r "lcd-olinuxino-[147]" /proc/device-tree -a -h | tr -d '\0')
[[ -z $LCD ]] && exit 0

overlays=$(cat /boot/uEnv.txt)

# Select transformation matrix
if [[ $overlays == *"-gt911inv"* ]];
then
        /usr/bin/memtool mw -l 0x1C0C010  0x80000000 || :
        /usr/bin/memtool mw -l 0x1C0C044  0xF0000006 || :
fi

""""


my 98-screen-calibration.conf file looks like this after reboot (/etc/X11/xorg.conf.d/98-screen-calibration.conf)

"""
Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "1c25000.rtp"
        Option          "TransformationMatrix" "1.04 0.0 -0.03 0.0 1.09 -0.07 0.0 0.0 1.0"
EndSection

"""

vrendtop

I forgot to mention that I use an A10 with an updated buster, because I didn't get an answer on the A10 forum ...