main.c

来自「一个基于ARM平台的触摸屏程序。」· C语言 代码 · 共 58 行

C
58
字号
#include "key.h" 
#include "system.h"
#include "LCD.h"
#include "serial.h"
#include "timer.h"

	int VRAM_column;
	int VRAM_page;	
	volatile char key_up_flag;	/* 	1 - key release
									0 - key not release
								 */
	volatile unsigned int x1, x2, y1, y2;
	pen_pos_t	pen_pos;		/* the touch screen points corresponding 
									to the reference display points. 		*/
	MATRIX		CAL_MAX;		/* the calibration matrix computed 
									for the set of points being provided. 	*/
	POINT		TRUE_POINT;		/* the calculated (true) display point. 	*/
	extern volatile int gb_count;
	extern unsigned char buff[MAIN_LCD_WIDTH*MAIN_LCD_HEIGHT*3];

void demo()
{

	int i,j, cnt;
	char cNumberCount;
	unsigned int  sub_x, sub_y;

	printf("start\n");

	LCD_Initial();
	memset(buff, 0xff, MAIN_LCD_WIDTH*MAIN_LCD_HEIGHT*3);
	seDrawRect(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1, buff);
		
	x1 = x2 = y1 = y2 = kbNULL;
	key_up_flag = 1;
	init_tch_screen();
	i = scr_calibrate();
	if (i == OK)
		printf("calibrate ok\n");
	else
		printf("calibrate fail\n");
	gb_count = 0;
	pen_pos.x = pen_pos.y = NO_PEN_PRESS;
	while(1)
	{
		//vDelay(100);
		for (i=0; i<100; i++);
		if (pen_pos.x != NO_PEN_PRESS)
		{
			getDisplayPoint(&TRUE_POINT, &pen_pos, &CAL_MAX);
			printf("lcd position: x=%d, y=%d; \n", TRUE_POINT.x, TRUE_POINT.y);
			memset(buff, 0xff, MAIN_LCD_WIDTH*MAIN_LCD_HEIGHT*3);
			b_circle(TRUE_POINT.x, TRUE_POINT.y, 20, 0xFF0000, buff);
			seDrawRect(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1, buff);			
			pen_pos.x = pen_pos.y = NO_PEN_PRESS;	
		}
	}	
}

⌨️ 快捷键说明

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