⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receive.lst

📁 GPS开发 NEA1803 51单片机与12864 由串口中断收取数据 显示经度纬度 高度 速度 时间 使用卫星数
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.02   RECEIVE                                                               07/15/2008 18:31:32 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE RECEIVE
OBJECT MODULE PLACED IN Receive.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Receive.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          /*************************************
   2               GPS解码1602显示程序
   3               作者:BG4UVR
   4          最后更新:
   5          2007.01.27
   6               1.2版,改时间由RMC语句解码,取消日期显示
   7          2007.01.25
   8               1.1版,修正定位后页面不能转换的BUG。
   9               1.0版,基本功能。
  10          ***************************************/
  11          
  12          #include <AT89X51.H>
  13          #include <stdio.h>
  14          #include "LCD12864_c51.h"
  15          char code TIME_AREA= 8;                  //时区
  16          //GPS数据存储数组
  17          unsigned char JD[10];                  //经度
  18          unsigned char JD_a;                  //经度方向
  19          unsigned char WD[9];                  //纬度
  20          unsigned char WD_a;                  //纬度方向
  21          unsigned char time[6];            //时间
  22          unsigned char speed[5];            //速度
  23          unsigned char high[6];            //高度
  24          unsigned char angle[5];            //方位角
  25          unsigned char use_sat[2];            //使用的卫星数
  26          unsigned char total_sat[2];      //天空中总卫星数
  27          unsigned char lock;                  //定位状态
  28          
  29          //串口中断需要的变量
  30          unsigned char seg_count;            //逗号计数器
  31          unsigned char dot_count;            //小数点计数器
  32          unsigned char byte_count;            //位数计数器
  33          unsigned char cmd_number;            //命令类型
  34          unsigned char mode;                        //0:结束模式,1:命令模式,2:数据模式
  35          unsigned char buf_full;                  //1:整句接收完成,相应数据有效。0:缓存数据无效。
  36          unsigned char cmd[5];                  //命令类型存储数组
  37          
  38          //显示需要的变量
  39          unsigned int dsp_count;            //刷新次数计数器
  40          unsigned char time_count;
  41          //bit page;
  42          //bit spd_type;
  43          
  44          void sys_init(void);
  45          //bit chk_key(void);
  46          
  47          main()
  48          {
  49   1           unsigned char i;
  50   1           char Bhour;
  51   1           sys_init();
  52   1                      while(1){
  53   2                 if(buf_full==0)                        //无GPS信号时
  54   2                 {
  55   3                       dsp_count++;
C51 COMPILER V8.02   RECEIVE                                                               07/15/2008 18:31:32 PAGE 2   

  56   3                       if(dsp_count>=65000){
  57   4                             Init_Lcd12864();                  //清屏
  58   4                                                 ResetCursor(0,2);
  59   4                                         printf("No GPS connect..");
  60   4                             while(buf_full==0);
  61   4                             ClearAS();      
  62   4                             dsp_count=0;
  63   4                       }
  64   3                 }
  65   2                 else{                                    //有GPS信号时
  66   3                       if(buf_full|0x01){                        //GGA语句
  67   4        //                           if(lock=='0'){                              //如果未定位
  68   4        //                                 LCD_write_string(0,0,"*---.--.----  ");
  69   4        //                                 LCD_write_string(0,1,"* --.--.----  ");                              
  70   4        //                           }else{                                          //如果已定位
  71   4                                                                         ResetCursor(0,0);
  72   4                                                         printf("%c",JD_a);
  73   4        //                                 LCD_write_char(0,0,JD_a);                  //显示经度
  74   4                                         for(i=0;i<3;i++){
  75   5                                                                                       ResetCursor(i+1,0);
  76   5                                                                                       printf("%s",JD);
  77   5        //                                     LCD_write_char(i+1,0,JD);
  78   5                                         }
  79   4                                                                         ResetCursor(4,0);
  80   4                                                                         printf(".");
  81   4        //                                 LCD_write_char(4,0,'.');
  82   4                                         for(i=3;i<10;i++){
  83   5                                                                         ResetCursor(i+2,0);
  84   5                                                                         printf("%s",JD);
  85   5         //                                      LCD_write_char(i+2,0,JD);
  86   5                                         }
  87   4                                                                               ResetCursor(0,1);
  88   4                                                           printf("%c",JD_a);
  89   4                                                                               for(i=0;i<9;i++)
  90   4                                                                               {
  91   5                                                                                      ResetCursor(i+1,0);
  92   5                                                                              printf("%s",WD);
  93   5                                                                               }
  94   4         //                                LCD_write_char(0,1,WD_a);                  //显示纬度
  95   4          //                               LCD_write_char(1,1,' ');
  96   4          //                               for(i=0;i<2;i++){
  97   4          //                                     LCD_write_char(i+2,1,WD);
  98   4          //                               }                  
  99   4          //                               LCD_write_char(4,1,'.');
 100   4          //                               for(i=2;i<9;i++){
 101   4          //                                     LCD_write_char(i+3,1,WD);
 102   4           //                              }
 103   4           //                                     }
 104   4           //                        LCD_write_char(14,0,use_sat[0]);            //显示接收卫星数
 105   4           //                        LCD_write_char(15,0,use_sat[1]);
 106   4                                   buf_full&=~0x01;
 107   4                                   dsp_count=0;
 108   4                             }
 109   3                             if(buf_full|0x02){                        //GSV语句
 110   4            //                       LCD_write_char(14,1,total_sat[0]);
 111   4            //                       LCD_write_char(15,1,total_sat[1]);
 112   4                                   buf_full&=~0x02;
 113   4                                   dsp_count=0;
 114   4                             }
 115   3                             if(buf_full|0x04){
 116   4                                   buf_full&=~0x04;
 117   4                                   dsp_count=0;
C51 COMPILER V8.02   RECEIVE                                                               07/15/2008 18:31:32 PAGE 3   

 118   4                             }
 119   3                       }
 120   2                    //   else{                                          //页面2
 121   2                             if(buf_full|0x01){                        //GGA语句
 122   3                                   buf_full&=~0x01;
 123   3                                   dsp_count=0;
 124   3                             }
 125   2                             if(buf_full|0x02){
 126   3                                   buf_full&=~0x02;
 127   3                                   dsp_count=0;
 128   3                             }
 129   2                             if(buf_full|0x04){                        //RMC语句
 130   3                                   Bhour=((time[0]-0x30)*10+time[1]-0x30)+TIME_AREA;
 131   3                                   if(Bhour>=24){
 132   4                                         Bhour-=24;
 133   4                                   }else if(Bhour<0){
 134   4                                         Bhour+=24;
 135   4                                   }
 136   3                                                                 ResetCursor(0,2);
 137   3                                                                 printf("BJT:");
 138   3                                                                 ResetCursor(4,2);
 139   3                                                                 printf("%c",Bhour/10+0x30);
 140   3                                                                 ResetCursor(5,2);
 141   3                                                                 printf("%c",Bhour%10+0x30);
 142   3                                                                 ResetCursor(6,2);
 143   3                                                                 printf(":");
 144   3                                                                 ResetCursor(7,2);
 145   3                                                                 printf("%c",time[2]);
 146   3                                                                 ResetCursor(8,2);
 147   3                                                                 printf("%c",time[3]);
 148   3                             //      LCD_write_string(2,1,"BJT ");
 149   3                             //      LCD_write_char(6,1,Bhour/10+0x30);
 150   3                            //       LCD_write_char(7,1,Bhour%10+0x30);
 151   3                            //       LCD_write_char(8,1,':');
 152   3                            //       LCD_write_char(9,1,time[2]);
 153   3                            //       LCD_write_char(10,1,time[3]);
 154   3                            //       LCD_write_char(11,1,':');
 155   3                           //        LCD_write_char(12,1,time[4]);
 156   3                           //        LCD_write_char(13,1,time[5]);
 157   3                           //        if(spd_type){
 158   3                           //              LCD_write_string(5,0,"km/h A");
 159   3                            //       }else{
 160   3                            //             LCD_write_string(5,0,"knot A");
 161   3                             //      }
 162   3                            //      if(lock=='0'){                              //如果未定位
 163   3                             //            LCD_write_string(0,0,"---.-");
 164   3                             //            LCD_write_string(11,0,"---.-");
 165   3                             //      }else{                                          //已经定位
 166   3                             //            if(spd_type){                              //km/h显示
 167   3                             //                  for(i=0;i<5;i++){
 168   3                              //                       LCD_write_char(i,0,speed);
 169   3                              //                 }
 170   3                              //           }else{                                          //knot显示
 171   3                              //                 Knots=      (((speed[0]-0x30)*1000
 172   3                               //                            +(speed[1]-0x30)*100
 173   3                              //                             +(speed[2]-0x30)*10
 174   3                              //                             +(speed[4]-0x30))*1000)/1852;
 175   3                              //                 LCD_write_char(0,0,Knots/1000+0x30);
 176   3                              //                 LCD_write_char(1,0,(Knots%1000)/100+0x30);
 177   3                              //                 LCD_write_char(2,0,(Knots%100)/10+0x30);
 178   3                              //                 LCD_write_char(3,0,'.');
 179   3                              //                 LCD_write_char(4,0,Knots%10+0x30);
C51 COMPILER V8.02   RECEIVE                                                               07/15/2008 18:31:32 PAGE 4   

 180   3                               //          }
 181   3                               //          for(i=0;i<5;i++){
 182   3                              //                 LCD_write_char(11+i,0,angle);
 183   3                               //          }
 184   3                                   }
 185   2                                   buf_full&=~0x04;
 186   2                                   dsp_count=0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -