ReadTouchKeyValue 函数主要是读取触控键值,并进行简单操作,这里以我自己DIY的板子为例,主要是TK12、TK13,TK14,TK15. /**************************************************
*函数名称: void ReadTouchKeyvalue()
*函数功能: 读取触控键值,并进行操作
*入口参数: void
*出口参数: void
**************************************************/
void ReadTouchKeyValue()
{
if(exKeyValueFlag &0x1000)
{
Lcd1602_Delay(1000); //延时消抖
if(exKeyValueFlag &0x1000)
{
Lcd1602_Delay(1000); //延时消抖
exKeyValueFlag &= 0x0;
DisplayListChar(0, 1, "TK12 is Touch!"); //Lcd显示
TkFlag =~ TkFlag;
if(TkFlag)
{
Led_Toggle(TK1_R); //LED翻转
BuzzerWork(); //蜂鸣
}
}
}
if(exKeyValueFlag &0x2000)
{
Lcd1602_Delay(1000);
if(exKeyValueFlag &0x2000)
{
Lcd1602_Delay(1000);
exKeyValueFlag &= 0x0;
DisplayListChar(0, 1, "TK13 is Touch!");
TkFlag =~ TkFlag;
if(TkFlag)
{
Led_Toggle(TK2_R);
BuzzerWork();
}
}
}
if(exKeyValueFlag &0x4000)
{
Lcd1602_Delay(1000);
if(exKeyValueFlag &0x4000)
{
Lcd1602_Delay(1000);
exKeyValueFlag &= 0x0;
DisplayListChar(0, 1, "TK14 is Touch!");
TkFlag =~ TkFlag;
if(TkFlag)
{
Led_Toggle(TK3_R);
BuzzerWork();
}
}
}
if(exKeyValueFlag &0x8000)
{
Lcd1602_Delay(1000);
if(exKeyValueFlag &0x8000)
{
Lcd1602_Delay(1000);
exKeyValueFlag &= 0x0;
DisplayListChar(0, 1, "TK15 is Touch!");
TkFlag =~ TkFlag;
if(TkFlag)
{
Led_Toggle(TK4_R);
BuzzerWork();
}
}
}
}
|