📄 lcm_t.lst
字号:
496 1
497 1 //if(read_clock(0x8b) != xq){
498 1 xq = read_clock(0x8b);
499 1 sel = (read_clock(0x8b))%16; //字节低4位的BCD码放入sel
500 1 lcm_w_test(0,0x97);//写入指定区域(97H 第二行第8个字)
501 1 if(sel==7) {lcm_w_word("日");} //
502 1 if(sel==6) {lcm_w_word("六");} //
503 1 if(sel==5) {lcm_w_word("五");} //
504 1 if(sel==4) {lcm_w_word("四");} //
505 1 if(sel==3) {lcm_w_test(1,0xc8);lcm_w_test(1,0xfd);} //此指令等于lcm_w_word("三"); 因为“三”的内码失效
-。
506 1 if(sel==2) {lcm_w_word("二");} //
507 1 if(sel==1) {lcm_w_word("一");} //星期一
508 1 lcm_w_test(0,0x95);
509 1 lcm_w_word("星期");
510 1 //}
511 1 }
512 /*****************************************************************************/
513 //向LCM中填写 日 数据
514 void lcm_w_dd(void){
515 1 // if(read_clock(0x87) != dd){
516 1 dd = read_clock(0x87);
517 1 lcm_w_test(0,0x92);
518 1 if(dd/16 != 0){lcm_w_test(1,(dd/16)+0x30);} //十位消隐
519 1 else{lcm_w_test(1,0x20);}//同上
520 1 lcm_w_test(1,dd%16+0x30);
521 1 lcm_w_test(0,0x93);
522 1 lcm_w_word("日 ");
523 1
524 1 } //}
525 /*****************************************************************************/
526 //向LCM中填写 小时 数据
527 void lcm_w_hh(void){
528 1 if(read_clock(0x85) != hh){
529 2 hh = read_clock(0x85);
530 2 if (hh > 0x07 && hh < 0x22 && w == 0){
531 3 beep = 0; led_r = 0;
532 3 DelayM(100);
533 3 beep = 1; led_r = 1;
534 3 }
535 2 }
536 1 lcm_w_test(0,0x88);
537 1 lcm_w_test(1,(hh/16)+0x30);
538 1 lcm_w_test(1,hh%16+0x30);
539 1
540 1 } //}
541 /*****************************************************************************/
542 //向LCM中填写 分钟 数据
543 void lcm_w_mm(void){
544 1 if(read_clock(0x83) != mm){
545 2 mm = read_clock(0x83);
546 2 if( w == 0){
547 3 days(); //节日显示
*** WARNING C209 IN LINE 547 OF LCM_T.C: '_days': too few actual parameters
548 3 updata (); //刷新数据
549 3 }
C51 COMPILER V6.12 LCM_T 02/10/2007 00:13:53 PAGE 10
550 2 }
551 1 lcm_w_test(0,0x89);
552 1 lcm_w_test(1,0x3a); //":"
553 1 lcm_w_test(1,(mm/16)+0x30);
554 1 lcm_w_test(1,mm%16+0x30);
555 1 lcm_w_test(1,0x2e); //"."
556 1 }
557 /*****************************************************************************/
558 //刷新数据
559 void updata (void){
560 1 lcm_w_hh();//刷新 小时
561 1 lcm_w_dd();//刷新 日
562 1 lcm_w_xq();//更新星期值
563 1 lcm_w_mo();//刷新 月
564 1 lcm_w_yy();//刷新 年
565 1
566 1 }
567 /*****************************************************************************/
568 //向LCM中填写 秒 数据
569 void lcm_w_ss(void){
570 1 unsigned int i=0;
571 1 unsigned char a=0,b=0,c=0;
572 1 if(read_clock(0x81) != ss){ //判断是否需要更新
573 2 ss = read_clock(0x81); //更新数据
574 2 lcm_w_test(0,0x8b); //秒值在LCM上的写入位置
575 2 lcm_w_test(1,(ss/16)+0x30); //写十位
576 2 lcm_w_test(1,ss%16+0x30); //写个位
577 2 led_b = ~led_b; //背光闪烁
578 2 lcm_w_mm();//刷新 分
579 2 lcm_w_test(0,0x8d); //温度在LCM上的写入位置
580 2 i=ReadTemperature();//读温度并送显
581 2 a=i/100;
582 2 lcm_w_test(1,a+0x30); //显示温度十位
583 2 b=i/10-a*10;
584 2 lcm_w_test(1,b+0x30); //个位
585 2 lcm_w_test(1,0x2e); //"."
586 2 c=i-a*100-b*10;
587 2 lcm_w_test(1,c+0x30); //小位1位
588 2 lcm_w_word("℃"); //度C
589 2 } }
590 /*****************************************************************************/
591 //---主程序---//
592
593 main() {
594 1
595 1 unsigned char e=0;
596 1 KEY_I = 0;KEY_1 = 1;KEY_2 = 1;KEY_3 = 1;KEY_4 = 1;//初始键盘
597 1 yy=0xff;mo=0xff;dd=0xff;xq=0xff;hh=0xff;mm=0xff;ss=0xff; //各数据刷新
598 1 beep = 0;
599 1 DelayM(900);
600 1 beep = 1;
601 1 lcm_init();//初始化液晶显示器
602 1 lcm_clr();//清屏
603 1 lcm_w_word(" 12864LcdClock Hello !! from DoYoung.net");//显示欢迎字
604 1 //----------|-------1-------|-------3-------|-------2-------|-------4-------|-----//标尺
605 1 DelayM(3000); //显示等留3秒
606 1 //lcm_w_test(0,0x80);
607 1 //lcm_w_word("[Dis] [Set]");
608 1
609 1 while(1){
610 2 if (w == 0){ //正常走时
611 3 lcm_w_ss();//刷新 秒
C51 COMPILER V6.12 LCM_T 02/10/2007 00:13:53 PAGE 11
612 3 }
613 2 else { //启动调时
614 3
615 3
616 3 }
617 2
618 2 //------------------------------------------------------------------
619 2 if (KEY_3 == 0) // 设置时间
620 2 {
621 3 DelayM(20); //去抖
622 3 led_g3 = 0;led_r = 1;
623 3 if(KEY_3 == 0 && w == 1) //当是调时状态 本键用于调整下一项
624 3 {
625 4 e++;
626 4 if (e >= 6 ){e = 0;}
627 4 Set_time(e);//调整
628 4 }
629 3
630 3 if(KEY_3 == 0 && w == 0) //当是正常状态时就进入调时状态
631 3 {
632 4 led_b = 1;//
633 4 lcm_clr();//清屏
634 4 //yy=0xff;mo=0xff;dd=0xff;xq=0xff;hh=0xff;mm=0xff;ss=0xff; //各数据刷新
635 4 w=1; //进入调时
636 4 lcm_w_test(0,0x9e);
637 4 lcm_w_word(" [-]");
638 4 lcm_w_test(0,0x80);
639 4 lcm_w_word("[Esc]");
640 4 lcm_w_test(0,0x85);
641 4 lcm_w_word("[Next]");
642 4 lcm_w_test(0,0x98);
643 4 lcm_w_word("[+]");
644 4 Set_time(e);//调整
645 4 }
646 3 while(KEY_3 == 0);//等待键松开
647 3 led_g3 = 1; led_r = 0;//红灯亮,表示调时
648 3 }
649 2
650 2 //------------------------------------------------------------------
651 2 if (KEY_1 == 0) // 当在调时状态时就退出调时
652 2 {
653 3 DelayM(20);led_g1 = 0;led_r = 1;
654 3 if(KEY_1 == 0 && w == 1){
655 4 w = 0; //退出调时
656 4 e = 0; //“下一项”计数器清0
657 4 }
658 3
659 3 if(KEY_1 == 0 && w == 0){
660 4 lcm_clr();//清屏
661 4 lcm_w_test(0,0x80);
662 4 lcm_w_word(" 12864LcdClock V1.01 2006-11-26 Hello !! from DoYoung.net");
663 4 //----------|-------1-------|-------3-------|-------2-------|-------4-------|-----//标尺
664 4 while(KEY_1 == 0);//等待键松开
665 4 }
666 3 lcm_clr();//清屏
667 3 //lcm_w_word("[Dis] [Set]");
668 3 //yy=0xff;mo=0xff;dd=0xff;xq=0xff;hh=0xff;mm=0xff;ss=0xff; //各数据刷新
669 3 days(); //节日显示
*** WARNING C209 IN LINE 669 OF LCM_T.C: '_days': too few actual parameters
670 3 updata (); //刷新数据
671 3 lcm_w_mm();//刷新 分
672 3
C51 COMPILER V6.12 LCM_T 02/10/2007 00:13:53 PAGE 12
673 3
674 3 while(KEY_1 == 0);//等待键松开
675 3 led_g1 = 1;
676 3 }
677 2
678 2 //------------------------------------------------------------------
679 2 if (KEY_2 == 0 && w == 1){ // 加减调整{
680 3 DelayM(20);led_g2 = 0;led_r = 1;
681 3 if(KEY_2 == 0 && w == 1){
682 4 Set_time(e);//调整
683 4 }
684 3 while(KEY_2 == 0);//等待键松开
685 3 led_g2 = 1; led_r = 0;
686 3 }
687 2
688 2 //------------------------------------------------------------------
689 2 if (KEY_4 == 0 && w == 1){ // 加减调整
690 3 DelayM(20); led_g4 = 0;led_r = 1;
691 3 if(KEY_4 == 0 && w == 1){
692 4 Set_time(e);//调整
693 4 }
694 3 while(KEY_4 == 0);//等待键松开
695 3 led_g4 = 1; led_r = 0;
696 3 }
697 2
698 2 //------------------------------------------------------------------
699 2 if(KEY_1 == 1 && KEY_2 == 0 && KEY_3 == 1 && KEY_4 == 0){ //时钟初始化{
700 3 led_r = 0;
701 3 DelayM(3000);
702 3 led_r = 1;
703 3 if(KEY_1 == 0 && KEY_2 == 0&& KEY_3 == 1&& KEY_4 == 0){
704 4 Init_1302();
705 4 lcm_w_test(0,0x80);
706 4 lcm_clr();//清屏
707 4 lcm_w_word("初始化成功! 2007-1-1 00:00.0");
708 4 //----------|-------1-------|-------3-------|
709 4 while(1);
710 4 }
711 3 }
712 2 } }
713
714 /*****************************************************************************/
715 /*
716 //编程日志
717 2007-02-10 修改为正式发布版。
718 2007-01-26 用每分钟刷新数据,防止显示乱码。
719 2006-11-30
720 2006-11-29 时钟主显示部分完成。
721 2006-11-28 时钟驱动程序植入完成。
722 2006-11-27 LCM驱动程序植入完成。
723 2006-11-26 硬件制作完成。
724
725 /*****************************************************************************/
726
727
728
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3421 ----
CONSTANT SIZE = 1356 ----
XDATA SIZE = ---- ----
C51 COMPILER V6.12 LCM_T 02/10/2007 00:13:53 PAGE 13
PDATA SIZE = ---- ----
DATA SIZE = 10 28
IDATA SIZE = ---- ----
BIT SIZE = 1 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 2 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -