📄 12864lcd显示.lst
字号:
946 1 timecount++;
947 1 if(timecount > 9)//500MS
948 1 {
949 2 timecount = 0;
950 2 flag = ~flag; //闪烁标志位
951 2 }
952 1 }
953
954
955 void Init_1302(void) //设置1302的初始时间
956 {
957 1 write_clock(0x8e,0x00);//允许写操作
958 1 write_clock(0x8c,0x05);//年
959 1 write_clock(0x8a,0x06);//星期
960 1 write_clock(0x88,0x01);//月
961 1 write_clock(0x86,0x01);//日
962 1 write_clock(0x84,0x12);//小时
963 1 write_clock(0x82,0x00);//分钟
964 1 write_clock(0x80,0x00);//秒
965 1 write_clock(0x90,0xa5);//充电
966 1 write_clock(0x8e,0x80);//禁止写操作
967 1 }
968
969
970 void Lcd_Mark1(void)//在LCD预定的位置上写入汉字
971 {
972 1 Clr_Scr();//清屏
973 1
974 1 LCD_Write_string(1,1,bt);//标题-电子万年历-
975 1 LCD_set_xy(2,1);
976 1 LCD_Write_number(2);//2
977 1 LCD_Write_number(0);//0
978 1 LCD_Write_string(2,3,nian);//显示年月日
979 1 LCD_Write_string(2,5,yue);
980 1 LCD_Write_string(2,7,ri);
981 1 LCD_Write_string(3,0,xq);//星期
982 1 LCD_Write_string(4,0,sw);//室温
983 1 LCD_Write_string(4,4,ssd);//℃
984 1
985 1 if(Bell_Swh == 1)//闹钟为开
C51 COMPILER V7.02b 12864LCD_允_ 04/06/2009 00:17:44 PAGE 17
986 1 {
987 2 LCD_Write_string(4,6,nzbz);//显示闹钟图标
988 2 }
989 1 }
990
991
992 void Lcd_Mark2(void) //闹钟界面显示字符
993 {
994 1 Clr_Scr();//清屏
995 1
996 1 //显示闹钟设定等几个汉字
997 1 LCD_Write_string(1,1,nzsd);//
998 1 LCD_Write_string(2,3,xsfz);//
999 1 }
1000
1001
1002 void Bell(void) //启动蜂鸣器
1003 {
1004 1 Bell_Out = 0;
1005 1 Delaynms(150);//150ms
1006 1 Bell_Out = 1;
1007 1 Delaynms(50);//50ms
1008 1 Bell_Out = 0;
1009 1 Delaynms(250);//250ms
1010 1 Bell_Out = 1;
1011 1 Delaynms(400);//400ms
1012 1 }
1013
1014
1015 void main(void)//主函数
1016 {
1017 1 Timer0_Init();//定时器T0初始化
1018 1 Lcd_init();//设置液晶显示器
1019 1
1020 1 Clr_Scr();//清屏
1021 1 Disp_img(logo); //显示LOGO
1022 1 Delaynms(1000);
1023 1 Lcd_init();//从图形显示状态下返回
1024 1
1025 1 Bell_Swh = read_clock(0xc9);//读取开关的状态
1026 1 Lcd_Mark1( );
1027 1
1028 1 while(1)//主循环
1029 1 {
1030 2 //设置时钟的初始值,显示05年1月1号12:00:00
1031 2 if(Add_Key == 0 && Dec_Key == 0)
1032 2 {
1033 3 Delay(1000);
1034 3 if(Add_Key == 0 && Dec_Key == 0)
1035 3 {
1036 4 Init_1302();
1037 4 }
1038 3 }
1039 2
1040 2 if(OK_Key == 0 && Dec_Key ==0 )//进入闹钟设置界面
1041 2 {
1042 3 Delaynms(100);
1043 3 if(OK_Key == 0 && Dec_Key ==0 )
1044 3 {
1045 4 Lcd_Mark2();
1046 4 if(Bell_Swh == 0)
1047 4 {
C51 COMPILER V7.02b 12864LCD_允_ 04/06/2009 00:17:44 PAGE 18
1048 5 LCD_Write_string(1,6,guan);
1049 5 }//关
1050 4 else
1051 4 {
1052 5 LCD_Write_string(1,6,kai);
1053 5 }
1054 4 while(1)
1055 4 {
1056 5 if (OK_Key == 0) // 设置和选择项目键
1057 5 {
1058 6 Delay(1000);
1059 6 if(OK_Key == 0)
1060 6 {
1061 7 id2++;
1062 7 if(id2>4)
1063 7 id2=0;
1064 7 }
1065 6 while(OK_Key == 0);//等待键松开
1066 6 }
1067 5 switch( id2 )
1068 5 {
1069 6 case 0:
1070 6 Disp2();
1071 6 break;//正常显示
1072 6 case 1:
1073 6 Kgb = 1;
1074 6 id_case2_key();
1075 6 Disp2();
1076 6 break;//开关
1077 6 case 2:
1078 6 Kgb= 0;
1079 6 Hourb=1;
1080 6 id_case2_key();
1081 6 Disp2();
1082 6 break;//
1083 6 case 3:
1084 6 Hourb=0;
1085 6 Minb=1;
1086 6 id_case2_key();
1087 6 Disp2();break;
1088 6 case 4:
1089 6 Minb=0;
1090 6 id2=0;
1091 6 Lcd_Mark1();
1092 6 goto MF;
1093 6 break;//返回主界面
1094 6 default:
1095 6 break;
1096 6 }
1097 5 }//while(1)
1098 4 }//if
1099 3 }//if
1100 2 /*****************************************/
1101 2 MF: //返回主界面
1102 2 /*****************************************/
1103 2 if (OK_Key == 0) // 设置和选择项目键
1104 2 {
1105 3 Delay(1000);
1106 3 if(OK_Key == 0)
1107 3 {
1108 4 id++;if(id>7)id=0;
1109 4 }
C51 COMPILER V7.02b 12864LCD_允_ 04/06/2009 00:17:44 PAGE 19
1110 3 while(OK_Key == 0);//等待键松开
1111 3 }
1112 2 switch( id )
1113 2 {
1114 3 case 0:
1115 3 sec=0;
1116 3 Disp();
1117 3 break;//正常显示
1118 3 case 1:
1119 3 year=1;
1120 3 id_case1_key();
1121 3 Disp();
1122 3 break;//年
1123 3 case 2:
1124 3 year=0;
1125 3 mon=1;
1126 3 id_case1_key();
1127 3 Disp();
1128 3 break;//月
1129 3 case 3:
1130 3 mon=0;
1131 3 day=1;
1132 3 id_case1_key();
1133 3 Disp();
1134 3 break; //日
1135 3 case 4:
1136 3 day=0;
1137 3 weekk=1;
1138 3 id_case1_key();
1139 3 Disp();
1140 3 break;//星期
1141 3 case 5:
1142 3 weekk=0;
1143 3 hour=1;
1144 3 id_case1_key();
1145 3 Disp();
1146 3 break; //小时
1147 3 case 6:
1148 3 hour=0;
1149 3 min=1;
1150 3 id_case1_key();
1151 3 Disp();
1152 3 break; //分钟
1153 3 case 7:
1154 3 min=0;
1155 3 sec=1;
1156 3 id_case1_key();
1157 3 Disp();
1158 3 break; //秒
1159 3 default:
1160 3 break;
1161 3 }
1162 2
1163 2 if(Bell_Swh == 1)//闹钟为开
1164 2 {
1165 3 H_Bell=read_clock(0xc3);//读取闹钟的时
1166 3 S_Bell=read_clock(0xc5);//读取闹钟的分
1167 3
1168 3 H_1302=read_clock(0x85);//读小时
1169 3 S_1302=read_clock(0x83);//读分钟
1170 3
1171 3 if(H_Bell == H_1302)
C51 COMPILER V7.02b 12864LCD_允_ 04/06/2009 00:17:44 PAGE 20
1172 3 {
1173 4 if(S_Bell == S_1302)
1174 4 {
1175 5 Clr_Scr();//清屏
1176 5 LCD_Write_string(2,2,nzsjd);//闹钟显示时间到!
1177 5
1178 5 while(S_Bell == S_1302)//判断是否到闹钟设定时间
1179 5 {
1180 6 Bell();
1181 6 S_Bell=re
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -