📄 song.lst
字号:
361 1 {
362 2
363 2 stop_5s();
364 2 stopFlag = 1;
365 2 }
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 7
366 1
367 1
368 1 tie_flag=1;
369 1 count++;
370 1 char_show = ledk[count];
371 1 dsp[3] = char_show;
372 1 P17=0;//声光信息
373 1 for (i=0;i<20;i++)
374 1 {
375 2 display();
376 2 }
377 1 P17=1;
378 1
379 1
380 1
381 1
382 1 }
383 /////////////////////外部1中断检测脉冲数
384 //void ceju()
385 void int1() interrupt 2
386 {
387 1 //unsigned char ms0, s1;
388 1 // float juli_real;
389 1 unsigned char juli_int;
390 1 unsigned char tie_juli_start;
391 1 unsigned char tie_juli_end;
392 1 unsigned char round_int;
393 1 unsigned char round_real;
394 1
395 1 //if(P07==1)
396 1 // { ms++;
397 1 // P07=0;
398 1 // }
399 1 ms++;
400 1
401 1 if(P32==1&&tie_flag==1)
402 1 {
403 2 show_tie_juli = 1;
404 2 ms2=ms;
405 2 tie_flag=0;
406 2 //ms0=(ms2-ms1)/4;
407 2 //s1=(ms2-ms1) * 20/2/4;
408 2 //distance[count]=ms*20 / 4 +(ms2-ms1) * 20/2/4;
409 2 round_int = ms1 /POINT_NUM;
410 2 round_real = ms1 % POINT_NUM;
411 2 round_real = round_real *6;
412 2 round_real= round_real/10;
413 2 tie_juli_start = round_real + round_int * 20;
414 2
415 2 round_int = ms2 /POINT_NUM;
416 2 round_real = ms2 % POINT_NUM;
417 2 round_real = round_real *6;
418 2 round_real= round_real/10;
419 2 tie_juli_end= round_real + round_int * 20;
420 2
421 2 distance[count]=(tie_juli_start +tie_juli_end) / 2;
422 2 juli_int = distance[count]/100;
423 2 dsp[2] = ledk[juli_int];
424 2 //dsp[2] = dsp[2] | 0x80;
425 2 juli_int = distance[count] %100 /10;
426 2 dsp[1] = ledk[juli_int];
427 2
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 8
428 2 juli_int = distance[count] %10;
429 2 dsp[0] = ledk[juli_int];
430 2 //juli_real = (float)(distance[count]/100.0 - juli_int);
431 2
432 2
433 2
434 2 }
435 1
436 1
437 1 }
438 /////////////////////////////////////
439 void display()
440 {
441 1 unsigned char i;
442 1 for ( i= 0;i<4;i++)
443 1 {
444 2 //dsp[i] = ledk[dsp[i]];
445 2 shift(dsp[i]);
446 2
447 2 switch ( i)
448 2 {
449 3 case 0:
450 3 P2 = 0xfe;delay(25);
451 3 break;
452 3 case 1:
453 3 P2 = 0xfd;delay(25);
454 3 break;
455 3 case 2:
456 3 P2 = 0xfb;delay(25);
457 3 break;
458 3 case 3:
459 3 P2 = 0xf7;delay(25);
460 3 break;
461 3 }
462 2
463 2 }
464 1
465 1 }
466 ///////////////////////////小车停五秒子函数
467 void stop_5s(void)
468 {unsigned char s_sec=0,i;
469 1 //if(P32==0)
470 1 //{
471 1 //TH0=hi;TL0=lo;
472 1 //stop_count++;
473 1 //if(stop_count==20)
474 1 //s_sec++;
475 1 TR1=0;
476 1
477 1 P10=1;
478 1 P11=1;
479 1 P12=1;
480 1 P13=1;
481 1 //if(s_sec<=5)
482 1 //{
483 1 if(time<30)
484 1 {
485 2 P17=0;//停车声光信息
486 2 for (i=0;i<20;i++)
487 2 {
488 3 display();
489 3 }
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 9
490 2 P17=1;
491 2 }
492 1
493 1 //}
494 1 //else
495 1 //{P10=0;P12=0;}
496 1
497 1 }
498 /////////////////////////检测障碍物子函数
499 void zaw(void)
500 {
501 1 //unsigned char i;
502 1
503 1 ///////////////////////
504 1
505 1 if(turn_l_time<3)
506 1 {
507 2 speedl=1;
508 2 speedr=254;
509 2 }
510 1 else
511 1 {
512 2 speedr=180;
513 2 speedl=230;
514 2 }
515 1 return;
516 1 /////////////////////
517 1
518 1 }
519
520
521
522 //
523 ////////////////////
524 void c_sun(void)
525 {
526 1 ///////////////////////
527 1
528 1 if(turn_r_time<5)
529 1
530 1 {
531 2 speedr=5;
532 2 speedl=250;
533 2 }
534 1 else
535 1 { speedr=180;
536 2 speedl=230;
537 2 }
538 1
539 1
540 1 /*if(P03==1&&P14==1)
541 1 {
542 1 speedr=180;
543 1 speedl=230;
544 1 }
545 1 else
546 1 {
547 1
548 1 if(P03==1 && P14==0)
549 1 { speedl=1;
550 1 speedr=250;
551 1
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 10
552 1 }
553 1
554 1 if(P14==1 && P03==0)
555 1 {
556 1 speedr=1;
557 1 speedl=250;
558 1 }
559 1
560 1 }*/
561 1
562 1
563 1
564 1 return;
565 1 ///////////////////////
566 1
567 1
568 1 }
569 /////////////////
570 void cheting(void)
571 { /*unsigned char i;
572 1 if(P06==0)
573 1 {
574 1
575 1 TR1=0;
576 1
577 1 P10=1;
578 1 P11=1;
579 1 P12=1;
580 1 P13=1;
581 1 //if(s_sec<=5)
582 1 //{
583 1 P17=0;//停车声光信息
584 1 for (i=0;i<20;i++)
585 1 {
586 1 display();
587 1 }
588 1 P17=1;
589 1 }*/
590 1
591 1 //if(P03==1&&P14==1)
592 1 {
593 2 speedr=180;
594 2 speedl=230;
595 2 }
596 1 //else
597 1 {
598 2
599 2 if(P03==1 && P14==0)
600 2 { speedl=1;
601 3 speedr=250;
602 3
603 3 }
604 2
605 2 if(P14==1 && P03==0)
606 2 {
607 3 speedr=1;
608 3 speedl=250;
609 3 }
610 2
611 2 }
612 1 if(P03==0&&P14==0)
613 1 {
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 11
614 2 TR1=0;
615 2 Status=5;
616 2
617 2 }
618 1
619 1
620 1 if(P04==1&&P05==1)
621 1 {
622 2 TR1=0;
623 2 Status=5;
624 2 }
625 1 return;
626 1 }
627
628 void ButtonAction()
629 {
630 1 int juli;
631 1 unsigned char char_show ,i;
632 1 unsigned char Sw_Press;
633 1
634 1 P24=0;
635 1 P25=0;
636 1 P26=0;
637 1 P27=0;
638 1
639 1 if ( P37==0)
640 1 {
641 2 for (i=0;i<10;i++)
642 2 display();
643 2 if (P37==0)
644 2 {
645 3
646 3 P2=P2 & 0x0f;
647 3 P2=P2 |0xe0;
648 3 if(P37==0)
649 3 Sw_Press=1;//P24按下
650 3
651 3 P2=P2 & 0x0f;
652 3 P2=P2 |0xd0;
653 3 if(P37==0)
654 3 Sw_Press=2;//P25按下
655 3
656 3 P2=P2 & 0x0f;
657 3 P2=P2 |0xb0;
658 3 if(P37==0)
659 3 Sw_Press=3;//P26按下
660 3
661 3 P2=P2 & 0x0f;
662 3 P2=P2 |0x70;
663 3 if(P37==0)
664 3 Sw_Press=4;//P27按下
665 3
666 3 }
667 2
668 2 }
669 1
670 1 switch(Sw_Press)
671 1 {
672 2 case 1://P24按下
673 2 juli = (ms *20) /POINT_NUM;
674 2 char_show = juli /100;
675 2 dsp[2]=ledk[char_show];
C51 COMPILER V7.50 SONG 12/10/2006 12:17:20 PAGE 12
676 2 char_show=(juli % 100)/10;
677 2 dsp[1]= ledk[char_show];
678 2 char_show=juli%10;
679 2 dsp[0]=ledk[char_show];
680 2 break;
681 2
682 2 case 2://P25按?
683 2
684 2 index++;
685 2 distance[index]=(ms*20 / POINT_NUM +ms1 * 20/POINT_NUM) / 2;
686 2 juli = distance[index]/100;
687 2 dsp[2] = ledk[juli];
688 2 //dsp[2] = dsp[2] | 0x80;
689 2 juli = distance[index] %100 /10;
690 2 dsp[1] = ledk[juli];
691 2
692 2 juli = distance[index] %10;
693 2 dsp[0] = ledk[juli];
694 2
695 2 dsp[3]=ledk[index+1];
696 2
697 2
698 2 if (index>count)
699 2 index=0;
700 2
701 2 break;
702 2
703 2 case 3://P26按下
704 2 break;
705 2
706 2 case 4://P27按下
707 2 break;
708 2 }
709 1 return;
710 1
711 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1548 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 40 9
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 + -