Laura Olivré / Mbed 2 deprecated recupcoordonnees_original

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
olivrela
Date:
Fri Jan 25 14:37:06 2019 +0000
Commit message:
gps_tom

Changed in this revision

coordonnees.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 166cb8335ad5 coordonnees.h
diff -r 000000000000 -r 166cb8335ad5 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 25 14:37:06 2019 +0000
@@ -0,0 +1,76 @@
+#include "mbed.h"
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+//Serial GPS(A4, A5); //uart1
+Serial GPS(A0, A1); //uart4
+
+int main() {
+    GPS.baud(4800);
+    //int a=0;
+    //char z;
+    char msg[256];
+    float time, latitude, longitude;
+    int lock;
+    char ns, ew;
+    float trunc;
+    
+    pc.printf(" --------------  debut ------------------\n\r");
+    while(1) {
+        
+        if(GPS.readable()){
+             //pc.printf(" --------------  qq chose  -\n\r");
+           while(GPS.getc() != '$');    // s'il n'y a pas de dollar on récupère ce qui suit
+            //pc.printf(" -------------- un $          ---\n\r");
+                for(int i=0; i<256; i++) { // on récupère les 256 caractères (trame =256 caractères peut-être)
+                  msg[i] = GPS.getc();
+                     if(msg[i] == '\r') { //on rempli le buffer msg par les caractères récupérés
+                     msg[i] = 0;}
+                   }
+         }
+          pc.printf(" %s \n\r",msg);
+        if(sscanf(msg, "GPGGA,%f,%f,%c,%f,%c,%d", &time, &latitude, &ns, &longitude, &ew, &lock) >= 1) { // on scan s'il y a du float etc dans "GPGGA"... dans "msg" 
+            
+            pc.printf("####################### LAT ET LONG #####################\n\r");   
+                 pc.printf("%f,%f\n\n\r",latitude,longitude);
+                 //pc.printf("%f",altitude);
+                    
+            if(!lock) {         // si on capte aucun satellite
+                longitude = 0.0;
+                latitude = 0.0;        
+                
+            } 
+   /*        else {            // si on en capte
+                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;
+                
+    pc.printf("%f\n\r",degrees);       
+     pc.printf("%f,%f\n\r",latitude,longitude);                  
+            }
+        
+     //pc.printf("%f,%f\n\r",latitude,longitude);    
+*/     }               //if
+        
+        
+
+  
+    
+    
+    }                    //while   
+}
+            
+
+
+
+
+
+
+        //if(pc.readable()){pc.printf("%c",pc.getc());}
+        //pc.printf("%d ", a);
diff -r 000000000000 -r 166cb8335ad5 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 25 14:37:06 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file