2010年3月7日 星期日

tslib Touch Screen

tslib Touch Screen

This is a very popular library, almost every small device test board use it to navigating on a touch screen with an GUI applications.

It can be download in tslib.

As usual, unzip the file and configure it first.

autogen.sh
echo ac_cv_func_malloc_0_nonnull=yes >config.cache
./configure --host=arm-linux --prefix=/usr --sysconfdir=/etc --libdir=/lib --datadir=/usr/share



Compile the source and install package to a temporary directory, this is to avoid overwrite any files and examine what files are install.

make
mkdir /install
make install DESTDIR=/install/tslib-1.0



Three main directories etc, lib and usr are created.

Copy all the files to our root filesystem.

cd /rootfs/lib
cp /install/tslib-1.0/lib/* .
cd ../usr
cp -a /install/tslib-1.0/usr/include .
mkdir -p local/bin
cp /install/tslib-1.0/usr/bin/* ./local/bin
cd ../etc
cp /install/tslib-1.0/etc/ts.conf .



Modify the ts.conf configuration file, to uncommend the 'module_raw input' line, the contents show as below.

module_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear

Next, create a directory /etc/profile.d and make a shell script tslib.sh to setup the tslib environment variable settings.

export TSLIB_TSDEVICE=/dev/input/event1
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/lib/ts
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_CONSOLEDEVICE=none


Add job process to the system profile so that it will automatically export the settings while start up the system.

Edit the /etc/profile to append instructions below to look at the profile.d directory and run the script.

# auto shell script startup process
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i


Also, make sure to append the new /usr/local/bin directory to the search system PATH.

PATH=$PATH:/usr/local/bin


At last, change the libtool library file and pkgconfig file.

Go to /rootfs/lib change the tslib.la libdir option to '/rootfs/lib' becuase the actual location of this library is in our root filesystem.

Same goes to directory /rootfs/lib/ts for all the '.la' files (input.la is important)

One more, the tslib-0.0.pc pkgconfig file in /rootfs/pkgconfig, change the include and library reference directory show as below.

prefix=/rootfs
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/usr/include

Name: tslib
Description: Touchscreen Access Library
Version: 0.0.2
Libs: -L${libdir} -lts
Cflags: -I${includedir}


Restart the board to test the setup library.

First, use the calibrate utility to initialize and adjust the drawing boundary, it will show a crosshair on screen, touch it with a pen to finish the procedure.

ts_calibrate


Start the test program, touch on the 'Draw' box and drawing on screen is now enable.

ts_test


3 則留言:

  1. Hello,
    I am able to run ts_*. But I am getting wrong calibration values. wats the problem. Please help me...

    回覆刪除
  2. Hi
    Its very nice post.
    I am able to get touchscreen work.
    My requirement is to get a click/beep sound on every press
    on touch screen.
    Are there any way to do this?
    Your suggestions will be helpful to me a lot.
    thanks,
    -Nagesh A

    回覆刪除
  3. Hi. I followed your tutorial step by step. After I rebooting and running the calibration utility, the touch screen did not work and now whenever I boot, I see the calibration screen. Is there a way to bypass the screen and enter the OS?

    回覆刪除