affichage d m s

Dependencies:   mbed

Fork of GPS by tito tito

Revision:
3:8234e0d5854e
Parent:
2:addb687a4e73
--- a/main.cpp	Fri Mar 11 10:25:05 2016 +0000
+++ b/main.cpp	Fri Mar 18 10:09:38 2016 +0000
@@ -12,10 +12,10 @@
         unsigned char   char_match ;
  char msg[1000];
   /** The longitude (call sample() to set) */
-    float longitude;
+    float longitude,longitude2;
 
     /** The latitude (call sample() to set) */
-    float latitude,time2;
+    float latitude,latitude2,time2;
     
     char ns, ew;
     int lock;
@@ -28,7 +28,7 @@
                 
              getline(uart1,msg,999);
             if ( sscanf(msg, "$GPGGA,%f,%f,%c,%f,%c,%d", &time2, &latitude, &ns, &longitude, &ew, &lock )>=1)
-            {          
+            {    pc.printf("long= %f %c  latitude= %f %c\n",longitude, ew, latitude, ns);       
                 if(!lock) {
                     longitude = 0.0;
                     latitude = 0.0; 
@@ -36,14 +36,18 @@
                 } else {
                     if(ns == 'S') {    latitude  *= -1.0; }
                     if(ew == 'W') {    longitude *= -1.0; }
-                    float degrees =(latitude / 100.0f);
-                    float minutes = latitude - (degrees * 100.0f);
-                    latitude = degrees + minutes / 60.0f;    
-                    degrees = (longitude / 100.0f * 0.01f);
-                    minutes = longitude - (degrees * 100.0f);
-                    longitude = degrees + minutes / 60.0f;
-                    pc.printf("time = %f \n", time2);
-                    pc.printf("long= %f %c  latitude= %f %c\n",longitude, ew, latitude, ns);
+                    int iDeg=(int) latitude/100;
+                    int iMin=(int) (latitude-iDeg*100);
+                    float iSec= ((latitude-(iDeg*100+iMin))*60);
+                     pc.printf(" latitude degree= %d  minutes=%d secondes=%f \n", iDeg,iMin,iSec); 
+                    int iDeg2=(int) longitude/100;
+                    int iMin2=(int) (longitude-iDeg2*100);
+                    float iSec2= ((longitude-(iDeg2*100+iMin2))*60);
+                     pc.printf(" longitude= %d  minutes=%d secondes=%f \n", iDeg2,iMin2,iSec2);  
+                   
+                    
+                    
+                    
               }//end else
            }//end if
         }//end if