📄 ds1302+lcd1602-c51.lst
字号:
791 1 // write_position(1,3);
792 1 // lcd_wdat('/');
793 1
794 1 write_position(1,4); //设定显示位置
795 1 lcd_wdat('0'+((init[4]&0xf0)>>4));
796 1
797 1 write_position(1,5); //设定显示位置
C51 COMPILER V8.02 DS1302_LCD1602_C51 01/22/2008 14:37:10 PAGE 14
798 1 lcd_wdat('0'+(init[4]&0x0f)); //读月
799 1
800 1 // write_position(1,6);
801 1 // lcd_wdat('/');
802 1
803 1 write_position(1,7); //设定显示位置
804 1 lcd_wdat('0'+((init[3]&0xf0)>>4)); //写显示数据到LCD
805 1
806 1 write_position(1,8); //设定显示位置
807 1 lcd_wdat('0'+(init[3]&0x0f)); //读日
808 1
809 1 write_position(1,15); //设定显示位置
810 1 lcd_wdat('0'+(init[5]&0x0f)); //读周 &0x0f
811 1
812 1 flash();
813 1 }
814
815 /*********************************************************/
816 // 键设定函数
817 /*********************************************************/
818 void key_set(uchar num,uchar row,uchar col )
819 {
820 1 if(!K2)
821 1 {
822 2 delay1(32); //消除抖动
823 2 if(!K2)
824 2 { beep();
825 3 if(count!=num)
826 3 count++;
827 3 else count=0;
828 3 }
829 2 }
830 1 if(!K1)
831 1 {
832 2 delay1(32); //消除抖动Delay(100);
833 2 if(!K1)
834 2 { beep();
835 3 if(count!=0)
836 3 count--;
837 3 else count=num;
838 3 }
839 2 }
840 1 Set_Flash(row,col);
841 1
842 1 }
843 /*********************************************************/
844 // 报警时间设定
845 /*********************************************************/
846 void alarm_time()
847 {
848 1 k=8;
849 1 if(!K4&flag) //开始设定报警时间
850 1 {
851 2 delay1(35); //消除抖动
852 2 if(!K4&flag)
853 2 {
854 3
855 3 do
856 3 {
857 4 write_str(0x80,str4);
858 4 write_str(0xc0,str3); //液晶显示提示信息
859 4 Play_alarmtime(); //报警时间显示
C51 COMPILER V8.02 DS1302_LCD1602_C51 01/22/2008 14:37:10 PAGE 15
860 4 beep();
861 4 num=1;
862 4 // k=Read_One_Byte(0xaf);
863 4 count=k;
864 4 while(num) //写入闹钟个数
865 4 {
866 5 key_set(8,1,14);
867 5 if(!K4)
868 5 {
869 6 delay1(35);
870 6 if(!K4)
871 6 {
872 7 Set_place(1,14);
873 7 k=(init1[0]<<4|init1[1]);
874 7 Write_One_Byte(0xaf,k);
875 7 beep();
876 7 num=0;
877 7 hour=1;
878 7 count=((alarm2.h&0xf0)>>4)*10+(alarm2.h&0x0f); //读当前时报警数据
879 7 }
880 6 }
881 5 }
882 4 while(hour) //设定时
883 4 {
884 5 key_set(23,2,7); // 键设定函数
885 5
886 5 if(!K4)
887 5 {
888 6 delay1(35); //消除抖动
889 6 if(!K4)
890 6 {
891 7 Set_place(2,7); //指定位置显示
892 7 alarm2.h=((init1[0]<<4)|init1[1]);
893 7
894 7 Write_One_Byte(0x01+(0x08-k)*0x02,alarm2.h); //把报警时间的小时写入24C02
895 7
896 7 beep();
897 7 hour=0;
898 7 min=1;
899 7 count=((alarm2.m&0xf0)>>4)*10+(alarm2.m&0x0f); //读当前时报警数据
900 7 }
901 6 }
902 5 }
903 4
904 4 while(min) //设定分
905 4 {
906 5 key_set(59,2,10); // 键设定函数
907 5
908 5 if(!K4)
909 5 {
910 6 delay1(35); //消除抖动
911 6 if(!K4)
912 6 {
913 7 Set_place(2,10); //指定位置显示
914 7 alarm2.m=((init1[0]<<4)|init1[1]);
915 7
916 7 Write_One_Byte(0x00+(0x08-k)*0x02,alarm2.m); //把报警时间的分钟写入24C02
917 7
918 7 beep();
919 7 min=0;
920 7 sec=0;
921 7 count=(((alarm2.s)&0xf0)>>4)*10+((alarm2.s)&0x0f); //读当前秒报警数据
C51 COMPILER V8.02 DS1302_LCD1602_C51 01/22/2008 14:37:10 PAGE 16
922 7 write_str(0xc0,str2); //液晶显示提示信息
923 7 }
924 6 }
925 5 }
926 4 write_str(0x80,str1);
927 4 }while(k>=1);
928 3 //**************************************
929 3
930 3 /*
931 3 while(sec) //设定秒
932 3 {
933 3 key_set(59,2,13);
934 3
935 3 if(!K4)
936 3 {
937 3 Set_place(2,13);
938 3 bj_time[0]=((init1[0]<<4)|init1[1]);
939 3 beep();
940 3 min=0;
941 3 sec=0;
942 3 count=0;
943 3 write_str(0xc0,str2); //液晶显示提示信息
944 3 }
945 3 }*/
946 3 }
947 2
948 2 }
949 1
950 1 }
951
952 /*********************************************************/
953 // 报警时间显示
954 /*********************************************************/
955 void Play_alarmtime()
956 {
957 1 // char i;
958 1 // write_str(0x80,str4);
959 1 // k=Read_One_Byte(0xaf);
960 1 /*
961 1 count=k;
962 1 num=1;
963 1 while(num) //写入闹钟个数
964 1 {
965 1 key_set(8,1,14);
966 1 if(!K4)
967 1 {
968 1 delay1(35);
969 1 if(!K4)
970 1 {
971 1 Set_place(1,14);
972 1 k=(init1[0]<<4|init1[1]);
973 1 beep();
974 1 num=0;
975 1 }
976 1 }
977 1 }
978 1 */
979 1
980 1 alarm2.h=Read_One_Byte(0x01+(8-k)*2);
981 1 alarm2.m=Read_One_Byte(0x00+(8-k)*2);
982 1
983 1 write_position(2,7);
C51 COMPILER V8.02 DS1302_LCD1602_C51 01/22/2008 14:37:10 PAGE 17
984 1 lcd_wdat(((alarm2.h&0xf0)>>4)+0x30); //写显示数据到LCD
985 1
986 1 write_position(2,8);
987 1 lcd_wdat('0'+(alarm2.h&0x0f)); //读小时
988 1 /*
989 1 write_position(2,9); //设定显示位置
990 1 lcd_wdat(':');
991 1 */
992 1 write_position(2,10); //设定显示位置
993 1 lcd_wdat('0'+((alarm2.m&0xf0)>>4)); //写显示数据到LCD
994 1
995 1 write_position(2,11); //设定显示位置
996 1 lcd_wdat('0'+(alarm2.m&0x0f)); //读分钟
997 1 /*
998 1 write_position(2,12); //设定显示位置
999 1 lcd_wdat(':'); //写显示数据到LCD
1000 1 */
1001 1 write_position(2,13); //设定显示位置
1002 1 lcd_wdat('0'+((alarm2.s&0xf0)>>4)); //写显示数据到LCD
1003 1
1004 1 write_position(2,14);
1005 1 lcd_wdat('0'+(alarm2.s&0x0f)); //读秒
1006 1
1007 1
1008 1
1009 1
1010 1 }
1011
1012 /*********************************************************/
1013 // 时间比较
1014 /*********************************************************/
1015 void Time_compare()
1016 {
1017 1 int i;
1018 1 if(alarm_flag)
1019 1 {
1020 2
1021 2 for(k=0;k<ALARM_NUM;k++)
1022 2 {
1023 3 alarm2.h=Read_One_Byte(0x01+i);
1024 3 alarm2.m=Read_One_Byte(0x00+i);
1025 3
1026 3 if(init[2]==alarm2.h)
1027 3 {
1028 4 if(init[1]==alarm2.m)
1029 4 beep();
1030 4 }
1031 3 }
1032 2
1033 2 }
1034 1 }
1035 //*********************************************************
1036
1037
1038
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2347 ----
CONSTANT SIZE = 8 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
C51 COMPILER V8.02 DS1302_LCD1602_C51 01/22/2008 14:37:10 PAGE 18
DATA SIZE = 90 17
IDATA SIZE = ---- ----
BIT SIZE = 10 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -