?? 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 + -