📄 1602时钟.lst
字号:
185 void key()
186 {
187 1 uchar clock_s1, clock_s2, clock_f1, clock_f2;
188 1 rw=0;
189 1
190 1 if(set==0)
191 1 {
192 2 delay(10);
193 2 if(set==0)
194 2 {
195 3 did=0;
196 3 delay(10); did=1;
197 3 b++;
198 3
199 3 }
200 2 while(!set);
201 2
202 2 if(b==1)
203 2 {
204 3 hour=clock_ss*10+clock_sg;
205 3 mie=clock_fs*10+clock_fg;
206 3 write_com(0x80+0x45);
207 3 write_com(0x0f);
208 3
209 3 }
210 2 if(b==2)
211 2 {
212 3 write_com(0x80+0x48);
213 3
214 3
215 3 }
216 2 if(b==3)
217 2 {
218 3 write_com(0x80+0x45);
219 3 write_com(0x0c);
220 3 b=0;
221 3 clock_s1=hour/10;
222 3 clock_s2=hour%10;
223 3 clock_s1=clock_s1&0xff;
224 3 clock_s2=clock_s2&0xff;
225 3 clock_s1<<=4;
226 3 clock_s1=clock_s1|clock_s2;
227 3
228 3 clock_f1=mie/10;
229 3 clock_f2=mie%10;
230 3 clock_f1=clock_f1&0xff; //全1出1 与运算
231 3 clock_f2=clock_f2&0xff;
232 3 clock_f1<<=4;
233 3 clock_f1=clock_f1|clock_f2;
234 3
235 3 write_1302(0x8e,0x00); //WP=0 写操作
236 3 write_1302(0x80,0x00);
237 3 write_1302(0x82,clock_f1);
238 3 write_1302(0x84,clock_s1);
239 3 write_1302(0x8e,0x80); //WP=1 写保护
240 3
241 3
C51 COMPILER V7.06 1602蔩钟 12/29/2008 20:43:40 PAGE 5
242 3 }
243 2 }
244 1 if(b!=0)
245 1 {
246 2 if(up==0)
247 2 {
248 3 delay(10);
249 3 if(up==0)
250 3 {
251 4 did=0;
252 4 delay(10);
253 4 did=1;
254 4 while(!up);
255 4 if(b==1)
256 4 {
257 5
258 5 hour++;
259 5 if(hour>=24)
260 5 {
261 6 delay(1);
262 6 hour=0;
263 6 }
264 5 display(4,hour);
265 5 write_com(0x80+0x45);
266 5
267 5 }
268 4 if(b==2)
269 4 {
270 5 mie++;
271 5
272 5 if(mie>=60)
273 5 {
274 6 mie=0;
275 6 }
276 5 display(7,mie);
277 5 write_com(0x80+0x48);
278 5 }
279 4 }
280 3
281 3 }
282 2
283 2 if(down==0)
284 2 {
285 3 delay(10);
286 3 if(down==0)
287 3 {
288 4 did=0;
289 4 delay(10);
290 4 did=1;
291 4 while(!down);
292 4 if(b==1)
293 4 {
294 5 hour--;
295 5 if(hour<0)
296 5 {
297 6
298 6 hour=23;
299 6 }
300 5 display(4,hour);
301 5 write_com(0x80+0x45);
302 5
303 5 }
C51 COMPILER V7.06 1602蔩钟 12/29/2008 20:43:40 PAGE 6
304 4 if(b==2)
305 4 {
306 5 mie--;
307 5 if(mie<0)
308 5 {
309 6 mie=59;
310 6 }
311 5 display(7,mie);
312 5 write_com(0x80+0x48);
313 5 }
314 4
315 4 }
316 3
317 3 }
318 2 }
319 1 }
320
321 void main()
322 {
323 1 uchar temp=0x80;
324 1 uchar i;
325 1 init();
326 1 for(num=0;num<14;num++)
327 1 {
328 2 write_data(table[num]);
329 2 delay(255);
330 2 }
331 1
332 1 write_com(0x80+0x40);
333 1 for(num=0;num<15;num++)
334 1 {
335 2 write_data(table1[num]);
336 2
337 2 }
338 1 /*for(num=0;num<16;num++)
339 1 {
340 1 write_com(0x18);
341 1 delay(20);
342 1 }*/
343 1 while(1)
344 1 {
345 2
346 2 if(b==0)
347 2
348 2 { temp=0x81;
349 3 for(i=0;i<3;i++)
350 3 {
351 4 clk_time[i]=read_1302(temp);
352 4 temp+=2;
353 4 }
354 3 display(0x4b,0x00);
355 3 }
356 2
357 2
358 2 key();
359 2 }
360 1 }
361
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 921 ----
C51 COMPILER V7.06 1602蔩钟 12/29/2008 20:43:40 PAGE 7
CONSTANT SIZE = 32 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 15 3
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -