code char smg_short[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff,
0x40,0xf9-0x80,0xa4-0x80,0xb0-0x80,0x99-0x80,0x92-0x80,0x82-0x80,0xf8-0x80,0x80-0x80,0x90-0x80,
0xc6,0x8c,0x88};
code char smg_post[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
char smg_cache[8] = {10,10,10,10,10,10,10,10};
void display_Init(void)
{
P0 = 0xff;Y4;Y0;
P0 = 0xff;Y5;Y0;
P0 = 0xff;Y6;Y0;
P0 = 0xff;Y7;Y0;
}
void smg_while(void)
{
static char neo;
P0 = 0xff;Y7;Y0;
P0 = smg_post[neo];Y6;Y0;
P0 = smg_short[smg_cache[neo]];Y7;Y0;
neo++;
neo%=8;
}
void smg_display(char t0,t1,t2,t3,t4,t5,t6,t7)
{
smg_cache[0] = t0;
smg_cache[1] = t1;
smg_cache[2] = t2;
smg_cache[3] = t3;
smg_cache[4] = t4;
smg_cache[5] = t5;
smg_cache[6] = t6;
smg_cache[7] = t7;
}數(shù)碼管顯示,
char Key_Open(void)
{
unsigned char key;
P3 &= 0xf0;
P34=1;P35=1;P42=1;P44=1;
if(!(P34&P35&P42&P44))
{
if(!(P34&P35&P42&P44))
{
if(P34==0) key=1;
if(P35==0) key=2;
if(P42==0) key=3;
if(P44==0) key=4;
P3 |= 0x0f;
P34=0;P35=0;P42=0;P44=0;
if(P30==0) key=key;
if(P31==0) key=key+4;
if(P32==0) key=key+8;
if(P33==0) key=key+12;
}
while(P30 == 0 | P31 == 0 | P32 == 0 | P33 == 0);
}
return key;
}矩陣按鍵 |