树莓派USB触摸屏校准及旋转屏幕方向后校准
下载地址 Index of /pool/universe/x/xinput-calibrator (ubuntu.com)
1、 树莓派安装
sudo apt-get install xinput-calibrator
2、安装完成后 输入xinput_calibrator --list查看触摸设备列表
输入 xinput_calibrator --device "ILITEK ILITEK-TP"
这样就校准完成了,执行以下命令拷贝对应校准数据保存
cd /usr/share/X11/xorg.conf.d/
sudo nano 99-calibration.conf
复制黏贴对应的校准数据
Section "InputClass"
Identifier "calibration"
MatchProduct "ILITEK ILITEK-TP"
Option "MinX" "-1674"
Option "MaxX" "66086"
Option "MinY" "654"
Option "MaxY" "65051"
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
二、旋转屏幕方向后校准
下面我们将详细讲解如何在树莓派操作系统中将屏幕旋转为纵向(90度)或纵向翻转(270度),并通过指定变换矩阵的位置将USB触摸屏旋转为纵向或纵向翻转,以满足信息、导航系统或工业控制的触摸需求
1、先旋转屏幕方向,使用树莓派自带的工具旋转屏幕方向
首选项->Screen Configuration
配置触摸屏旋转矩阵
cd /usr/share/X11/xorg.conf.d
sudo nano 40-libinput.conf
找到触摸屏的InputClass的 InputClass 部分。
输入
Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1
1
输入完 Control+O 写入 Enter 确定
Control+X 退出
其他方向转换的矩阵如下
90° = 选项“转换矩阵”“0 1 0 -1 0 1 0 0 1”
180° = 选项“转换矩阵”“-1 0 1 0 -1 1 0 0 1”
270° = 选项“转换矩阵”“0 -1 1 1 0 0 0 0 1"
设置完重启生效sudo reboot
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1、安装工具
xinput-calibrator工具:sudo apt-get install xinput-calibrator
xinput工具:sudo apt-get install xinput
2、校准实例
(1)查看触摸设备id:xinput_calibrator --list
上面可知:device name:ILITEK ILITEK-TP,device id:11
(2)校准触摸设备:xinput_calibrator -v --device <device name or id>
此处为xinput_calibrator -v --device 11
(3)在显示的屏幕触摸校准页面进行页面校准,终端会输出屏幕校准后的数据
(4)将屏幕校准数据根据提示复制至/etc/X11/xorg.conf.d/目录下的99-touchscreen-evdev.conf文件中,部分发行版系统下的路径为/usr/share/X11/xorg.conf.d/。如果没有99-touchscreen-evdev.conf文件可手动创建一个。
Section "InputClass"
Identifier "calibration"
MatchProduct "ILITEK ILITEK-TP"
Option "MinX" "20207"
Option "MaxX" "20343"
Option "MinY" "52844"
Option "MaxY" "54101"
Option "SwapXY" "1" # unless it was already set to 1
Option "InvertX" "0" # unless it was already set
Option "InvertY" "0" # unless it was already set
EndSection
(5)重启系统校准生效
3、相关问题
(1)屏幕旋转后校准未跟着旋转的问题
屏幕顺时针旋转270度时,添加Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"至99-touchscreen-evdev.conf,文件内容如下
Section "InputClass"
Identifier "calibration"
MatchProduct "ILITEK ILITEK-TP"
Option "MinX" "20207"
Option "MaxX" "20343"
Option "MinY" "52844"
Option "MaxY" "54101"
Option "SwapXY" "1" # unless it was already set to 1
Option "InvertX" "0" # unless it was already set
Option "InvertY" "0" # unless it was already set
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection
屏幕顺时针旋转180度时,添加Option "TransformationMatrix" "-1 0 1 0 -1 1 0 0 1"至99-touchscreen-evdev.conf
屏幕顺时针旋转270度时,添加Option "TransformationMatrix" "0 1 0 -1 0 1 0 0 1"至99-touchscreen-evdev.conf
(2)校准不准的问题
上下相反,比如点击左上角,反馈至左下角,类似于Y轴方向改变
99-touchscreen-evdev.conf文件中Option的InvertY值:"0"改为"1"
左右相反,比如点击左上角,反馈至右上角,类似于X轴方向改变
99-touchscreen-evdev.conf文件中Option的InvertX值:"0"改为"1"
XY相反,比如点击左上角,反馈至右下角,类似于X、Y轴方向改变
99-touchscreen-evdev.conf文件中Option的SwapXY值:"0"改为"1"
边缘偏移,比如点击最外侧,反馈却在旁边,说明位置点未设置准确
修改99-touchscreen-evdev.conf文件中Option的MinX、MaxX、MinY、MaxY值,修改尝试一下