Slightly modified version of the SerialGPS library (https://os.mbed.com/teams/components/code/SerialGPS/) to support the BufferedSerial class

Revision:
4:2c76f1ec13a9
Parent:
3:ebd79e3acf14
Child:
5:cc8f9d7f9bdb
--- a/SerialGPS.cpp	Tue Mar 02 18:27:46 2021 +0100
+++ b/SerialGPS.cpp	Thu Apr 01 21:18:48 2021 +0200
@@ -112,42 +112,23 @@
         }
         else
         {
-            //printf("No NMEA sentence found");
             this->_fix = false;
         }
 
     // Clear the NMEA buffer
-    strcpy(this->_nmea, "");
-}
-
-float SerialGPS::trunc(float v) 
-{
-    if(v < 0.0) 
-    {
-        v*= -1.0;
-        v = floor(v);
-        v*=-1.0;
-    } 
-    else 
-    {
-        v = floor(v);
-    }
-    return v;
+    memset(this->_nmea, 0, strlen(this->_nmea));
 }
 
 void SerialGPS::set_vals()
 {
+
+    this->_lat = convert(this->_lat);
+    this->_lon = convert(this->_lon);
+
     if(this->_NS == 'S') { this->_lat *= -1.0; }
     if(this->_EW == 'W') { this->_lon *= -1.0; }
 
-    float degrees   = trunc(_lat / 100.0f);
-    float minutes   = this->_lat *= -1.0;
-
-    this->_lat            = degrees + minutes / 60.0f;
-    degrees               = trunc(this->_lon / 100.0f * 0.01f);
-    minutes               = this->_lon - (degrees * 100.0f);
-    this->_lon            = degrees + minutes / 60.0f;
-    this->_fix            = true;
+    this->_fix = true;
 }
 
 void SerialGPS::getline() 
@@ -155,10 +136,7 @@
     char ch;
     int idx = -1;
 
-    if(!this->_gps_p->readable())
-    {
-        return;
-    }
+    if(!this->_gps_p->readable()) { return; }
 
     // Wait for start of sentence
     while(read_char() != '$');
@@ -168,10 +146,7 @@
     {
         ch = read_char();
 
-        if(ch == '\r')
-        {
-            break;
-        }
+        if(ch == '\r') { break; }
 
         this->_nmea[idx] = ch;
     }