"); //-->
static INT8U step=0;
static INT8U RepeatCount;
static BOOLEAN AllPress;
switch (step)
{
static INT8U PrevGetkey;
case 0:
if (Getkey)
{
PrevGetkey=Getkey;
step=1;
RepeatCount=0;
}
break;
case 1:
if (PrevGetkey==Getkey)
{
if (++RepeatCount > 8)//证明是长按
{
AllPress=1;
RepeatCount = 0;
printf("\r\n长按");
}
else//短按
{
printf("\r\n按下");
}
}
else
{
step=2;
}
break;
case 2:
if (Getkey)
{
step=1;
}
else if (AllPress)//长按弹起不作处理。
{
AllPress=0;
step=0;
printf("\r\n长按弹起");
break;
}
else//弹起
{
step=0;
printf("\r\n弹起");
}
break;
}
*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。