📄 ex6-5.lst
字号:
232 2 write_GLCD_command(SET_Y_ADDRESS_0);
233 2 for(j=0;j<64;j++)
234 2 write_GLCD_data(0);
235 2 }
236 1 }
237
238 void show_pattern(unsigned char page,unsigned char y,
239 unsigned char *pattern,unsigned char len)
240 {
241 1 int i;
C51 COMPILER V8.02 EX6_5 09/26/2006 20:28:21 PAGE 5
242 1
243 1 write_GLCD_command(SET_PAGE+page);
244 1 write_GLCD_command(SET_Y_ADDRESS_0+y);
245 1 for(i=0;i<len;i++)
246 1 {
247 2 write_GLCD_data(*pattern);
248 2 pattern++;
249 2 }
250 1 }
251
252 void display_GLCD_data(unsigned char *p)
253 {
254 1 if (gx<64) {
255 2 GLCD_CS1=1;
256 2 GLCD_CS2=0;
257 2 show_pattern(gy,gx,p,8);
258 2 show_pattern(gy,gx+8,p+8,8);
259 2 show_pattern(gy+1,gx,p+16,8);
260 2 show_pattern(gy+1,gx+8,p+24,8);
261 2 } else
262 1 {
263 2 GLCD_CS1=0;
264 2 GLCD_CS2=1;
265 2 show_pattern(gy,gx-64,p,8);
266 2 show_pattern(gy,gx-58,p+8,8);
267 2 show_pattern(gy+1,gx-64,p+16,8);
268 2 show_pattern(gy+1,gx-58,p+24,8);
269 2 }
270 1 gx=gx+16;
271 1 }
272
273 void display_GLCD_string(unsigned char *p,int len)
274 {
275 1 int i;
276 1
277 1 for(i=0;i<len;i++)
278 1 display_GLCD_data((p+32*i));
279 1 }
280 void display_GLCD_number(char number)
281 {
282 1 int x,y;
283 1 x=number/10;
284 1 y=number%10;
285 1 display_GLCD_data(digit[x]);
*** WARNING C182 IN LINE 285 OF EX6-5.C: pointer to different objects
286 1 display_GLCD_data(digit[y]);
*** WARNING C182 IN LINE 286 OF EX6-5.C: pointer to different objects
287 1 }
288
289 void gotoxy(unsigned x,unsigned y)
290 {
291 1 gy=y;
292 1 gx=x;
293 1 }
294
295 void display_time(time dispaly_time)
296 {
297 1 gotoxy(0,2);
298 1 display_GLCD_number(dispaly_time.hour);
299 1 display_GLCD_data(comma);
*** WARNING C182 IN LINE 299 OF EX6-5.C: pointer to different objects
300 1 display_GLCD_number(dispaly_time.minute);
C51 COMPILER V8.02 EX6_5 09/26/2006 20:28:21 PAGE 6
301 1 display_GLCD_data(comma);
*** WARNING C182 IN LINE 301 OF EX6-5.C: pointer to different objects
302 1 display_GLCD_number(dispaly_time.second);
303 1 }
304
305 void display_date(date tmp_date)
306 {
307 1 gotoxy(0,4);
308 1 display_GLCD_number(tmp_date.year);
309 1 display_GLCD_data(slash);
*** WARNING C182 IN LINE 309 OF EX6-5.C: pointer to different objects
310 1 display_GLCD_number(tmp_date.month);
311 1 display_GLCD_data(slash);
*** WARNING C182 IN LINE 311 OF EX6-5.C: pointer to different objects
312 1 display_GLCD_number(tmp_date.day);
313 1 }
314 char monthday(char year,char month)
315 {
316 1 if(month==2 && year%4==0) //润年的2月有29天
317 1 return(29);
318 1 else
*** ERROR C100 IN LINE 318 OF EX6-5.C: unprintable character 0xA1 skipped
*** ERROR C100 IN LINE 318 OF EX6-5.C: unprintable character 0xA1 skipped
*** ERROR C100 IN LINE 318 OF EX6-5.C: unprintable character 0xA1 skipped
*** ERROR C100 IN LINE 318 OF EX6-5.C: unprintable character 0xA1 skipped
319 1 return(dayofmonth[month-1]); //非闰年时的该月份天数
320 1
321 1 }
322 static void timer0_isr(void) interrupt 1 using 1
323 {
324 1
325 1 TR0=0;
326 1 TL0=(TIMER0_COUNT & 0x00FF);
327 1 TH0=(TIMER0_COUNT >> 8);
328 1 TR0=1;
329 1 timer0_tick++;
330 1 if (timer0_tick==100) {
331 2 timer0_tick=0;
332 2 now.second++;
333 2 if (now.second==60) {
334 3 now.second=0;
335 3 now.minute++;
336 3 if (now.minute==60) {
337 4 now.minute=0;
338 4 now.hour++;
339 4 if (now.hour==24) {
340 5 now.hour=0;
341 5 today.day++;
342 5 if (today.day>monthday(today.year,today.mont
*** ERROR C204 IN LINE 342 OF EX6-5.C: 'mont': undefined member
343 5 h)) {
*** ERROR C141 IN LINE 343 OF EX6-5.C: syntax error near 'h'
*** ERROR C141 IN LINE 343 OF EX6-5.C: syntax error near ')'
344 6 today.day=0;
345 6 today.month++;
346 6 if(today.month==13) {
347 7 today.month=1;
348 7 today.year++;
349 7 }
350 6 }
351 5 if(mode!=0) return;
352 5 display_date(today);
C51 COMPILER V8.02 EX6_5 09/26/2006 20:28:21 PAGE 7
353 5 }
354 4 }
355 3 }
356 2 if(mode!=0) return;
357 2 display_time(now);
358 2 }
359 1 }
360
361 static void timer0_initialize(void)
362 {
363 1
364 1 EA=0;
365 1 timer0_tick=0;
366 1 TR0=0;
367 1 TMOD &= 0XF0;
368 1 TMOD |=0x01;
369 1 TL0=(TIMER0_COUNT & 0x00FF);
370 1 TH0=(TIMER0_COUNT >> 8);
371 1 PT0=0;
372 1 ET0=1;
373 1 TR0=1;
374 1 EA=1;
375 1 }
376 void delay(void)
377 {
378 1 unsigned char i,j;
379 1 for(i=0;i<125;i++)
380 1 for(j=0;j<255;j++)
381 1 ;
382 1 }
383 char gotkey() {
384 1 if (mode_button==0) {
385 2 delay();
386 2 if (mode_button==0) return(0);
387 2 }
388 1 if (up_button==0) {
389 2 delay();
390 2 if (up_button==0) return(1);
391 2 }
392 1 return(15);
393 1 }
394
395 void main (void)
396 {
397 1 unsigned char keys,i=0;
398 1
399 1 clear_GLCD();
400 1 gotoxy(0,0);
401 1 display_GLCD_string(token,7);
402 1 display_time(now);
403 1 display_date(today);
404 1 timer0_initialize();
405 1 mode=0;
406 1 do {
407 2 switch(keys) {
408 3 case 0 :
409 3 mode++;
410 3 if(mode==6) {
411 4 mode=0;
412 4 now=display;
413 4 today=tmpday;
414 4 break;
C51 COMPILER V8.02 EX6_5 09/26/2006 20:28:21 PAGE 8
415 4 }
416 3 if(mode==1) {
417 4 display=now;
418 4 tmpday=today;
419 4 break;
420 4 }
421 3 break;
422 3 case 1 :
423 3 if(mode==0) break;
424 3 switch(mode) {
425 4 case 1 : display.hour++;
426 4 if(display.hour>=24) display.hour=0;
427 4 display_time(display);
428 4 break;
429 4 case 2 : display.minute++;
430 4 if(display.minute>=60) display.minut
431 4 e=0;
432 4 display_time(display);
433 4 break;
434 4 case 3 : tmpday.year++;
435 4 if(tmpday.year>=100) tmpday.year=0;
436 4 display_date(tmpday);
437 4 break;
438 4 case 4 : tmpday.month++;
439 4 if(tmpday.month>12) tmpday.month=1;
440 4 display_date(tmpday);
441 4 break;
442 4 case 5 : tmpday.day++;
443 4 if(tmpday.day>monthday
444 4 (tmpday.year,tmpday.month))
445 4 tmpday.day=1;
446 4 display_date(tmpday);
447 4 break;
448 4 }
449 3 break;
450 3 }
451 2 } while(1);
452 1 }
453
C51 COMPILATION COMPLETE. 6 WARNING(S), 7 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -