📄 wannianli.lst
字号:
453 2 dat>>=1;
454 2 }
455 1 }
456
457 /******************************************************************************/
458 unsigned int ReadTemperature(void)//读取温度
459 {
460 1 unsigned char a=0;
461 1 unsigned char b=0;
462 1 unsigned int t=0;
463 1 float tt=0;
464 1 Init_DS18B20();
465 1 WriteOneChar(0xCC); // 跳过读序号列号的操作
466 1 WriteOneChar(0x44); // 启动温度转换
467 1 Init_DS18B20();
468 1 WriteOneChar(0xCC); //跳过读序号列号的操作
469 1 WriteOneChar(0xBE); //读取温度寄存器
470 1 a=ReadOneChar(); //读低8位
471 1 b=ReadOneChar(); //读高8位
472 1 t=b;
473 1 t<<=8;
474 1 t=t|a;
475 1 tt=t*0.0625;
476 1 t= tt*10+0.5; //放大10倍输出并四舍五入
477 1 return(t);
478 1 }
479
480 /******************************************************************************/
481 //1302驱动程序
482 void clock_out(unsigned char dd)
483 {
484 1 ACC=dd;
485 1 clock_dat=a0; clock_clk=1; clock_clk=0;
486 1 clock_dat=a1; clock_clk=1; clock_clk=0;
487 1 clock_dat=a2; clock_clk=1; clock_clk=0;
488 1 clock_dat=a3; clock_clk=1; clock_clk=0;
489 1 clock_dat=a4; clock_clk=1; clock_clk=0;
490 1 clock_dat=a5; clock_clk=1; clock_clk=0;
491 1 clock_dat=a6; clock_clk=1; clock_clk=0;
492 1 clock_dat=a7; clock_clk=1; clock_clk=0;
493 1 }
494
495 /******************************************************************************/
496 unsigned char clock_in(void)
497 {
498 1 clock_dat=1;
499 1 a0=clock_dat;
500 1 clock_clk=1; clock_clk=0; a1=clock_dat;
501 1 clock_clk=1; clock_clk=0; a2=clock_dat;
502 1 clock_clk=1; clock_clk=0; a3=clock_dat;
503 1 clock_clk=1; clock_clk=0; a4=clock_dat;
504 1 clock_clk=1; clock_clk=0; a5=clock_dat;
505 1 clock_clk=1; clock_clk=0; a6=clock_dat;
506 1 clock_clk=1; clock_clk=0; a7=clock_dat;
507 1 return(ACC);
508 1 }
509
510 /******************************************************************************/
511 unsigned char read_clock(unsigned char ord)
512 {
C51 COMPILER V7.50 WANNIANLI 05/23/2006 13:38:52 PAGE 10
513 1 unsigned char dd=0;
514 1 clock_clk=0;
515 1 clock_Rst=0;
516 1 clock_Rst=1;
517 1 clock_out(ord);
518 1 dd=clock_in();
519 1 clock_Rst=0;
520 1 clock_clk=1;
521 1 return(dd);
522 1 }
523
524 /******************************************************************************/
525 void write_clock(unsigned char ord, unsigned char dd)
526 {
527 1 clock_clk=0;
528 1 clock_Rst=0;
529 1 clock_Rst=1;
530 1 clock_out(ord);
531 1 clock_out(dd);
532 1 clock_Rst=0;
533 1 clock_clk=1;
534 1 }
535
536 /******************************************************************************/
537 void Disp(void)//显示和闪烁函数!
538 {
539 1 unsigned int i=0;
540 1 unsigned char a=0,b=0,c=0,f=0;
541 1
542 1 i=ReadTemperature();//读温度并送显
543 1 a=i/100;
544 1 Mcs=1;Scs=0;
545 1 Disp_Digit(5,40,zero+a*16);
546 1 b=i/10-a*10;
547 1 Mcs=1;Scs=0;
548 1 Disp_Digit(5,48,zero+b*16);
549 1 c=i-a*100-b*10;
550 1 Mcs=0;Scs=1;
551 1 Disp_Digit(5,0,zero+c*16);
552 1
553 1 if(sec==1) //秒闪烁标志位
554 1 {
555 2 if(flag==1)
556 2 {
557 3 d=read_clock(0x81);//读秒
558 3 e=d;
559 3 d=d>>4;
560 3 e=e&0x0f;
561 3 Mcs=0;Scs=1;
562 3 Disp_Digit(3,40,zero+d*16);//送显示
563 3 Disp_Digit(3,48,zero+e*16);
564 3 }
565 2 else
566 2 {
567 3 Mcs=0;Scs=1;
568 3 Disp_Digit(3,40,space); //显示空格
569 3 Disp_Digit(3,48,space);
570 3 }
571 2 }
572 1 else
573 1 {
574 2 d=read_clock(0x81);//读秒
C51 COMPILER V7.50 WANNIANLI 05/23/2006 13:38:52 PAGE 11
575 2 e=d;
576 2 d=d>>4;
577 2 e=e&0x0f;
578 2 Mcs=0;Scs=1;
579 2 /********************************************************************************/
580 2 if(d == 0 && e == 0)
581 2 {
582 3 flag_sec = 1;//秒标志位设定
583 3 }
584 2 /********************************************************************************/
585 2 Disp_Digit(3,40,zero+d*16);
586 2 Disp_Digit(3,48,zero+e*16);
587 2 }
588 1
589 1 if(min==1) //分钟闪烁标志位
590 1 {
591 2 if(flag==1)
592 2 {
593 3 d=read_clock(0x83);//读分钟
594 3 e=d;
595 3 d=d>>4;
596 3 e=e&0x0f;
597 3 Mcs=0;Scs=1;
598 3 Disp_Digit(3,16,zero+d*16);
599 3 Disp_Digit(3,24,zero+e*16);
600 3 }
601 2 else
602 2 {
603 3 Mcs=0;Scs=1;
604 3 Disp_Digit(3,16,space); //显示空格
605 3 Disp_Digit(3,24,space);
606 3 }
607 2 }
608 1 else
609 1 {
610 2 d=read_clock(0x83);//读分钟
611 2 e=d;
612 2 d=d>>4;
613 2 e=e&0x0f;
614 2 Mcs=0;Scs=1;
615 2 /******************************************************************************/
616 2 if(d == 0 && e == 0)
617 2 {
618 3 flag_min = 1;//分标志位设定
619 3 }
620 2 /******************************************************************************/
621 2 Disp_Digit(3,16,zero+d*16);
622 2 Disp_Digit(3,24,zero+e*16);
623 2 }
624 1
625 1 if(flag_sec == 1 && flag_min == 1)
626 1 {
627 2 Beep();//整点报警
628 2 flag_sec = 0;//清除标志位
629 2 flag_min = 0;
630 2 }
631 1
632 1 if(hour==1) //小时闪烁标志位
633 1 {
634 2 if(flag==1)
635 2 {
636 3 d=read_clock(0x85);//读小时
C51 COMPILER V7.50 WANNIANLI 05/23/2006 13:38:52 PAGE 12
637 3 e=d;
638 3 d=d>>4;
639 3 e=e&0x0f;
640 3 Mcs=1;Scs=0;
641 3 Disp_Digit(3,56,zero+d*16);
642 3 Mcs=0;Scs=1;
643 3 Disp_Digit(3,0,zero+e*16);
644 3 }
645 2 else
646 2 {
647 3 Mcs=1;Scs=0;
648 3 Disp_Digit(3,56,space); //显示空格
649 3 Mcs=0;Scs=1;
650 3 Disp_Digit(3,0,space);
651 3 }
652 2 }
653 1 else
654 1 {
655 2 d=read_clock(0x85);//读小时
656 2 e=d;
657 2 d=d>>4;
658 2 e=e&0x0f;
659 2 Mcs=1;Scs=0;
660 2 Disp_Digit(3,56,zero+d*16);
661 2 Mcs=0;Scs=1;
662 2 Disp_Digit(3,0,zero+e*16);
663 2 }
664 1
665 1 if(year==1) //年闪烁标志位
666 1 {
667 2 if(flag==1)
668 2 {
669 3 d=read_clock(0x8d);//读年
670 3 e=d;
671 3 d=d>>4;
672 3 e=e&0x0f;
673 3 Mcs=1;Scs=0;
674 3 Disp_Digit(1,8,two);
675 3 Disp_Digit(1,16,zero);
676 3 Disp_Digit(1,24,zero+d*16);
677 3 Disp_Digit(1,32,zero+e*16);
678 3 }
679 2 else
680 2 {
681 3 Mcs=1;Scs=0;
682 3 Disp_Digit(1,24,space); //显示空格
683 3 Disp_Digit(1,32,space);
684 3 }
685 2 }
686 1 else
687 1 {
688 2 d=read_clock(0x8d);//读年
689 2 e=d;
690 2 d=d>>4;
691 2 e=e&0x0f;
692 2 Mcs=1;Scs=0;
693 2 Disp_Digit(1,8,two);
694 2 Disp_Digit(1,16,zero);
695 2 Disp_Digit(1,24,zero+d*16);
696 2 Disp_Digit(1,32,zero+e*16);
697 2 }
698 1
C51 COMPILER V7.50 WANNIANLI 05/23/2006 13:38:52 PAGE 13
699 1 if(mon==1) //月闪烁标志位
700 1 {
701 2 if(flag==1)
702 2 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -