The road to Qt learning (1) - porting the tslib library to the development board

1. Download the tslib source code:
The installation package here is directly decompressed
cd tslib
Software needs to be installed before this: such as automake, libtool, autoconf (or autoconf2.13).
Otherwise there will be some problems: such as:
autoreconf :command not found
erro:  possibly undefined macro: AC_DISABLE_STATI...
Some undefined errors.
If there are other problems, you can only Baidu, or you can send the problem to me, let's discuss it together.
Execute the command below:
. /configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes CC=/opt/xtools/arm920t/bin/arm-linux-gcc

explain:
--prefix=/usr/local/tslib/  Specify the installation path of tslib
ac_cv_func_malloc_0_nonnull=yes // malloc may be used in tslib, so let it execute


then executing
make && make install
Then in the installation directory tslib will see the generated five files

Package the four files of bin etc include lib in the figure, I named it tslib.tar.gz
Then download the compressed package to the app directory of the development board.
cd /apps/
tftp -gr tslib.tar.gz 192.168.1.20 //Download to the development board.
The next step is to add environment variables in the profile file
vi /etc/profile
export TSLIB_ROOT=/apps/tslib           // (Extract the directory where the four folders are located)
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf      // (tslib module configuration file)
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/pointercal      // ( tell QTOPIA where the pointercal file is ) 
export TSLIB_TSDEVICE=/dev/input/event1     // (touch screen device node file) (because the function of each device is different, so the selected device is different, my touch screen device here is event1)   
export TSLIB_CONSOLEDEVICE=none      // (The console required for tslib to run, here is the LCD screen, the set console device is none, the default is /dev/tty)
export TSLIB_FBDEVICE=/dev/fb0     // (framebuffer device file) 
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts    // (tslib plugin library directory)

export LD_LIBRARY_PATH=/lib:/usr/lib:/apps/tslib/lib    // (Set the path of lib under your tslib so that the system can find it)
Then modify and add the code in the ts.conf file (if the source file has it, there is no need to add it)
#module_raw inputRemove    the # sign here, and then place the code on the left, without anything in front of it, otherwise an error will occur
module_raw input

No raw modules loaded.
ts_config: No such file or directory

Add to:
module pthres pmin=1
module variance delta=30
module dejitter delta = 100
module linear
Next run the program check
Go to /apps/tslib/bin ( (this is my directory, you look at your own directory)
Execute ./ts_calibrate (it is better to re-grant its execution permission, because the file may change when it is moved)
Then there is an error as shown in the figure:

This is because I lack support for touchscreen drivers in the linux kernel file, so I need to modify it:


After the modification is completed, re-burn the kernel, and then you can.
Switch to the bin directory
cd /apps/tslib/bin/
Execute calibration file
/ts_calibrate

However, the calibration here is not very accurate. Just click the screen, and the cursor still shows that the calibration is successful. (There will be time analysis later)
程序中,触摸屏设备 TSLIB_TSDEVICE 校准文件 TSLIB_CALIBFILE 都是从环境变量中获取的,在配置tslib库中应该指定。 TSLIB_TSDEVICE 一般是/dev/input/event0文件,这个跟触屏设备有关,可以用cat /proc/bus/input/devices命令查看确认,或者直接在终端用cat /dev/input/event0命令,然后点击触摸屏,会有数据打印出。 TSLIB_TSCALIBFILE 一般是/etc/pointercal文件,文件中记录了计算后的校准值。通过ts_open()、ts_config()函数打开和初始化触摸屏设备后,在get_sample()函数中通过put_cross()函数显示光标,然后通过getxy()函数等待用户点击触屏上的光标,获取触点数据,然后存在cal结构体中。获取完5个校准点(左上、右上、右下、左下、中间)数据后,通过perform_calibration()进行计算,把校准值写入到/etc/pointercal文件中。  
再次校准前,需要把pointercal文件删掉,否则它的值仍然是错误的。
后来校准过后,屏幕采集数据正确后,测试效果正确
执行
./ts_rest
如图:

测试如图(画得丑,随便看看.haha)






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325765062&siteId=291194637