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

July 04, 2022, 11:15:44 am #21 Last Edit: July 04, 2022, 11:17:27 am by kalata23
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