arm9 6410 tslib触屏小程序
#include <stdio.h>
#include <stdlib.h>
#include "tslib.h"
#include "Event.h"
#define DEV_NAME "/dev/event1"??? //瑙︽懜灞忚澶?
int a[2];
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);
??? }
?? int i=0;
?? while(1)
??? {
??????? ret = ts_read(ts , &sample, 1);
??????? if (ret < 0)
????????? {
??????????? perror("ts_read");
?? ???exit(1);
?? }
??
??if(sample.pressure == 1)
??? ?{
??????
??????? ?
????? ?? a[0]=sample.x;
????? ?? a[1]=sample.y;
????? ?? //ts_close(ts);
????? ?? i++;
?? ? ?}
??if(i>0&&sample.pressure == 0)
??{? printf("x = %d\ty = %d\t press = %u\n",sample.x,sample.y,sample.pressure);
??ts_close(ts);
??return a;
??}
?}
???? return 0;
}
?
轉載于:https://blog.51cto.com/4623233/861203
總結
以上是生活随笔為你收集整理的arm9 6410 tslib触屏小程序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux Shell学习(3)
- 下一篇: 20120511学习笔记