树莓派4B 微雪7寸触摸屏 双屏 触摸屏校正

        树莓派4B+微雪7寸触摸屏+PC显示器,以触摸屏位主显示,PC显示器扩展,这时会有触摸不准的情况。

        通过观察可以发现触摸被放大到了整个屏幕,即触摸屏+PC显示器。

        1. 通过查看2个屏幕分辨率和位置,这边位置关系是左右,触摸屏左,PC显示器右。分辨率如下:

        触摸屏        PC显示器

        800x480     1920x1080

        全屏幕

        2720x1080

        2. 通过修改/usr/share/X11/xorg.conf.d/40-libinput.conf文件,增加缩放系数。

        找到touchscreen ,如下:

Section "InputClass"
Identifier "libinput touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection

        增加一行Option "CalibrationMatrix" "0.2941 0 0 0 0.4444 0 0 0 1"  修改如下:

Section "InputClass"
Identifier "libinput touchscreen catchall"
Option "CalibrationMatrix" "0.2941 0 0 0 0.4444 0 0 0 1"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
EndSection

     变化矩阵信息如图:

    缩放矩阵是修改2个cos位置的值,缩放系数是全屏幕缩小到触摸屏尺寸。xy各自计算可得。

xscale=800/2720
yscale=480/1080

参考:

Raspberry 3B+ 微雪3.5 LCD(A) 触摸屏遇到的问题

矩阵运算——平移,旋转,缩放

原文地址:https://www.cnblogs.com/SamFang/p/14381220.html