📄 clock.lst
字号:
C51 COMPILER V7.50 CLOCK 04/09/2007 18:39:44 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE CLOCK
OBJECT MODULE PLACED IN clock.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE clock.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /**************************************************************************
2
3
4
5 File Name: clock.c
6 Author: liao xu ming
7 Created: 2007/3/23
8 Modified: NO
9 Revision: 1.0
10
11 ***************************************************************************/
12
13 #include"clock.H"
14 #include"keyboard.h"
15 #include"lcd1602.h"
16 #include"ds1302.h"
17 #include"main.h"
18 #define ON 1
19 #define OFF 0
20
21 void BurstWrite1302_New(void); //DS1302 时钟芯片 多字节数据写入函数声明
22 void Display_Adjust_ALARM_Time(void); //显示 调整打玲时间的函数声明
23 void Display_Time(void); //显示函数 声明
24
25 bit Bell_Flag; //打玲标志
26 bit Bell_Enable; //打玲使能
27 bit LCD_LIGHT_FLAG; //LCD 背光灯亮标志
28 unsigned char Bell_f; //蜂呜器响玲频
29 bit BurstWrite1302_Flag; //多字节数据写入 DS1302 标志
30 bit Bell_State_switch_flag; //打玲状态切换标志
31 bit Call_Display_Adjust_ALARM_Time_Bit; //调用显示调整打玲时间标志
32 unsigned char ClockRtc[8]={0,0,0,0,0,0,0,0}; //时钟数据
33 unsigned char DateString[9]={0,0,0,0,0,0,0,0,0}; //日期数据
34 unsigned char TimeString[9]={0,0,0,0,0,0,0,0,0}; //时间数据
35
36 unsigned char count_50ms; //50ms 中断计数
37 //打玲数据
38 static unsigned char Alarm_Ram[9]={0+'0',0+'0','-',0+'0',0+'0','-',0+'0',0+'0','\0'};
39
40 unsigned char code string_input_the_alarm_time[]="Input alarm time"; //字符串显示 输入打玲时间的英文
41 extern unsigned char code string_clear_line2[]; //字符串 清空
42
43 /***********************
44 宏定义
45
46 ***********************/
47 #define HOUR_H 0
48 #define HOUR_L 1
49 #define MIN_H 3
50 #define MIN_L 4
51 #define SECOND_H 6
52 #define SECOND_L 7
53
54 #define YEAR_H 0
55 #define YEAR_L 1
C51 COMPILER V7.50 CLOCK 04/09/2007 18:39:44 PAGE 2
56 #define MONTH_H 3
57 #define MONTH_L 4
58 #define DATA_H 6
59 #define DATA_L 7
60
61 #define NORMAL 0
62 #define SECOND_ADJ_L 1
63 #define SECOND_ADJ_H 2
64
65 #define MINUTE_ADJ_L 3
66 #define MINUTE_ADJ_H 4
67
68 #define HOUR_ADJ_L 5
69 #define HOUR_ADJ_H 6
70
71 #define DATA_ADJ_L 7
72 #define DATA_ADJ_H 8
73
74 #define MONTH_ADJ_L 9
75 #define MONTH_ADJ_H 10
76
77 #define YEAR_ADJ_L 11
78 #define YEAR_ADJ_H 12
79
80 #define ALARM_ADJ_SECOND_L 13
81 #define ALARM_ADJ_SECOND_H 14
82 #define ALARM_ADJ_MIN_L 15
83 #define ALARM_ADJ_MIN_H 16
84 #define ALARM_ADJ_HOUR_L 17
85 #define ALARM_ADJ_HOUR_H 18
86 #define Bell_Enable_ON_OFF 19
87
88 #define STATUS_MIN 0 //最小状态数
89 #define STATUS_MAX 19 //最大状态数
90 extern bit State_Switch_Flag; //状态切换标志
91 unsigned char State_ADJ; //状态
92
93 void Clock(unsigned char Key_temp) //时钟处理函数
94 {
95 1
96 1 if(State_Switch_Flag==1) //状态切换
97 1 {
98 2 EA=1; //开中断
99 2 State_Switch_Flag=0;
100 2 LCD_send_command(LCD_CLEAR_SCREEN); //清屏
101 2 GotoXY(0,0);
102 2 Print("Date: ");
103 2 GotoXY(0,1);
104 2 Print("Time: ");
105 2 }
106 1
107 1 if(Key_temp==ADD) //如果'+'键按下
108 1 {
109 2 if(State_ADJ<STATUS_MAX)State_ADJ++; //如果状态值小于对大状态,则状态值加1
110 2 else State_ADJ=STATUS_MIN; //否则,状态值置最小状态值
111 2 }
112 1 if(Key_temp==DEC) //如果'-'键按下
113 1 {
114 2 if(State_ADJ>STATUS_MIN)State_ADJ--; //如果状态值小于对大状态,则状态值加1
115 2 else State_ADJ=STATUS_MIN; //否则,状态值置最小状态值
116 2
117 2 if(State_ADJ==YEAR_ADJ_H) //如果状态是 YEAR_ADJ_H
C51 COMPILER V7.50 CLOCK 04/09/2007 18:39:44 PAGE 3
118 2 { LCD_send_command(LCD_CLEAR_SCREEN); //清屏
119 3 GotoXY(0,0);
120 3 Print("Date: ");
121 3 GotoXY(0,1);
122 3 Print("Time: ");
123 3 GotoXY(6,0);
124 3 Print(DateString);
125 3 GotoXY(6,1);
126 3 Print(TimeString);
127 3 }
128 2 }
129 1 if(State_ADJ!=NORMAL) //如果状态不等于常态
130 1 {
131 2 if(Key_temp==EQUAL) //如果'='键按下
132 2 {
133 3 BurstWrite1302_New(); //多字节数据写入 DS1302
134 3 BurstWrite1302_Flag=0; //
135 3 State_ADJ=NORMAL; //状态初始化
136 3 LCD_send_command(LCD_CLEAR_SCREEN);//清屏
137 3 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_OFF);//不显示光标
138 3 GotoXY(0,0);
139 3 Print("Date: ");
140 3 GotoXY(0,1);
141 3 Print("Time: ");
142 3 GotoXY(6,0);
143 3 Print(DateString);
144 3 GotoXY(6,1);
145 3 Print(TimeString);
146 3 EA=1;
147 3 }
148 2 }
149 1
150 1
151 1
152 1 switch(State_ADJ) //状态选择
153 1 {
154 2 case NORMAL: //常态
155 2 //displayTime
156 2 {// Bell=0;
157 3 if(BurstWrite1302_Flag==1) //多字节写入DS1302标志为1
158 3 {
159 4 BurstWrite1302_New(); //多字节数据写入DS1302 函数
160 4 BurstWrite1302_Flag=0; //多字节数据写入DS1302标志为0
161 4 LCD_send_command(LCD_CLEAR_SCREEN); //清屏
162 4 GotoXY(0,0);
163 4 Print("Date: ");
164 4 GotoXY(0,1);
165 4 Print("Time: ");
166 4 EA=1;
167 4 TR0=1;
168 4 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_OFF);//不显示光标
169 4 }
170 3 }
171 2 break;
172 2 case SECOND_ADJ_L: //秒底位调整
173 2 { EA=0; //关中断
174 3 /* switch(Key_temp) //根据按键值选择要写入的 !!好像可以很简单的处理就是用一条语句就可
-以
175 3 {
176 3 case ZERO : TimeString[SECOND_L]=0+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
177 3 case ONE : TimeString[SECOND_L]=1+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
-
C51 COMPILER V7.50 CLOCK 04/09/2007 18:39:44 PAGE 4
178 3 case TWO : TimeString[SECOND_L]=2+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
-
179 3 case THREE: TimeString[SECOND_L]=3+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
180 3 case FOUR : TimeString[SECOND_L]=4+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
181 3 case FIVE : TimeString[SECOND_L]=5+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
182 3 case SIX : TimeString[SECOND_L]=6+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
183 3 case SEVEN: TimeString[SECOND_L]=7+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
-
184 3 case EIGHT: TimeString[SECOND_L]=8+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
-
185 3 case NINE : TimeString[SECOND_L]=9+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]); break;
186 3 default :break;
187 3 }*/
188 3 if((Key_temp>=0)&&(Key_temp<=9))
189 3 {
190 4 TimeString[SECOND_L]=Key_temp+'0';GotoXY(13,1);LCD_send_data(TimeString[SECOND_L]);
191 4 }
192 3 GotoXY(13,1); //写入秒底位
193 3 LCD_send_command(LCD_DISPLAY_ON|LCD_CURSOR_ON|LCD_CURSOR_BLINK_ON);//光标闪烁
194 3 GotoXY(13,1);
195 3 Delay1ms(20);
196 3 BurstWrite1302_Flag=1;
197 3 }
198 2 break;
199 2 case SECOND_ADJ_H: //秒高位调整
200 2 //display
201 2 {
202 3 if((Key_temp>=0)&&(Key_temp<=5))
203 3 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -