触摸屏移植 tslib-master.zip
打开tslib/plugins/input-raw.c
把其中的ts_input_read 函数改成如下:
static int ts_input_read(struct tslib_module_info *inf,struct ts_sample *samp, int nr){
struct tslib_input *i = (struct tslib_input*)inf;
struct tsdev *ts = inf->dev;
struct input_event ev;
int ret = nr;
int total = 0;
unsigned long jjts;
while(total<nr)
{
ret=read(ts->fd,&jjts,sizeof(jjts));
if(ret==-1) return 0;
samp->pressure=(jjts>>31)&0x01;
samp->x=(jjts>>16)&0xffff;
samp++;
total++;
}
ret=total;
return ret;
}
编译步骤:
1)./autogen.sh
出错:
./autogen.sh: 3: autoreconf: not found
解决:
apt-get install autoconf
2)./autogen.sh
出错:
Can't exec "libtoolize": No such file or directory at /usr/bin/autoreconf line 196.
Use of uninitialized value in pattern match (m//) at /usr/bin/autoreconf line 196.
configure.ac:24: error: possibly undefined macro: AC_DISABLE_STATIC
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:25: error: possibly undefined macro: AC_ENABLE_SHARED
configure.ac:26: error: possibly undefined macro: AC_LIBTOOL_DLOPEN
configure.ac:27: error: possibly undefined macro: AC_PROG_LIBTOOL
autoreconf: /usr/bin/autoconf failed with exit status: 1
解决:
apt-get install libtool
3)
4)
5)
qt库编译和移植 qt-embedded-linux-opensource-src-4.5.3.tar.gz
1)#tar zxvf qt-embedded-linux-opensource-src-4.5.3.tar.gz
2)#cd qt-embedded-linux-opensource-src-4.5.3
3)# ./configure -prefix /opt/qt4 -release -shared -fast -pch -no-qt3support -qt-sql-sqlite -no-libtiff -no-libmng -qt-libjpeg -qt-zlib -qt-libpng -qt-freetype -no-openssl -no-webkit -nomake examples -nomake demos -nomake tools -optimized-qmake -no-phonon -no-nis -no-opengl -no-cups -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-xkb -no-sm -no-xinerama -no-xshape -no-separate-debug-info -xplatform qws/linux-arm-g++ -embedded arm -little-endian -depths 16 -no-qvfb -qt-gfx-linuxfb -no-gfx-qvfb -no-kbd-qvfb -no-mouse-qvfb -qt-kbd-usb -confirm-license -qt-mouse-tslib -I/opt/tslib/include -L/opt/tslib/lib 此处是触摸屏库的路径
4)#make
5)#make install
make 小技巧 :
当知道编译不会错时
可以用 make -j4 (-j4 代表用4个线程同时编译)再执行 make install
也可以 make && make install
当然出错时就有可能找不到位置 那我们就可以利用重定向 make 2 > log 这样如果错误我们就可以cat 或者 vi 去看 log 文件
<span style="font-size:14px;">#!bin/bash
PATH=/opt/qt4/bin:$PATH //注意路径
QTDIR=/opt/qt4
MAINPATH=$QTDIR/man:$MAINPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH QTDIRMAINPATH LD_LIBRARY_PATH </span>
注:电脑重启后路径会被还原,所以需要用到arm-qt编译时记得执行.sh文件
7)移植库文件到开发板。
#cd /opt
#mkdir tslib qt4lib
#cp /mnt/tslib-mipsel/lib /mnt/tslib-mipsel/etc /opt/tslib/ –rdf
#cp /mnt/tslib-mipsel/bin/ts_calibrate /mnt/tslib-mipsel/bin/ts_test /bin/
#cp /mnt/qt4-mipsel/lib /opt/qt4lib/ -rdf
注:
1)这里的qt移植可能会因为空间不足移植失败,可以删去/opt/下的qt**文件夹,移植完之后看到屏幕黑屏不要惊讶,因为原有的qt被删去了嘛!
2)如果删去还是移植失败,那就要考虑arm的网络传输问题,一般的copy都是高数据传输,所以arm接收数据可能就会失败,这里我们就要这样挂载啦! nfs挂载方式请参考这里
mount -t nfs -o nolock,intr,wsize=1024,rsize=1024[宿主计算机IP]:[共享目录] /mnt
8)设置开发板的环境变量使其支持触摸屏与QT4的操作,打开/etc/profile,加入如下内容:
export T_ROOT=/opt/tslib/
export QTDIR=/opt/qt4lib
export PATH=$QTDIR/bin:$PATH
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/touchscreen-1wire
export TSLIB_PLUGINDIR=$T_ROOT/lib/ts
export TSLIB_CONFFILE=$T_ROOT/etc/ts.conf
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_TSEVENTTYPE=INPUT
export QWS_MOUSE_PROTO=tslib:/dev/touchscreen-1wire
export QT_QWS_FONTDIR=/opt/qt4lib/lib/fonts
export LD_LIBRARY_PATH=$T_ROOT/lib:$QTDIR/lib:$LD_LIBRARY_PATH
9)需要对tslib的配置文件作相应的修改,才可以使用,打开/opt/tslib/etc/ts.conf:
module_rawinput
module pthrespmin=1
module variancedelta=30
module dejitterdelta=100
module linear
10)修改/etc/init.d.rcS的相应代码, “好像是” 使原带的QT置顶解除。
# /bin/qtopia &
# echo " " > /dev/tty1
# echo"Starting Qtopia, please waiting..." > /dev/tty1
11)验证触摸较正程序,在开发板终端下执行:
#ts_calibrate
这一步是必须的,因为他会生成触摸屏配置文件,之后的程序都是以它为标准
12)验证,运行触摸屏拖曳测试程序:
#ts_test
13)开发板执行qt程序
#./application -qws 这个别忘了,小编我虽然经常忘记!