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