I don’t see a way to add a file to the post, so I’ve just copied and pasted the updated code for the affected function from the firmware file. This should replace the function by the same name in the SFE firmware. The whole project will need to be recompiled and loaded into the GPS logger.
I also added comments so others could understand the code a bit better.
-Matt
void get_GPS_KML(void)
{
float q = 0, r = 0, s = 0;
int x, y, z;
char temp;
char temp2[7];
char north = 0, west = 0;
char lat[10], lon[11], alt[5];
char mark1 = 0, mark2 = 0;
for (x = 0; x < 160; x++) //zero the arrays
{
GPS_short[x] = 0;
if (x < 11) lon[x] = 0;
if (x < 10) lat[x] = 0;
if (x < 5) alt[x] = 0;
}
U1FCR = 0x02;
while(1)
{
temp = getc2();
//this is the GPS message that's being converted:
//$GPGGA,hhmmss.ss,ddmm.mmmmm,s,dddmm.mmmmm,s,n,qq,pp.p,±aaaaa.aa,M,±xxxx.xx,M,sss,aaaa *cc<CR><LF>
//sync UTC Latitude Longitude Altitude
// N/S E/W
if (temp == '
)
{
temp = getc2(); //‘G’
temp = getc2(); //‘P’
temp = getc2(); //‘G’
if (temp == 'G')
{
temp = getc2(); //'G'
temp = getc2(); //'A'
temp = getc2(); //','
temp = getc2(); //start of UTC
if (temp != ',') //if there's real data (if there's a GPS lock?)
{
stat0_on();
temp = 0;
y = 0;
x = 0;
while (x < 9)
{
temp = getc2();
if (temp == ',') //"Clear out data" Mode (scrolls past UTC data etc.)
{
x++;
y = 0;
temp = getc2();
}
if (x == 1) //Latitude Mode
{
lat[y] = temp;
if (temp == '.') mark1 = y;
y++;
}
if (x == 2) //North/South Mode
{
north = temp; //setting the North/South flag
y++;
}
if (x == 3) //Longitude Mode
{
lon[y] = temp;
if (temp == '.') mark2 = y;
y++;
}
if (x == 4) //East/West Mode
{
west = temp; //setting the East/West flag
y++;
}
if (x == 8) //Altitude mode
{
alt[y] = temp;
y++;
}
}
break;
}
}
}
}
for (x = 0; x < 8; x++) //convert latitude to two strings (degrees and minutes)
{
temp2[x] = lat[mark1 - 2 + x]; //move minutes data to new string
lat[mark1 - 2 + x] = 0; //clear minutes data out of degrees string
}
//change strings to floats
q = atof(temp2)/60; //minutes
r = atof(lat); //degrees
r += q; //combined latitude (all degrees with decimal)
if(north == 'S'){
r = 0 - r; //if south, make latitude negative
}
for (x = 0; x < 8; x++) //convert longitude to two strings (degrees and minutes)
{
temp2[x] = lon[mark2 - 2 + x]; //move minutes data to new string
lon[mark2 - 2 + x] = 0; //clear minutes data out of degrees string
}
//change strings to floats
q = atof(temp2)/60; //minutes
s = atof(lon); //degrees
s += q;
if(west == 'W'){
s = 0-s; //if west, make longitude negative
}
//convert altitude string to integer
x = atoi(alt);
sprintf(GPS_short,"%3.13f,%3.13f,%d \r\n",s,r,x);
}