📄 main.lst
字号:
554 1 //时
555 1 if(sel==1)
556 1 {
557 2 address=0x04;
558 2 if(Add_Key ==0 || Dec_Key ==0)
559 2 Bell_Swh=~Bell_Swh;
560 2 Write_One_Byte(address,Bell_Swh);
561 2 }
562 1 //开关
563 1
564 1 item = Read_One_Byte(address);
565 1 if(sel_1==0)
566 1 item++;
567 1 else
568 1 item--;
569 1 if(item>max) item=mini;
570 1 if(item<mini) item=max;
571 1
572 1 Write_One_Byte(address,item);//写入24
573 1 }
574
575 /******************************************************************************/
576 void Timer0_Init(void)//定时器0初始化
577 {
578 1 TMOD=0x01;
579 1 TH0=(65535-50000)/256;
580 1 TL0=(65535-50000)%256;
581 1 EA=1;
582 1 ET0=1;
583 1 TR0=1;
584 1 }
585
586 /******************************************************************************/
587 void Timer0(void) interrupt 1 using 1//中断入口,冒号闪烁
588 {
589 1 static unsigned char timecount = 0;//
590 1
591 1 TH0=(65535-50000)/256; //50ms定时
592 1 TL0=(65535-50000)%256;
593 1 timecount++;
594 1 if(timecount > 9)//500MS
595 1 {
596 2 timecount = 0;
597 2 flag = ~flag;
598 2 }
599 1 }
600
601
602
603 /******************************************************************************/
604 void Lcd_Mark1(void)//在预定的位置上写入汉字)
605 {
606 1 Clr_Scr();//清屏
607 1 // frame();//显示边框
608 1 Mcs=1;Scs=0;
609 1 Disp_Chinese(6,8,shi);
610 1 Disp_Chinese(6,24,wen);
611 1 Disp_Chinese(2,8,xing);
C51 COMPILER V8.08 MAIN 06/28/2008 15:24:32 PAGE 11
612 1 Disp_Chinese(2,24,qi);
613 1 Disp_Chinese(0,32,nian);
614 1 Disp_Digit(6,56,point);
615 1 Mcs=0;Scs=1;
616 1 Disp1_Digit(0,56,m);
617 1 Disp1_Chinese(6,8,sheshidu);
618 1 if(Bell_Swh == 1)//闹钟为开
619 1 {
620 2 Mcs=0;Scs=1;
621 2 Disp1_Chinese(6,40,biaozhi);//显示闹钟图标
622 2 }
623 1
624 1 }
625
626 /******************************************************************************/
627 void Lcd_Mark2(void)
628 {
629 1 Clr_Scr();//清屏
630 1 // frame();//显示边框
631 1
632 1 Mcs=1;Scs=0;//显示闹钟设定等几个汉字
633 1 Disp_Chinese(2,16,nao);
634 1 Disp_Chinese(2,32,zhong);
635 1 Disp_Chinese(2,48,she);
636 1 Mcs=0;Scs=1;
637 1 Disp1_Chinese(2,0,ding);
638 1 Disp1_Digit(4,0,maohao);
639 1 Disp1_Digit(4,24,maohao);
640 1 }
641
642 /******************************************************************************/
643 void main(void)
644 {
645 1 unsigned char a;
646 1 Init_8563();
647 1 Timer0_Init();
648 1 Init_lcd();//设置液晶显示器
649 1 Delay(10);
650 1 Disp_Img(logo);
651 1 Delay(30000);
652 1 Clr_Scr();//清屏
653 1
654 1 Bell_Swh = Read_One_Byte(0x04);//读取开关的状态
655 1 Lcd_Mark1();
656 1
657 1 while(1)//主循环
658 1 {
659 2 if(Add_Key == 0 && Dec_Key == 0)
660 2 {
661 3 Delay(1000);
662 3 if(Add_Key == 0 && Dec_Key == 0)
663 3 {
664 4 Init_8563();
665 4 }
666 3 }
667 2
668 2 if(Add_Key == 0)
669 2 {
670 3 Delay(1000);
671 3 if(Add_Key ==0)
672 3 {
673 4 //写入闹钟初始值08:00:00
C51 COMPILER V8.08 MAIN 06/28/2008 15:24:32 PAGE 12
674 4 Write_One_Byte(0x01,8);
675 4 Write_One_Byte(0x02,0);
676 4 Write_One_Byte(0x03,0);
677 4 }
678 3
679 3 }
680 2 if(OK_Key == 0 && Dec_Key ==0 )//进入闹钟设置界面
681 2 {
682 3 Delay12864(100);
683 3 if(OK_Key == 0 && Dec_Key ==0 )
684 3 {
685 4 Lcd_Mark2();
686 4 if(Bell_Swh == 0)
687 4 {
688 5 Mcs=0;Scs=1;Disp1_Chinese(2,32,guan);
689 5 }
690 4 //关
691 4 else
692 4 {
693 5 Mcs=0;Scs=1;Disp1_Chinese(2,32,kai);
694 5 }
695 4 while(1)
696 4 {
697 5 if (OK_Key == 0) // 设置和选择项目键
698 5 {
699 6 Delay(1000);
700 6 if(OK_Key == 0)
701 6 {
702 7 id2++;if(id2>5) id2=0;
703 7 }
704 6 while(OK_Key == 0);//等待键松开
705 6 }
706 5 switch( id2 )
707 5 {
708 6 case 0:Disp2();break;//正常显示
709 6 case 1:Kgb = 1;id_case2_key();Disp2();break;//开关
710 6 case 2:Kgb= 0;Hourb=1;id_case2_key();Disp2();break;//
711 6 case 3:Hourb=0;Minb=1;id_case2_key();Disp2();break;
712 6 case 4:Minb=0;Secb=1;id_case2_key();Disp2();break;
713 6 case 5:Secb=0;id2 = 0;Lcd_Mark1();goto FF;break;//返回主界面
714 6 default:break;
715 6 }
716 5 }
717 4 //while(1)
718 4 }
719 3 //if
720 3 }
721 2 //if
722 2 /*****************************************/
723 2 FF: //返回主界面
724 2 /*****************************************/
725 2 if(flag == 0)
726 2 {
727 3 Mcs=0;Scs=1;
728 3 Disp1_Digit(2,8,maohao);// :闪烁
729 3 Disp1_Digit(2,32,maohao);
730 3 }
731 2 else
732 2 {
733 3 Mcs=0;Scs=1;
734 3 Disp1_Digit(2,8,space);//显示空格
735 3 Disp1_Digit(2,32,space);
C51 COMPILER V8.08 MAIN 06/28/2008 15:24:32 PAGE 13
736 3 }
737 2 if (OK_Key == 0) // 设置和选择项目键
738 2 {
739 3 Delay(1000);
740 3 if(OK_Key == 0)
741 3 {
742 4 id++;if(id>7)id=0;
743 4 }
744 3 while(OK_Key == 0);//等待键松开
745 3 }
746 2 switch( id )
747 2 {
748 3 case 0:sec = 0; Disp( );break;//正常显示
749 3 case 1:year = 1;id_case1_key();Disp();break;//年
750 3 case 2:year=0;mon=1;id_case1_key();Disp();break;//月
751 3 case 3:mon=0;day=1;id_case1_key();Disp();break; //日
752 3 case 4:day=0;weekk=1;id_case1_key();Disp();break;//星期
753 3 case 5:weekk=0;hour=1;id_case1_key();Disp();break; //小时
754 3 case 6:hour=0;min=1;id_case1_key();Disp();break; //分钟
755 3 case 7:min=0;sec=1;id_case1_key();Disp();break; //秒
756 3 default:break;
757 3 }
758 2
759 2 if(Bell_Swh == 1)//闹钟为开
760 2 {
761 3 H_2402=Read_One_Byte(0x01);//读取2408的
762 3 S_2402=Read_One_Byte(0x02);
763 3
764 3 d=read_clock(0x04);//读小时
765 3 e=d;
766 3 d=d>>4;
767 3 e=e&0x0f;
768 3 H_8563=10*d+e;
769 3
770 3 d=read_clock(0x03);//读分钟
771 3 e=d;
772 3 d=d>>4;
773 3 e=e&0x0f;
774 3 S_8563=10*d+e;
775 3
776 3 if(H_2402 == H_8563)
777 3 {
778 4 if(S_2402 == S_8563)
779 4 {
780 5 Clr_Scr();//清屏
781 5 // frame();//显示边框
782 5 Mcs=1;Scs=0;
783 5 Disp_Chinese(3,16,nao);//闹钟显示时间到!
784 5 Disp_Chinese(3,32,zhong);
785 5 Disp_Chinese(3,48,shit);
786 5 Mcs=0;Scs=1;
787 5 Disp1_Chinese(3,0,jian);
788 5 Disp1_Chinese(3,16,dao);
789 5 Disp_Digit(3,40,fh);
790 5
791 5 while(S_2402 == S_8563)//判断是否到闹钟设定时间
792 5 {
793 6 for(a=0; a<100; a++)//BELL脉冲输出,驱动蜂鸣器
794 6 {
795 7 if(a<50)
796 7 {
797 8 Bell_Out = 0;Delay(100);
C51 COMPILER V8.08 MAIN 06/28/2008 15:24:32 PAGE 14
798 8 }
799 7 else
800 7 {
801 8 Bell_Out = 1;Delay(100);
802 8 }
803 7 }
804 6
805 6 d=read_clock(0x03);//读分钟
806 6 e=d;
807 6 d=d>>4;
808 6 e=e&0x0f;
809 6 S_8563=10*d+e;
810 6 }
811 5 Lcd_Mark1();
812 5 }
813 4 //if
814 4 }
815 3 }
816 2 //if
817 2 }
818 1 //while
819 1 }
820 //main
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 4422 ----
CONSTANT SIZE = 2784 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 13 24
IDATA SIZE = ---- ----
BIT SIZE = 14 6
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -