📄 gui_x_touch.c
字号:
#include "..\APP\includes.h"
unsigned short int X,Y;
void GUI_TOUCH_X_ActivateX(void) {
}
void GUI_TOUCH_X_ActivateY(void) {
}
int GUI_TOUCH_X_MeasureX(void)
{
unsigned char t=0,t1,count=0;
unsigned short int databuffer[10]={5,7,9,3,2,6,4,0,3,1};//数据组
unsigned short temp=0,X=0;
while(/*GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0)==0&&*/count<10)//循环读数10次
{
databuffer[count]=TPReadX();
count++;
}
if(count==10)//一定要读到10次数据,否则丢弃
{
do//将数据X升序排列
{
t1=0;
for(t=0;t<count-1;t++)
{
if(databuffer[t]>databuffer[t+1])//升序排列
{
temp=databuffer[t+1];
databuffer[t+1]=databuffer[t];
databuffer[t]=temp;
t1=1;
}
}
}while(t1);
X=(databuffer[3]+databuffer[4]+databuffer[5])/3;
}
return(X);
}
int GUI_TOUCH_X_MeasureY(void) {
unsigned char t=0,t1,count=0;
unsigned short int databuffer[10]={5,7,9,3,2,6,4,0,3,1};//数据组
unsigned short temp=0,Y=0;
while(/*GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_0)==0&&*/count<10) //循环读数10次
{
databuffer[count]=TPReadY();
count++;
}
if(count==10)//一定要读到10次数据,否则丢弃
{
do//将数据X升序排列
{
t1=0;
for(t=0;t<count-1;t++)
{
if(databuffer[t]>databuffer[t+1])//升序排列
{
temp=databuffer[t+1];
databuffer[t+1]=databuffer[t];
databuffer[t]=temp;
t1=1;
}
}
}while(t1);
Y=(databuffer[3]+databuffer[4]+databuffer[5])/3;
}
return(Y);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -