📄 main.lst
字号:
439 3 if(!(Key3&Key4&Key5))
440 3 {
441 4 //SendChar('1');
442 4 if(Key3==0) return 0x01;
443 4 if(Key4==0) return 0x02;
444 4 if(Key5==0) return 0x03;
445 4 }
446 3
447 3 P3MDOUT|=0x0e;
448 3 P0MDOUT|=0x03;
449 3 Key1=0;
450 3 Key2=1; //第一行
451 3 Key3=1;
452 3 Key4=1;
453 3 Key5=1;
454 3 P3MDOUT&=0xf1;
455 3 P0MDOUT&=0xfc;
456 3 if(!(Key3&Key4&Key5))
457 3 {
458 4 //SendChar('2');
459 4 if(Key3==0) return 0x04;
460 4 if(Key4==0) return 0x05;
461 4 if(Key5==0) return 0x06;
462 4 }
463 3 }
464 2 else //只是抖动
465 2 {
466 3 return 0;
467 3 }
468 2 }
469 1 else //没有按下任何键
470 1 {
471 2 return 0;
472 2 }
473 1 }
474 void main(void)
475 {
476 1 //****************************************
477 1 INIT_PORT();
478 1 WDT_Init();
479 1 INIT_SYS_CLK();
480 1 EA=1;
481 1 Timer0_Init();
482 1 RS232_Init();
483 1 LcdInit();
484 1 //****************************************
485 1 PutStr(0,0,"Welcome to YLong");
486 1 PutStr(0,1," Idle,Press KEY ");
487 1
488 1 for(LED_Count=0;LED_Count<3;LED_Count++)
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 9
489 1 {
490 2 Time_Out_Count=0;
491 2 while(Time_Out_Count<500) //5ms
492 2 {;}
493 2 Led1=~Led1;
494 2 Led2=~Led2;
495 2 Led3=~Led3;
496 2 }
497 1
498 1 while(1)
499 1 {
500 2 //增加键盘扫描程序,键值放在Key_Value
501 2 Key_Value=Key_Scan();
502 2 if (Key_Enable)
503 2 {
504 3 if (Key_Value)
505 3 {
506 4 Led1=~Led1;
507 4 Present_State=Key_Value;
508 4 Key_Value=0;
509 4 switch(Present_State)
510 4 {
511 5 case 1:
512 5 serial_tx_buff[0]=FRAME_WATER;
513 5 Need_to_Send=1;
514 5 Work_Time_Out=WATER_WORKONG_TIME;
515 5 break;
516 5 case 2:
517 5 serial_tx_buff[0]=FRAME_NOW_COFF;
518 5 Need_to_Send=1;
519 5 Work_Time_Out=NOW_WORKONG_COFF_TIME;
520 5 break;
521 5 case 3:
522 5 serial_tx_buff[0]=FRAME_CLEAN;
523 5 Need_to_Send=1;
524 5 Work_Time_Out=CLEAN_WORKONG_TIME;
525 5 break;
526 5 case 4:
527 5 serial_tx_buff[0]=FRAME_DIRTY;
528 5 Need_to_Send=1;
529 5 Work_Time_Out=DIRTY_WORKONG_TIME;
530 5 break;
531 5 case 5:
532 5 serial_tx_buff[0]=FRAME_STEAM;
533 5 Need_to_Send=1;
534 5 Work_Time_Out=STEAM_WORKONG_TIME;
535 5 break;
536 5 case 6:
537 5 serial_tx_buff[0]=FRAME_RESET;
538 5 Need_to_Send=1;
539 5 Work_Time_Out=RESET_WORKONG_TIME;
540 5 break;
541 5 default:
542 5 Need_to_Send=0;
543 5 Work_Time_Out=0;
544 5 break;
545 5 }
546 4 if (Need_to_Send)
547 4 {
548 5 Led3=~Led3;
549 5 Need_to_Send=0;
550 5 SendString(serial_tx_buff,8);
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 10
551 5 //Led3=0;
552 5 //PutStr(0,0,"Order Have Send!");
553 5 //PutStr(2,1,"Please Wait");
554 5 SelectedKeyShow(Present_State,0);
555 5 Time_Out_Count=0;
556 5 Uart_Flag=0;
557 5 Uart_Coun=0;
558 5 while(Time_Out_Count<COFFE_TIME_OUT)
559 5 {
560 6 if (Uart_Flag)
561 6 break;
562 6 }
563 5 if (Uart_Flag)
564 5 {
565 6 Uart_Flag=0;
566 6 Uart_Coun=0;
567 6 //Led2=~Led2;
568 6 if (serial_rx_buff[0]==COFFE_BUSY_STATUS)
569 6 {
570 7 //PutStr(0,0,"Start to Working");
571 7 //PutStr(2,1,"Please Wait");
572 7 Uart_Enable=1;
573 7 Key_Enable=0;
574 7 Recv_Out_Times=0;
575 7 Recv_Time_Out=0;
576 7 SelectedKeyShow(Present_State,1);
577 7 }
578 6 else if(serial_rx_buff[0]==COFFE_ERROR_STATUS)
579 6 {
580 7 PutStr(0,0,"Have Some Error!");
581 7 PutStr(0,1,"Please Reselect!");
582 7 }
583 6 else
584 6 {
585 7 PutStr(0,0,"Unknown Status 0");
586 7 PutStr(0,1,"Please Reselect!");
587 7 }
588 6 //serial_rx_buff[0]=0x00;
589 6 }
590 5 else
591 5 {
592 6 PutStr(0,0,"Coffee Center is Busy or Timeout");
593 6 Time_Out_Count=0;
594 6 while(Time_Out_Count<1000)
595 6 {;}
596 6 PutStr(0,0,"Welcome to YLong");
597 6 PutStr(0,1," Idle,Press KEY ");
598 6 }
599 5 }
600 4 else
601 4 {
602 5 PutStr(0,0," Key Not Exist! ");
603 5 PutStr(0,1," Wait For Press ");//按键错误
604 5 }
605 4 }
606 3 }
607 2
608 2 if (Uart_Enable)
609 2 {
610 3 if (Recv_Out_Times < Work_Time_Out)
611 3 {
612 4 if (Uart_Flag)
C51 COMPILER V7.07 MAIN 11/29/2008 23:08:07 PAGE 11
613 4 {
614 5 Uart_Enable=0;
615 5 Key_Enable=1;
616 5 Uart_Flag=0;
617 5 Uart_Coun=0;
618 5 if (serial_rx_buff[0]==COFFE_IDLE_STATUS)
619 5 {
620 6 //PutStr(0,0,"Working Has Done");
621 6 //PutStr(0,1,"Please Reselect!");
622 6 SelectedKeyShow(Present_State,2);
623 6 }
624 5 else if(serial_rx_buff[0]==COFFE_ERROR_STATUS)
625 5 {
626 6 PutStr(0,0,"Have Some Error!");
627 6 PutStr(0,1,"Please Reselect!");
628 6 }
629 5 else
630 5 {
631 6 PutStr(0,0,"Unknown Status 1");
632 6 PutStr(0,1,"Please Reselect!");
633 6 }
634 5 //serial_rx_buff[0]=0x00;
635 5 }
636 4 }
637 3 else
638 3 {
639 4 Uart_Enable=0;
640 4 Key_Enable=1;
641 4 PutStr(0,0,"Working Time Out");
642 4 PutStr(0,1,"Please Reselect!");
643 4 }
644 3 }
645 2 }
646 1 _nop_();
647 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1752 ----
CONSTANT SIZE = 526 ----
XDATA SIZE = 34 9
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -