#include "all.h"
unsigned char day[6];
unsigned char time[6];
unsigned char GPS[200];//;
unsigned char GPS_GGA[100]={"$PSRF103,00,01,00,01*25"};
unsigned char Latitude[10];
unsigned char Longitude[11];
unsigned char temp_GPS [200]={"$GPRMC,121252.000,A,3958.3032,N,11629.6046,E,15.15,359.95,070306,,,A*54"};
unsigned char GPS_OK=0;
unsigned char count_s[2]={"00"};
unsigned char Elevation[8]={0x48,0x2E,0x0D}; //没初始值显示会乱码
void send_cmd(unsigned char *cmd)
{
unsigned char i;
i=0;
while(cmd[i]!=0x0D && i<100)
{
usart0_T(cmd[i]);
i++;
}
usart0_T(0x0D);
usart0_T(0x0A);
}
void get_GPS(void)
{ unsigned char j;
//GPS_OK=1;
temp_GPS [150]=0x0D;
if(GPS_OK==1)
{
for(j=0;temp_GPS[j]!=0x0D;j++)
{
GPS[j]=temp_GPS[j];
}
//s_LCD_float(0xa0,0x0a0,0x0f00,0xf000, 4,8,0,12333444);
GPS[j+1]=0x0D;
GPS_OK=0;
}
}
void get_day(void)
{
unsigned char i,j,k,flag;
unsigned char cmd[6]="$GPRMC";
//s_LCD_float(0xa0,0x0a0,0x0f00,0xf000, 4,8,0,12333444);
for(i=0,flag=0;i<6;i++)
{
if(cmd[i]==GPS[i])
flag++;
}
if(flag>5)
{
for(i=0,j=0,k=0;GPS[i]!=0x0D;i++)
{
if(GPS[i]==',')
{
j++;
}
else if(j==9)
{
day[k]=GPS[i];
k++;
}
if(j>9) break;
}
}
}
void get_time(void)
{
unsigned char i,j,k,flag;
unsigned char cmd[6]="$GPRMC";
//s_LCD_float(0xa0,0x0a0,0x0f00,0xf000, 4,8,0,12333444);
for(i=0,flag=0;i<6;i++)
{
if(cmd[i]==GPS[i])
flag++;
}
if(flag>5)
{
for(i=0,j=0,k=0;GPS[i]!=0x0D;i++)
{
if(GPS[i]==',')
{
j++;
}
else if(j==1)
{
time[k]=GPS[i];
k++;
}
if(j>2) break;
}
}
}
void get_Elevation(void)
{
unsigned char i,j,k,l,flag;
unsigned char cmd[6]="$GPGGA";
//s_LCD_float(0xa0,0x0a0,0x0f00,0xf000, 4,8,0,12333444);
for(i=0,flag=0;i<6;i++)
{
if(cmd[i]==GPS[i])
flag++;
}
if(flag>5)
{
for(i=0,j=0,k=0,l=0;GPS[i]!=0x0D;i++)
{
if(GPS[i]==',')
{
j++;
}
else if(j==7)
{
count_s[k]=GPS[i];
k++;
}
else if(j==9)
{
Elevation[l]=GPS[i];
l++;
}
else if(j>9)
{
Elevation[l]=0x0D;
break;
}
}
}
}
void display_time(unsigned int x, unsigned int y,unsigned int c_color,unsigned int b_color)
{
unsigned char temp;
get_time();
get_day();
s_code(biao,x,y+8,c_color,b_color);
s_code(zhun,x+16,y+8,c_color,b_color);
s_code(shi, x+32,y+8,c_color,b_color);
s_code(jian,x+48,y+8,c_color,b_color);
s_wdbit(s_maohao,x+64,y+8,c_color,b_color); //:
s_wdbit(s_num[2],x+80,y,c_color,b_color);
s_wdbit(s_num[0],x+88,y,c_color,b_color);
s_wdbit(s_num[day[4]-48],x+96,y,c_color,b_color);
s_wdbit(s_num[day[5]-48],x+104,y,c_color,b_color);
s_code(nian,x+112,y,c_color,b_color);
s_wdbit(s_num[day[2]-48],x+128,y,c_color,b_color);
s_wdbit(s_num[day[3]-48],x+136,y,c_color,b_color);
s_code(yue,x+144,y,c_color,b_color);
s_wdbit(s_num[day[0]-48],x+160,y,c_color,b_color);
s_wdbit(s_num[day[1]-48],x+168,y,c_color,b_color);
s_code(ri,x+176,y,c_color,b_color);
s_wdbit(s_num[time[0]-48],x+80,y+16,c_color,b_color);
s_wdbit(s_num[time[1]-48],x+88,y+16,c_color,b_color);
s_wdbit(s_maohao,x+96,y+16,c_color,b_color); //:
s_wdbit(s_num[time[2]-48],x+104,y+16,c_color,b_color);
s_wdbit(s_num[time[3]-48],x+112,y+16,c_color,b_color);
s_wdbit(s_maohao,x+120,y+16,c_color,b_color); //:
s_wdbit(s_num[time[4]-48],x+128,y+16,c_color,b_color);
s_wdbit(s_num[time[5]-48],x+136,y+16,c_color,b_color);
}
void get_coordinate(void)
{
unsigned char i,j,k,l,flag;
unsigned char cmd[6]="$GPRMC";
//s_LCD_float(0xa0,0x0a0,0x0f00,0xf000, 4,8,0,12333444);
for(i=0,flag=0;i<6;i++)
{
if(cmd[i]==GPS[i])
flag++;
}
if(flag>5)
{
for(i=0,j=0,k=0,l=0;GPS[i]!=0x0D;i++)
{
if(GPS[i]==',')
{
j++;
}
else if(j==3)
{
Latitude[k]=GPS[i];
k++;
}
else if(j==4)
{
Latitude[9]=GPS[i];
}
else if(j==5)
{
Longitude[l]=GPS[i];
l++;
}
else if(j==6)
{
Longitude[10]=GPS[i];
}
}
}
}
void display_coordinate(unsigned int x, unsigned int y,unsigned int c_color,unsigned int b_color)
{
get_coordinate();
s_code(zuo,x,y+8,c_color,b_color);
s_code(biao,x+16,y+8,c_color,b_color);
s_wdbit(s_maohao,x+32,y+8,c_color,b_color); //:
s_wdbit(s_num[Latitude[0]-48],x+40,y,c_color,b_color);
s_wdbit(s_num[Latitude[1]-48],x+48,y,c_color,b_color);
s_code(du,x+56,y,c_color,b_color);
s_wdbit(s_num[Latitude[2]-48],x+72,y,c_color,b_color);
s_wdbit(s_num[Latitude[3]-48],x+80,y,c_color,b_color);
s_wdbit(s_doc,x+88,y,c_color,b_color);
s_wdbit(s_num[Latitude[5]-48],x+96,y,c_color,b_color);
s_wdbit(s_num[Latitude[6]-48],x+104,y,c_color,b_color);
s_wdbit(s_num[Latitude[7]-48],x+112,y,c_color,b_color);
s_wdbit(s_num[Latitude[8]-48],x+120,y,c_color,b_color);
if(Latitude[9]=='N')
s_wdbit(N,x+128,y,c_color,b_color);
else
s_wdbit(S,x+128,y,c_color,b_color);
s_wdbit(s_num[Longitude[0]-48],x+40,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[1]-48],x+48,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[2]-48],x+56,y+16,c_color,b_color);
s_code(du,x+64,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[3]-48],x+80,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[4]-48],x+88,y+16,c_color,b_color);
s_wdbit(s_doc,x+96,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[6]-48],x+104,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[7]-48],x+112,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[8]-48],x+120,y+16,c_color,b_color);
s_wdbit(s_num[Longitude[9]-48],x+128,y+16,c_color,b_color);
if(Longitude[10]=='W')
s_wdbit(W,x+136,y+16,c_color,b_color);
else
s_wdbit(E,x+136,y+16,c_color,b_color);
}
void display_Elevation(unsigned int x, unsigned int y,unsigned int c_color,unsigned int b_color)
{
unsigned char i;
get_Elevation();
s_code(hai,x,y,c_color,b_color);
s_code(ba,x+16,y,c_color,b_color);
s_wdbit(s_maohao,x+32,y,c_color,b_color); //:
i=0;
while(Elevation[i]!=0x0D)
{
if(Elevation[i]=='-')
s_wdbit(s_plus,x+40+i*8,y,c_color,b_color);
else if(Elevation[i]=='.')
s_wdbit(s_doc,x+40+i*8,y,c_color,b_color);
else
s_wdbit(s_num[Elevation[i]-48],x+40+i*8,y,c_color,b_color);
i++;
}
s_wdbit(M,x+40+i*8,y,c_color,b_color);
}