📄 main.lst
字号:
366 1 lcd_string(0,"循迹\r\n");
367 1 }
368 void start5()
369 {
370 1 lcd_cls();
371 1 lcd_string(0,"定点\r\n");//背光显示
372 1 lcd_string(0,"矩形\r\n");
373 1 lcd_string(0,"三角\r\n");
374 1 lcd_string(0,"圆形\r\n");
375 1 lcd_string(1,"循迹\r\n");
376 1 }
377 //********************************
378 void middle6()
379 {
380 1 lcd_cls();
381 1 lcd_string(0,"★设置终点坐标★\r\n");
382 1 shape=XIAN;
383 1 // lcd_string(0,"\r\nX: ");
384 1 // lcd_string(0,"\r\nY: cm");
385 1
386 1 }
387 //******************************
388 void middle7()//矩形
389 {
390 1 // lcd_cls();
391 1 // lcd_string(0," ★实时坐标显示★");
392 1 // lcd_string(0,"\r\n\r\nX: cm");
393 1 // lcd_string(0,"\r\nY: k cm");
394 1 /*
395 1 pt1_x=0;
396 1 pt1_y=0;
397 1 pt2_x=50;
398 1 pt2_y=30;
399 1 line();
400 1 while(state);
401 1 pt1_x=50;
402 1 pt1_y=30;
403 1 pt2_x=50;
404 1 pt2_y=70;
405 1 line();*/
406 1
407 1 }
408 void middle8()//三角
409 {
410 1 //lcd_cls();
411 1 //lcd_string(0," ★实时坐标显示★");
412 1 //lcd_string(0,"\r\n\r\nX: cm");
413 1 //lcd_string(0,"\r\nY: k cm");
414 1 /*
415 1 pt1_x=0;
416 1 pt1_y=0;
417 1 pt2_x=60;
418 1 pt2_y=0;
419 1 line();
420 1 displayxy();
421 1 // while(state);
422 1 pt1_x=60;
423 1 pt1_y=0;
424 1 pt2_x=0;
425 1 pt2_y=60;
426 1 line();
427 1 displayxy();
C51 COMPILER V7.06 MAIN 09/12/2005 12:55:40 PAGE 8
428 1
429 1 // while(state);
430 1 pt1_x=0;
431 1 pt1_y=60;
432 1 pt2_x=0;
433 1 pt2_y=0;
434 1 line();
435 1 displayxy();
436 1 */
437 1 pt1_x=0;
438 1 pt1_y=0;
439 1 pt2_x=24;
440 1 pt2_y=38;
441 1 line();
442 1 displayxy();
443 1 // while(state);
444 1 pt1_x=24;
445 1 pt1_y=38;
446 1 pt2_x=62;
447 1 pt2_y=9;
448 1 line();
449 1 displayxy();
450 1
451 1 // while(state);
452 1 pt1_x=62;
453 1 pt1_y=9;
454 1 pt2_x=0;
455 1 pt2_y=0;
456 1 line();
457 1 displayxy();
458 1 }
459 //**********************
460 uchar xdata yuanptcount _at_ 0x20cd;
461 bit bdata yuanflag=1;
462 void middle9()
463 {
464 1 lcd_cls();
465 1 lcd_string(0,"★设置圆心坐标★\r\n");
466 1
467 1 //
468 1 //lcd_string(0," ★实时坐标显示★");
469 1 //lcd_string(0,"\r\n\r\nX: cm");
470 1 //lcd_string(0,"\r\nY: cm");
471 1 shape=YUAN;
472 1
473 1 }
474 void middle10()
475 {
476 1 //lcd_string(0,"\r\n\r\n 运行中...\r\n");
477 1 lcd_cls();
478 1 lcd_string(0,"★设置起点坐标★\r\n");
479 1 shape=QUXIAN;
480 1 }
481
482 void gif()
483 {
484 1 lcd_cls();
485 1 lcd_string(0,"\r\n 悬挂运动控制系统\r\n");
486 1 lcd_string(0,"\r\n 2005-9-13");
487 1 lcd_string(0,"\r\n待机");
488 1 return;
489 1 }
C51 COMPILER V7.06 MAIN 09/12/2005 12:55:40 PAGE 9
490 //**********************
491 typedef struct
492 {
493 uchar KeyStateIndex; //当前状态索引号
494 uchar KeyDnState; //按下"向下"键时状态索引号
495 uchar KeyUpState; //按下"向上"键时状态索引号
496 uchar KeyCrState; //按下"回车"键时状态索引号
497 uchar KeyCaState; //按下"取消"键时状态索引号
498 void (*CurrentOperate)(); //当前状态应该执行的功能操作
499 } KbdTabStruct;
500
501 void (*KeyFuncPtr)(); //按键功能函数指针
502
503 //************************
504 KbdTabStruct code KeyTab[]=
505 {//cur down up enter cancel curfunction
506 {0, 0, 0, 0, 0,(*gif)}, //开机画面
507
508 {1, 2, 5, 6, 1, (*start1)},
509 {2, 3, 1, 7, 2, (*start2)},
510 {3, 4, 2, 8, 3, (*start3)},
511 {4, 5, 3, 9, 4, (*start4)},
512 {5, 1, 4, 10, 5, (*start5)},
513
514 {6, 6, 6, 6, 1, (*middle6)},
515 {7, 7, 7, 7, 2, (*middle7)},
516 {8, 8, 8,8, 3, (*middle8)},
517 {9, 9, 9, 9, 4, (*middle9)},
518 {10, 10, 10, 10, 5,(*middle10)},
519
520 };
521 //状态函数结束
522
523 void yuan()
524 {
525 1 for(yuanptcount=0;yuanptcount<72;yuanptcount++)
526 1 {
527 2 pt2_x=40*cos(0.08726646*yuanptcount)*1.05+xend;
528 2 pt2_y=40*sin(0.08726646*yuanptcount)*0.95+yend;
529 2 if(yuanflag)
530 2 {
531 3 pt1_x=pt2_x;
532 3 pt1_y=pt2_y;
533 3 yuanflag=0;
534 3 }
535 2 line();
536 2 displayxy();
537 2 pt1_x=pt2_x;
538 2 pt1_y=pt2_y;
539 2 }
540 1 }
541 float qxtemp;
542 uchar qxcount;
543 bit bdata quxianflag=1;
544 void quxian()
545 {
546 1
547 1 while(1)
548 1 {
549 2 qxtemp=0;
550 2 if(quxianflag)
551 2 {
C51 COMPILER V7.06 MAIN 09/12/2005 12:55:40 PAGE 10
552 3 pt1_x=xend;
553 3 pt1_y=yend;
554 3 pt2_x=pt1_x;
555 3 quxianflag=0;
556 3 }
557 2 pt2_y=pt1_y+0.2;
558 2 if(!P1_4)qxtemp=-1.4;//,lcd_string(0,"z0");
559 2 // else lcd_string(0,"z1");
560 2 if(!P1_5)qxtemp=1.4;//,lcd_string(0,"y0");
561 2 //else lcd_string(0,"y1");
562 2 if(P1_6)qxcount++;//,lcd_string(0,"q1");
563 2 else qxcount=0;//,lcd_string(0,"q0");
564 2 if(qxcount>100)break;
565 2 // if(!P1_4||!P1_5)
566 2 pt2_x=pt1_x+qxtemp;
567 2 line();
568 2 displayxy();
569 2 while(state);
570 2 pt1_x=pt2_x;
571 2 pt1_y=pt2_y;
572 2 }
573 1 }
574
575 void GetKeyInput(void)
576 {
577 1 switch(key)
578 1 {
579 2 case 0x00:
580 2 return;
581 2 case 0xda://回车键
582 2 if(KeyFuncIndex==0)
583 2 return;
584 2 if(count)
585 2 {
586 3 keystr[isy][count]='\0';
587 3 count=0;
588 3 if(!isy)
589 3 {
590 4 xend=atoi(keystr[0]);
591 4 }
592 3 else
593 3 {
594 4 yend=atoi(keystr[isy]);
595 4 pt1_x=xstart;
596 4 pt1_y=ystart;
597 4 pt2_x=xend;
598 4 pt2_y=yend;
599 4 if(shape==XIAN)
600 4 line();
601 4 else if(shape==YUAN)
602 4 yuan();
603 4 else if(shape==QUXIAN)
604 4 quxian();
605 4 displayxy();
606 4 shape=0;
607 4 }
608 3 isy=!isy;
609 3 }
610 2 KeyFuncIndex=KeyTab[KeyFuncIndex].KeyCrState;
611 2 break;
612 2 case 0xdc://开始循迹
613 2 lcd_cls();
C51 COMPILER V7.06 MAIN 09/12/2005 12:55:40 PAGE 11
614 2 lcd_string(0,"开始循迹");
615 2 break;
616 2 case 0xdb: //启动键
617 2 if(KeyFuncIndex==0)
618 2 KeyFuncIndex=1;
619 2 break;
620 2 case 0xd2://取消键
621 2 if(KeyFuncIndex<=5)
622 2 return;
623 2 KeyFuncIndex=KeyTab[KeyFuncIndex].KeyCaState;
624 2 break;
625 2 case 0xc2://向上键
626 2 if(KeyFuncIndex==0)
627 2 return;
628 2 KeyFuncIndex=KeyTab[KeyFuncIndex].KeyUpState;
629 2 break;
630 2 case 0xca://向下键
631 2 if(KeyFuncIndex==0)
632 2 return;
633 2 KeyFuncIndex=KeyTab[KeyFuncIndex].KeyDnState;
634 2 break;
635 2 case 0xdd:
636 2 keystr[isy][count++]=48;
637 2 key=0;
638 2 lcd_string(0,"0");
639 2 return;
640 2 case 0xd5:
641 2 keystr[isy][count++]=49;
642 2 key=0;
643 2 lcd_string(0,"1");
644 2 return;
645 2 case 0xd4:
646 2 keystr[isy][count++]=50;
647 2 key=0;
648 2 lcd_string(0,"2");
649 2 return;
650 2 case 0xd3:
651 2 keystr[isy][count++]=51;
652 2 key=0;
653 2 lcd_string(0,"3");
654 2 return;
655 2 case 0xcd:
656 2 keystr[isy][count++]=52;
657 2 key=0;
658 2 lcd_string(0,"4");
659 2 return;
660 2 case 0xcc:
661 2 keystr[isy][count++]=53;
662 2 key=0;
663 2 lcd_string(0,"5");
664 2 return;
665 2 case 0xcb:
666 2 keystr[isy][count++]=54;
667 2 key=0;
668 2 lcd_string(0,"6");
669 2 return;
670 2 case 0xc5:
671 2 keystr[isy][count++]=55;
672 2 key=0;
673 2 lcd_string(0,"7");
674 2 return;
675 2 case 0xc4:
C51 COMPILER V7.06 MAIN 09/12/2005 12:55:40 PAGE 12
676 2 keystr[isy][count++]=56;
677 2 key=0;
678 2 lcd_string(0,"8");
679 2 return;
680 2 case 0xc3:
681 2 keystr[isy][count++]=57;
682 2 key=0;
683 2 lcd_string(0,"9");
684 2 return;
685 2 default: //按键错误的处理
686 2 return;
687 2 }
688 1
689 1 KeyFuncPtr=KeyTab[KeyFuncIndex].CurrentOperate;
690 1 (*KeyFuncPtr)();//执行当前按键的操作
691 1 key=0;
692 1 }
693 //*************************
694 void init_main()
695 {
696 1 serial_init();
697 1 init8279();
698 1 timer0_init();
699 1 timer1_init();
700 1 KeyFuncPtr=KeyTab[0].CurrentOperate;//开机画面
701 1 (*KeyFuncPtr)();//执行当前按键的操作
702 1
703 1 }
704
705 void main(void)
706 {
707 1 isy=0;
708 1 count=0;
709 1 xstart=0,ystart=0;
710 1 num0=0,num1=0;
711 1 state=0;
712 1 l_xishu=1;
713 1 r_xishu=1;
714 1 quxianflag=1;
715 1 init_main();
716 1 for(;;)
717 1 {
718 2 GetPCdata();
719 2 shoudong();
720 2 GetKeyInput();
721 2 }
722 1
723 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 4495 ----
CONSTANT SIZE = 270 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 16 2
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -