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