tito tito
/
GPS
programme GPS pour ERS4
Fork of GPS_IUT_Nice by
Diff: main.cpp
- Revision:
- 1:f24af888e699
- Parent:
- 0:2c0686a07ab8
- Child:
- 2:addb687a4e73
--- a/main.cpp Fri Nov 23 19:10:01 2012 +0000 +++ b/main.cpp Fri Mar 11 10:18:09 2016 +0000 @@ -1,15 +1,87 @@ #include "mbed.h" -#include "GPS.h" +//#include "GPS.h" +#include <Serial.h> +#include "getline.h" +#include <math.h> +//#include "stream.h" Serial pc(USBTX, USBRX); -GPS gps(p13, p14); +//GPS gps(p13, p14); +Serial uart1(p13, p14); +char c; + int event_callback_t ; + int event; + unsigned char char_match ; + char msg[1000]; + /** The longitude (call sample() to set) */ + float longitude; + + /** The latitude (call sample() to set) */ + float latitude,time2; + + char ns, ew; + int lock; int main() { + uart1.baud(9600); + printf("hello\n"); + while (1){ + if (uart1.readable()) + { + + getline(uart1,msg,999); + // pc.printf("\n %s",msg); + //pc.printf("long= %f %c latitude= %f %c\n",&longitude, &ew, &latitude, &ns); + // Check if it is a GPGGA msg (matches both locked and non-locked msg) + if ( sscanf(msg, "$GPGGA,%f,%f,%c,%f,%c,%d", &time2, &latitude, &ns, &longitude, &ew, &lock )>=1) + { + if(!lock) { + longitude = 0.0; + latitude = 0.0; + pc.printf("long= %f %c latitude= %f %c\n",&longitude, &ew, &latitude, &ns); + //return 0; + } 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; + printf("time = %f \n", time2); + pc.printf("long= %f %c latitude= %f %c\n",longitude, ew, latitude, ns); + //return 1; + }//end else + }//end if + }//end if + } //end while +} //end main + + /* + c=uart1.getc(); + pc.printf("%c",c); + */ + /* } + + + */ +/* while(1) { + //wait(1.0); + //printf("hello bis\n"); + if(gps.sample()) { - pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude); + printf("I'm at %f, %f\n", gps.longitude, gps.latitude); } else { - pc.printf("Oh Dear! No lock :(\n"); + printf("Oh Dear! No lock :(\n"); } } -} \ No newline at end of file +} + + +// Print "Hello World" to the PC + +#include "mbed.h" +*/ +