Improved, thread compatible. Adds new features

Dependents:   GroveGPS-Example

Fork of GroveGPS by Michael Ray

Revision:
3:cc5c9faa1cc6
Parent:
1:403eb5e9e994
Child:
4:4615d6e99bb4
--- a/GroveGPS.h	Sat Apr 14 00:03:58 2018 +0000
+++ b/GroveGPS.h	Sun Apr 22 00:06:53 2018 +0000
@@ -61,6 +61,12 @@
 		std::string  checksum;
 	} gps_vtg;
 
+	void getTimestamp(char* buffer) {
+		if (gps_gga.position_fix==0)
+			sprintf(buffer, "N/A");
+		else
+			sprintf(buffer, "%f", gps_gga.utc_time);
+	}
     
 	void getAltitude(char* buffer) {
 		if (gps_gga.position_fix==0)
@@ -82,20 +88,22 @@
 		else
 			sprintf(buffer, "%f", gps_vtg.speed1);
 	}
-     
-	void getTimestamp(char* buffer) {
+
+    
+	void getUncertanty(char* buffer) {
 		if (gps_gga.position_fix==0)
 			sprintf(buffer, "N/A");
 		else
-			sprintf(buffer, "%f", gps_gga.utc_time);
+			sprintf(buffer, "%f", gps_gga.hdop);
 	}
-    
+     	
 	void getLatitude(char* buffer) {
 		double coordinate = convertGPSToDecimal(gps_gga.latitude);
-		if (gps_gga.position_fix==0)
+		if (gps_gga.position_fix==0) {
 			sprintf(buffer, "N/A");
-		else
-			sprintf(buffer, "%c%f", (gps_gga.ns_indicator == 'N') ? '0' : '-', coordinate);
+		} else {	
+		sprintf(buffer, "%c%f", (gps_gga.ns_indicator == 'N') ? '0' : '-', coordinate);
+		}
 	}
 
 	void getLongitude(char* buffer) {
@@ -145,6 +153,8 @@
 			} else if (i==7) {
 				gps_vtg.speed2 = strtod(current_item.c_str(), &pEnd);
 			}
+			if(gps_vtg.course2 > gps_vtg.course1) gps_vtg.course1 = gps_vtg.course2;
+			if(gps_vtg.speed2 > gps_vtg.speed1) gps_vtg.speed1 = gps_vtg.speed2;
 		}
 	gps_vtg.new_flag = 1;	
 	}
@@ -188,10 +198,13 @@
 				gps_gga.position_fix = strtod(current_item.c_str(), &pEnd);
 			}else if (i==7) {
 				gps_gga.sats_used = strtod(current_item.c_str(), &pEnd);
-			} else if (i==8) {
+			} else if (i==8) { // Uncertanty
 				gps_gga.hdop = strtod(current_item.c_str(), &pEnd);
-			} else if (i==9) {
+			} else if (i==9) { //  Altitude mean sea level
 				gps_gga.msl_altitude = strtod(current_item.c_str(), &pEnd);
+			} else if (i==11) {
+				gps_gga.geoid_separation = strtod(current_item.c_str(), &pEnd);
+				gps_gga.msl_altitude += gps_gga.geoid_separation;
 			}
 		}
 	gps_gga.new_flag = 1;