tito tito
/
GPS
programme GPS pour ERS4
Fork of GPS_IUT_Nice by
main.cpp
- Committer:
- pierrick
- Date:
- 2016-03-11
- Revision:
- 1:f24af888e699
- Parent:
- 0:2c0686a07ab8
- Child:
- 2:addb687a4e73
File content as of revision 1:f24af888e699:
#include "mbed.h" //#include "GPS.h" #include <Serial.h> #include "getline.h" #include <math.h> //#include "stream.h" Serial pc(USBTX, USBRX); //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()) { printf("I'm at %f, %f\n", gps.longitude, gps.latitude); } else { printf("Oh Dear! No lock :(\n"); } } } // Print "Hello World" to the PC #include "mbed.h" */