📄 receive.c
字号:
/*************************************
GPS解码1602显示程序
作者:BG4UVR
最后更新:
2007.01.27
1.2版,改时间由RMC语句解码,取消日期显示
2007.01.25
1.1版,修正定位后页面不能转换的BUG。
1.0版,基本功能。
***************************************/
#include <AT89X51.H>
#include <stdio.h>
#include "LCD12864_c51.h"
char code TIME_AREA= 8; //时区
//GPS数据存储数组
unsigned char JD[10]; //经度
unsigned char JD_a; //经度方向
unsigned char WD[9]; //纬度
unsigned char WD_a; //纬度方向
unsigned char time[6]; //时间
unsigned char speed[5]; //速度
unsigned char high[6]; //高度
unsigned char angle[5]; //方位角
unsigned char use_sat[2]; //使用的卫星数
unsigned char total_sat[2]; //天空中总卫星数
unsigned char lock; //定位状态
//串口中断需要的变量
unsigned char seg_count; //逗号计数器
unsigned char dot_count; //小数点计数器
unsigned char byte_count; //位数计数器
unsigned char cmd_number; //命令类型
unsigned char mode; //0:结束模式,1:命令模式,2:数据模式
unsigned char buf_full; //1:整句接收完成,相应数据有效。0:缓存数据无效。
unsigned char cmd[5]; //命令类型存储数组
//显示需要的变量
unsigned int dsp_count; //刷新次数计数器
unsigned char time_count;
//bit page;
//bit spd_type;
void sys_init(void);
//bit chk_key(void);
main()
{
unsigned char i;
char Bhour;
sys_init();
while(1){
if(buf_full==0) //无GPS信号时
{
dsp_count++;
if(dsp_count>=65000){
Init_Lcd12864(); //清屏
ResetCursor(0,2);
printf("No GPS connect..");
while(buf_full==0);
ClearAS();
dsp_count=0;
}
}
else{ //有GPS信号时
if(buf_full|0x01){ //GGA语句
// if(lock=='0'){ //如果未定位
// LCD_write_string(0,0,"*---.--.---- ");
// LCD_write_string(0,1,"* --.--.---- ");
// }else{ //如果已定位
ResetCursor(0,0);
printf("%c",JD_a);
// LCD_write_char(0,0,JD_a); //显示经度
for(i=0;i<3;i++){
ResetCursor(i+1,0);
printf("%s",JD);
// LCD_write_char(i+1,0,JD);
}
ResetCursor(4,0);
printf(".");
// LCD_write_char(4,0,'.');
for(i=3;i<10;i++){
ResetCursor(i+2,0);
printf("%s",JD);
// LCD_write_char(i+2,0,JD);
}
ResetCursor(0,1);
printf("%c",JD_a);
for(i=0;i<9;i++)
{
ResetCursor(i+1,0);
printf("%s",WD);
}
// LCD_write_char(0,1,WD_a); //显示纬度
// LCD_write_char(1,1,' ');
// for(i=0;i<2;i++){
// LCD_write_char(i+2,1,WD);
// }
// LCD_write_char(4,1,'.');
// for(i=2;i<9;i++){
// LCD_write_char(i+3,1,WD);
// }
// }
// LCD_write_char(14,0,use_sat[0]); //显示接收卫星数
// LCD_write_char(15,0,use_sat[1]);
buf_full&=~0x01;
dsp_count=0;
}
if(buf_full|0x02){ //GSV语句
// LCD_write_char(14,1,total_sat[0]);
// LCD_write_char(15,1,total_sat[1]);
buf_full&=~0x02;
dsp_count=0;
}
if(buf_full|0x04){
buf_full&=~0x04;
dsp_count=0;
}
}
// else{ //页面2
if(buf_full|0x01){ //GGA语句
buf_full&=~0x01;
dsp_count=0;
}
if(buf_full|0x02){
buf_full&=~0x02;
dsp_count=0;
}
if(buf_full|0x04){ //RMC语句
Bhour=((time[0]-0x30)*10+time[1]-0x30)+TIME_AREA;
if(Bhour>=24){
Bhour-=24;
}else if(Bhour<0){
Bhour+=24;
}
ResetCursor(0,2);
printf("BJT:");
ResetCursor(4,2);
printf("%c",Bhour/10+0x30);
ResetCursor(5,2);
printf("%c",Bhour%10+0x30);
ResetCursor(6,2);
printf(":");
ResetCursor(7,2);
printf("%c",time[2]);
ResetCursor(8,2);
printf("%c",time[3]);
// LCD_write_string(2,1,"BJT ");
// LCD_write_char(6,1,Bhour/10+0x30);
// LCD_write_char(7,1,Bhour%10+0x30);
// LCD_write_char(8,1,':');
// LCD_write_char(9,1,time[2]);
// LCD_write_char(10,1,time[3]);
// LCD_write_char(11,1,':');
// LCD_write_char(12,1,time[4]);
// LCD_write_char(13,1,time[5]);
// if(spd_type){
// LCD_write_string(5,0,"km/h A");
// }else{
// LCD_write_string(5,0,"knot A");
// }
// if(lock=='0'){ //如果未定位
// LCD_write_string(0,0,"---.-");
// LCD_write_string(11,0,"---.-");
// }else{ //已经定位
// if(spd_type){ //km/h显示
// for(i=0;i<5;i++){
// LCD_write_char(i,0,speed);
// }
// }else{ //knot显示
// Knots= (((speed[0]-0x30)*1000
// +(speed[1]-0x30)*100
// +(speed[2]-0x30)*10
// +(speed[4]-0x30))*1000)/1852;
// LCD_write_char(0,0,Knots/1000+0x30);
// LCD_write_char(1,0,(Knots%1000)/100+0x30);
// LCD_write_char(2,0,(Knots%100)/10+0x30);
// LCD_write_char(3,0,'.');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -