Calcula bien la latitud y la longitud teniendo en cuenta los conversión de grados, minutos y segundos a grados decimales.

Dependents:   TAREA_4_GPS_GSM Tarea6_GSM Tarea6_GPSGSM TareaGSM ... more

Fork of GPS7 by Gustavo Ramirez

Revision:
3:7f621626d7e9
Parent:
2:8d7c7165ffe2
--- a/GPS.cpp	Mon Apr 27 02:08:24 2015 +0000
+++ b/GPS.cpp	Fri Nov 18 21:25:45 2016 +0000
@@ -32,10 +32,14 @@
     float time;
     char ns, ew;
     int lock;
-
+    int degla;
+    float minla;
+    int deglo;
+    float minlo;
+    
     while(1) {        
         getline();
-      //$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
+        //$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47
         // Check if it is a GPGGA msg (matches both locked and non-locked msg)
         if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d", &time, &latitude, &ns, &longitude, &ew, &lock) >= 1) { 
             if(!lock) {   //si lock es 1  hay lecturas ok
@@ -43,13 +47,19 @@
                 latitude = 0.0;        
                 return 0;
             } 
-                else {
+            else {
                 if(ns == 'S') {    latitude  *= -1.0; }
                 if(ew == 'W') {    longitude *= -1.0; }
                 latitude = (latitude / 100.0f);
+                degla = (int)latitude;
+                minla = latitude - (degla);
+                latitude = degla + minla/60.0f*100.0f;
                 //float minutes = latitude - (degrees * 100.0f);
                 //latitude = degrees + minutes / 60.0f;    
                 longitude = (longitude / 100.0f);
+                deglo = (int)longitude;
+                minlo = longitude - (deglo);
+                longitude = deglo + minlo/60.0f*100.0f;
                 //minutes = longitude - (degrees * 100.0f);
                 //longitude = degrees + minutes / 60.0f;