📄 2402test.lst
字号:
784 1 { //第一个声音的长度
785 2 Bell_Out=~Bell_Out; //取反扬声器驱动口,以产生音频
786 2 Delay(100); //音调设置延时
787 2 }
788 1 for(a=100;a>0;a--)
789 1 { //同上
790 2 Bell_Out=~Bell_Out;
791 2 Delay(80);
792 2 }
793 1 for(a=100;a>0;a--)
794 1 { //同上
795 2 Bell_Out=~Bell_Out;
796 2 Delay(30);
797 2 }
798 1 }
799 /****** 扬声器--成功音 **********************************************/
C51 COMPILER V8.05a 2402TEST 07/02/2008 20:45:43 PAGE 14
800 void beep_y(void)
801 {
802 1 unsigned char a; //定义变量用于发声的长度设置
803 1 for(a=250;a>0;a--)
804 1 { //第一个声音的长度
805 2 Bell_Out=~Bell_Out; //取反扬声器驱动口,以产生音频
806 2 Delay(20); //音调设置延时
807 2 }
808 1 for(a=100;a>0;a--)
809 1 { //同上
810 2 Bell_Out=~Bell_Out;
811 2 Delay(80);
812 2 }
813 1 }
814 /****** 扬声器--按键音 ********************************************************/
815 void beep_k(void)
816 {
817 1 unsigned char a; //定义变量用于发声的长度设置
818 1 for(a=100;a>0;a--)
819 1 { //声音的长度
820 2 Bell_Out=~Bell_Out;
821 2 Delay(50); //音调设置延时
822 2 }
823 1 }
824 //================================纯软件部分=========================================//
825 //显示项目 时间部分 在第一行全行显示时间
826 /******************************************************************************************/
827 void RealTime_Display(void)
828 {
829 1 print(0x80,"20");
830 1 print2(0x82,(read_clock(0x8d)/16)+0x30);
831 1 print2(0x83,(read_clock(0x8d)%16)+0x30);
832 1 print(0x84,"-"); // 显示年
833 1
834 1 print2(0x85,(read_clock(0x89)/16)+0x30);
835 1 print2(0x86,(read_clock(0x89)%16)+0x30);
836 1 print(0x87,"-"); // 显示月
837 1
838 1 print2(0x88,(read_clock(0x87)/16)+0x30);
839 1 print2(0x89,(read_clock(0x87)%16)+0x30);
840 1
841 1 print(0x8a," ^"); // 显示[
842 1 print2(0x8c,read_clock(0x8b)%16); // 显示星期
843 1 print(0x8d,"^ "); // 显示]
844 1
845 1 print2(0x8f,(read_clock(0x85)/16)+0x30); // 显示小时
846 1 print2(0x90,(read_clock(0x85)%16)+0x30);
847 1 print(0x91,":"); // 显示cgram第一个字模":"
848 1
849 1 print2(0x92,(read_clock(0x83)/16)+0x30); // 显示分钟
850 1 print2(0x93,(read_clock(0x83)%16)+0x30);
851 1 print(0x94,":"); // 显示cgram第一个字模":"
852 1
853 1 print2(0x95,(read_clock(0x81)/16)+0x30); // 显示秒
854 1 print2(0x96,(read_clock(0x81)%16)+0x30);
855 1
856 1 // print(0x8a," "); // 在主显示区空白处写入空格 防止乱码
857 1 // print(0x8d," ");
858 1 print(0x97," ");
859 1 print(0xc0," ");
860 1 }
861 /********************************************************************************************
C51 COMPILER V8.05a 2402TEST 07/02/2008 20:45:43 PAGE 15
862 //显示项目 定时时间部分 在第一行全行显示时间
863 ********************************************************************************************/
864 void alarm_Display(void)
865 {
866 1 print(0x80,"AL");
867 1 print2(0x82,(AT24C02_Read1Byte(0x05+(rom*10))/16)+0x30);
868 1 print2(0x83,(AT24C02_Read1Byte(0x05+(rom*10))%16)+0x30);
869 1 print(0x84,"-"); // 显示年
870 1
871 1 print2(0x85,(AT24C02_Read1Byte(0x06+(rom*10))/16)+0x30);
872 1 print2(0x86,(AT24C02_Read1Byte(0x06+(rom*10))%16)+0x30);
873 1 print(0x87,"-"); // 显示月
874 1
875 1 print2(0x88,(AT24C02_Read1Byte(0x07+(rom*10))/16)+0x30);
876 1 print2(0x89,(AT24C02_Read1Byte(0x07+(rom*10))%16)+0x30);
877 1
878 1 print(0x8a," ^"); // 显示[
879 1 if(AT24C02_Read1Byte(0x08+(rom*10))==0xff)
880 1 {
881 2 print(0x8c,"?");
882 2 }
883 1 else
884 1 {
885 2 print2(0x8c,AT24C02_Read1Byte(0x08+(rom*10))%16); // 显示星期
886 2 }
887 1 print(0x8d,"^ "); // 显示]
888 1
889 1 print2(0x8f,(AT24C02_Read1Byte(0x09+(rom*10))/16)+0x30); // 显示小时
890 1 print2(0x90,(AT24C02_Read1Byte(0x09+(rom*10))%16)+0x30);
891 1 print(0x91,":"); // 显示cgram第一个字模":"
892 1
893 1 print2(0x92,(AT24C02_Read1Byte(0x0a+(rom*10))/16)+0x30); // 显示分钟
894 1 print2(0x93,(AT24C02_Read1Byte(0x0a+(rom*10))%16)+0x30);
895 1 print(0x94,":"); // 显示cgram第一个字模":"
896 1
897 1 print2(0x95,(AT24C02_Read1Byte(0x0b+(rom*10))/16)+0x30); // 显示秒
898 1 print2(0x96,(AT24C02_Read1Byte(0x0b+(rom*10))%16)+0x30);
899 1
900 1 print2(0xc0,AT24C02_Read1Byte(0x04+(rom*10))/16+0x30); //显示控制项值 控制项值
901 1 print2(0xc1,AT24C02_Read1Byte(0x04+(rom*10))%16+0x30);
902 1 }
903 /********************************************************************************************
904 //清屏+刷新显示+延时+清空DT 一体函数
905 //LRDD()
906 ********************************************************************************************/
907 void LRDD(void)
908 {
909 1 LCM2402_Init();
910 1 RealTime_Display();
911 1 DelayS(500);
912 1 DT=0xff;
913 1 }
914 /********************************************************************************************
915 //清屏+刷新定时值显示+延时+清空DT 一体函数
916 //LADD()
917 ********************************************************************************************/
918 void LADD(void)
919 {
920 1 LCM2402_Init();
921 1 alarm_Display();
922 1 DT=0xff;
923 1 }
C51 COMPILER V8.05a 2402TEST 07/02/2008 20:45:43 PAGE 16
924 /********************************************************************************************
925 //闹钟呜响查寻程序
926 //BEEPing();
927 ********************************************************************************************/
928 void BEEPing(void)
929 {
930 1 uint8 a;
931 1 LADD();
932 1 print(0xc3,"Time is up! AV: Exit");
933 1 for(a=0;a<250&&DT==0xff;a++)
934 1 {
935 2 beep_a();
936 2 }
937 1 DT=0xff;
938 1 }
939 /********************************************************************************************
940 //闹钟和无线遥控的键值处理
941 //ALARMing();
942 ********************************************************************************************/
943 void ALARMing(void)
944 {
945 1 uint8 alarm_bit;
946 1 alarm_bit=AT24C02_Read1Byte(0x03); // 从AT24C02的地址0x03读出定时报警设置数据
947 1 if(AT24C02_Read1Byte(0x04+(rom*10))<2&&alarm_bit==1||alarm_bit==3)
948 1 { //键值值为0则是闹钟,不为0则是无线控制
949 2 if(AT24C02_Read1Byte(0x04+(rom*10))==0)
950 2 {
951 3 BEEPing();
952 3 }
953 2 else
954 2 {
955 3 beep_y();
956 3 }
957 2 }
958 1 if(AT24C02_Read1Byte(0x04+(rom*10))==0&&alarm_bit==2||alarm_bit==3)
959 1 {
960 2 //**这里将写入一个或是调用无线遥控键值处理程序**
961 2 }
962 1 }
963 /********************************************************************************************
964 //定时值校对&处理函数
965 //search_time() 整个流程必须在1秒里完成,不然将有部分定时值不响应。
966 ********************************************************************************************/
967 void search_time(void)
968 {
969 1 uint8 timeS,s,i;
970 1 static unsigned char data alarmS[25];
971 1 alarm_con=0;
972 1 s=read_clock(0x81); //读取秒数据
973 1 for(i=0;i<25;i++)
974 1 {
975 2 alarmS[i]=AT24C02_Read1Byte(0x0B+i*10); //一次性将全部项目中的秒数据送入数组中
976 2 }
977 1 for(i=0;i<25;i++)
978 1 {
979 2 if(alarmS[i]!=0xff) //不为0xff则表示这项已经设置
980 2 {
981 3 alarm_con++; //定时项目个数寄存位
982 3 if(s==alarmS[i])
983 3 {
984 4 timeS=AT24C02_Read1Byte(0x0a+(i*10));
985 4 if(timeS==read_clock(0x83)||timeS==0xff) //校验 分钟
C51 COMPILER V8.05a 2402TEST 07/02/2008 20:45:43 PAGE 17
986 4 {
987 5 timeS=AT24C02_Read1Byte(0x09+(i*10));
988 5 if(timeS==read_clock(0x85)||timeS==0xff) //校验 小时
989 5 {
990 6 timeS=AT24C02_Read1Byte(0x08+(i*10));
991 6 if(timeS==read_clock(0x8b)||timeS==0xff) //校验 星期
992 6 {
993 7 timeS=AT24C02_Read1Byte(0x07+(i*10));
994 7 if(timeS==read_clock(0x87)||timeS==0xff) //校验 日
995 7 {
996 8 timeS=AT24C02_Read1Byte(0x06+(i*10));
997 8 if(timeS==read_clock(0x89)||timeS==0xff) //校验 月
998 8 {
999 9 timeS=AT24C02_Read1Byte(0x05+(i*10));
1000 9 if(timeS==read_clock(0x8d)||timeS==0xff)//校验 年
1001 9 {
1002 10 rom=i; //走到响应的位置
1003 10
1004 10 ALARMing(); //闹钟和无线遥控的键值处理
1005 10 //这里将调用一个到时的响应程序alarming();
1006 10 }
1007 9 }
1008 8 }
1009 7 }
1010 6 }
1011 5 }
1012 4 }
1013 3 }
1014 2 }
1015 1 }
1016 /********************************************************************************************
1017 //系统主程序 菜单切换
1018 //main()
1019 ********************************************************************************************/
1020 void main(void)
1021 {
1022 1 beep_a();
1023 1 keyboard_int();
1024 1 LCM2402_Init(); //LCM2402初始化
1025 1 Init_1302(); //检测时钟芯片是否未被初始化
1026 1 CgramWrite();
1027 1 print(0x81,"Sun-2402C eClock V0.01");
1028 1 print(0xc3,"MSN: 5isun@live.cn");
1029 1 DelayS(5000);
1030 1 LCM2402_Init(); //LCM2402初始化
1031 1 beep_y();
1032 1 while(1) //主线程
1033 1 {
1034 2 //------------------0 主显示-----------------------------------------------------------
1035 2 if(menu==0)
1036 2 {
1037 3 RealTime_Display(); //在第一行显示时间部分
1038 3 print(0xc7," !AL");
1039 3 print2(0xcb,AT24C02_Read1Byte(0x03)+0x30);
1040 3 print(0xcc," Used:");
1041 3 print2(0xd2,alarm_con/16+0x30);
1042 3 print2(0xd3,alarm_con%16+0x30);
1043 3 print(0xd4,"/25 ");
1044 3 printTemperature(); //显示温度
1045 3 search_time(); //定时值校对&处理函数
1046 3 if (DT!=0xff)
1047 3 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -