📄 ds1302.lst
字号:
665 3 if(up_flag==1||down_flag==1)
666 3 {
667 4 Write1302(0x8e,0x00); //写入允许
668 4 Write1302(0x82,temp); //写入新的分数
669 4 Write1302(0x8e,0x80); //禁止写入
C51 COMPILER V7.06 DS1302 05/03/2008 20:11:44 PAGE 12
670 4 up_flag=0;
671 4 down_flag=0;
672 4 }
673 3 hide_min++;
674 3 if(hide_min>3)
675 3 hide_min=0;
676 3 show_time();
677 3 }while(count==3);break;
678 2 case 3:do //count=3,调整小时
679 2 {
680 3 hide_min=0;
681 3 outkey();
682 3 Upkey();
683 3 Downkey();
684 3 if(up_flag==1||down_flag==1)
685 3 {
686 4 Write1302(0x8e,0x00); //写入允许
687 4 Write1302(0x84,temp); //写入新的小时数
688 4 Write1302(0x8e,0x80); //禁止写入
689 4 up_flag=0;
690 4 down_flag=0;
691 4 }
692 3 hide_hour++;
693 3 if(hide_hour>3)
694 3 hide_hour=0;
695 3 show_time();
696 3 }while(count==4);break;
697 2 case 4:do //count=4,调整星期
698 2 {
699 3 hide_hour=0;
700 3 outkey();
701 3 Upkey();
702 3 Downkey();
703 3 if(up_flag==1||down_flag==1)
704 3 {
705 4 Write1302(0x8e,0x00); //写入允许
706 4 Write1302(0x8a,temp); //写入新的星期数
707 4 Write1302(0x8e,0x80); //禁止写入
708 4 up_flag=0;
709 4 down_flag=0;
710 4 }
711 3 hide_week++;
712 3 if(hide_week>3)
713 3 hide_week=0;
714 3 show_time();
715 3 }while(count==5);break;
716 2 case 5:do //count=5,调整日
717 2 {
718 3 hide_week=0;
719 3 outkey();
720 3 Upkey();
721 3 Downkey();
722 3 if(up_flag==1||down_flag==1)
723 3 {
724 4 Write1302(0x8e,0x00); //写入允许
725 4 Write1302(0x86,temp); //写入新的日数
726 4 Write1302(0x8e,0x80); //禁止写入
727 4 up_flag=0;
728 4 down_flag=0;
729 4 }
730 3 hide_day++;
731 3 if(hide_day>3)
C51 COMPILER V7.06 DS1302 05/03/2008 20:11:44 PAGE 13
732 3 hide_day=0;
733 3 show_time();
734 3 }while(count==6);break;
735 2 case 6:do //count=6,调整月
736 2 {
737 3 hide_day=0;
738 3 outkey();
739 3 Upkey();
740 3 Downkey();
741 3 if(up_flag==1||down_flag==1)
742 3 {
743 4 Write1302(0x8e,0x00); //写入允许
744 4 Write1302(0x88,temp); //写入新的月数
745 4 Write1302(0x8e,0x80); //禁止写入
746 4 up_flag=0;
747 4 down_flag=0;
748 4 }
749 3 hide_month++;
750 3 if(hide_month>3)
751 3 hide_month=0;
752 3 show_time();
753 3 }while(count==7);break;
754 2 case 7:do //count=7,调整年
755 2 {
756 3 hide_month=0;
757 3 outkey();
758 3 Upkey();
759 3 Downkey();
760 3 if(up_flag==1||down_flag==1)
761 3 {
762 4 Write1302(0x8e,0x00); //写入允许
763 4 Write1302(0x8c,temp); //写入新的年数
764 4 Write1302(0x8e,0x80); //禁止写入
765 4 up_flag=0;
766 4 down_flag=0;
767 4 }
768 3 hide_year++;
769 3 if(hide_year>3)
770 3 hide_year=0;
771 3 show_time();
772 3 }while(count==8);break;
773 2 case 8:do
774 2 {
775 3 hide_year=0;
776 3 outkey();
777 3 Upkey();
778 3 Downkey();
779 3 if(up_flag==1||down_flag==1)
780 3 {
781 4 settemp1=temp;//写入新设定的温度/////////////////////////////////////
782 4 up_flag=0;
783 4 down_flag=0;
784 4 }
785 3 hide_settemp++;
786 3 if(hide_settemp>3)
787 3 hide_settemp=0;
788 3 show_time();
789 3 }while(count==9);break;
790 2 case 9: count=0;hide_settemp=0; //count8, 跳出调整模式,返回默认显示状态
791 2 Second=Read1302(DS1302_SECOND);
792 2 Write1302(0x8e,0x00); //写入允许
793 2 Write1302(0x80,Second&0x7f);
C51 COMPILER V7.06 DS1302 05/03/2008 20:11:44 PAGE 14
794 2 Write1302(0x8E,0x80); //禁止写入
795 2 done=0;
796 2 break; //count=7,开启中断,标志位置0并退出
797 2 default:break;
798 2 }
799 1 }
800
801 void hot(void) //判断加热程序
802 {
803 1 if(temp_value<=settemp1)
804 1 {
805 2 p24=1;
806 2 GotoXY(13,0);
807 2 Print("col");
808 2 }
809 1 else
810 1 {
811 2 p24=0;
812 2 GotoXY(13,0);
813 2 Print("hot");
814 2 }
815 1 }
816
817 void show_time() //液晶显示程序
818 {
819 1 DS1302_GetTime(&CurrentTime); //获取时钟芯片的时间数据
820 1 TimeToStr(&CurrentTime); //时间数据转换液晶字符
821 1 DateToStr(&CurrentTime); //日期数据转换液晶字符
822 1 ReadTemp(); //开启温度采集程序
823 1 temp_to_str(); //温度数据转换成液晶字符
824 1 settemp_to_str(); //设定温度转换成字符
825 1 hot();
826 1 GotoXY(12,1); //液晶字符显示位置
827 1 Print(TempBuffer); //显示温度
828 1 GotoXY(0,1);
829 1 Print(CurrentTime.TimeString); //显示时间
830 1 GotoXY(0,0);
831 1 Print(CurrentTime.DateString); //显示日期
832 1 GotoXY(11,0);
833 1 Print(week_value); //显示星期
834 1 //GotoXY(11,0);
835 1 //Print("week"); //在液晶上显示 字母 week
836 1 GotoXY(9,1);
837 1 Print(set_temp1); //显示设定温度值
838 1 Delay1ms(400); //扫描延时
839 1 }
840
841
842
843 main()
844 {
845 1 p24=0;
846 1 flag=1; //时钟停止标志
847 1 LCD_Initial(); //液晶初始化
848 1 Init_DS18B20( ) ; //DS18B20初始化
849 1 Initial_DS1302(); //时钟芯片初始化
850 1 up_flag=0;
851 1 down_flag=0;
852 1 done=0; //进入默认液晶显示
853 1 wireless_1=0;
854 1 wireless_2=0;
855 1 wireless_3=0;
C51 COMPILER V7.06 DS1302 05/03/2008 20:11:44 PAGE 15
856 1 wireless_4=0;
857 1 while(1)
858 1 {
859 2 while(done==1)
860 2 keydone(); //进入调整模式
861 2 while(done==0)
862 2 {
863 3 show_time(); //液晶显示数据
864 3 flag=0;
865 3 Setkey(); //扫描各功能键
866 3 }
867 2 }
868 1 }
869
870
871
872
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2621 ----
CONSTANT SIZE = 8 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 54 2
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -