📄 time.lst
字号:
332 2 DisplayOneChar(13,1,0x20);
333 2 }
334 1 if(set1==3)
335 1 {
336 2 WriteCommand(0x0f);
337 2 WriteCommand(0x88+set2);
338 2 }
339 1 delay(250);
340 1 WriteCommand(0x0c);
341 1 }
342 /*
343 void displaystopwatchjudge(void)
344 {
345
346 DisplayOneChar(5,1,stopwatchjudge[0][0]/10+0x30);
347 DisplayOneChar(6,1,stopwatchjudge[0][0]%10+0x30);
348 DisplayOneChar(8,1,stopwatchjudge[0][1]/10+0x30);
349 DisplayOneChar(9,1,stopwatchjudge[0][1]%10+0x30);
350 DisplayOneChar(11,1,stopwatchjudge[0][2]/10+0x30);
351 DisplayOneChar(12,1,stopwatchjudge[0][2]%10+0x30);
352 delay(250);
353 if(set==1)
354 {
355 DisplayOneChar(5,1,0x20);
356 DisplayOneChar(6,1,0x20);
357 }
358 if(set==2)
359 {
360 DisplayOneChar(8,1,0x20);
361 DisplayOneChar(9,1,0x20);
362 }
363 if(set==3)
C51 COMPILER V8.02 TIME 08/15/2008 20:57:00 PAGE 7
364 {
365 DisplayOneChar(11,1,0x20);
366 DisplayOneChar(12,1,0x20);
367 }
368 delay(250);
369 }
370 /*
371 void displaydateclock(void)
372 {
373 displayclockjudge();
374 DisplayListChar(8,0,"SMTWTFS");
375 delay(250);
376 for(m=0;m<7;m++)
377 {
378 if(clockjudge[n]&dateclock[week1]!=0)
379 DisplayOneChar(m+8,0,0x20);
380 delay(250);
381 }
382 }
383 void displayhourjudge(void)
384 {
385 displayclockjudge();
386 delay(250);
387 DisplayOneChar(9,1,0x20);
388 DisplayOneChar(10,1,0x20);
389 delay(250);
390 }
391 void displayminitejudge(void)
392 {
393 displayclockjudge();
394 delay(250);
395 DisplayOneChar(12,1,0x20);
396 DisplayOneChar(13,1,0x20);
397 delay(250);
398 } */
399 /**************键盘扫描子函数******************/
400
401 void keyscan(void)
402 {
403 1 uchar xx; //局部变量
404 1 P2=0xff;
405 1 if(P2!=0xff)
406 1 {
407 2 delay(30);
408 2
409 2 if(P2!=0xff)
410 2 {
411 3 xx=P2;
412 3 switch(xx) // 根据按键状态,调用不同的子函数
413 3 {
414 4 case 0xfe: menu_key();
415 4 break;
416 4 case 0xfd: tab_key();
417 4 break;
418 4 case 0xfb:inc_key();
419 4 break;
420 4 case 0xf7:dec_key();
421 4 default:
422 4 break;
423 4 }
424 3
425 3 }
C51 COMPILER V8.02 TIME 08/15/2008 20:57:00 PAGE 8
426 2
427 2 }
428 1 delay(400);
429 1 switch(status)
430 1 {
431 2 case 0:TR0=1;displaytime();break;
432 2 case 1:TR0=1;displaydate();break;
433 2 case 2:TR0=1;displayclock();break;
434 2 default:
435 2 break;
436 2 }
437 1 }
438
439 /*******************显示主界面*******************/
440 void menu_key(void)
441 {
442 1 //delay(500);
443 1 disturb=0;
444 1 if(set1!=3)
445 1 {
446 2 status++;
447 2 set=0;
448 2 set1=0;
449 2 view=0;
450 2 }
451 1 if(status==2)
452 1 {
453 2 if(set1==3)
454 2 {
455 3 if((clockjudge[set]&dateclock[set2])==0)
456 3 {
457 4 next=1;
458 4 clockjudge[set]=(clockjudge[set]|dateclock[set2]);
459 4 }
460 3
461 3 if(((clockjudge[set]&dateclock[set2])!=0)&&(next==0))
462 3 {
463 4
464 4 clockjudge[set]=(clockjudge[set]&(~dateclock[set2]));
465 4 }
466 3 next=0;
467 3
468 3 }
469 2 }
470 1
471 1 if(status>2)
472 1 {
473 2 status=0;
474 2 }
475 1 }
476 /**************设定工作模式子函数****************/
477
478 void tab_key(void)
479 {
480 1 // set2=0;
481 1 disturb=0;
482 1 if(status!=2)
483 1 {
484 2 set++;
485 2 }
486 1 if(status==2)
487 1 {set1++;
C51 COMPILER V8.02 TIME 08/15/2008 20:57:00 PAGE 9
488 2 if(set1>3)
489 2 set1=0;
490 2 }
491 1
492 1 }
493 /****************按键加法子函数******************/
494
495 void inc_key(void)
496 {
497 1 set2++;
498 1 if(set2>6)
499 1 {set2=0;}
500 1 disturb=0;
501 1 switch(status)
502 1 {
503 2 case 0:inc_time();
504 2 break;
505 2 case 1:
506 2 break;
507 2 case 2:inc_clock();
508 2 break;
509 2
510 2 default:
511 2 break;
512 2 }
513 1 }
514 /****************时间加法子函数*****************/
515 void inc_time(void)
516 {
517 1 if(set==1)
518 1 {
519 2 hour++;
520 2 if(hour==24)
521 2 hour=0;
522 2
523 2 }
524 1 if(set==2)
525 1 {
526 2 minite++;
527 2 if(minite==60)
528 2 minite=0;
529 2 }
530 1 if(set==3)
531 1 {
532 2 second++;
533 2 if(second==60)
534 2 second=0;
535 2 }
536 1 if(set==4)
537 1 {
538 2 year++;
539 2 }
540 1 if(set==5)
541 1 {
542 2 month++;
543 2 if(month>12)
544 2 month=1;
545 2 }
546 1 if(set==6)
547 1 {
548 2 day++;
549 2 k1=dayjudge(year,month);
C51 COMPILER V8.02 TIME 08/15/2008 20:57:00 PAGE 10
550 2 if(day>k1)
551 2 day=1;
552 2 }
553 1
554 1 }
555 /****************闹钟加法子函数*****************/
556 void inc_clock(void)
557 {
558 1 if(set1==1)
559 1 {
560 2 hourjudge[set]++;
561 2 if(hourjudge[set]>23)
562 2 hourjudge[set]=0;
563 2 }
564 1 if(set1==2)
565 1 {
566 2 minitejudge[set]++;
567 2 if(minitejudge[set]>59)
568 2 minitejudge[set]=0;
569 2 }
570 1 if(set1==0)
571 1 set++;
572 1 if(set>31)
573 1 set=0;
574 1 }
575
576 /****************按键减法子函数*****************/
577
578 void dec_key(void)
579 {
580 1 set2--;
581 1 if(set2<0)
582 1 {set2=6;}
583 1 disturb=0;
584 1 switch(status)
585 1 {
586 2 case 0:dec_time();
587 2 break;
588 2 case 1:
589 2 break;
590 2 case 2:dec_clock();
591 2 break;
592 2 default:
593 2 break;
594 2 }
595 1 }
596 /****************时间减法子函数*****************/
597 void dec_time(void)
598 {
599 1 if(set==1)
600 1 {
601 2 hour--;
602 2 if(hour<0)
603 2 hour=23;
604 2
605 2 }
606 1 if(set==2)
607 1 {
608 2 minite--;
609 2 if(minite<0)
610 2 minite=59;
611 2 }
C51 COMPILER V8.02 TIME 08/15/2008 20:57:00 PAGE 11
612 1 if(set==3)
613 1 {
614 2 second--;
615 2 if(second<0)
616 2 second=59;
617 2 }
618 1
619 1 if(set==4)
620 1 {
621 2 year--;
622 2 }
623 1 if(set==5)
624 1 {
625 2 month--;
626 2 if(month<1)
627 2 month=12;
628 2 }
629 1 if(set==6)
630 1 {
631 2 day--;
632 2 k1=dayjudge(year,month);
633 2 if(day<1)
634 2 day=k1;
635 2 }
636 1
637 1 }
638 /****************闹钟减法子函数*****************/
639 void dec_clock(void)
640 {
641 1 if(set1==1)
642 1 {
643 2 hourjudge[set]--;
644 2 if(hourjudge[set]<0)
645 2 hourjudge[set]=23;
646 2 }
647 1 if(set1==2)
648 1 {
649 2 minitejudge[set]--;
650 2 if(minitejudge[set]<0)
651 2 minitejudge[set]=59;
652 2 }
653 1 if(set1==0)
654 1 set--;
655 1 if(set<0)
656 1 set=31;
657 1 }
658
659 /****************当月天数判断子函数*****************/
660 int dayjudge(int year,int month)
661 {
662 1 int s,judge1;
663 1 if((year%4==0&&year%100!=0)||(year%100==0&&year%400==0)) /*判断当年是否为闰年*/
664 1 judge1=1;
665 1 else judge1=0;
666 1 if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)/*判断每月的天数*/
667 1 {s=31;
668 2 return(s);
669 2 }
670 1 if(month==4||month==6||month==9||month==11)
671 1 {s=30;
672 2 return(s);
673 2 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -