GPS Library for Nucleo
Dependencies: Adafruit_GPS
Fork of MBed_Adafruit-GPS-Library by
Revision 5:1249c2cfdede, committed 2015-12-07
- Comitter:
- ptcrews
- Date:
- Mon Dec 07 00:05:43 2015 +0000
- Parent:
- 4:d28ff2012e9f
- Commit message:
- Added comments.
Changed in this revision
GPS_Wrapper.cpp | Show annotated file Show diff for this revision Revisions of this file |
GPS_Wrapper.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r d28ff2012e9f -r 1249c2cfdede GPS_Wrapper.cpp --- a/GPS_Wrapper.cpp Sat Dec 05 07:34:56 2015 +0000 +++ b/GPS_Wrapper.cpp Mon Dec 07 00:05:43 2015 +0000 @@ -1,5 +1,9 @@ #include "GPS_Wrapper.h" +/* Function: setup + * --------------- + * Initially sets up the GPS. Draws from the Adafruit GPS library. + */ void GPS_Sensor::setup() { wait(2); turnOn(); @@ -13,26 +17,30 @@ wait(2); } -// n_queries is the number of times we query the GPS. We need something like 23000 characters. +/* Function: read + * -------------- + * Records a single reading to the reading struct passed by reference. + */ void GPS_Sensor::read(struct reading& lastReadingBuffer) { + // Continually checks for a GPS fix for SEC_WAIT_FOR_FIX (default = 60) for(int i = 0; i < SEC_WAIT_FOR_FIX; i++){ wait(1); if(myGPS.fix) break; } printf("\n"); for (int i = 0; i < N_GPS_QUERIES; i++) { - char c = myGPS.read(); //queries the GPS //when read via Adafruit_GPS::read(), the class returns single character stored here + char c = myGPS.read(); // Queries the GPS. When read via Adafruit_GPS::read(), the class returns single character stored here - if (c) { printf("%c", c); } //this line will echo the GPS data if not paused + if (c) { printf("%c", c); } // This line will echo the GPS data if not paused - //check if we recieved a new message from GPS, if so, attempt to parse it, + //Check if we recieved a new message from GPS, if so, attempt to parse it, if ( myGPS.newNMEAreceived() ) { if ( !myGPS.parse(myGPS.lastNMEA()) ) { continue; } } - //check if enough time has passed to warrant printing GPS info to screen - //note if refresh_Time is too low or pcSerial.baud is too low, GPS data may be lost during printing + // Check if enough time has passed to warrant printing GPS info to screen + // Note if refresh_Time is too low or pcSerial.baud is too low, GPS data may be lost during printing if (refresh_Timer.read_ms() >= REFRESH_TIME ) { refresh_Timer.reset(); printf("Time: %d:%d:%d.%u\n", myGPS.hour, myGPS.minute, myGPS.seconds, myGPS.milliseconds);
diff -r d28ff2012e9f -r 1249c2cfdede GPS_Wrapper.h --- a/GPS_Wrapper.h Sat Dec 05 07:34:56 2015 +0000 +++ b/GPS_Wrapper.h Mon Dec 07 00:05:43 2015 +0000 @@ -1,13 +1,20 @@ #include "main.h" #include "MBed_Adafruit_GPS.h" -#define REFRESH_TIME 2000 //Refresh time in ms - -// GPS global variables +#define REFRESH_TIME 2000 // Refresh time in ms +#define N_GPS_QUERIES 300000 // Number of queries to send GPS -- changing may lose readings +#define SEC_WAIT_FOR_FIX 60 // Number of seconds to wait for the GPS to get a fix +#define GPS_BAUD 9600 // Sets the GPS baud rate #ifndef _GPS_WRAPPER_CLASS #define _GPS_WRAPPER_CLASS +/* Class: GPS_Sensor + * ---------------- + * Defines a "wrapper" class for the Adafruit GPS + * library. Abstracts their functions for use with + * this project. + */ class GPS_Sensor { public: GPS_Sensor() : gps_Serial(GPS_TX, GPS_RX), myGPS(&gps_Serial), gpsEN(GPS_EN){}