Slight update to sford's GPS library. Returns more data from the NMEA sentence and allows for different serial speeds (e.g. used for the Adafruit Ultimate GPSv3 Breakout Board).
Dependents: C027_C20_U20_G350_GPS
Fork of GPS by
Revision 3:36c3411086a2, committed 2014-02-22
- Comitter:
- timrock
- Date:
- Sat Feb 22 13:27:53 2014 +0000
- Parent:
- 2:1430e56047da
- Commit message:
- Add a sample programe
Changed in this revision
GPS.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1430e56047da -r 36c3411086a2 GPS.cpp --- a/GPS.cpp Sat Feb 22 13:16:16 2014 +0000 +++ b/GPS.cpp Sat Feb 22 13:27:53 2014 +0000 @@ -1,6 +1,6 @@ /* mbed GPS Module Library for C027-SARA-G350 * Copyright (c) 2008-2010, sford - * Copyright (c) 2014, Jianliang Gao + * Copyright (c) 2014, Jianliang Gao Based on * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -55,7 +55,7 @@ latitude = degrees + minutes/60.0f; if(ns == 'S') { latitude *= -1.0; } - degrees = trunc(longitude / 100.0f); // * 0.01f); + degrees = trunc(longitude / 100.0f); minutes = longitude - (degrees * 100.0f); longitude = degrees + minutes / 60.0f; if(ew == 'W') { longitude *= -1.0; } @@ -86,4 +86,36 @@ } } error("Overflowed message limit"); -} \ No newline at end of file +} + +/* sample +#include "mbed.h" +#include "GPS.h" + +Serial pc(USBTX, USBRX); +GPS gps(P0_10, P0_11, 9600); + +int main() { + pc.baud(9600); + + while (1) { + wait(3); + pc.printf("hello, a test \n"); + gps.sample(); + pc.printf("GPS Sats number is %d \n", gps.sats); + + if (gps.ns == 'S') + pc.printf("GPS Latitude = %.4f South; ", gps.latitude * -1.0); + else if (gps.ns == 'N') + pc.printf("GPS Latitude = %.4f North; ", gps.latitude); + if (gps.ew == 'W') + pc.printf("Longitude = %.4f West; ", gps.longitude * - 1.0); + else if (gps.ew == 'E') + pc.printf("Longitude = %.4f East; ", gps.longitude); + pc.printf("Alt = %.4f ", gps.alt); + + } + + +} +*/ //Enjoy it! \ No newline at end of file