?? main.c
字號:
#include <stdio.h>
#include <iom8v.h>
#include <macros.h>
#include "config.h"
unsigned char hz0[65]={"智能家電控制系統 輸入 "};
unsigned char KeyFlag=0;
uchar zhishi=123;
unsigned char KeyI[3];
extern uchar TxBuf[],RxBuf[];
void main(void)
{ uchar KeyValue,kk,detect;
uint i;
init_devices();
screen(hz0);
// display_int(KeyI,0x88,3);
while(1)
{
RfRecvProc();
if(KeyFlag==1)
{
KeyFlag=0;
KeyValue=KeyI[2];
}
// displayint(0x9d,KeyValue);
switch(KeyValue)
{
case 112:kk=0; displayint(0x98,kk);
nrf2401A_SendData();
delay(2000);
nrf2401A_RxOn();
KeyValue=0; break;
case 105:kk=1;displayint(0x98,kk);
display_int(RxBuf,0x80,12);KeyValue=0;break;
case 114:kk=2;displayint(0x98,kk);
display_int(RxBuf+12,0x80,12);KeyValue=0;break;
case 122:kk=3;displayint(0x98,kk);KeyValue=0;break;
case 107:kk=4;displayint(0x98,kk);zhishi++;
displayint(0x9a,zhishi);
nrf2401A_WR(0xa5);
KeyValue=0;break;
case 115:kk=5;displayint(0x98,kk);
zhishi=nrf2401A_RD();
displayint(0x9a,zhishi);
KeyValue=0;break;
case 116:kk=6;displayint(0x98,kk);KeyValue=0;break;
case 108:kk=7;displayint(0x98,kk);KeyValue=0;break;
case 117:kk=8;displayint(0x98,kk);KeyValue=0;break;
case 125:kk=9;displayint(0x98,kk);KeyValue=0;break;
case 90: kk='k'; KeyValue=0;
lcd_write_comm(0x98);
lcd_write_data('k');
break;
default :KeyValue=0;break;
}
}
}
#pragma interrupt_handler int0_isr:2
void int0_isr(void)
{
static unsigned char IntNum=0,index=0;
if((IntNum>0)&&(IntNum<9))
{
KeyI[index]>>=1;
if(PINB&0x80)
KeyI[index]|=0x80;
}
IntNum++;
// while (!Key_CLK); //等待PS/2CLK拉高 use??????
if(IntNum>10)
{
IntNum=0;
index++;
if(index==3)
{
IntNum=0;
index=0;
KeyFlag=1;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -