Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:166cb8335ad5
--- /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);