📄 lcd_touch.c
字号:
// --------------------- compiler condition --------------------------)
/*-------------------------------------------------------------------*/
/* include files */
/*---------------------------------------------------------------- --*/
#include "..\..\com\lpc_lib_lcd_touch_interface\lcd_touch.h"
/*-------------------------------------------------------------------*/
/* local function declare */
/*-------------------------------------------------------------------*/
/*
void disp_x(INT16U x,INT8U y,INT8U col);
void mylcd_touch_jiao();
void conversion_touch_to_lcd(POINT *touch,POINT *lcd);
*/
/*-------------------------------------------------------------------*/
/* variable define */
/*-------------------------------------------------------------------*/
/* An array of perfect input screen points used to obtain a first pass */
/* calibration matrix good enough to collect calibration samples. */
//用于校正的在液晶上的三个点。根据实际情况来定点
POINT perfectScreenSample[3] = {
{ 20,20 },
{ 50, 200 },
{ 300, 50 }
} ;
/* An array of perfect display points used to obtain a first pass */
/* calibration matrix good enough to collect calibration samples. */
//数据采集的那三个点对应的触摸屏的位置
POINT perfectDisplaySample[3] = {
{ 0, 0 },
{ 0, 0 },
{ 0, 0 }
} ;
//转换中要用到的数据
MATRIX matrix={0};
/*-------------------------------------------------------------------*/
/* extern function declare */
/*-------------------------------------------------------------------*/
/*--- define in XXX.c ---
extern void XXX();
*/
/*-------------------------------------------------------------------*/
/* extern variable declare */
/*-------------------------------------------------------------------*/
/*--- USED in XXX() ---
XXX SSS; // used inXXX()
*/
/*-------------------------------------------------------------------*/
/* function code */
/*-------------------------------------------------------------------*/
/*
*********************************************************************
* name : disp_x
* func : 用于显示校正点(x)的图标
* para : x:图标的x轴位置 ,y:图标y轴的位置 ,col:图标的颜色
* modify:
* comment:
*********************************************************************
*/
void disp_x(INT16U x,INT8U y,INT8U col)
{
INT16U x_x;
INT8U x_y;
//画叉的第一画 "\"
x_x=x-jiao_zheng_length/2;
x_y=y+jiao_zheng_length/2;
myposi_piexl_start(x_x,x_y);
x_x=x+jiao_zheng_length/2;
x_y=y-jiao_zheng_length/2;
myposi_piexl_end(x_x,x_y);
myLCD_line(col);
//画叉的第二画 "/"
x_x=x-jiao_zheng_length/2;
x_y=y-jiao_zheng_length/2;
myposi_piexl_start(x_x,x_y);
x_x=x+jiao_zheng_length/2;
x_y=y+jiao_zheng_length/2;
myposi_piexl_end(x_x,x_y);
myLCD_line(col);
}
/*
*********************************************************************
* name : mylcd_touch_jiao
* func : 校正程序
* para : xxxx
* modify:
* comment:bit_jiao 为校正完一个点的标志位,count 为校正的第几个
data 为接收到的数据
*********************************************************************
*/
void mylcd_touch_jiao()
{
INT8U bit_jiao=1,i=0,count=0,over=0;
POINT data,sample[3];
while(1)
{
mycls(jiao_back); //清屏
for(i=0;i<3;i++)
{
disp_x(perfectScreenSample[i].x,perfectScreenSample[i].y,jiao_col); //画十字
}
data=mytouch_get_key();
if(!(data.x==0&&data.y==0)) //接收到有效数据时,保存数据
{
sample[i++]=data;
bit_jiao=1;
count++;
if(count>=3) //校正完三个点后,退出程序
{
over=1;
break;
}
}
//可以在这补一个按钮来退出校正程序
}
if(over)
{
for(i=0;i<3;i++)
perfectDisplaySample[i]=sample[i];
//计算校正程序中用到的 matrix 的值
setCalibrationMatrix(&perfectDisplaySample[0],&perfectScreenSample[0],&matrix);
}
}
/*
*********************************************************************
* name : conversion_touch_to_lcd
* func : 用于触摸屏的坐标转为液晶的坐标
* para : *touch->为要输入触摸屏的坐标点,*lcd->为要输出的液晶的坐标点
* modify:
* comment:
*********************************************************************
*/
void conversion_touch_to_lcd(POINT *touch,POINT *lcd)
{
getDisplayPoint(touch,lcd,&matrix);
}
/*
*********************************************************************
* name : which_rectangle
* func : 看data是否在所在矩形的范围内
* para : 矩形范围为 x_start~x_end y_start~y_end data:为触摸点
的位置
* ret : 触摸点是否在规定位置上
* modify:
* comment:
*********************************************************************
*/
INT8U which_rectangle(Rectangle_rang xy,POINT data)
{
if((data.x<xy.x_end)&&(data.x>xy.x_start)&&(data.y>xy.y_start)&&(data.y<xy.y_end))
{
return 1;
}
else
{
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -