void Touch_UpIngEvent()
{
if(Touch_Event.UpIng_Event)
{
DeBug("TOUCH_EVENT_UPING",Infor_Infor);
Touch_Event.UpIng_Event=Null;
}
}
void Touch_DownIngEvent()
{
if(Touch_Event.DownIng_Event)
{
DeBug("TOUCH_EVENT_DOWNING",Infor_Infor);
Touch_Event.DownIng_Event=Null;
}
}
void Touch_UpDelayEvent()
{
if(Touch_Event.Up_Event)
{
DeBug("TOUCH_EVENT_UP",Infor_Infor);
Touch_Event.Up_Event=Null;
}
}
void Touch_DownDelayEvent()
{
if(Touch_Event.Down_Event)
{
DeBug("TOUCH_EVENT_DOWN",Infor_Infor);
Touch_Event.Down_Event=Null;
}
}
void Task_GetTouch(void *Tags)
{
uint32 Temp_ADC1,Temp_ADC2,Temp_ADC11;
TGUI_TouchMsg TouchMsg;
TOUCH_Tos_TaskID=Tos_TaskCurrent;
ADC_WatchdogConfig();
while(1)
{
Tos_TaskDelay(30);
Touch_ADCX_Config();
Tos_TaskDelay(10);
Temp_ADC11=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][1],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize);
if(Temp_ADC11>100)
{
Tos_TaskDelay(10);
Temp_ADC1=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][1],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize);
Touch_ADCY_Config();
Tos_TaskDelay(10);
Temp_ADC2=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][0],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize);
if(__fabs(Temp_ADC11-Temp_ADC1)<20&Temp_ADC2>400)//消抖
{
TOUCH_ADC_YValue=Temp_ADC2;
TOUCH_ADC_XValue=Temp_ADC1;
if(Touch_Update==TOUCH_DOWNING){Touch_Update=TOUCH_DOWN;}
if(Touch_Update!=TOUCH_DOWN)
{
Touch_Update=TOUCH_DOWNING;
Touch_Event.DownIng_Event=Touch_DownIngEvent;//事件测试
Touch_Event.Down_Event=Touch_DownDelayEvent;//事件测试
if(Touch_Event.DownIng_Event)Touch_Event.DownIng_Event();//当存在按下事件时触发
Touch_Event.UpIng_Event=Touch_UpIngEvent;//事件测试
Touch_Event.DownDelay_Count=0;
}
if(Touch_Update==TOUCH_DOWN)
{
if(Touch_Event.DownDelay_Count
{
Touch_Event.DownDelay_Count++;
}else if(Touch_Event.Down_Event)Touch_Event.Down_Event();//当存在持续按下事件时触发
}
TOUCH_XValue=Opera_WhithADC(TOUCH_ADC_XValue,TOUCH_CROSS_DATA[0][0],TOUCH_CROSS_ADDR[0][0],TOUCH_CROSS_DATA[1][0],TOUCH_CROSS_ADDR[1][0],LCD_XMAX);
TOUCH_YValue=Opera_WhithADC(TOUCH_ADC_YValue,TOUCH_CROSS_DATA[0][1],TOUCH_CROSS_ADDR[0][1],TOUCH_CROSS_DATA[3][1],TOUCH_CROSS_ADDR[3][1],LCD_YMAX);
DeBug("X=%d Y=%d",TOUCH_ADC_XValue,TOUCH_ADC_YValue,Infor_Infor);
TouchMsg.TouchValueX=TOUCH_XValue;
TouchMsg.TouchValueY=TOUCH_YValue;
TouchMsg.TouchType=Touch_Update;
TouchMsg.TouchTime=0;
if(Touch_Update==TOUCH_DOWN)TouchMsg.TouchTime=Touch_Event.DownDelay_Count;
if(Touch_Update==TOUCH_UP)TouchMsg.TouchTime=Touch_Event.UpDelay_Count;
Tos_TaskPutQmsg(Touch_Screen_UserTaskID,TGUI_MsgType_TouchScreen,sizeof(TGUI_TouchMsg),&TouchMsg);
}
}else
{
if(Touch_Update==TOUCH_UPING){Touch_Update=TOUCH_UP;}
if(Touch_Update!=TOUCH_UP)//触摸屏第一次按下触发
{
Touch_Update=TOUCH_UPING;
if(Touch_Event.UpIng_Event)Touch_Event.UpIng_Event();//当存在放下动作时触发
Touch_Event.UpDelay_Count=0;//按下第一次时清除按下时间计数
Touch_Event.Up_Event=Touch_UpDelayEvent;//事件测试
}
if(Touch_Update==TOUCH_UP)//触摸屏一直按下
{
if(Touch_Event.UpDelay_Count
{
Touch_Event.UpDelay_Count++;
}else if(Touch_Event.Up_Event)Touch_Event.Up_Event();//当存在持续未按下触发
}
}
}
}