以下内容参考
http://blog.csdn.net/newthinker_wei/article/details/39560109
http://blog.csdn.net/newthinker_wei/article/details/8639276
http://blog.csdn.net/dongqing27/article/details/51501619
http://blog.csdn.net/xishuang_gongzi/article/details/49422879
http://www.arm9home.net/read.php?tid-20248.html
http://blog.csdn.net/bobbat/article/details/51484975
http://www.bubuko.com/infodetail-556461.html
http://blog.csdn.net/zerokkqq/article/details/53045989
1 首先安装必要的工具
sudo apt-get install libtool autoconf automake git
2 使用git获取tslib源代码
git clone https://github.com/kergoth/tslib
3 支持友善之臂一线触摸的tslib补丁tslib-one-wire.patch
友善已经提供开源tslib(源码见:http://www.arm9home.Net/read.php?tid-16105.html)。
但是另外再编译它有点罗嗦,所以我直接制作一个补丁tslib-one-wire.patch来支持友善之臂一线触摸。
操作如下,把tslib-one-wire.patch拷贝到tslib根目录,然后补丁上:
- cp tslib-one-wire.patch tslib/
- cd tslib/
- patch -p1 <tslib-one-wire.patch
tslib-one-wire.patch源码见下,copy下来然后命名成tslib-one-wire.patch就ok了,然后用上面操作。
- #
- # This patch adds support for one wire input raw module (Linux /dev/touchscreen-1wire support).
- #
- # Signed-off-by: Richard Nee <richard.nee.cn@gmail.com>
- #
- --- tslib.orig/configure.ac 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/configure.ac 2012-05-07 23:53:18.849542215 +0800
- @@ -68,6 +68,7 @@
- TSLIB_CHECK_MODULE([dmc], [yes], [Enable building of dmc raw module (HP iPaq DMC support)])
- TSLIB_CHECK_MODULE([input], [yes], [Enable building of generic input raw module (Linux /dev/input/eventN support)])
- TSLIB_CHECK_MODULE([touchkit], [yes], [Enable building of serial TouchKit raw module (Linux /dev/ttySX support)])
- +TSLIB_CHECK_MODULE([one-wire-ts-input], [yes], [Enable building of one wire input raw module (Linux /dev/touchscreen-1wire support)])
- AC_MSG_CHECKING([where to place modules])
- AC_ARG_WITH(plugindir,
- --- tslib.orig/plugins/Makefile.am 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/plugins/Makefile.am 2012-05-08 00:08:59.229542649 +0800
- @@ -114,6 +114,12 @@
- CY8MRLN_PALMPRE_MODULE =
- endif
- +if ENABLE_ONE_WIRE_TS_INPUT_MODULE
- +ONE_WIRE_TS_INPUT_MODULE = one_wire_ts_input.la
- +else
- +ONE_WIRE_TS_INPUT_MODULE =
- +endif
- +
- pluginexec_LTLIBRARIES = \
- $(LINEAR_MODULE) \
- $(DEJITTER_MODULE) \
- @@ -130,7 +136,8 @@
- $(H2200_LINEAR_MODULE) \
- $(INPUT_MODULE) \
- $(TOUCHKIT_MODULE) \
- - $(CY8MRLN_PALMPRE_MODULE)
- + $(CY8MRLN_PALMPRE_MODULE) \
- + $(ONE_WIRE_TS_INPUT_MODULE)
- variance_la_SOURCES = variance.c
- variance_la_LDFLAGS = -module $(LTVSN)
- @@ -185,3 +192,6 @@
- cy8mrln_palmpre_la_SOURCES = cy8mrln-palmpre.c
- cy8mrln_palmpre_la_LDFLAGS = -module $(LTVSN)
- +
- +one_wire_ts_input_la_SOURCES = one-wire-ts-input.c
- +one_wire_ts_input_la_LDFLAGS = -module $(LTVSN)
- --- tslib.orig/plugins/plugins.h 2012-05-07 22:28:42.000000000 +0800
- +++ tslib/plugins/plugins.h 2012-05-07 23:57:38.369542335 +0800
- @@ -16,3 +16,4 @@
- TSLIB_DECLARE_MODULE(tatung);
- TSLIB_DECLARE_MODULE(input);
- TSLIB_DECLARE_MODULE(cy8mrln_palmpre);
- +TSLIB_DECLARE_MODULE(one_wire_ts_input);
- --- /dev/null 2012-05-08 11:52:49.481035009 +0800
- +++ tslib/plugins/one-wire-ts-input.c 2012-05-08 12:04:38.749035337 +0800
- @@ -0,0 +1,66 @@
- +#include <termios.h>
- +#include <stdio.h>
- +#include <unistd.h>
- +#include <stdlib.h>
- +#include <sys/types.h>
- +#include <sys/stat.h>
- +#include <sys/ioctl.h>
- +#include <fcntl.h>
- +#include <linux/fs.h>
- +#include <errno.h>
- +#include <string.h>
- +#include <sys/utsname.h>
- +#include <time.h>
- +
- +#include "config.h"
- +#include "tslib-private.h"
- +
- +static int misc_read(struct tslib_module_info *inf, struct ts_sample *samp, int nr)
- +{
- + struct tsdev *ts = inf->dev;
- +
- + int ret;
- + unsigned ts_status;
- + ret = read(ts->fd, &ts_status, sizeof ts_status);
- + if (ret < 0) {
- + return 0;
- + }
- + if (ret == 0) {
- + return 0;
- + }
- +
- + samp->x = ((ts_status) >> 16) & 0x7FFF;
- + samp->y = ts_status & 0x7FFF;
- + samp->pressure = ts_status >> 31;
- + gettimeofday(&samp->tv,NULL);
- + nr = nr;
- +
- + return 1;
- +}
- +static int ts_fini(struct tslib_module_info *inf)
- +{
- + free(inf);
- + return 0;
- +}
- +
- +static const struct tslib_ops misc_ops =
- +{
- + .read = misc_read,
- + .fini = ts_fini,
- +};
- +
- +TSAPI struct tslib_module_info *one_wire_ts_mod_init(struct tsdev *dev, const char *params)
- +{
- + struct tslib_module_info *m;
- +
- + m = malloc(sizeof(struct tslib_module_info));
- + if (m == NULL)
- + return NULL;
- +
- + m->ops = &misc_ops;
- + return m;
- +}
- +
- +#ifndef TSLIB_STATIC_FRIENDLYARM_TS_MODULE
- +TSLIB_MODULE_INIT(one_wire_ts_mod_init);
- +#endif
4 下面是配置编译tslib
./autogen.sh
echo "ac_cv_func_malloc_0_nonnull=yes">arm-none-linux-gnueabi.cache
./configure --host=arm-none-linux-gnueabi --cache-file=arm-none-linux-gnueabi.cache --prefix=/opt/tslib_new3
make && make install
5:编译one-wire-ts-input.so
step1: 解压源代码包,执行make
#tar xvzf one-wire-ts-input-src-20111026.tar.gz(下载地址:http://download.csdn.net/download/bobbat/9528962)
#make
得到" one-wire-ts-input.so ",把它放入板子中,目录为:/opt/tslib_new3/lib/ts/
第五步:修改tslib下面的etc/ts.conf
作如下配置:
[objc] view plain copy 在CODE上查看代码片派生到我的代码片
# Uncomment if you wish to use the linux input layer event interface
# module_raw input
# Uncomment if you're using a Sharp Zaurus SL-5500/SL-5000d
# module_raw collie
# Uncomment if you're using a Sharp Zaurus SL-C700/C750/C760/C860
# module_raw corgi
# Uncomment if you're using a device with a UCB1200/1300/1400 TS interface
# module_raw ucb1x00
# Uncomment if you're using an HP iPaq h3600 or similar
# module_raw h3600
# Uncomment if you're using a Hitachi Webpad
# module_raw mk712
# Uncomment if you're using an IBM Arctic II
# module_raw arctic2
module_raw one-wire-ts-input.so
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
第六步:
配置开发板etc/profile文件:
配置如下:
第七步:修改 ts.conf文件
#module_raw顶头写,前面不能有空格
module_raw one-wire-ts-input
到此为止 tslib 就基本能用了,首次使用时应先运行 ts_calibrate 进行触摸屏校准。
第八步:生成libqtslibplugin.so
有了tslib后,进入Qt源码目录中的 "qtbase/src/plugins/generic/tslib/",运行 qmake-arm 生成 Makefile,
并在Makefile中将tslib的头文件和库文件路径添加到编译链接选项中(-I /opt/tslib_new3/include -L/opt/tslib_new3/lib);
然后运行 make 和 make install即可。这时,Qt5安装目录的 "plugins/generic/"目录下就出现"libqtslibplugin.so"这个库文件了。
第9步:运行Qt程序
需要说明的是,Qt5.0开始,Qt自身不再单独实现窗口系统,QWS不复存在,取而代之的新机制是QPA(Qt平台抽象),QPA使得Qt对不同平台的支持变得更加灵活,当需要支持一个新平台时,只需为该平台编写一个QPA插件。
With the release of Qt 5.0, Qt no longer contains its own window system implementation: QWS is no longer a supported platform. For single-process use cases, theQt Platform Abstraction is a superior solution......参考 http://qt-project.org/doc/qt-5/embedded-linux.html
编译完Qt后,只需将生成的lib和plugins文件夹拷贝到开发板,另外,当在嵌入式Linux平台上运行应用程序前,应根据自己平台的实际情况提前设置好下面几个环境变量:
然后就可以运行Qt程序了
以前Qt4的程序在嵌入式Linux平台运行时,需要在命令行输入-qws选项以启动Qt窗口系统服务,如" ./HelloWorld -qws";而使用Qt5后,不再需要-qws,而需要通过-platform来指定要使用的QPA插件,如" ./HelloWorld -platform linuxfb",如果不指定,则用默认的QPA插件,默认的QPA插件通过上面的QT_QPA_PLATFORM变量指定。