经典按键扫描程序
来源:互联网 发布:猜数游戏编程 编辑:程序博客网 时间:2024/05/29 03:11
setbit(PORTC,PORTC0);
NOP();
NOP();
if (checkbit(PINC,PINC4)) setbit(new_key1,0);
if (checkbit(PINC,PINC5)) setbit(new_key1,1);
if (checkbit(PINC,PINC6)) setbit(new_key1,2);
clrbit(PORTC,PORTC0);
setbit(PORTC,PORTC1);
NOP();
NOP();
if (checkbit(PINC,PINC4)) setbit(new_key2,0);
if (checkbit(PINC,PINC5)) setbit(new_key2,1);
if (checkbit(PINC,PINC6)) setbit(new_key2,2);
clrbit(PORTC,PORTC1);
setbit(PORTC,PORTC2);
NOP();
NOP();
if (checkbit(PINC,PINC4)) setbit(new_key3,0);
if (checkbit(PINC,PINC5)) setbit(new_key3,1);
if (checkbit(PINC,PINC6)) setbit(new_key3,2);
clrbit(PORTC,PORTC2);
setbit(PORTC,PORTC3);
NOP();
NOP();
if (checkbit(PINC,PINC4)) setbit(new_key4,0);
if (checkbit(PINC,PINC5)) setbit(new_key4,1);
if (checkbit(PINC,PINC6)) setbit(new_key4,2);
clrbit(PORTC,PORTC3);
//------------------------------------接收到正确命令处理
if (checkbit(works,uorder_ok)) unit_order();
if (checkbit(works,norder_ok)) net_order();
time1++;
}while (time1<0xfe);
time1=0x00;
//-------------------------------------按键处理程序
tmp_key1=old_key1;
tmp_key1=(tmp_key1^new_key1);
tmp_key1=(tmp_key1&new_key1);
old_key1=new_key1;
if (checkbit(tmp_key1,0))
{
key_data=0x01;
scan_in();
}
if (checkbit(tmp_key1,1))
{
key_data=0x02;
scan_in();
}
if (checkbit(tmp_key1,2))
{
key_data=0x03;
scan_in();
}
new_key1=0x00;
tmp_key2=old_key2;
tmp_key2=(tmp_key2^new_key2);
tmp_key2=(tmp_key2&new_key2);
old_key2=new_key2;
if (checkbit(tmp_key2,0))
{
key_data=0x04;
scan_in();
}
if (checkbit(tmp_key2,1))
{
key_data=0x05;
scan_in();
}
if (checkbit(tmp_key2,2))
{
key_data=0x06;
scan_in();
}
new_key2=0x00;
tmp_key3=old_key3;
tmp_key3=(tmp_key3^new_key3);
tmp_key3=(tmp_key3&new_key3);
old_key3=new_key3;
if (checkbit(tmp_key3,0))
{
key_data=0x07;
scan_in();
}
if (checkbit(tmp_key3,1))
{
key_data=0x08;
scan_in();
}
if (checkbit(tmp_key3,2))
{
key_data=0x09;
scan_in();
}
new_key3=0x00;
tmp_key4=old_key4;
tmp_key4=(tmp_key4^new_key4);
tmp_key4=(tmp_key4&new_key4);
old_key4=new_key4;
if (checkbit(tmp_key4,0))
{
key_data=0x0C;
scan_in();
}
if (checkbit(tmp_key4,1))
{
key_data=0x00;
scan_in();
}
if (checkbit(tmp_key4,2))
{
key_data=0x0A;
scan_in();
}
new_key4=0x00;—原文来自《新e代电子网》网址是:http://www.elecm.com/a/read-htm-tid-103023-fpage-6.html
- 经典按键扫描程序
- 经典按键扫描程序
- 仅三行代码的按键扫描程序,绝对够经典(秒杀郭天祥讲解的按键扫描)
- 新型按键扫描程序
- AVR按键扫描程序
- 按键扫描程序
- 新型按键扫描程序
- 关于按键扫描程序
- 按键扫描程序
- 按键扫描程序
- 经典的按键扫描算法
- 经典按键扫描算法理解
- 新型的按键扫描程序
- 新型的按键扫描程序
- 新型的按键扫描程序
- 新型的按键扫描程序
- 新型的按键扫描程序
- 新型的按键扫描程序
- Perl命令行应用介绍
- 看看baidu是如何AJAX跨域的
- 博百优
- Java动态代理类(包括客户端服务端使用反射机制来代理的)
- IE和FIREFOX在解析JS方面的区别
- 经典按键扫描程序
- jsp jstl 遍历的问题
- 慎用today 做列初始值
- 1比4
- 正确认识SQL Server中的延迟名称解析(Deferred Name Resolution)
- sqlite中的journal
- 调试时,用彩色来打印输出自己关心的数据
- 10个你闻所未闻的奇趣网站
- Vim 6.0 代码折叠