Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: Klaus on March 30, 2020, 03:28:15 pm

Title: Calibrate Touchscreen
Post by: Klaus on March 30, 2020, 03:28:15 pm
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 (http://ftp://staging.olimex.com/Allwinner_Images/A20-OLinuXino/1.latest_mainline_images/buster/images/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?
Title: Re: Calibrate Touchscreen
Post by: kalata23 on April 01, 2020, 08:57:00 am
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.
Title: Re: Calibrate Touchscreen
Post by: 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
Title: Re: Calibrate Touchscreen
Post by: kalata23 on March 23, 2021, 03:04:27 pm
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/lib/olinuxino/olinuxino-ts on every boot. This overrides the .conf file after reboot, that's why I can suggest you to change default values in /usr/lib/olinuxino/olinuxino-ts
Title: Re: Calibrate Touchscreen
Post by: tropek on March 23, 2021, 09:18:30 pm
Thank you, I will try it.
Title: Re: Calibrate Touchscreen
Post by: tropek on April 04, 2021, 01:22:03 pm
I'll get back to it soon !
Title: Re: Calibrate Touchscreen
Post by: tropek on April 05, 2021, 03:36:19 pm
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 ?
Title: Re: Calibrate Touchscreen
Post by: LubOlimex on April 07, 2021, 08:08:34 am
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.
Title: Re: Calibrate Touchscreen
Post by: tropek on April 07, 2021, 10:46:05 pm
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
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on June 30, 2022, 05:11:40 pm
I have done everything possible based on the official documents and instructions here... I have calculated the calibration matrix, and when I apply it under the Olimex user in the CLI using xinput set-prop, my touchscreen works perfectly. I made changes to /usr/lib/olinuxino/olinuxino-ts, I have the correct /etc/X11/xorg.conf.d/98-screen-calibration.conf after reboot. But these settings don't work. The touchscreen still have the wrong calibration. To be sure, I performed a new deployment with the OS on the SD card and made changes to /usr/lib/olinuxino/olinuxino-ts from the beginning. The results are exactly the same... correct data in /etc/X11/xorg.conf.d/98-screen-calibration.conf and incorrect calibration (((( To be honest, I do not know what to do.

Hardware: SODIMM 204 PIN EVALUATION BOARD WITH A20-SOM204-1GS16ME16G-MC
LCD: LCD-OLinuXino-7RTS
Software: A20-OLinuXino-bullseye-base-20220413-094751.img
jumper in correct position
Title: Re: Calibrate Touchscreen
Post by: LubOlimex on July 01, 2022, 08:43:56 am
It is a bit more convoluted. Check the replies of kalata23 in this thread here:

https://www.olimex.com/forum/index.php?msg=28314
https://www.olimex.com/forum/index.php?msg=31101
Title: Re: Calibrate Touchscreen
Post by: kalata23 on July 01, 2022, 08:46:41 am
Quote from: alex_u-94 on June 30, 2022, 05:11:40 pmI have done everything possible based on the official documents and instructions here... I have calculated the calibration matrix, and when I apply it under the Olimex user in the CLI using xinput set-prop, my touchscreen works perfectly. I made changes to /usr/lib/olinuxino/olinuxino-ts, I have the correct /etc/X11/xorg.conf.d/98-screen-calibration.conf after reboot. But these settings don't work. The touchscreen still have the wrong calibration. To be sure, I performed a new deployment with the OS on the SD card and made changes to /usr/lib/olinuxino/olinuxino-ts from the beginning. The results are exactly the same... correct data in /etc/X11/xorg.conf.d/98-screen-calibration.conf and incorrect calibration (((( To be honest, I do not know what to do.

Hardware: SODIMM 204 PIN EVALUATION BOARD WITH A20-SOM204-1GS16ME16G-MC
LCD: LCD-OLinuXino-7RTS
Software: A20-OLinuXino-bullseye-base-20220413-094751.img
jumper in correct position

Please, copy the content of /usr/lib/olinuxino/olinuxino-ts here.

PS: Please also markup the line(s) that you have changed.
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 01, 2022, 11:51:46 am
All steps which I did.

Preparation
Fresh new deployment of OS on SD
$ sudo olinuxino-overlay
    1. Enabled: som204-lcd-olinuxino-7.dtbo        LCD-OLinuXino-7 800x480 panel without TS
    2. Enabled: som-i2c2-ar1021.dtbo              Microchip AR1021 RTS controller on I2C2 bus
    3. Disabled: som204-lcd-olinuxino.dtbo          LCD-OLinuXino PnP panel
$ sudo apt install xrandr (no longer available for installation, performed to demonstrate the result)
 Reading package lists... Done
 Building dependency tree... Done
 Reading state information... Done
 Package xrandr is not available, but is referred to by another package.
 This may mean that the package is missing, has been obsoleted, or
 is only available from another source
 However the following packages replace it:
  x11-xserver-utils

 E: Package 'xrandr' has no installation candidate
$ sudo apt install x11-xserver-utils (performed to demonstrate the result)
 Reading package lists... Done
 Reading state information... Done
 xinput-calibrator is already the newest version (0.7.5+git20140201-1+b2).
 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install xinput
 Reading package lists... Done
 Building dependency tree... Done
 Reading state information... Done
 The following NEW packages will be installed:
   xinput
 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
 Need to get 50.4 kB of archives.
 After this operation, 84.0 kB of additional disk space will be used.
 Get:1 http://httpredir.debian.org/debian bullseye/main armhf xinput armhf 1.6.3-1 [50.4 kB]
 Fetched 50.4 kB in 0s (117 kB/s)
 Selecting previously unselected package xinput.
 (Reading database ... 126380 files and directories currently installed.)
 Preparing to unpack .../xinput_1.6.3-1_armhf.deb ...
 Unpacking xinput (1.6.3-1) ...
 Setting up xinput (1.6.3-1) ...
 Processing triggers for man-db (2.9.4-2) ...
Сheckout
$ cat /etc/X11/xorg.conf.d/98-screen-calibration.conf
 Section "InputClass"
         Identifier      "calibration"
         MatchProduct    "1c25000.rtp"
         Option          "TransformationMatrix" "1.06 0.0 -0.03 0.0 1.11 -0.08 0.0 0.0 1.0"
 EndSection
Visual test (touch screen works, calibration has a significant deviation)
(https://i.ibb.co/Dky3yQL/alp-40-000-32.png)

Calibration
$ export DISPLAY=:0
$ xinput_calibrator -v
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: Skipping device 'PixArt Microsoft USB Optical Mouse' id=6, does not report Absolute events.
DEBUG: Skipping device 'Microsoft Wired Keyboard 600 Consumer Control' id=8, does not report Absolute events.
DEBUG: Skipping device 'sunxi-ir' id=10, does not report Absolute events.
DEBUG: Selected device: ar1021 I2C Touchscreen
DEBUG: Not usbtouchscreen calibrator: Not a usbtouchscreen device
DEBUG: Not evdev calibrator: Evdev: invalid "Evdev Axis Calibration" property format
Calibrating standard Xorg driver "ar1021 I2C Touchscreen"
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 'ar1021 I2C Touchscreen' is a sysfs name.
DEBUG: Adding click 0 (X=106, Y=87)
DEBUG: Adding click 1 (X=685, Y=88)
DEBUG: Adding click 2 (X=106, Y=409)
DEBUG: Adding click 3 (X=687, Y=413)
--> Making the calibration permanent <--
DEBUG: Found that 'ar1021 I2C Touchscreen' is a sysfs name.
  copy the snippet below into '/etc/X11/xorg.conf.d/99-calibration.conf' (/usr/share/X11/xorg.conf.d/ in some distro's)
Section "InputClass"
Identifier "calibration"
MatchProduct "ar1021 I2C Touchscreen"
Option "MinX" "765"
Option "MaxX" "64115"
Option "MinY" "4585"
Option "MaxY" "63476"
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

Preliminary verification of the calculations
$ xinput_calibratot --list
Device "ar1021 I2C Touchscreen" id=12
$ xinput set-prop 12 'Coordinate Transformation Matrix' 1.04 0.0 -0.02 0.0 1.12 -0.08 0.0 0.0 1.0

Visual test
(https://i.ibb.co/DYpfvxL/12-Coordinate-Transformati.png)

Making changes to olinuxino-ts

$ sudo nano /usr/lib/olinuxino/olinuxino-ts

Old parameters for olimex lcd-olinuxino-7
(https://i.ibb.co/xzJhX3D/old-ts.png)

New parameters for olimex lcd-olinuxino-7
(https://i.ibb.co/ZX3g61y/new-ts.png)

Rebooting and checking the results

$ cat /etc/X11/xorg.conf.d/98-screen-calibration.conf (The content of the file corresponds to the specified parameters)
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

Visual test (touch screen works, calibration has a significant deviation)
(https://i.ibb.co/25thFjG/a20-olinuxino.png)
Title: Re: Calibrate Touchscreen
Post by: kalata23 on July 01, 2022, 01:02:00 pm
Thank you for the detailed step list. However, I think you have edited the wrong line in  olinuxino-ts  script.

From the images, that you applied here, I see that you edit olimex,lcd-olinuxino-7 line in the following section:

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
But this sections is related to CTS displays, not RTS. The correct sections, where you have to change the values for 7" LCD is this:

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"

Change the values in the correct section, and tell us if this solved your problem.
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 01, 2022, 01:48:58 pm
A 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....
Title: Re: Calibrate Touchscreen
Post by: kalata23 on July 01, 2022, 03:17:13 pm
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.
Title: Re: Calibrate Touchscreen
Post by: LubOlimex on July 01, 2022, 03:36:02 pm
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.
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 01, 2022, 03:42:36 pm
Quote from: kalata23 on July 01, 2022, 03:17:13 pmCan you, please attach screenshot of
Code Select Expand
olinuxino-overlay command.

All options:

(https://i.ibb.co/fNgz9qc/Enable-FDT-overlays1.png)

(https://i.ibb.co/2t8p600/Enable-FDT-overlays2.png)

(https://i.ibb.co/r44htXZ/Enable-FDT-overlays3.png)

(https://i.ibb.co/87L8bSC/Enable-FDT-overlays4.png)
Title: Re: Calibrate Touchscreen
Post by: kalata23 on July 01, 2022, 03:58:34 pm
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
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 01, 2022, 04:01:15 pm
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

(https://i.ibb.co/6s2CTxL/photo-2022-07-01-15-58-14.jpg)
(https://i.ibb.co/7gqYCVz/photo-2022-07-01-15-58-30.jpg)
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 01, 2022, 04:21:17 pm
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
Title: Re: Calibrate Touchscreen
Post by: kalata23 on July 04, 2022, 11:15:44 am
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.
Title: Re: Calibrate Touchscreen
Post by: alex_u-94 on July 05, 2022, 12:00:09 pm
Thanks a lot!!!!