if(AdcValue[1]>=DOWN_B_KEY) //This is B Key scan
{
switch(KeyKindB)
{
case DOWNB_KEY:
{
if(LongKeyB==SHORT_KEY)
{
WriteMessage(1,KeyStatus|PRESS_SBS_MSG);
WriteMessage(1,KeyStatus|RELEASE_SBS_MSG);
}
else if(LongKeyB==LONG_KEY)
{
WriteMessage(1,SaveKStatus|RELEASE_LBS_MSG);
}
LongKeyB=NO_KEY;
KeyKindB=OTHER_KEY;
break;
}
case UPB_KEY:
{
if(LongKeyB==SHORT_KEY)
{
WriteMessage(1,KeyStatus|PRESS_SBI_MSG);
WriteMessage(1,KeyStatus|RELEASE_SBI_MSG);
}
else if(LongKeyB==LONG_KEY)
{
WriteMessage(1,SaveKStatus|RELEASE_LBI_MSG);
}
LongKeyB=NO_KEY;
KeyKindB=OTHER_KEY;
break;
}
default :
{
break;
}
}
KeyCntB=0;
}
else if(AdcValue[1]<DOWN_B_KEY&&AdcValue[1]>=UP_B_KEY) //this is Down Key
{
++KeyCntB;
if((KeyCntB>=CNTS_KEY)&&(KeyCntB<=CNTS_KEY+2))
{
if(LongKeyB!=LONG_KEY)
{
LongKeyB=SHORT_KEY;
}
KeyKindB=DOWNB_KEY;
}
else if(KeyCntB>=CNTL_KEY)
{
if(RA7_NU==1)
{
RA7_NU=0;
}
else
{
RA7_NU=1;
}
SaveKStatus=KeyStatus;
KeyCntB=0;
LongKeyB=LONG_KEY;
WriteMessage(1,KeyStatus|PRESS_LBS_MSG);
}
}
else if(AdcValue[1]<UP_B_KEY) //This is Up Key
{
++KeyCntB;
if((KeyCntB>=CNTS_KEY)&&(KeyCntB<=CNTS_KEY+2))
{
if(LongKeyB!=LONG_KEY)
{
LongKeyB=SHORT_KEY;
}
KeyKindB=UPB_KEY;
}
else if(KeyCntB>=CNTL_KEY)
{
SaveKStatus=KeyStatus;
KeyCntB=0;
LongKeyB=LONG_KEY;
WriteMessage(1,KeyStatus|PRESS_LBI_MSG);
}
} |