求解读51单片机控制步进电机转动程序一部分 最好给个注释啊各路大神!!!急急急
ucharGetKey(void){staticucharKey_Num_last=0,Key_Num,KeyEventTimes=0;ucharKeyCmd=0;if(...
uchar GetKey(void)
{
static uchar Key_Num_last=0,Key_Num,KeyEventTimes=0;
uchar KeyCmd=0;
if(KeyEventTimes < 3)
{
if(KEY0 == 0)
{
Key_Num = 0x81;
KeyEventTimes++;
}
else if(KEY1 == 0)
{
Key_Num = 0x82;
KeyEventTimes++;
}
else if(KEY2 == 0)
{
Key_Num = 0x83;
KeyEventTimes++;
}
else if(KEY3 == 0)
{
Key_Num = 0x84;
KeyEventTimes++;
}
switch(KeyEventTimes)
{
case 0: break;
case 1:
{
Key_Num_last = Key_Num;
break;
}
}
}
else
{
if(KEY0&&KEY1&&KEY2&&KEY3)
{
KeyEventTimes++;
if(KeyEventTimes > 7)
{
KeyEventTimes = 0;
KeyCmd = Key_Num&0x0F;
}
}
}
return KeyCmd;
} 展开
{
static uchar Key_Num_last=0,Key_Num,KeyEventTimes=0;
uchar KeyCmd=0;
if(KeyEventTimes < 3)
{
if(KEY0 == 0)
{
Key_Num = 0x81;
KeyEventTimes++;
}
else if(KEY1 == 0)
{
Key_Num = 0x82;
KeyEventTimes++;
}
else if(KEY2 == 0)
{
Key_Num = 0x83;
KeyEventTimes++;
}
else if(KEY3 == 0)
{
Key_Num = 0x84;
KeyEventTimes++;
}
switch(KeyEventTimes)
{
case 0: break;
case 1:
{
Key_Num_last = Key_Num;
break;
}
}
}
else
{
if(KEY0&&KEY1&&KEY2&&KEY3)
{
KeyEventTimes++;
if(KeyEventTimes > 7)
{
KeyEventTimes = 0;
KeyCmd = Key_Num&0x0F;
}
}
}
return KeyCmd;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询