📄 main.lst
字号:
507 3 if(PlayAdd != 0x00)
508 3 {
509 4 clock_cutt[9] = 0x1; //1 为打开定时
510 4 PlayAdd = 0;
511 4 }
512 3 else if(PlaySub != 0x00)
513 3 {
514 4 clock_cutt[9] = 0; //0 为关闭定时
515 4 PlaySub = 0;
516 4 }
517 3 } break;
518 2 }
519 1 }
520
521
522 clock3_set() //为定时3设置参数,放入下面代码后,可能因为编译器问题,导致正常时间不能显示,故做成函数
523 {
524 1 switch(PlayMode_low)
525 1 {
526 2 case 1:
527 2 {
528 3 if(PlayAdd != 0x00)
529 3 {
530 4 clock_cutt[14]++;
531 4 if(clock_cutt[14]>23)
532 4 clock_cutt[14] = 0;
533 4 PlayAdd = 0;
534 4 }
535 3 else if(PlaySub != 0x00)
536 3 {
537 4 if(clock_cutt[14]==0)
538 4 {
539 5 clock_cutt[14]=23;
540 5 }
541 4 else{
542 5 clock_cutt[14]--;
543 5 }
544 4 PlaySub = 0;
545 4 }
546 3 } break;
547 2
548 2 case 2:
549 2 {
550 3 if(PlayAdd != 0x00)
C51 COMPILER V7.00 MAIN 09/30/2007 23:44:12 PAGE 10
551 3 {
552 4 clock_cutt[13]++;
553 4 PlayAdd = 0;
554 4 }
555 3 else if(PlaySub != 0x00)
556 3 {
557 4 if(clock_cutt[13]==0)
558 4 {
559 5 clock_cutt[13]=59;
560 5 }
561 4 else{
562 5 clock_cutt[13]--;
563 5 }
564 4 PlaySub = 0;
565 4 }
566 3 } break;
567 2 case 3:
568 2 {
569 3 if(PlayAdd != 0x00)
570 3 {
571 4 clock_cutt[12] = 0x1; //1 为打开定时
572 4 PlayAdd = 0;
573 4 }
574 3 else if(PlaySub != 0x00)
575 3 {
576 4 clock_cutt[12] = 0; //0 为关闭定时
577 4 PlaySub = 0;
578 4 }
579 3 } break;
580 2 }
581 1 }
582 Play_set()
583 {
584 1
585 1 if(PlayMode_hi == 0) //正常模式
586 1 {
587 2 cutt_mode();
588 2 clock_play(0);
589 2 }
590 1 else if(PlayMode_hi == 1) //设置时间
591 1 {
592 2 play_mode = 0;
593 2 clock_play(PlayMode_low);
594 2 led_play = 0x1;
595 2 set_cutt_clock();
596 2 }
597 1
598 1
599 1 else if(PlayMode_hi == 2) //设置日期
600 1 {
601 2 play_mode = 3;
602 2 clock_play(PlayMode_low);
603 2 led_play = 0x2;
604 2 set_date();
605 2 }
606 1 else if(PlayMode_hi == 3) //设置定时1
607 1 {
608 2 play_mode = 6;
609 2 clock_play(PlayMode_low);
610 2 led_play = 0x4;
611 2 clock1_set();
612 2
C51 COMPILER V7.00 MAIN 09/30/2007 23:44:12 PAGE 11
613 2 }
614 1 else if(PlayMode_hi == 4) //设置定时2
615 1 {
616 2 play_mode = 9;
617 2 clock_play(PlayMode_low);
618 2 led_play = 0x8;
619 2 clock2_set();
620 2
621 2 }
622 1 else if(PlayMode_hi == 5) //设置定时3
623 1 {
624 2 play_mode = 12;
625 2 clock_play(PlayMode_low);
626 2 led_play = 0x10;
627 2 clock3_set();
628 2 }
629 1 }
630
631
632
633 /***********************延时程序=a*1ms**************************************/
634 /*
635 void delay(unsigned char a)
636 {
637 unsigned char i;
638 for(i=0;i<a;i++);
639 }
640 */
641 led_disp(unsigned char num,unsigned char vdata,unsigned char on_switch) //on_switch = 0 ,开,on_switch = 1
-,关
642 {
643 1 P3_0 = on_switch;
644 1 P2 = play_bit[num-1];
645 1 P0 = vdata;
646 1 delay(200);
647 1 P3_0 = 1;
648 1 P0 =0x0;
649 1 }
650
651 void beep(void)
652 {
653 1 P2_4 = 0;
654 1 delay(20);
655 1 P2_4 = 1;
656 1 delay(50);
657 1 }
658 void beep_beep(void)
659 {
660 1 unsigned int i;
661 1 for(i=0;i<300;i++)
662 1 beep();
663 1 for(i=0;i<1000;i++)
664 1 { i=i;
665 2 }
666 1 for(i=0;i<300;i++)
667 1 beep();
668 1 for(i=0;i<1000;i++)
669 1 { i=i;
670 2 }
671 1 }
672
673 set_beep_clock()
C51 COMPILER V7.00 MAIN 09/30/2007 23:44:12 PAGE 12
674 {
675 1 if(clock_cutt[6]==1)
676 1 {
677 2 if((clock_cutt[8]==clock_cutt[2])&&(clock_cutt[7]==clock_cutt[1]))
678 2 {
679 3 beep_beep();
680 3 }
681 2 }
682 1 if(clock_cutt[9]==1)
683 1 {
684 2 if((clock_cutt[11]==clock_cutt[2])&&(clock_cutt[10]==clock_cutt[1]))
685 2 {
686 3 beep_beep();
687 3 }
688 2 }
689 1 if(clock_cutt[12]==1)
690 1 {
691 2 if((clock_cutt[14]==clock_cutt[2])&&(clock_cutt[13]==clock_cutt[1]))
692 2 {
693 3 beep_beep();
694 3 }
695 2 }
696 1
697 1 }
698 /************************主程序**********************************************/
699 void main(void)
700 {
701 1 //秒,分,时寄存器初始值
702 1 unsigned char temp=0x80;
703 1 unsigned int i;
704 1
705 1 P3_0 = 0;
706 1
707 1
708 1 while(1)
709 1 {
710 2
711 2 Read_key_code();
712 2 Key_set(key_velual);
713 2
714 2 clock_cutt[0]++;
715 2 for(i=0;i<10;i++)
716 2 Play_set();
717 2
718 2 set_beep_clock();
719 2 /**/
720 2 //Play_set();
721 2 // beep();
722 2 // delay(30000);
723 2 // delay(30000);
724 2
725 2 /*
726 2 clock_play(2);
727 2
728 2
729 2 */
730 2 /* led_disp(1,0xff,1);
731 2 led_disp(2,0xff,0);
732 2 led_disp(3,0xff,1);
733 2 led_disp(4,0xff,0);
734 2 led_disp(5,0xff,1);
735 2 led_disp(6,0xff,0);
C51 COMPILER V7.00 MAIN 09/30/2007 23:44:12 PAGE 13
736 2 delay(1000);
737 2 */
738 2 // Read_key_code();
739 2 /* Key_set(key_velual);
740 2 Play_set();
741 2 */
742 2 }
743 1
744 1 }
745
746
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1508 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 71 10
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 + -