📄 rx.c
字号:
{0xcb,0xc4},{0xce,0xe5},{0xc1,0xf9}}; //星期一--星期日
code Chinese_Char Time_c[]={{0xca,0xb1},{0xbc,0xe4},{0xc9,0xe8},{0xd6,0xc3}}; //时间设置
code Chinese_Char Time_On_c[]={{0xc9,0xe8},{0xb1,0xb8},{0xbf,0xaa},{0xb9,0xd8},
{0xca,0xb1},{0xbc,0xe4}}; //开机时间
code Chinese_Char Fixture_c[]={{0xc9,0xe8},{0xb1,0xb8},{0xd7,0xb4},{0xcc,0xac}}; //设备状态
code Chinese_Char State_Now_c[]={{0xc9,0xe8},{0xb1,0xb8},{0xcf,0xd6},{0xd7,0xb4}}; //设备现状
code Chinese_Char Fix_State_On[]={{0xc9,0xe8},{0xb1,0xb8},{0xbf,0xaa},{0xca,0xb1},
{0xbc,0xe4},{0xc9,0xe8},{0xd6,0xc3}}; //设备开时间设置
code Chinese_Char Fix_State_Off[]={{0xc9,0xe8},{0xb1,0xb8},{0xb9,0xd8},{0xca,0xb1},
{0xbc,0xe4},{0xc9,0xe8},{0xd6,0xc3}}; //设备关时间设置
code Chinese_Char Fix_State_Time[]={{0xb2,0xe9},{0xbf,0xb4},{0xc9,0xe8},{0xb1,0xb8},
{0xbf,0xaa},{0xca,0xb1},{0xbc,0xe4}}; //查看设备开时间
code Chinese_Char Oper_c[]={{0xb4,0xf2},{0xbf,0xaa},{0xb9,0xd8},{0xb1,0xd5},
{0xc9,0xe8},{0xb1,0xb8}}; //打开关闭设备
code Chinese_Char Oper_On_c[]={{0xb4,0xf2},{0xbf,0xaa},{0xc9,0xe8},{0xb1,0xb8}}; //打开设备
code Chinese_Char Oper_Off_c[]={{0xb9,0xd8},{0xb1,0xd5},{0xc9,0xe8},{0xb1,0xb8}}; //关闭设备
code Chinese_Char All_Fixture_c[]={{0xb9,0xd8},{0xb1,0xd5},{0xcb,0xf9},
{0xd3,0xd0},{0xc9,0xe8},{0xb1,0xb8}}; //关闭所有设备
code Chinese_Char Find_Fixture_c[]={{0xb2,0xe9},{0xd1,0xaf},{0xd2,0xd1},{0xbf,0xaa},
{0xc9,0xe8},{0xb1,0xb8}}; //查询已开设备
code Chinese_Char Oper_Fixture_Off_c[]={{0xcb,0xf9},{0xd3,0xd0},{0xc9,0xe8},{0xb1,0xb8},
{0xd2,0xd1},{0xb9,0xd8},{0xb1,0xd5},}; //所有设备已关闭
code Chinese_Char Find_Fixture_One_c[]={{0xb2,0xe9},{0xbf,0xb4},{0xb8,0xf7},
{0xc9,0xe8},{0xb1,0xb8}}; //查看各设备
code Chinese_Char Turn_On_Fixture_c[]={{0xb4,0xf2},{0xbf,0xaa},{0xb8,0xf7},
{0xc9,0xe8},{0xb1,0xb8}}; //打开各设备
code Chinese_Char Freq_c[]={{0xbf,0xaa},{0xb9,0xd8},{0xd0,0xc5},
{0xba,0xc5},{0xca,0xe4},{0xb3,0xf6}}; //开关信号输出
Year code Leap_year[]={{1,31,3},{2,29,6},{3,31,0},{4,30,3},{5,31,5},{6,30,1},{7,31,3},
{8,31,6},{9,30,2},{10,31,4},{11,30,0},{11,31,2}};
Year code Ping_year[]={{1,31,4},{2,28,0},{3,31,0},{4,30,3},{5,31,5},{6,30,1},{7,31,3},
{8,31,6},{9,30,2},{10,31,4},{11,30,0},{12,31,2}};
code Month_Code[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
uchar k;
uchar addr1;
uchar hour;
uchar min;
uchar sec;
uchar sec1;
uchar year=20;
uchar year1=5;
uchar month=1;
uchar week;
uchar data_data=1;
uchar ij;
uint count_tr0;
uint inf_num;
uchar Time_Addr;
uchar Disp_Addr;
uchar KeyFuncIndex=0;
uchar inf_dat,inf_old;
idata uchar Set_Time[24][2];
idata uchar Set_Time1[24][2];
idata uchar frequ[24];
idata uchar frequ1[24];
uchar Time_Flag_Set;
uchar Flag_State;
uchar regist;
uchar regist2;
uchar Key_Back;
uchar aa,bb;
bit Flag_Flag;
bit flag;
bit Flag_Disp_Time;
bit flag1;
bit Flag_Select;
bit Flag_Time;
bit Flag_TR0;
bit Flag_Or_On;
bit Flag_Key;
bit Flag_Key_Int;
bit Flag_State_1;
bit Flag_State_2;
bit Flag_State_3;
bit Flag_State_4;
bit Flag_State_5;
bit Flag_State_6;
bit Flag_State_7;
bit Flag_State_8;
bit Flag_State_9;
bit Flag_State_10;
bit Flag_State_11;
bit Flag_State_12;
bit Flag_State_13;
bit Flag_State_14;
bit Flag_State_15;
bit Flag_State_16;
bit Flag_State_17;
bit Flag_State_18;
bit Flag_State_19;
bit Flag_State_20;
bit Flag_State_21;
bit Flag_State_22;
bit Flag_State_23;
bit Flag_State_24;
bit _State1;
bit _State2;
bit _State3;
bit _State4;
bit _State5;
bit _State6;
bit _State7;
bit _State8;
bit _State9;
bit _State10;
bit _State11;
bit _State12;
bit _State13;
bit _State14;
bit _State15;
bit _State16;
bit _State17;
bit _State18;
bit _State19;
bit _State20;
bit _State21;
bit _State22;
bit _State23;
bit _State24;
/****************************** 短延时函数 ******************************/
void delay500us(uchar time)
{uchar x,y;
{for(x=0;x<time;x++)
{for(y=0;y<120;y++)_nop_(); /*12MHZ TIMER=663uS*/
_nop_();
}
}
}
/**************************************主函数***********************************************/
void main(void) {
TMOD=0x11;EA=1;EX1=1;
ET0=1;ET1=1;TR0=1;
TR1=1;TH1=0x3c;TL1=0xba;
TH0=0x63;TL0=0xbf; EX0=1;
inf_num=0;inf_dat=0;k=0;
P0=0;P2=0;P1=0;
flag=1;Flag_Disp_Time=1;
Flag_Key=0;Flag_Key_Int=0;
SP=0xe3;delay500us(1);P0=0;P2=0;P1=0;P0=0;P2=0;P1=0;
for(Time_Flag_Set=0;Time_Flag_Set<24;Time_Flag_Set++)
{frequ1[Time_Flag_Set]=0;
frequ[Time_Flag_Set]=0;}
_Fixture_Off();
LcdReset();
loop: while(flag1);
Disp_Time();
if(flag==0)goto loop1;
if(Flag_Key==1)goto loop2;
goto loop;
loop1: while(flag);
Get_Key_Time();
goto loop1;
loop2: if(Flag_Key==1) goto loop3;
while(Set_Pin==1&&Add_Pin==1&&Dec_Pin==1&&Cursor_right==1&&Cursor_left==1);
loop3:Rcognise_Key();
Get_Key_Time();
Flag_Key=0;
goto loop2;
}
/***************************************红外线接收解码******************************************/
/* 红外线低电平时间 */
void int_X1(void) interrupt 2 { //遥控器操作控制程序
unsigned char i;EX1=0;k=0;inf_dat=0;
for(i=0;i<146;i++)_nop_(); //识别起始码
if(count_pin==0)k+=0;else goto end;
for(i=0;i<146;i++)_nop_();
if(count_pin==0)k+=0;else goto end;
for(i=0;i<146;i++)_nop_();
if(count_pin==0)k+=0;else goto end;
for(i=0;i<146;i++)_nop_();
if(count_pin==0)k+=1;else goto end;
for(i=0;i<80;i++);_nop_();
inf_num=0x0000;
loop: while(count_pin==1)if(inf_dat==12)goto end; //等待低电平
for(i=0;i<200;i++)_nop_();
if(count_pin==1) //识别0或1
inf_num|=0x0000;
else
inf_num|=0x0001;
inf_num=inf_num<<1; //记录
inf_dat+=1;
while(count_pin==0); goto loop;
end:inf_num=inf_num>>1;
Flag_TR0=1;
if(k==1)flag=0;else flag=1;
if(inf_num==0x0481||inf_num==0x0a61||inf_num==0x0c81||inf_num==0x02cb||inf_num==0x0ccb||inf_num==0x03eb)
flag=0;
else
flag=1;
}
void Int_e0(void) interrupt 1
{TH0=0x63;
TL0=0xc9;
if(count_tr0==125) //5s
{if(Flag_State_1==1){if(frequ[0]==frequ1[0]){State_1=~State_1;frequ1[0]=0;}frequ1[0]++;}
if(Flag_State_2==1){if(frequ[1]==frequ1[1]){State_2=~State_2;frequ1[1]=0;} frequ1[1]++;}
if(Flag_State_3==1){if(frequ[2]==frequ1[2]){State_3=~State_3;frequ1[2]=0;} frequ1[2]++;}
if(Flag_State_4==1){if(frequ[3]==frequ1[3]){State_4=~State_4;frequ1[3]=0;} frequ1[3]++;}
if(Flag_State_5==1){if(frequ[4]==frequ1[4]){State_5=~State_5;frequ1[4]=0;} frequ1[4]++;}
if(Flag_State_6==1){if(frequ[5]==frequ1[5]){State_6=~State_6;frequ1[5]=0;} frequ1[5]++;}
if(Flag_State_7==1){if(frequ[6]==frequ1[6]){State_7=~State_7;frequ1[6]=0;} frequ1[6]++;}
if(Flag_State_8==1){if(frequ[7]==frequ1[7]){State_8=~State_8;frequ1[7]=0;} frequ1[7]++;}
if(Flag_State_9==1){if(frequ[8]==frequ1[8]){State_9=~State_9;frequ1[8]=0;} frequ1[8]++;}
if(Flag_State_10==1){if(frequ[9]==frequ1[9]){State_10=~State_10;frequ1[9]=0;} frequ1[9]++;}
if(Flag_State_11==1){if(frequ[10]==frequ1[10]){State_11=~State_11;frequ1[10]=0;}frequ1[10]++;}
if(Flag_State_12==1){if(frequ[11]==frequ1[11]){State_12=~State_12;frequ1[11]=0;} frequ1[11]++;}
if(Flag_State_13==1){if(frequ[12]==frequ1[12]){State_13=~State_13;frequ1[12]=0;} frequ1[12]++;}
if(Flag_State_14==1){if(frequ[13]==frequ1[13]){State_14=~State_14;frequ1[13]=0;} frequ1[13]++;}
if(Flag_State_15==1){if(frequ[14]==frequ1[14]){State_15=~State_15;frequ1[14]=0;} frequ1[14]++;}
if(Flag_State_16==1){if(frequ[15]==frequ1[15]){State_16=~State_16;frequ1[15]=0;} frequ1[15]++;}
if(Flag_State_17==1){if(frequ[16]==frequ1[16]){State_17=~State_17;frequ1[16]=0;} frequ1[16]++;}
if(Flag_State_18==1){if(frequ[17]==frequ1[17]){State_18=~State_18;frequ1[17]=0;} frequ1[17]++;}
if(Flag_State_19==1){if(frequ[18]==frequ1[18]){State_19=~State_19;frequ1[18]=0;} frequ1[18]++;}
if(Flag_State_20==1){if(frequ[19]==frequ1[19]){State_20=~State_20;frequ1[19]=0;} frequ1[19]++;}
if(Flag_State_21==1){if(frequ[20]==frequ1[20]){State_21=~State_21;frequ1[20]=0;} frequ1[20]++;}
if(Flag_State_22==1){if(frequ[21]==frequ1[21]){State_22=~State_22;frequ1[21]=0;} frequ1[21]++;}
if(Flag_State_23==1){if(frequ[22]==frequ1[22]){State_23=~State_23;frequ1[22]=0;} frequ1[22]++;}
if(Flag_State_24==1){if(frequ[23]==frequ1[23]){State_24=~State_24;frequ1[23]=0;}frequ1[23]++;}
count_tr0=0;
}
else count_tr0++;
}
/***************************************时间中断,计数器1**************************************/
void Int_e1(void) interrupt 3
{ TH1=0x3c;
TL1=0xbf;
if(sec1==95)
{sec1=0;
if(sec==59)
{sec=0;
if(min==59)
{min=0;
if(hour==23)
{hour=min=sec=sec1=0;
if(data_data==31){data_data=1;if(month==12){month=1;year1+=1;}else month+=1;}
else data_data+=1; }
else hour+=1; LcdReset();
}else min+=1;
}else sec+=1;
}else sec1+=5;
if(Flag_TR0==1){inf_old+=1;if(inf_old==5){inf_old=0;EX1=1;Flag_TR0=0;}}
regist=Time_Flag_Set;
for(Time_Flag_Set=0;Time_Flag_Set<24;Time_Flag_Set++)
{if(Set_Time[Time_Flag_Set][0]==hour&&Set_Time[Time_Flag_Set][1]==min&&sec==0)
switch(Time_Flag_Set)
{case 0: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State1==0){}else
State_1=1;break;
case 1: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State2==0){}else
State_2=1;break;
case 2: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State3==0){}else
State_3=1;break;
case 3: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State4==0){}else
State_4=1;break;
case 4: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State5==0){}else
State_5=1;break;
case 5: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State6==0){}else
State_6=1;break;
case 6: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State7==0){}else
State_7=1;break;
case 7: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State8==0){}else
State_8=1;break;
case 8: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State9==0){}else
State_9=1;break;
case 9: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State10==0){}else
State_10=1;break;
case 10: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State11==0){}else
State_11=1;break;
case 11: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State12==0){}else
State_12=1;break;
case 12: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State13==0){}else
State_13=1;break;
case 13: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State14==0){}else
State_14=1;break;
case 14: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State15==0){}else
State_15=1;break;
case 15: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State16==0){}else
State_16=1;break;
case 16: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State17==0){}else
State_17=1;break;
case 17: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State18==0){}else
State_18=1;break;
case 18: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State19==0){}else
State_19=1;break;
case 19: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State20==0){}else
State_20=1;break;
case 20: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State21==0){}else
State_21=1;break;
case 21: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State22==0){}else
State_22=1;break;
case 22: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State23==0){}else
State_23=1;break;
case 23: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State24==0){}else
State_24=1;break;
default:break;}
if(Set_Time1[Time_Flag_Set][0]==hour&&Set_Time1[Time_Flag_Set][1]==min&&sec==0)
switch(Time_Flag_Set)
{case 0: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State1==0){}else
{State_1=0;Flag_State_1=0;Set_Time1[0][0]=Set_Time1[0][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State1=0;}
break;
case 1:if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State2==0){}else
{State_2=0; Flag_State_2=0;Set_Time1[1][0]=Set_Time1[1][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State2=0;}
break;
case 2:if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State3==0){}else{
State_3=0; Flag_State_3=0;Set_Time1[2][0]=Set_Time1[2][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State3=0;}
break;
case 3:if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State4==0){}else{
State_4=0; Flag_State_4=0;Set_Time1[3][0]=Set_Time1[3][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State4=0;}
break;
case 4: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State5==0){}else{
State_5=0; Flag_State_5=0;Set_Time1[4][0]=Set_Time1[4][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State5=0;}
break;
case 5: if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State6==0){}else{
State_6=0; Flag_State_6=0;Set_Time1[5][0]=Set_Time1[5][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State6=0;}
break;
case 6:if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State7==0){}else{
State_7=0;Flag_State_7=0;Set_Time1[6][0]=Set_Time1[6][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State7=0;}
break;
case 7:if(Set_Time1[Time_Flag_Set][0]==0&&Set_Time1[Time_Flag_Set][1]==0&&_State8==0){}else{
State_8=0;Flag_State_8=0;Set_Time1[7][0]=Set_Time1[7][1]=0;
Set_Time[Time_Flag_Set][0]=Set_Time[Time_Flag_Set][1]=0;
frequ[Time_Flag_Set]=frequ1[Time_Flag_Set]=0;_State8=0;}
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -