2021 mbed Grove GPS
Revision 6:dffd55375288, committed 2021-02-12
- Comitter:
- anthonyv
- Date:
- Fri Feb 12 08:18:15 2021 +0000
- Parent:
- 4:0ee729b4a211
- Commit message:
- IUT mbed GPS
Changed in this revision
GroveGPS.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 0ee729b4a211 -r dffd55375288 GroveGPS.h --- a/GroveGPS.h Thu Jun 06 21:26:39 2019 -0500 +++ b/GroveGPS.h Fri Feb 12 08:18:15 2021 +0000 @@ -47,7 +47,7 @@ m.lock(); parseLine(); - double coordinate = convertGPSToDecimal(gps_gga.latitude); + double coordinate = gps_gga.latitude; if (gps_gga.position_fix==0) sprintf(buffer, "N/A"); else @@ -59,13 +59,31 @@ m.lock(); parseLine(); - double coordinate = convertGPSToDecimal(gps_gga.longitude); + double coordinate = gps_gga.longitude; if (gps_gga.position_fix==0) sprintf(buffer, "N/A"); else sprintf(buffer, "%c%f", (gps_gga.ew_indicator == 'E') ? '0' : '-', coordinate); m.unlock(); } + + void getAltitude(char* buffer) { + m.lock(); + parseLine(); + + double coordinate = gps_gga.msl_altitude; + if (gps_gga.position_fix==0) + sprintf(buffer, "N/A"); + else + sprintf(buffer, " %f", coordinate); + m.unlock(); + } + + void update() { + m.lock(); + parseLine(); + m.unlock(); + } private: static const size_t max_line_length = 256; @@ -139,17 +157,33 @@ if (i==0) { // NMEA Tag } else if (i==1) { // UTC time gps_gga.utc_time = strtod(line_pos, 0); + + } else if (i==2) { // Latitude gps_gga.latitude = strtod(line_pos, 0); + gps_gga.latitude=convertGPSToDecimal(gps_gga.latitude); + } else if (i==3) { // Latitude North/South indicator gps_gga.ns_indicator = line_pos[0]; } else if (i==4) { // Longitude gps_gga.longitude = strtod(line_pos, 0); + gps_gga.longitude=convertGPSToDecimal(gps_gga.longitude); } else if (i==5) { // Longitude indicator gps_gga.ew_indicator = line_pos[0]; } else if (i==6) { - gps_gga.position_fix = strtod(line_pos, 0); + gps_gga.position_fix= strtod(line_pos, 0); + } + else if (i==7) { + gps_gga.sats_used= strtod(line_pos, 0);//nb satellite used } + else if (i==8) { + gps_gga.hdop= strtod(line_pos, 0);//horizontal precision + } + else if (i==9) { + gps_gga.msl_altitude= strtod(line_pos, 0);//altitute + } + + line_pos = strchr(line_pos, ','); if (line_pos == NULL) { break;