?? zdbwnl.lst
字號:
C51 COMPILER V7.50 ZDBWNL 12/22/2005 13:04:37 PAGE 17
947 void id_case2_key(void)//id為1時的下一級選擇
948 {
949 1 if(Add_Key == 0) //增加1
950 1 {
951 2 Delay(100);
952 2 if(Add_Key == 0)
953 2 Set_Bell(id2,0); //調(diào)用Set_Bell函數(shù)
954 2 while(Add_Key ==0);//等待鍵松開
955 2 }
956 1 if(Dec_Key == 0) //減少1
957 1 {
958 2 Delay(100);
959 2 if(Dec_Key == 0)
960 2 Set_Bell(id2,1); //調(diào)用Set_Bell函數(shù)
961 2 while(Dec_Key ==0);//等待鍵松開
962 2 }
963 1 }
964
965 /******************************************************************************/
966 void Set_Bell(unsigned char sel, bit sel_1)//根據(jù)選擇調(diào)整相應(yīng)項目并寫入
967 {
968 1 signed char address,item;
969 1 signed char max,mini;
970 1 if(sel==4) {address=0xc6; max=59;mini=0;} //秒
971 1 if(sel==3) {address=0xc4; max=59;mini=0;} //分
972 1 if(sel==2) {address=0xc2; max=23; mini=0;} //時
973 1 if(sel==1) //標志位
974 1 {
975 2 address=0xc8;//for read
976 2 if(Add_Key ==0 || Dec_Key ==0)
977 2 Bell_Swh=~Bell_Swh;
978 2 write_clock(address,Bell_Swh);
979 2 } //開關(guān)
980 1
981 1 item=((read_clock(address+1))/16)*10 + (read_clock(address+1))%16;
982 1 if(sel_1==0)
983 1 item++;
984 1 else
985 1 item--;
986 1 if(item>max) item=mini;
987 1 if(item<mini) item=max;
988 1
989 1 write_clock(0x8e,0x00);//允許寫操作
990 1 write_clock(address,(item/10)*16+item%10);//轉(zhuǎn)換成16進制寫入1302
991 1 write_clock(0x8e,0x80);//寫保護,禁止寫操作
992 1 }
993
994 /******************************************************************************/
995 void Timer0_Init(void)//定時器0初始化
996 {
997 1 TMOD=0x01;
998 1 TH0=(65535-50000)/256;
999 1 TL0=(65535-50000)%256;
1000 1 EA=1;
1001 1 ET0=1;
1002 1 TR0=1;
1003 1 }
1004
1005 /******************************************************************************/
1006 void Timer0(void) interrupt 1 using 1//中斷入口,冒號閃爍
1007 {
1008 1 static unsigned char timecount = 0;
C51 COMPILER V7.50 ZDBWNL 12/22/2005 13:04:37 PAGE 18
1009 1
1010 1 TH0=(65535-50000)/256; //50ms定時
1011 1 TL0=(65535-50000)%256;
1012 1 timecount++;
1013 1 if(timecount > 9)//500MS
1014 1 {
1015 2 timecount = 0;
1016 2 flag = ~flag;
1017 2 }
1018 1 }
1019
1020 /******************************************************************************/
1021 void Init_1302(void)//設(shè)置1302的初始時間
1022 {
1023 1 write_clock(0x8e,0x00);//允許寫操作
1024 1 write_clock(0x8c,0x05);//年
1025 1 write_clock(0x8a,0x06);//星期
1026 1 write_clock(0x88,0x01);//月
1027 1 write_clock(0x86,0x01);//日
1028 1 write_clock(0x84,0x12);//小時
1029 1 write_clock(0x82,0x00);//分鐘
1030 1 write_clock(0x80,0x00);//秒
1031 1 write_clock(0x90,0xa5);//充電
1032 1 write_clock(0x8e,0x80);//禁止寫操作
1033 1 }
1034
1035 /******************************************************************************/
1036 void Lcd_Mark1(void)//在預(yù)定的位置上寫入漢字
1037 {
1038 1 Clr_Scr();//清屏
1039 1 frame();//顯示邊框
1040 1 Mcs=1;Scs=0;
1041 1 Disp_Chinese(5,8,shi);//顯示室溫,星期,年, . ,℃
1042 1 Disp_Chinese(5,24,wen);
1043 1 Disp_Chinese(3,8,xing);
1044 1 Disp_Chinese(3,24,qi);
1045 1 Disp_Chinese(1,40,nian);
1046 1 Disp_Digit(5,56,point);
1047 1 Mcs=0;Scs=1;
1048 1 Disp_Chinese(5,8,sheshidu);
1049 1 if(Bell_Swh == 1)//鬧鐘為開
1050 1 {
1051 2 Mcs=0;Scs=1;
1052 2 Disp_Chinese(5,40,biaozhi);//顯示鬧鐘圖標
1053 2 }
1054 1 }
1055
1056 /******************************************************************************/
1057 void Lcd_Mark2(void)
1058 {
1059 1 Clr_Scr();//清屏
1060 1 frame();//顯示邊框
1061 1
1062 1 Mcs=1;Scs=0;//顯示鬧鐘設(shè)定等幾個漢字
1063 1 Disp_Chinese(2,16,nao);
1064 1 Disp_Chinese(2,32,zhong);
1065 1 Disp_Chinese(2,48,she);
1066 1 Mcs=0;Scs=1;
1067 1 Disp_Chinese(2,0,ding);
1068 1 Disp_Digit(4,0,maohao);//顯示:
1069 1 Disp_Digit(4,24,maohao);
1070 1 }
C51 COMPILER V7.50 ZDBWNL 12/22/2005 13:04:37 PAGE 19
1071
1072 /******************************************************************************/
1073 void Beep(void)//BELL 蜂明器發(fā)聲,整點報警
1074 {
1075 1 Bell_Out = 0;
1076 1 Delay(6000);//50ms
1077 1 Bell_Out = 1;
1078 1 Delay(6000);//50ms
1079 1 }
1080
1081 /*****************************************************************************/
1082 void Bell_now(void)
1083 {
1084 1 Bell_Out = 0;
1085 1 Delay(31250); //for 250ms
1086 1 Bell_Out = 1;
1087 1 Delay(6350); //50ms
1088 1 Bell_Out = 0;
1089 1 Delay(18750);//150ms
1090 1 Bell_Out = 1;
1091 1 Delay(50000);//400ms
1092 1 }
1093
1094 /******************************************************************************/
1095 void main(void) //主函數(shù)
1096 {
1097 1 //初始化狀態(tài)
1098 1 Bell_Out = 1;//蜂明器關(guān)閉
1099 1 Bak_Light = 0;//開機背光開
1100 1
1101 1 Timer0_Init();
1102 1 Init_lcd();//設(shè)置液晶顯示器
1103 1
1104 1 Clr_Scr();//清屏
1105 1 Disp_Img(logo); //顯示湘靈電子LOGO開機畫面
1106 1 Delay12864(60000);//Delay 4s
1107 1
1108 1 Bak_Light = 1;//關(guān)閉背光
1109 1 Bell_Swh = read_clock(0xc9);//讀取開,關(guān)的狀態(tài)
1110 1 Lcd_Mark1();
1111 1
1112 1 while(1)//主循環(huán)
1113 1 {
1114 2 //設(shè)置時鐘的初始值,顯示05年1月1號星期六12:00:00
1115 2 if(Rst_Key == 0)//按下系統(tǒng)復(fù)位鍵,S4
1116 2 {
1117 3 Delay(1000);//延時消抖
1118 3 if(Rst_Key == 0)
1119 3 {
1120 4 Init_1302();//初始化時鐘
1121 4 }
1122 3 }
1123 2
1124 2 if(OK_Key == 0 && Dec_Key ==0 )//進入鬧鐘設(shè)置界面
1125 2 {
1126 3 Delay12864(100);
1127 3 if(OK_Key == 0 && Dec_Key ==0 )
1128 3 {
1129 4 Lcd_Mark2();
1130 4 if(Bell_Swh == 0){Mcs=0;Scs=1;Disp_Chinese(2,32,guan);}//關(guān)
1131 4 else {Mcs=0;Scs=1;Disp_Chinese(2,32,kai);}
1132 4 while(1)
C51 COMPILER V7.50 ZDBWNL 12/22/2005 13:04:37 PAGE 20
1133 4 {
1134 5 if (OK_Key == 0) // 設(shè)置和選擇項目鍵
1135 5 {
1136 6 Delay(1000);
1137 6 if(OK_Key == 0)
1138 6 {
1139 7 id2++;if(id2>5) id2=0;
1140 7 }
1141 6 while(OK_Key == 0);//等待鍵松開
1142 6 }
1143 5 switch( id2 )
1144 5 {
1145 6 case 0:Disp2();break;//正常顯示
1146 6 case 1:Kgb = 1;id_case2_key();Disp2();break;//開關(guān)
1147 6 case 2:Kgb= 0;Hourb=1;id_case2_key();Disp2();break;//
1148 6 case 3:Hourb=0;Minb=1;id_case2_key();Disp2();break;
1149 6 case 4:Minb=0;Secb=1;id_case2_key();Disp2();break;
1150 6 case 5:Secb=0;id2 = 0;Lcd_Mark1();goto FF;break;//返回主界面
1151 6 default:break;
1152 6 }
1153 5 }//while(1)
1154 4 }//if
1155 3 }//if
1156 2 /*****************************************/
1157 2 FF: //返回主界面
1158 2 /*****************************************/
1159 2 if(flag == 0)
1160 2 {
1161 3 Mcs=0;Scs=1;
1162 3 Disp_Digit(3,8,maohao);// :閃爍
1163 3 Disp_Digit(3,32,maohao);
1164 3 }
1165 2 else
1166 2 {
1167 3 Mcs=0;Scs=1;
1168 3 Disp_Digit(3,8,space);//顯示空格
1169 3 Disp_Digit(3,32,space);
1170 3 }
1171 2 if (OK_Key == 0) // 設(shè)置和選擇項目鍵
1172 2 {
1173 3 Delay(1000);
1174 3 if(OK_Key == 0)
1175 3 {
1176 4 id++;if(id>7)id=0;
1177 4 }
1178 3 while(OK_Key == 0);//等待鍵松開
1179 3 }
1180 2 switch( id )
1181 2 {
1182 3 case 0:sec = 0; Disp( );break;//正常顯示
1183 3 case 1:year = 1;id_case1_key();Disp();break;//年
1184 3 case 2:year=0;mon=1;id_case1_key();Disp();break;//月
1185 3 case 3:mon=0;day=1;id_case1_key();Disp();break; //日
1186 3 case 4:day=0;weekk=1;id_case1_key();Disp();break;//星期
1187 3 case 5:weekk=0;hour=1;id_case1_key();Disp();break; //小時
1188 3 case 6:hour=0;min=1;id_case1_key();Disp();break; //分鐘
1189 3 case 7:min=0;sec=1;id_case1_key();Disp();break; //秒
1190 3 default:break;
1191 3 }
1192 2
1193 2 if(Bell_Swh == 1)//鬧鐘為
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -