[Beijing Xunwei] i.MX6ULL Terminator Linux capacitive touch screen experiment Tslib transplantation and use

1 Get tslib source code

The source code of tslib can be obtained from the official address: https://github.com/libts/tslib, open the website and you can see that the latest version is 1.21, which can be obtained from the official website or from the online disk data, the data path: i. MX6UL Terminator CD-ROM information/06_Linux driver example/third-party library source code/tslib-1.21.tar.bz2. After obtaining the tslib source code, copy it to the Ubuntu system and decompress it to get the tslib-1.21 folder.

2 Compile tslib

After obtaining the tslib source code, you can compile the tslib source code. There are several steps specifically as follows.
1. Modify the user who belongs to the tslib source code. Modify the user who belongs
to the tslib-1.21 directory obtained by decompression as the current user. If you don't modify it, you may encounter various problems in later compilation. My current ubuntu login user name is "topeet", then the modification command is as follows:
sudo chown topeet:topeet tslib-1.21 -R
After modification, it is shown in Figure 2.1:
Insert picture description here

Figure 2.1

2. Ubuntu tool installation When
compiling tslib, you need to install some files in ubuntu first to prevent errors during compiling tslib. The command is as follows:

sudo apt-get install autoconf 
sudo apt-get install automake 
sudo apt-get install libtool 

3. Compile tslib.
First create a tslib folder to store the compiled results. For example, the file path is: /home/topeet/tslib
and then use the following commands to configure and compile tslib:

cd tslib-1.21/ //进入 tslib 源码目录 
./configure --host=arm-none-linux-gnueabi --prefix=/home/topeet/tslib 
make //编译 
make install //安装

Note that when using ./configure to configure tslib, the "–host" parameter specifies the compiler, and the specified compiler must use the same compiler as the compiled file system, otherwise it cannot be used normally under the development board. The "-prefix" parameter specifies where to install the tslib file after the compilation is complete. It must be installed in the "tslib" directory we just created.
After compiling, the tslib directory is shown in Figure 2.2:
Insert picture description here

Figure 2.2

Then copy all the files in the tslib directory to the root file system of the development board. If you copy it directly, the symlink file cannot be copied. You can use the tar command to pack it first, and then decompress it to the root file system. The command is as follows:

tar -czvf lib.tar.gz *		//打包生成lib.tar.gz压缩包
tar -xvf lib.tar.gz /		//解压到开发板根文件目录下

3 Test tslib

After copying the compiled tslib to the development board, perform command test.
1. Configure tslib to
open the /etc/ts.conf file and find the following line:
module_raw input
If there is a "#" before the above sentence, delete the "#".
Open the /etc/profile file and add the following content:

1 export TSLIB_TSDEVICE=/dev/input/event1 
2 export TSLIB_CALIBFILE=/etc/pointercal 
3 export TSLIB_CONFFILE=/etc/ts.conf 
4 export TSLIB_PLUGINDIR=/lib/ts 
5 export TSLIB_CONSOLEDEVICE=none 
6 export TSLIB_FBDEVICE=/dev/fb0 

In line 1, TSLIB_TSDEVICE represents the touch device file, here is set to /dev/input/event1, this should be set according to the specific situation, if your touch device file is event2, then it should be set to /dev/input/event2, and so on .
In the second line, TSLIB_CALIBFILE represents the calibration file. If the screen calibration is performed, the calibration result will be saved in this file. Here, the calibration file is set to /etc/pointercal. This file does not need to exist, and it will be automatically generated during calibration.
In line 3, TSLIB_CONFFILE represents the touch configuration file, the file is /etc/ts.conf, this file will be generated when tslib is transplanted.
In line 4, TSLIB_PLUGINDIR indicates the location of the tslib plugin directory, and the directory is /lib/ts.
In line 5, TSLIB_CONSOLEDEVICE represents the console setting, which is not set here, so it is none.
In line 6, TSLIB_FBDEVICE represents the FB device, which is the screen. According to the actual configuration, my screen file is /dev/fb0, so here is set to /dev/fb0.
After all configurations are complete, restart the development board, and then you can test.
2. After the test tslib
development board is restarted, you can calibrate first. Use the following command: After
ts_calibrate
calibration is completed, the /etc/pointercal file will be generated. If you want to recalibrate, you can directly delete the /etc/pointercal file and execute the calibration command again. .
Then you can use the ts_test_mt command to test whether the touch screen is working properly and whether the multi-touch is valid, execute the following command: After the
ts_test_mt
command is executed, a test interface will be opened, as shown in Figure 3.1:
Insert picture description here

Figure 3.1

There are three buttons "Drag", "Draw" and "Quit" in the above picture. The functions of these three buttons are as follows:
Drag: Drag the button, this function is the default, you can see that there is a cross cursor in the middle of the screen, we can Drag this cursor by touching the screen. One touch point has one cross cursor. For a 5-point capacitive touch screen, if 5 fingers are placed on the screen, there will be 5 cursors, one for each finger.
Draw: draw button, press this button, we can simply draw on the screen, you can use this function to check whether the multi-touch is working properly.
Quit: Exit button to exit the ts_test_mt test software.

Insert picture description here

Guess you like

Origin blog.csdn.net/BeiJingXunWei/article/details/112800663