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