MiniGUI 1.6.10 + tslib touch screen Solution

Source: Internet
Author: User
  • Port tslib1.3
  • Tslib and MiniGUI links
  • Test

Note: Because I recently used a PDA to implement camera functions, while my Development Board, mini2440, has only one USB, and my camera is USB, And the mouse is useless. I can only use a touch pen, the Touch coordinates are very inaccurate. First, I thought of tslib used in QT. I looked for it online and found the MiniGUI + tslib touch screen solution. After several days of experiments, I used tslib and smdk2410 on v1.6.0 to achieve a positive touch screen, and on v1.6.10, I used tslib + dummy as the ial to achieve a positive touch screen. This article first summarizes the MiniGUI v1.6.10 + tslib perfect touch screen comparison solution. Because 2410.c, 2410 is not released in libminigui. H and so on. The previous version has some, so it is difficult to use smdk2410 as the ial. If I have failed my experiment and don't want to do it, use dummy + tslib. The detailed steps are as follows: hardware environment: Host: x86pc target: friendly arm mini2440 development board software environment: Host: RedHat Linux 9.0 (fully installed) target under vmwarevm: arm-Linux kernel: linux-2.6.13 crosstool: arm-linux-gcc-3.4.1

Port tslib1.3

(1) Step 1: Download source codeand decompress tslib-1.3.tar.bz2. : Http://download.csdn.net/source/673898

(2) Step 2: modify the configuration information for the underlying driver

 

. /Autogen. sh // (this step will produce the configure file ). /configure cc = arm-Linux-GCC -- Build = i686-pc-linux -- target = arm-Linux -- Host = arm-Linux -- prefix =/home/huangsihua/tslib/build -- enable-inputapi = No

The last one -- enable-inputapi = No is because the driver does not support the ioctl operation. If you do not change it, the following occurs: I run it on the board. /ts_test always prompts me: ts_open: no such file or directory?

(3) Step 3: Modify the source code. 1. Find rpath in/tslib/plugins/makefile.

Set

 

LDFLAGS :=$(LDFLAGS) -rpath $(PLUGIN_DIR)

To:

 

Ldflags: = $ (ldflags)-rpath 'CD $ (plugin_dir) & pwd' // (this is a comma)

 

Otherwise, make will report the following error:

Libtool: Link: only absolute run-paths are allowed when making

2. Modify

 

char *defaulttseventtype="UCB1x00";

Change

Char * defaulttseventtype = "h3600"; // because my touch screen driver corresponds to this structure.

3. modify some code in the getxy function of tests/ts_calibrate.c in tslib source code. As follows:

 

Static int getxy (struct tsdev * ts, int * X, int * Y) {....................................... ........................................ ........................................ ............. // modified code/* read until we get a touch. */do {If (ts_read_raw (TS, & SAMP [0], 1) <0) {perror ("ts_read"); close_framebuffer (); exit (1 );}} while (SAMP [0]. pressure> 0); do {If (ts_read_raw (TS, & SAMP [0], 1) <0) {perror ("ts_read"); close_framebuffer (); exit (1) ;}while (SAMP [0]. pressure = 0); printf ("took % d samples... /n ", index );..................................... ........................................ ........................................ ...............}

I found that tslib and MiniGUI have the opposite requirements for pressure parameters. tslib stipulates SAMP [0]. pressure> 0 is press, SAMP [0]. pressure = 0 is the release of the hand, but the fact is the opposite, if not changed, it will appear in the operation. the/ts_calibrate program cannot be effectively calibrated. Please pay attention to this !!!!!!!!!!!!!!!

4. modify the code in the mousebuts_read function of tslib/plugins/mousebuts. C.

 

//if(t>60)//{//dest->pressure=1000;//buts->fLeftBut=0;//}//else//{dest->pressure=0;buts->fLeftBut=2;//}

Comment out the red part. Otherwise, if you click a button during the subsequent MiniGUI operation, when you move the cursor over the button, it will trigger the button clicking events continuously. This is of course not the result we want.

(4) Compilation and Installation

 

makemake install

After installation steps, go .... The/tslib/build directory contains the following folders: Bin, etc, share, Lib, and include.

 

# ls bin/ts_calibrate ts_print ts_test ts_print_raw

 

 

# ls etc/ts.conf 

The recommended configuration here is (I just used this configuration, the effect is good ):

 

module mousebuts#module variance xlimit=20 ylimit=20 pthreshold=3#module dejitter xdelta=20 ydelta=20 pthreshold=3module linear

If the jitter is found to be severe during actual operation, you can use the following Configuration:

 

module mousebuts#module variance xlimit=20 ylimit=20 pthreshold=3module dejitter xdelta=20 ydelta=20 pthreshold=3module linear

 

# ls lib/libts-0.0.so.0 libts-0.0.so.0.1.0 libts.la libts.so

 

# ls share/ts/plugins/

Copy lib and include content to/usr/local/ARM/3.4.1/ARM-Linux/[Lib, include. At the same time, create a directory tslib under/opt/friendlyarm/mini2440/root_nfs

 

mkdir tslib

Host ..... Copy the five folders under/tslib/build/to this directory and then install tslib.

 

Tslib and MiniGUI links

After cross-Compiling of tslib, the next step is to rewrite the ial engine of MiniGUI. The built-in ial input engine of MiniGUI contains dummy. C. In order to be as simple as possible, here we will make some modifications on the basis of the simplicity to make it meet our requirements.

 

#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <fcntl.h>#include "common.h"#include "tslib.h"#ifdef _DUMMY_IAL#include <sys/ioctl.h>#include <sys/poll.h>#include <sys/types.h>#include <sys/stat.h>#include <linux/kd.h>#include "ial.h"#include "dummy.h"#ifndef _DEBUG#define _DEBUG                    // for debugging#endif/* for storing data reading from /dev/touchScreen/0raw */typedef struct {        unsigned short pressure;        unsigned short x;        unsigned short y;        unsigned short pad;} TS_EVENT;static unsigned char state [NR_KEYS];static int mousex = 0;static int mousey = 0;static TS_EVENT ts_event;static struct tsdev *ts;/************************ Low Level Input Operations **********************//** Mouse operations -- Event*/static int mouse_update(void){        return 1;}static void mouse_getxy(int *x, int* y){        if (mousex < 0) mousex = 0;        if (mousey < 0) mousey = 0;        if (mousex > 639) mousex = 639;        if (mousey > 479) mousey = 479;        #ifdef _DEBUG        // printf ("mousex = %d, mousey = %d/n", mousex, mousey);        #endif        *x = mousex;        *y = mousey;}static int mouse_getbutton(void){        return ts_event.pressure;}#ifdef _LITE_VERSIONstatic int wait_event (int which, int maxfd, fd_set *in, fd_set *out, fd_set *except,                        struct timeval *timeout)#elsestatic int wait_event (int which, fd_set *in, fd_set *out, fd_set *except,struct timeval *timeout)#endif{        struct ts_sample sample;        int ret = 0;        int fd;        fd_set rfds;        int e;        if (!in) {                in = &rfds;                FD_ZERO (in);        }        fd = ts_fd(ts);        if ((which & IAL_MOUSEEVENT) && fd >= 0) {                FD_SET (fd, in);                #ifdef _LITE_VERSION                if (fd > maxfd) maxfd = fd;                #endif        }        #ifdef _LITE_VERSION        e = select (maxfd + 1, in, out, except, timeout) ;        #else        e = select (FD_SETSIZE, in, out, except, timeout) ;        #endif        if (e > 0) {                // input events is coming                if (fd > 0 && FD_ISSET (fd, in)) {                        FD_CLR (fd, in);                        ts_event.x=0;                        ts_event.y=0;                        ret = ts_read(ts, &sample, 1);                        if (ret < 0) {                                perror("ts_read()");                                exit(-1);                        }                        ts_event.x = sample.x;                        ts_event.y = sample.y;                        ts_event.pressure = (sample.pressure > 0 ? 4:0);                        //   if (ts_event.pressure > 0 &&                        if((ts_event.x >= 0 && ts_event.x <= 639) &&                        (ts_event.y >= 0 && ts_event.y <= 479)) {                                mousex = ts_event.x;                                mousey = ts_event.y;                                // printf("ts_event.x is %d, ts_event.y is %d------------------------------------->/n",ts_event.x ,ts_event.y);                        }                        //#ifdef _DEBUG                        //    if (ts_event.pressure > 0) {                        //  printf ("mouse down: ts_event.x = %d, ts_event.y = %d,ts_event.pressure = %d/n",ts_event.x,ts_event.y,ts_event.pressure);                        //   }                        //#endif                        ret |= IAL_MOUSEEVENT;                        return (ret);                }        }        else if (e < 0) {                return -1;        }        return (ret);}BOOL InitDummyInput(INPUT* input, const char* mdev, const char* mtype){        char *ts_device = NULL;        if ((ts_device = getenv("TSLIB_TSDEVICE")) != NULL) {                // open touch screen event device in blocking mode                ts = ts_open(ts_device, 0);        } else {                #ifdef USE_INPUT_API                ts = ts_open("/dev/input/0raw", 0);                #else                ts = ts_open("/dev/touchscreen/ucb1x00", 0);                #endif        }        #ifdef _DEBUG        printf ("TSLIB_TSDEVICE is open!!!!!!!!!!!/n");        #endif        if (!ts) {                perror("ts_open()");                exit(-1);        }        if (ts_config(ts)) {                perror("ts_config()");                exit(-1);        }        input->update_mouse = mouse_update;        input->get_mouse_xy = mouse_getxy;        input->set_mouse_xy = NULL;        input->get_mouse_button = mouse_getbutton;        input->set_mouse_range = NULL;        input->wait_event = wait_event;        mousex = 0;        mousey = 0;        ts_event.x = ts_event.y = ts_event.pressure = 0;        return TRUE;}void TermDummyInput(void){        if (ts)        ts_close(ts);}#endif /* _DUMMY_IAL */

After modifying the engine file of MiniGUI, you can re-compile the MiniGUI, because the tslib library is used, therefore, you must tell MiniGUI where to find the header file and shared library file related to tslib during compilation. The procedure is as follows:

 

[root@libminigui-1.6.10]# ./configure CC=arm-linux-gcc --build=i686-pc-linux --target=arm-linux --host=arm-linux --disable-galqvfb --disable-galecoslcd --disable-vbfsupport --prefix=/usr/local/arm/3.4.1/arm-linux CFLAGS="-I/usr/local/arm/3.4.1/arm-linux/include -L/usr/local/arm/3.4.1/arm-linux/lib -lts"[root@ libminigui-1.6.10]# make[root@ libminigui-1.6.10]# make install

Here we will explain why the cflags should be specified. In fact, specifying this flag tells the compiler where to find the header file and shared file related to tslib, -lts indicates that the shared library file of the MiniGUI generated by the linker is connected to the TS Library (TS is the abbreviation of touchscreen. Copy the generated MiniGUI library from/usr/local/ARM/3.4.1/ARM-Linux/lib to/opt/friendlyarm/mini2440/root_nfs/lib.

[Root] # cp/usr/local/ARM/3.4.1/ARM-Linux/etc/MiniGUI. CFG/home/FP/nfs/usr/local/etc/remember to keep the directory structure unchanged and modify MiniGUI. CFG, as shown below

 

[System] # ial engineial_engine = dummy // here, I am using a touch screen, so dummy won't be wrong. mdev =/dev/input/ts0 // touch screen mtype = none [fbcon] defaultmode = 240x320-16bpp // you can set it based on your LCD size, if the setting is incorrect, the MiniGUI cannot be started.

In this way, we can link tslib and MiniGUI through dummy.

 

Test

Recompile the PDA program I modified and copied it and the res file to/opt/freindlyarm/mini2440/root_nfs/usr/local/. Open the Super Terminal and open the Development Board, press enter to enter Vivi and enter the nfs startup command:

 

param set linux_cmd_line "console=ttySAC0 root=/dev/nfs nfsroot=192.168.1.111:/opt/FriendlyARM/root_nfs ip=192.168.1.70:192.168.1.111:192.168.1.111:255.255.255.0:sbc2440.arm9.net:eth0:off"

At the same time, enter the extension command on the terminal:

 

export QWS_MOUSE_PROTO=TPanel:/dev/input/event0export V_ROOT=/tslib#export TSLIB_TSEVENTTYPE=H3600export TSLIB_CONSOLEDEVICE=noneexport TSLIB_FBDEVICE=/dev/fb0export TSLIB_TSDEVICE=/dev/input/event0export TSLIB_CALIBFILE=$V_ROOT/etc/pointercalexport TSLIB_CONFFILE=$V_ROOT/etc/ts.confexport TSLIB_PLUGINDIR=$V_ROOT/share/ts/pluginsexport LD_LIBRARY_PATH=$V_ROOT/lib:$LD_LIBRARY_PATH

Of course, you can also add this string to the profile file so that the Development Board can run these commands at startup. Finally, run./PDA in the directory where the program is located. The results are very good and perfect. A little long. MiniGUI v1.6.10 + tslib touch screen is a perfect solution. You are welcome to provide comments and better solutions.

Email: huangsihua@hqu.edu.cn

My csdn blog http://blog.csdn.net/huangsihua

Reference: myleeming csdn blog MiniGUI + tslib compilation process

 

 

-- Siw.huang-17 Mar 2009

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.