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:
2:8d7c7165ffe2
Parent:
1:df8295aa2b2b
Child:
3:7f621626d7e9
--- a/GPS.cpp	Mon Oct 20 05:39:22 2014 +0000
+++ b/GPS.cpp	Mon Apr 27 02:08:24 2015 +0000
@@ -35,28 +35,31 @@
 
     while(1) {        
         getline();
-
+      //$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) {
+            if(!lock) {   //si lock es 1  hay lecturas ok
                 longitude = 0.0;
                 latitude = 0.0;        
                 return 0;
-            } else {
+            } 
+                else {
                 if(ns == 'S') {    latitude  *= -1.0; }
                 if(ew == 'W') {    longitude *= -1.0; }
-                float degrees = trunc(latitude / 100.0f);
-                float minutes = latitude - (degrees * 100.0f);
-                latitude = degrees + minutes / 60.0f;    
-                degrees = trunc(longitude / 100.0f * 0.01f);
-                minutes = longitude - (degrees * 100.0f);
-                longitude = degrees + minutes / 60.0f;
+                latitude = (latitude / 100.0f);
+                //float minutes = latitude - (degrees * 100.0f);
+                //latitude = degrees + minutes / 60.0f;    
+                longitude = (longitude / 100.0f);
+                //minutes = longitude - (degrees * 100.0f);
+                //longitude = degrees + minutes / 60.0f;
+                
                 return 1;
             }
         }
     }
 }
 
+/*
 float GPS::trunc(float v) {
     if(v < 0.0) {
         v*= -1.0;
@@ -67,7 +70,7 @@
     }
     return v;
 }
-
+*/
 void GPS::getline() {
     while(_gps.getc() != '$');    // wait for the start of a line
     for(int i=0; i<256; i++) {