Allows for a GPS module to be connected to a serial port and exposes an easy to use API to get the GPS data. New feature, added Mbed/LPC17xx RTC synchronisation
Dependents: SatGPS AntiTheftGPS FLIGHT_CONTROL_AND_COMMUNICATIONS_SYSTEM GPS-Lora ... more
Diff: GPS.h
- Revision:
- 2:8aa059e7d8b1
- Parent:
- 1:6aec92e77ad2
- Child:
- 3:28a1b60b0f37
diff -r 6aec92e77ad2 -r 8aa059e7d8b1 GPS.h --- a/GPS.h Sat Nov 20 21:02:06 2010 +0000 +++ b/GPS.h Fri Apr 15 12:23:52 2011 +0000 @@ -24,6 +24,7 @@ #define GPS_H #include "mbed.h" +#include "GPS_VTG.h" #include "GPS_Time.h" #include "GPS_Geodetic.h" @@ -258,6 +259,54 @@ */ double height(void) { return altitude(); } + //! Get all vector parameters together. + /** + * Pass a pointer to a GPS_VTG object and the current + * GPS data will be copied into it. + * + * @code + * // Assuming we have a GPS object previously created... + * GPS gps(NC, p9); + * + * // Then get the data... + * GPS_VTG p; + * gps.vtg(&p); + * printf("Speed (knots) = %.4f", p.velocity_knots); + * printf("Speed (kps) = %.4f", p.velocity_kps); + * printf("Track (true) = %.4f", p.track_true); + * printf("Track (mag) = %.4f", p.track_mag); + * + * @endcode + * + * @ingroup API + * @param g A GSP_VTG pointer to an existing GPS_VTG object. + * @return GPS_VTG * The pointer passed in. + */ + GPS_VTG *vtg(GPS_VTG *g); + + //! Get all vector parameters together. + /** + * Get all the vector data at once. For example:- + * + * @code + * // Assuming we have a GPS object previously created... + * GPS gps(NC, p9); + * + * // Then get the data... + * GPS_VTG *p = gps.vtg(); + * printf("Speed (knots) = %.4f", p->velocity_knots); + * printf("Speed (kps) = %.4f", p->velocity_kps); + * printf("Track (true) = %.4f", p->track_true); + * printf("Track (mag) = %.4f", p->track_mag); + * delete(p); // then remember to delete the object to prevent memory leaks. + * + * @endcode + * + * @ingroup API + * @return GPS_Geodetic * A pointer to the data. + */ + GPS_VTG *vtg(void) { return vtg(NULL); } + //! Get all three geodetic parameters together. /** * Pass a pointer to a GPS_Geodetic object and the current @@ -601,6 +650,52 @@ //! A callback object for the NMEA GGA message processed signal user API. FunctionPointer cb_gga; + + //! Attach a user callback function to the NMEA VTG message processed signal. + /** + * Attach a user callback object/method to call when an NMEA VTG packet has been processed. + * + * @code + * class FOO { + * public: + * void myCallback(void); + * }; + * + * GPS gps(NC, p9); + * Foo foo; + * + * gps.attach_vtg(foo, &FOO::myCallback); + * + * @endcode + * + * @ingroup API + * @param tptr pointer to the object to call the member function on + * @param mptr pointer to the member function to be called + */ + template<typename T> + void attach_vtg(T* tptr, void (T::*mptr)(void)) { cb_vtg.attach(tptr, mptr); } + + //! Attach a user callback function to the NMEA VTG message processed signal. + /** + * Attach a user callback function pointer to call when an NMEA VTG packet has been processed. + * + * @code + * void myCallback(void) { ... } + * + * GPS gps(NC, p9); + * Foo foo; + * + * gps.attach_vtg(&myCallback); + * + * @endcode + * + * @ingroup API + * @param fptr Callback function pointer. + */ + void attach_vtg(void (*fptr)(void)) { cb_vtg.attach(fptr); } + + //! A callback object for the NMEA RMS message processed signal user API. + FunctionPointer cb_vtg; //! Set the baud rate the GPS module is using. /** * Set the baud rate of the serial port @@ -640,7 +735,10 @@ GPS_Time theTime; //! A GPS_Geodetic object used to hold the last parsed positional data. - GPS_Geodetic thePlace; + GPS_Geodetic thePlace; + + //! A GPS_VTG object used to hold vector data. + GPS_VTG theVTG; }; #endif