linux 触屏校准命令,tslib-触摸屏校准

本文介绍了如何在Linux系统中使用tslib进行触摸屏校准,包括从GitHub下载tslib、安装必要的工具、编译安装tslib、配置环境变量以及创建calibrate脚本来启动校准程序。完成这些步骤后,通过输入'calibrate'命令即可在LCD屏幕上运行触摸屏校准程序。
摘要由CSDN通过智能技术生成

5.1移植tslib

5.1.1在https://github.com/kergoth/tslib下载最新的tslib

5.1.2为虚拟机里的Linux系统安装工具

sudo apt-get install autoconf

sudo apt-get install automake

sudo apt-get install libtool

要注意新版gcc open函数有3个参数,ts_calibrate.c后要加一个参数0777.

5.1.3  解压后编译

mv xxx(解压后名字) tslib //名字改为tslib

cd tslib

./autogen.sh

mkdir tmp

echo "ac_cv_func_malloc_0_nonnull=yes">arm-linux.cache

./configure --host=arm-linux--cache-file=arm-linux.cache --prefix=$(pwd)/tmp

make

make install

打开tmp目录,里面有四个文件夹,分别是bin、etc、include、lib。将etc目录下的ts.conf里的第2行去掉注释。即:

# module_raw input 改为: module_raw input

将tmp复制到开发板根文件目录下/usr/local/并改名tslib

在开发板根文件目录/bin/下新建一个文件calibrate,内容如下:

#! /bin/sh

export TSLIB_ROOT=/usr/local/tslib

export TSLIB_TSDEVIC

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是两种Linux触摸屏校准的方法: 1. 使用tslib编写触摸屏校准程序 如果你使用的是嵌入式Linux系统,并且已经安装了QT5.6版本和tslib库,你可以编写一个触摸屏校准程序。以下是一个示例程序: ```c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <linux/input.h> #include <tslib.h> #define DEVICE_NAME "/dev/input/event0" #define CALIBRATION_FILE "/etc/pointercal" int main(int argc, char *argv[]) { struct tsdev *ts; struct ts_sample samp[5]; int fd, i; struct ts_sample *calib; struct ts_sample *calib_result; int xres, yres; ts = ts_open(DEVICE_NAME, 0); if (!ts) { perror("ts_open"); exit(1); } if (ts_config(ts)) { perror("ts_config"); exit(1); } calib = malloc(sizeof(struct ts_sample) * 5); calib_result = malloc(sizeof(struct ts_sample) * 5); printf("Please touch the screen at the center of the cross.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i] = samp[i]; } calib_result[2].x = xres / 2; calib_result[2].y = yres / 2; printf("Please touch the screen at the top-left corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[0].x = 0; calib_result[0].y = 0; printf("Please touch the screen at the bottom-right corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[4].x = xres - 1; calib_result[4].y = yres - 1; printf("Please touch the screen at the top-right corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[1].x = xres - 1; calib_result[1].y = 0; printf("Please touch the screen at the bottom-left corner of the screen.\n"); for (i = 0; i < 5; i++) { ts_read(ts, &samp[i], 1); calib[i].x = samp[i].x; calib[i].y = samp[i].y; } calib_result[3].x = 0; calib_result[3].y = yres - 1; ts_close(ts); fd = open(CALIBRATION_FILE, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd < 0) { perror("open"); exit(1); } dprintf(fd, "%d %d %d %d %d %d %d %d %d\n", calib_result[0].x, calib_result[0].y, calib_result[1].x, calib_result[1].y, calib_result[2].x, calib_result[2].y, calib_result[3].x, calib_result[3].y, calib_result[4].x, calib_result[4].y); close(fd); printf("Calibration data saved to %s.\n", CALIBRATION_FILE); return 0; } ``` 2. 使用xinput_calibrator命令行工具校准触摸设备 如果你使用的是Linux桌面系统,你可以使用xinput_calibrator命令行工具校准触摸设备。以下是一个示例命令: ``` xinput_calibrator -v --device <device name or id> ``` 其中,`<device name or id>`是你要校准的触摸设备的名称或ID。你可以使用`xinput list`命令查看所有输入设备的列表。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值