wxzakcldw 发表于 2011-8-15 15:57:56

一个高效的键盘扫描函数

unsigned char keyscan()
{
        unsigned char com,com1,com2,i;
        keyport=0xf0;
        while(keyport!=0xf0)
        {   
                delayms(10);
                keyport=0xf0;
                while(keyport!=0xf0)
                {
                        keyport=0xf0;
                        if(keyport!=0xf0)
                        {
                                com1=keyport;
                                keyport=0x0f;
                                com2=keyport;
                        }
                        com=com1|com2;
                        if(com==0xee)i=12;
                        if(com==0xde)i=8;
                        if(com==0xbe)i=4;
                        if(com==0x7e)i=0;
                        if(com==0xed)i=13;
                        if(com==0xdd)i=9;
                        if(com==0xbd)i=5;
                        if(com==0x7d)i=1;
                        if(com==0xeb)i=14;
                        if(com==0xdb)i=10;
                        if(com==0xbb)i=6;
                        if(com==0x7b)i=2;
                        if(com==0xe7)i=15;
                        if(com==0xd7)i=11;
                        if(com==0xb7)i=7;
                        if(com==0x77)i=3;
                }
        }
        return(i);       
}

mTouch 发表于 2012-2-17 21:31:54

mark!

bigbear541 发表于 2012-10-22 12:46:43

能不能不用延时消抖???
页: [1]
查看完整版本: 一个高效的键盘扫描函数