test_ads7843_new.c

来自「xscale pxa255 处理器」· C语言 代码 · 共 50 行

C
50
字号
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types>
#include <sys/stat.h>
#include <fcntl.h>

int ts_fd;

static char *dev_name="/dev/ads7843";

typedef struct{
	short pressure;
	short x;
	short y;
	short millisecs;
} TS_EVENT;

int main(int argc, char **argv)
{
	TS_EVENT data;
	short x_pos, y_pos;
	
	
	ts_fd=open(dev_name ,O_RDONLY);
	
	if(!(ts_fd>=0))
		{
			printf("%s file open failed\n",dev_name);
			exit(-1);
		}
		printf("\n test_ads7843_touchscreen: press the touchscreen and see the position  - Exit Ctrl C \n",dev_name);

		 while (1)
		  {
			 
				read(ts_fd, &data,sizeof(data));
			  x_pos=data.x;
			  y_pos=data.y;

			
					printf("the x position is %d ,y position is %d\n", data[1],data[2]);
		  }
		
			close(fd);
			return 0;
}
			  
		    
			

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?