📄 1.lst
字号:
180 2 uip=ds12887_read(0x0a);
181 2 }
182 1 temp=ds12887_read(0) ;
183 1 return temp;
184 1 }
185
186 uchar get_m() //获取DS12c887分数据
187 {
188 1 uchar uip,temp;
189 1 while(uip & 0x80 !=0x80)
190 1 {
191 2 uip=ds12887_read(0x0a);
192 2 }
193 1 temp=ds12887_read(2) ;
194 1 return temp;
195 1 }
196
197 uchar get_h() //获取DS12c887时数据
198 {
199 1 uchar uip,temp;
200 1 while(uip & 0x80 !=0x80)
201 1 {
202 2 uip=ds12887_read(0x0a);
203 2 }
204 1 temp=ds12887_read(4) ;
205 1 return temp;
206 1 }
207
208 uchar get_week() //获取DS12c887星期数据
209 {
210 1 uchar uip,temp;
211 1 while(uip & 0x80 !=0x80)
212 1 {
213 2 uip=ds12887_read(0x0a);
214 2 }
215 1 temp=ds12887_read(6) ;
216 1 return temp;
217 1 }
218
219 uchar get_day()////获取DS12c887天数据
220 {
221 1 uchar uip,temp;
222 1 while(uip & 0x80 !=0x80)
223 1 {
224 2 uip=ds12887_read(0x0a);
225 2 }
226 1 temp=ds12887_read(7) ;
227 1 return temp;
228 1 }
229 uchar get_month() ////获取DS12c887月数据
230 {
231 1 uchar uip,temp;
232 1 while(uip & 0x80 !=0x80)
233 1 {
234 2 uip=ds12887_read(0x0a);
235 2 }
236 1 temp=ds12887_read(8) ;
237 1 return temp;
238 1 }
239
240 uchar get_year() //获取DS12c887年数据
241 {
C51 COMPILER V8.08 1 06/06/2008 15:43:25 PAGE 5
242 1 uchar uip,temp;
243 1 while(uip & 0x80 !=0x80)
244 1 {
245 2 uip=ds12887_read(0x0a);
246 2 }
247 1 temp=ds12887_read(9) ;
248 1 return temp;
249 1 }
250
251 void delay1() //延时1S
252 {
253 1 unsigned int i;
254 1 unsigned char j;
255 1 for(i=0;i<1000;i++)
256 1 for(j=0;j<72;j++);
257 1 }
258
259 void main(void) //主函数
260 {
261 1 uchar i,a,b,c;
262 1 lcd_init();
263 1
264 1
265 1 //ds12887_write(0x0a,0x20); //开启时钟芯片
266 1 //ds12887_write(9,7);
267 1 //ds12887_write(8,3);
268 1 //ds12887_write(7,11);
269 1 //ds12887_write(6,7);
270 1 ds12887_write(4,19);
271 1 ds12887_write(2,35);
272 1 ds12887_write(0,0);
273 1
274 1 while(1)
275 1 {
276 2 i=get_year(); //显示年
277 2 a=i/100;
278 2 b=(i-a*100)/10;
279 2 c=(i-a*100)%10;
280 2 dis_one_char(0,0,'2',1) ;
281 2 dis_one_char(0,1,'0',1) ;
282 2 dis_one_char(0,2,b+0x30,1) ;
283 2 dis_one_char(0,3,c+0x30,1) ;
284 2 dis_one_zi(0,2,x0,1,1);
285 2
286 2
287 2 i=get_month();
288 2 a=i/100;
289 2 b=(i-a*100)/10;
290 2 c=(i-a*100)%10;
291 2
292 2 dis_one_char(0,6,b+0x30,1) ;
293 2 dis_one_char(0,7,c+0x30,1) ;
294 2 dis_one_zi(0,4,x1,1,1);
295 2
296 2
297 2
298 2 i=get_day();
299 2 a=i/100;
300 2 b=(i-a*100)/10;
301 2 c=(i-a*100)%10;
302 2 dis_one_char(0,10,b+0x30,1) ;
303 2 dis_one_char(0,11,c+0x30,1) ;
C51 COMPILER V8.08 1 06/06/2008 15:43:25 PAGE 6
304 2 dis_one_zi(0,6,x2,1,1);
305 2
306 2
307 2 i=get_week();
308 2 a=i/100;
309 2 b=(i-a*100)/10;
310 2 c=(i-a*100)%10;
311 2
312 2 dis_one_char(1,9,c+0x30,1) ;
313 2 dis_one_zi(1,2,x3,1,1);
314 2 dis_one_zi(1,3,x4,1,1);
315 2
316 2 i=get_h();
317 2 a=i/100;
318 2 b=(i-a*100)/10;
319 2 c=(i-a*100)%10;
320 2 dis_one_char(2,2,b+0x30,1) ;
321 2 dis_one_char(2,3,c+0x30,1) ;
322 2 dis_one_zi(2,2,x5,1,1);
323 2
324 2
325 2 i=get_m();
326 2 a=i/100;
327 2 b=(i-a*100)/10;
328 2 c=(i-a*100)%10;
329 2 dis_one_char(2,6,b+0x30,1) ;
330 2 dis_one_char(2,7,c+0x30,1) ;
331 2 dis_one_zi(2,4,x6,1,1);
332 2
333 2 i=get_s();
334 2 a=i/100;
335 2 b=(i-a*100)/10;
336 2 c=(i-a*100)%10;
337 2 dis_one_char(2,10,b+0x30,1) ;
338 2 dis_one_char(2,11,c+0x30,1) ;
339 2 dis_one_zi(2,6,x7,1,1);
340 2
341 2 delay1(); //延时1秒
342 2 dis_cls(); //刷新屏幕
343 2 i=Read_Temperature(); //读取温度
344 2 a=i/100; //显示温度
345 2 b=(i-a*100)/10;
346 2 c=(i-a*100)%10;
347 2 dis_one_char(0,10,b+0x30,1) ;
348 2 dis_one_char(0,11,c+0x30,1) ;
349 2 dis_one_zi(0,6,x2,1,1);
350 2 }
351 1 }
352
353
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1323 ----
CONSTANT SIZE = 1792 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 17
IDATA SIZE = ---- ----
BIT SIZE = ---- 4
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -