Tslib arm 6410 開發板的移植(帶源碼)

Tslib arm 6410 開發板的移植(帶源碼)

 

Tslib是一個開源的程序,能夠爲觸摸屏驅動獲得的採樣提供諸如濾波、去抖、校準等功能,通常作爲觸摸屏驅動的適配層,爲上層的應用提供了一個統一的接口。

1.       首先在網上下載 tslib-1.4.tar..gz ;

2.       用命令 tar xvf tslib-1.4.tar.gz 解壓到當前文件夾中

3.       ls 可以看到很多文件直接運行 ./autogen.sh

4.       ls 可以看到已經生成了 configure文件

5.       直接 ./configure –host=arm-linux –prefix=/usr/test  ac_cv_func_malloc_0_nonnull = yes –enable-inputapi =no

6.       ls 可以看出已經生成了 make

7.       然後直接make makeinstall 就生成了 arm tslib庫,在usr/test下你可以找到 include lib 等文件夾,lib下就是你需要的庫。

 

 

/**********************************************************************

 

源碼  此代碼僅供測試

編譯方法 arm-linux-gcc test.c –o test –I/usr/test/include –L/usr/test/lib -lts

**********************************************************************/

 

#include <stdio.h>

#include <stdlib.h>

#include "tslib.h"

 

#define DEV_NAME "/dev/event1"    //觸摸屏設備

 

int getTsXY()

{    

       struct tsdev *ts;

       struct ts_sample sample;

       int ret;

       ts = ts_open(DEV_NAME, 0);

       if(!ts)

       {

              perror("Open error!\n");

              exit(1);

       }

       if(ts_config(ts))

       {

              perror("ts_config\n");

              exit(1);

       }

 

       while(1)

       {

              ret = ts_read(ts , &sample, 1);

              if (ret < 0)

              {

                     perror("ts_read");

                     exit(1);

              }

              printf("x = %d\ty = %d\t press = %u\n",sample.x,sample.y,sample.pressure);

       }

       ts_close(ts);

       return 0;

}

int main(int argc,char **argv)

{    

       getTsXY();

       return 0;

}

 

                                                                                    Write by :       douyuan888

                                                                                                         2013/4/4

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章