The touch screen is widely used in embedded devices, but the coordinates of the touchscreen and the coordinates of the screen are asymmetrical and need to be calibrated. Calibration is widely used by open source tslib.
Tslib is an open source program that provides touch-screen driven sampling with functions such as filtering, dithering, and calibration, often as a touchscreen-driven adaptation layer, providing a unified interface for upper-level applications.
1.TslibTool cross-compilation and installation
To compile the tslib-1.4.tar.gz steps:
# tar ZXVF tslib-1.4.tar.gz
# CD Tslib
# Export Path=/opt/gcc-3.4.6/bin: $PATH
#./autogen.sh
#./configure--host=mipsel-linux--prefix=/tslib
# make
# make Install
Note: The above steps are performed using root user rights
The folders generated under the/tslib directory are the toolkits that need to be ported.
A)problems and workarounds that you may encounter (Ubuntusystem)
Here are some of the problems and workarounds I encountered during the porting of the Tslib tool:
problem1.Execute./autogen.sh Tips
./autogen.sh:4: Autoreconf:not found
Workaround:
Without the Automake tool installed,
(Ubuntu 10.04) install with the following command:
sudo apt-get install autoconf automake libtool
problem2.An error message appears after you execute the./autogen.sh:
Libtoolize: ' configure.in ' does not exist
Try ' Libtoolize--help ' for more information.
Autoreconf:libtoolize failed with exit Status:1
Workaround:
#whereis libtoolize
Libtoolize:/usr/bin/libtoolize/usr/local/bin/libtoolize
The error message was found to be due to the two ilbtoolize toolchain installed in the system. The problem is resolved after the/usr/local/bin/libtoolize is removed (the problem persists after the/usr/bin/libtoolize is removed).
problem3.Execution./autogen.sh An error message appears:
/autogen.sh:4: Autoreconf:not found
Workaround:
Install the autoconf kit.
problem4.Error message after you perform make: ".../usr/local" is a directory .....
Workaround: This problem occurs because the tool chain is not found when the system compiles because the environment variable is configured. This issue is resolved after you open a new window, reconfigure environment variables, and then compile.
problem5.An error message occurs after you perform make:
ts_test.o:in function ' main ':
TS_TEST.C: (. text+0x3b4): Undefined reference to ' Rpl_malloc '
fbutils.o:in function ' Open_framebuffer ':
FBUTILS.C: (. text+0x2f8): Undefined reference to ' Rpl_malloc '
Collect2:ld returned 1 exit status
Workaround:
After executing #./configure--host=mipsel-linux--prefix=/tslib, the "#define malloc rpl_malloc malloc" is commented out in Config.h and compiled.
problem6.An error message occurs after you perform make:
In function ' open ',
inlined from ' main ' at ts_calibrate.c:227:
/usr/include/bits/fcntl2.h:51:error:call to ' __open_missing_mode ' declared with attribute error:open with O_CREAT in SE Cond argument needs 3 arguments
In function ' open ',
inlined from ' main ' at ts_calibrate.c:229:
/usr/include/bits/fcntl2.h:51:error:call to ' __open_missing_mode ' declared with attribute error:open with O_CREAT in SE Cond argument needs 3 arguments
Workaround:
sudo vim/home/loongson/workspace/tslib/tests/ts_calibrate.c +227 will cal_fd = open (Calfile, O_creat | O_RDWR); instead
CAL_FD = open (Calfile, O_creat | o_rdwr,0666);
229 rows
CAL_FD = open ("/etc/pointercal", O_creat | O_RDWR);
Change to CAL_FD = open ("/etc/pointercal", O_creat | o_rdwr,0666);
B)problems and workarounds that you may encounter (2Fsystem):
Question 1. An error message appears after you execute the./autogen.sh:
configure.ac:25:error:possibly undefined macro:ac_disable_static
If this token and others is legitimate,please use M4_pattern_allow.
See the Autoconf documentation.
configure.ac:26:error:possibly undefined macro:ac_enable_shared
configure.ac:27:error:possibly undefined Macro:ac_libtool_dlopen
configure.ac:28:error:possibly undefined Macro:ac_prog_libtool
Workaround: Reinstall the Libtool to/usr directory.
2.Tslibporting
The Tslib migration steps are as follows:
1. Copy the installation directory tslib to the root directory of the file system.
2. Create an empty calibration file in file system/etc pointercal (this step can be omitted). After the ts_calibrate is executed and calibrated, the calibration data is stored in the file (the file system needs to be writable, if the Cramfs file system can refer to note 1).
3. Modify the tslib/etc/ts.conf file to open Module_raw input. (Note: There can be no spaces before Module_raw Inut, refer to question 2)
4. Make a run script run.sh with the following:
(Note: Configuration of the following environment variables can also be written under the file system's/etc/profile file)[CPP]View Plaincopyprint?
- #!/bin/sh
- Export Tslib_root=/tslib
- Export ld_library_path= $TSLIB _root/lib: $LD _library_path
- Export Tslib_consoledevice=none
- Export Tslib_fbdevice=/dev/fb0//frambuffer Device node
- Export TSLIB_TSDEVICE=/DEV/EVENT0//Touch Screen device node
- Export Tslib_tseventtype=input
- Export tslib_calibfile=/etc/pointercal//calibration file
- Export tslib_conffile=/tslib/etc/ts.conf//dynamic library loaded configuration file
- Export tslib_plugindir=/tslib/lib/ts//Dynamic Library Path
- Cd/tslib/bin
- ./ts_calibrate//Running the calibration program
(Note: If you need to use Tslib in a graphical interface such as QT or SDL, additional environment variables should be configured, not described here)
5. Write the file system and the touch-screen driven kernel to the target board, and the calibration interface can be seen by powering up the run.sh. After pressing the screen cursor for 5 times, the program generates a pointercal coordinate calibration file in/etc (the/etc directory must be writable).
6. After the correction is complete, you can perform/tslib/bin/ts_print to see if the output coordinates are correct.
possible problems and workarounds
Here are the problems and workarounds that I encountered when I ran the Tslib tool:
problem1.Error running run.sh, prompting "Ts_open:no such file or directory"
Workaround:
This error is caused by a number of cases, the touch screen correction program will first open the touch screen device node, LOONGSON-1B Development Board of the touchscreen device node corresponding to/dev/event0, to see if the system environment variables are configured correctly, view/dev/ Whether there is a touch screen device node event0 in the directory.
problem2.Appears: no RAW modules load
Tsconfig:no such file or directory
Workaround:
/tslib/etc/ts_conf file may have a space before the statement Modle_raw input, remove the space.
problem3.Failure to load module when using Tslib in conjunction with graphical interface
Workaround:
such as Tslib reading the contact coordinates of the example program ts_pirnt, load h3600.so, pthres.so 、... The Dlopen () function is used to open the module, and in the case of/tslib/etc/ts_conf configuration without errors, the error of the load module may be that the compiler did not compile the Libts library together, causing the program to use Dlopen () An error occurred while opening the. so file.
Notes
If the file system is not writable, the program cannot create the pointercal calibration file in the file system's/etc/directory. The general root file System/tmp directory is set to RAMFS type, the folder is writable; In the root file system, in the/etc directory, create an empty link file named Pointercal, as follows:
#cd/etc
#ln –s. /tmp/pointercal pointercal
This will generate a calibration file pointercal in the/tmp directory after the calibration procedure is executed.
3.tslibts_calibrateCalibration Principle
Tslib is the adaptation layer between the touch screen driver and the application layer, which obtains the original device coordinate data from the touch screen drive, through a series of denoising, shaking, coordinate transformation and other operations, to remove noise and convert the original device coordinates to the corresponding screen coordinates. Tslib provides 2 main interfaces for the application Layer Ts_open (), Ts_close (), Ts_read () and Ts_read_raw (), where Ts_read () reads the corrected relative coordinate data, Ts_read_raw () The actual coordinates before reading the correction.
As can be seen from the tslib default ts.conf file, the process of tslib from the touch screen driver sampling to the device coordinates provided to the application side is as follows:
Raw device--variance--dejitter---linear application
Module Module Module module
In the case of calibration, the general process of tslib the data to be sampled by the driver is as follows:
1. Read the coordinates of the 5 points on the screen (Top left,top right,bottom left,bottom right,center), in a series of transformations, sampling 5 points, actually contains 3 different x values, 3 different y values. and a scaling value of 7 values, saved together into/etc/pointercal.
2. This/etc/pointercal file is intended for use by linear plugins. And every time we touch the operation, we make multiple touch coordinate transformations.
4.Tslibconfiguration filets.confIntroduction
Tslib configuration file ts.conf is also a very important part, in the ts.conf configuration of the plug-ins to be loaded, plug-in loading order, and some of the plug-in constraints, these configuration parameters on the touch screen touchscreen effect has a very important impact.
Wherein: Pthres for the tslib to provide the touch screen sensitivity threshold plug-in default parameter is pmin=1;
Variance for Tslib provides a touch screen filtering algorithm plug-in default parameter is delta=30;
Dejitter provides the tslib for the touchscreen denoising algorithm plug-in default parameter is delta=100;
Linear provides a touch screen coordinate transformation plugin for tslib.
Due to the influence of various factors, the relevant parameters may need to be adjusted on different hardware platforms. The correlation of the above parameters is: the larger the sampling interval, the less sampling points, the more distorted sampling, but because of less information, prone to loss of pen strokes, such as the situation, but the performance of the graphic effect will be better; the denoising algorithm should interact closely with the sampling interval, the larger the sampling interval, the smaller the sampling interval, The greater the de-noising constraint should be. To the relative independence of the jitter algorithm, the more complex the jitter algorithm, the resulting computational capacity will become larger, the system load will become heavier, but a good shake-out algorithm can be better to remove dithering, in the graphic drawing will be better effect; sensitivity and TS thresholds are sensitive indicators of the touchscreen, and generally do not need to be changed, Refer to the reference value.
Transferred from: HTTP://FORUM.EEPW.COM.CN/THREAD/267828/1
Tslib steps and solutions to problems (GO)