📄 arry_key.lst
字号:
302 2 ucCurtime[i] = R1302(ucAddr);/*格式为: 秒 分 时 日 月 星期 年 */
303 2 ucAddr += 2;
C51 COMPILER V7.50 ARRY_KEY 05/12/2008 22:17:16 PAGE 6
304 2 }
305 1 }
306 /*//////////////////////////////////////////////////////////////////////*/
307
308 void dis_time()
309 {
310 1 char sec[2],min[2],hour[2],day[2],mon[2],year[2],week;
311 1
312 1 sec[1]=(ucCurtime[0]&0x0f)|0x30;
313 1 sec[0]=((ucCurtime[0]&0x70)>>4)|0x30;
314 1
315 1 min[1]=(ucCurtime[1]&0x0f)|0x30;
316 1 min[0]=((ucCurtime[1]&0x70)>>4)|0x30;
317 1
318 1 hour[1]=(ucCurtime[2]&0x0f)|0x30;
319 1 hour[0]=((ucCurtime[2]&0x30)>>4)|0x30;
320 1
321 1 day[1]=(ucCurtime[3]&0x0f)|0x30;
322 1 day[0]=((ucCurtime[3]&0x30)>>4)|0x30;
323 1
324 1 mon[1]=(ucCurtime[4]&0x0f)|0x30;
325 1 mon[0]=((ucCurtime[4]&0x10)>>4)|0x30;
326 1
327 1 week=ucCurtime[5]&0x07;
328 1
329 1 year[1]=(ucCurtime[6]&0x0f)|0x30;
330 1 year[0]=((ucCurtime[6]&0xf0)>>4)|0x30;
331 1
332 1 lcdwritecom(0x80);
333 1 delayms(5) ;
334 1 chardis("20");
335 1 chardis(year);
336 1 chardis("年");
337 1 chardis(mon);
338 1 chardis("月");
339 1 chardis(day);
340 1 chardis("日");
341 1 chardis(" ");
342 1
343 1 lcdwritecom(0x90);
344 1 delayms(5) ;
345 1 chardis(" ");
346 1 chardis(" ");
347 1 chardis("星");
348 1 chardis("期");
349 1 if(week==3)
350 1 {
351 2 lcdwritedata(0xc8) ;
352 2 delayms(1) ;
353 2 lcdwritedata(0xfd) ;
354 2 delayms(1) ;
355 2 }
356 1 else
357 1 chardis(Week+(week-1)*2);
358 1
359 1
360 1 lcdwritecom(0x88);
361 1 delayms(5) ;
362 1 chardis(" ");
363 1 lcdwritedata(' ') ;
364 1 delayms(1) ;
365 1 chardis(hour);
C51 COMPILER V7.50 ARRY_KEY 05/12/2008 22:17:16 PAGE 7
366 1 lcdwritedata(':') ;
367 1 delayms(1) ;
368 1 chardis(min);
369 1 lcdwritedata(':') ;
370 1 delayms(1) ;
371 1 chardis(sec);
372 1
373 1 }
374
375 void DisTemperature( float Ddata) //显示温度
376 {
377 1 unsigned char z[2],x[4],flag=0,i=0,j=0;
378 1 unsigned int id,fd;
379 1 float Dd;
380 1 if(Ddata<0) //判是否负,并取绝对值
381 1 {
382 2 flag=1;
383 2 Dd=-Ddata;
384 2 }
385 1 else
386 1 Dd=Ddata;
387 1 id=(int)Dd; //取整数部分
388 1 fd=(Dd-id)*10000; //取小数部分
389 1 z[0]=id/10; //将各位数字取出
390 1 z[1]=id%10;
391 1 x[0]=fd/1000;
392 1 x[1]=(fd-x[0]*1000)/100;
393 1 x[2]=(fd/10)%10;
394 1 x[3]=fd%10;
395 1 lcdwritecom(0x98);
396 1 delayms(5) ;
397 1 chardis("温");
398 1 chardis("度");
399 1 chardis(": ");
400 1 if(flag)
401 1 {
402 2 lcdwritedata('-') ;
403 2 delayms(1) ; //判断是否负,是负输出负号
404 2 }
405 1 if(z[0]) //判断是第一个数字是否为0,若是,跳过第一个,输出第二个
406 1 {
407 2 lcdwritedata(z[0]|0x30) ;
408 2 delayms(1) ;
409 2 }
410 1 lcdwritedata(z[1]|0x30) ;
411 1 delayms(1) ;
412 1 lcdwritedata('.') ;
413 1 delayms(1) ;
414 1 lcdwritedata(x[j]|0x30) ;
415 1 delayms(1) ;
416 1
417 1
418 1 lcdwritecom(0x9e);
419 1 delayms(5) ;
420 1 chardis("度");
421 1 }
422
423 void disstr(unsigned char x,unsigned char *p)
424 {
425 1 int i,j;
426 1 lcdwritecom(x);
427 1 delayms(5);
C51 COMPILER V7.50 ARRY_KEY 05/12/2008 22:17:16 PAGE 8
428 1 for(i=0;p[i]!=0;i++)
429 1 {
430 2 lcdwritedata(p[i]) ;
431 2 delayms(1);
432 2 }
433 1 for(j=i;j<16;j++)
434 1 {
435 2 lcdwritedata(' ') ;
436 2 delayms(1);
437 2 }
438 1 }
439
440 void Gunp()
441 {
442 1 unsigned char a,b,c,d,t,i,j;
443 1 a=0x80;
444 1 b=0x90;
445 1 c=0x88;
446 1 d=0x98;
447 1
448 1 disstr(a,dis1);
449 1 disstr(b,dis2);
450 1 disstr(c,dis3);
451 1 disstr(d,dis4);
452 1 for(j=0;j<20;j++)
453 1 delayms(100);
454 1 for(i=1;i<9;i++)
455 1 {
456 2 t=a; a=b; b=c; c=d; d=t;
457 2 disstr(a,dis1);
458 2 disstr(b,dis2);
459 2 disstr(c,dis3);
460 2 disstr(d,dis4);
461 2
462 2 for(j=0;j<5;j++)
463 2 delayms(100);
464 2 }
465 1 for(j=0;j<20;j++)
466 1 delayms(100);
467 1 }
468
469
470
471
472
473
474
475 void main()
476 {
477 1 lcdinitial() ;
478 1
479 1 W1302(0x8e,0x00);
480 1 W1302(0x80,0x00);
481 1 W1302(0x90,0xa8);
482 1 W1302(0x8e,0x80);
483 1 Set1302(settime);
484 1 W1302(0x8e,0x80);
485 1
486 1 photodis(tutab);
487 1 delayms(5);
488 1 lcdinitial() ;
489 1 Gunp();
C51 COMPILER V7.50 ARRY_KEY 05/12/2008 22:17:16 PAGE 9
490 1 while(1)
491 1 {
492 2 Get1302();
493 2 dis_time();
494 2 delayms(5);
495 2 DData();
496 2 DisTemperature( tem );
497 2
498 2
499 2 }
500 1
501 1 }
502
503 void lcdinitial()
504 {
505 1 RST = 1 ;
506 1 _nop_() ;
507 1 PSB = 1 ;
508 1 _nop_() ;
509 1 lcdwritecom(0x30) ;
510 1 delayms(5) ;
511 1 lcdwritecom(0x0c) ;
512 1 delayms(5) ;
513 1 lcdwritecom(0x01) ;
514 1 delayms(5) ;
515 1 lcdwritecom(0x06) ;
516 1 delayms(5) ;
517 1 lcdwritecom(0x80) ;
518 1 delayms(5) ;
519 1 }
520
521 void lcdwritecom(unsigned char comm)
522 {
523 1 RS = 0 ;
524 1 RW = 0 ;
525 1 P0 = comm ;
526 1 E = 1 ;
527 1 E = 0 ;
528 1 }
529
530 void lcdwritedata(unsigned char dat)
531 {
532 1
533 1 RS = 1 ;
534 1 RW = 0 ;
535 1 P0 = dat ;
536 1 E = 1 ;
537 1 E = 0 ;
538 1 }
539
540 void chardis(char *ddata)
541 {
542 1 lcdwritedata(*ddata++) ;
543 1 delayms(1) ;
544 1 lcdwritedata(*ddata) ;
545 1 delayms(1) ;
546 1 }
547
548
549
550 void wtzb(unsigned int x,unsigned int y)
551 {
C51 COMPILER V7.50 ARRY_KEY 05/12/2008 22:17:16 PAGE 10
552 1 lcdwritecom(y);
553 1 delayms(5) ;
554 1 lcdwritecom(x);
555 1 delayms(5) ;
556 1 }
557 void delayms(unsigned char ms)
558 // 延时子程序
559 {
560 1 unsigned char i ;
561 1 while(ms--)
562 1 {
563 2 for(i = 0; i < 120; i++);
564 2 }
565 1 }
566
567 //********显示图形子程序****************
568 void photodis(unsigned char *s)
569 {
570 1
571 1 lcdwritecom(0x36) ;
572 1 delayms(5) ;
573 1 lcdx=0X80;
574 1 for (count3=0X02 ;count3!=0;count3--)
575 1 {
576 2 lcdy=0X80;
577 2
578 2 for (count2=0X20;count2!=0;count2--)
579 2 {
580 3
581 3
582 3 wtzb(lcdx,lcdy);
583 3 for (count1=0X10;count1!=0;count1--)
584 3 {
585 4 lcdwritedata(*s++);
586 4 delayms(1) ;
587 4
588 4 }
589 3 lcdy+=1;
590 3 }
591 2 lcdx=0X88;
592 2 }
593 1 lcdwritecom(0x34);
594 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1718 ----
CONSTANT SIZE = 1054 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 87 56
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 + -