||
#include "reg52.h"
//#define uchar unsigned char
//#define uint unsigned int
#include <intrins.h>
void delayF(unsigned int i)
{ unsigned char j;
for(;i;i--)
for(j=0;j<124;j++)
{;}
}
unsigned char keyscanF(void)
{
unsigned char kytp;
unsigned char kytp1;
//kytp=0x00; kytp1=0x00;
unsigned char pp1;
unsigned char k,m;
//pp1=0x00;
//k=0x00;
//m=0x00;
unsigned char a[4]={0xef,0xdf,0xbf,0x7f};//定义输出值
for(k=0;k<4;k++)
{
P1=a[k];
kytp=P1;
delayF(10);
kytp1=P1;
if (kytp==kytp1)
{
if (kytp1!=a[k])
{
pp1=kytp;
m=1;
break; //有按下,退出循环
}
else pp1=0x00;
}
}
if (m==1) {return(pp1);}
else {m=0;return(m);}
}
void main()
{
while(1)
{ unsigned char h;
h=keyscanF();
switch (h)
{
case 0 : break;
case 0xee :
{
P0=0xfe;
//unsigned char i;
delayF(500);
while (keyscanF()==0)
{delayF(1000);P0=_crol_(P0,1);delayF(1000);}
break;
}
case 0xdd :
{
P0=0x7f;
delayF(500);
while (keyscanF()==0)
{delayF(1000);P0=_cror_(P0,1);delayF(1000);}
break;
}
case 0xbb :
{P0=0x00;break;}
default :
{P0=0xff;break;}
}
}
}