(原文件名:0001.jpg)
(原文件名:0002.jpg)
(原文件名:0003.jpg)
(原文件名:0004.jpg)
#include "TYPEDEF.H"
#include "STC89C5X.H"
#include "INTRINS.H"
sfr P1M1 = 0x92;
#define ONSwitch() P1M1 |= 0x10; P1_4 = 1
#define OFFSwitch() P1M1 &= 0xEF; P1_4 = 0
INT8U RFLevel0;
INT8U RFLevel1;
INT8U RFStep;
INT8U RFBuf[25];
//
INT8U KeyAge;
INT8U KeyFlag;
INT8U SwitchState;
INT16U TimeOut;
//void Soft_Rst(void);
void SystemInit(void);
//INT8U Read_Flash_Byte(INT16U addr);
//void Write_Flash_Byte(INT8U byte, INT16U addr);
//void Erase_Flash_Sector(INT16U addr);
/*
* Main function
*/
int main(void)
{
SystemInit();
while(1) {
if(TF1) {
TF1 = 0;
RFLevel1 = RFLevel0;
RFLevel0 = P3 & 0x80;
if(RFStep == 0) {
if(RFLevel0 == 0) {
RFBuf[0]++;
} else {
if(RFBuf[0] >= 60) {
RFBuf[++RFStep] = 1;
} else {
RFBuf[0] = 0;
}
}
} else {
if(RFLevel0 != 0) {
if(++RFBuf[RFStep] == 0) {
RFStep = 0;
RFBuf[0] = 0;
}
} else if(RFLevel1 != 0) {
if(++RFStep > 24) {
RFLevel0 = RFBuf[0] / 15;
RFLevel1 = 0;
if(RFBuf[1] < RFLevel0) RFLevel1++;
if(RFBuf[2] > RFLevel0) RFLevel1++;
if(RFBuf[3] < RFLevel0) RFLevel1++;
if(RFBuf[4] > RFLevel0) RFLevel1++;
if(RFBuf[5] < RFLevel0) RFLevel1++;
if(RFBuf[6] > RFLevel0) RFLevel1++;
if(RFBuf[7] < RFLevel0) RFLevel1++;
if(RFBuf[8] > RFLevel0) RFLevel1++;
if(RFBuf[9] < RFLevel0) RFLevel1++;
if(RFBuf[10] > RFLevel0) RFLevel1++;
if(RFBuf[11] < RFLevel0) RFLevel1++;
if(RFBuf[12] > RFLevel0) RFLevel1++;
if(RFBuf[13] < RFLevel0) RFLevel1++;
if(RFBuf[14] > RFLevel0) RFLevel1++;
if(RFBuf[15] < RFLevel0) RFLevel1++;
if(RFBuf[16] > RFLevel0) RFLevel1++;
if(RFBuf[17] < RFLevel0) RFLevel1++;
if(RFBuf[18] < RFLevel0) RFLevel1++;
if(RFBuf[19] < RFLevel0) RFLevel1++;
if(RFBuf[20] < RFLevel0) RFLevel1++;
if(RFBuf[21] < RFLevel0) RFLevel1++;
if(RFBuf[22] < RFLevel0) RFLevel1++;
if(RFBuf[23] > RFLevel0) RFLevel1++;
if(RFBuf[24] > RFLevel0) RFLevel1++;
if(RFLevel1 >= 24) {
KeyAge++;
TimeOut = 0;
RFStep = 0;
RFBuf[0] = 0;
if((KeyFlag == 0) && (KeyAge >= 1)) {
KeyFlag = 1;
if(SwitchState == 0) {
SwitchState = 1;
ONSwitch();
} else {
SwitchState = 0;
OFFSwitch();
}
}
}
} else {
RFBuf[RFStep] = 0;
}
}
}
if(++TimeOut > 6000) {
TimeOut = 0;
KeyAge = 0;
KeyFlag = 0;
}
}
}
}
/*
* Initializtion System
*/
void SystemInit(void)
{
IE = 0x00;
TMOD = 0x21;
TH1 = 0xEC;
TR1 = 1;
}
我很喜欢楼主这种图,超帅,顺便说下:边缘距离会产生问题,处理一下可以更好
一周热门 更多>