A basic library for the Adafruit Ultimate GPS module. (MTK3339) http://www.adafruit.com/products/746
Fork of GPS by
GPS.h@3:5cb504ce2793, 2012-10-21 (annotated)
- Committer:
- SamClarke
- Date:
- Sun Oct 21 09:28:41 2012 +0000
- Revision:
- 3:5cb504ce2793
- Parent:
- 2:dcc14e81f8be
- Child:
- 4:9ac674d05370
Added cardinal directions / converted gps.speed knots to gps.kph
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SamClarke | 1:0a034c2dbea6 | 1 | /****************************************************** |
SamClarke | 1:0a034c2dbea6 | 2 | * A basic mbed library for the Adafruit ultimate * |
SamClarke | 1:0a034c2dbea6 | 3 | * GPS module NOTE: the LOCUS functions are yet to be * |
SamClarke | 1:0a034c2dbea6 | 4 | * implemented * |
SamClarke | 1:0a034c2dbea6 | 5 | * * |
SamClarke | 1:0a034c2dbea6 | 6 | * Written by: Sam Clarke * |
SamClarke | 1:0a034c2dbea6 | 7 | ******************************************************/ |
SamClarke | 1:0a034c2dbea6 | 8 | |
SamClarke | 1:0a034c2dbea6 | 9 | #include "mbed.h" |
SamClarke | 1:0a034c2dbea6 | 10 | #include <string> |
SamClarke | 1:0a034c2dbea6 | 11 | |
SamClarke | 1:0a034c2dbea6 | 12 | #ifndef GPS_H |
SamClarke | 1:0a034c2dbea6 | 13 | #define GPS_H |
SamClarke | 1:0a034c2dbea6 | 14 | |
SamClarke | 1:0a034c2dbea6 | 15 | // EXAMPLE OUTPUTS |
SamClarke | 1:0a034c2dbea6 | 16 | // |
SamClarke | 1:0a034c2dbea6 | 17 | // $GPRMC,064951.000,A,2307.1256,N,12016.4438,E,0.03,165.48,260406,3.05,W,A*2C |
SamClarke | 1:0a034c2dbea6 | 18 | // $GPRMC, time, status, latitude, N/S, longitude, E/W, speed(knots), heading, date, N/A, N/A, MODE*CHECKSUM |
SamClarke | 1:0a034c2dbea6 | 19 | // |
SamClarke | 1:0a034c2dbea6 | 20 | // $GPGGA,064951.000,2307.1256,N,12016.4438,E,1,8,0.95,39.9,M,17.8,M,,*65 |
SamClarke | 1:0a034c2dbea6 | 21 | // $GPGGA, time, latitude, N/S, longitude, E/W, fix, satellites, hdop, altitude, M, geoidal sep , M,,*CHECKSUM |
SamClarke | 1:0a034c2dbea6 | 22 | // $GPGGA, %f, %*f, %*c, %*f, %*c, %d, %d, %*f, %*f, %*c, %*f , %*c,,%*c%*c%*c0 |
SamClarke | 1:0a034c2dbea6 | 23 | |
SamClarke | 1:0a034c2dbea6 | 24 | class GPS |
SamClarke | 1:0a034c2dbea6 | 25 | { |
SamClarke | 1:0a034c2dbea6 | 26 | public: |
SamClarke | 1:0a034c2dbea6 | 27 | |
SamClarke | 1:0a034c2dbea6 | 28 | GPS(PinName tx, PinName rx); |
SamClarke | 1:0a034c2dbea6 | 29 | void Init(); |
SamClarke | 1:0a034c2dbea6 | 30 | int parseData(); |
SamClarke | 1:0a034c2dbea6 | 31 | float time; // UTC time |
SamClarke | 2:dcc14e81f8be | 32 | int hours; |
SamClarke | 2:dcc14e81f8be | 33 | int minutes; |
SamClarke | 2:dcc14e81f8be | 34 | float seconds; |
SamClarke | 1:0a034c2dbea6 | 35 | char validity,ns,ew;// RMC data status A = Data Valid; V = Data Not valid; |
SamClarke | 1:0a034c2dbea6 | 36 | float latitude; // |
SamClarke | 1:0a034c2dbea6 | 37 | float longitude; // |
SamClarke | 1:0a034c2dbea6 | 38 | float speed; // speed in knots |
SamClarke | 1:0a034c2dbea6 | 39 | float heading; // heading in degrees derived from previous & current location |
SamClarke | 1:0a034c2dbea6 | 40 | int date; // |
SamClarke | 1:0a034c2dbea6 | 41 | int fixtype; // 0 = no fix; 1 = fix; 2=differential fix |
SamClarke | 1:0a034c2dbea6 | 42 | int satellites; // number of satellites used |
SamClarke | 1:0a034c2dbea6 | 43 | float altitude; // |
SamClarke | 3:5cb504ce2793 | 44 | string fix; |
SamClarke | 3:5cb504ce2793 | 45 | string cardinal; |
SamClarke | 3:5cb504ce2793 | 46 | float kph; |
SamClarke | 1:0a034c2dbea6 | 47 | |
SamClarke | 1:0a034c2dbea6 | 48 | private: |
SamClarke | 1:0a034c2dbea6 | 49 | |
SamClarke | 1:0a034c2dbea6 | 50 | float trunc ( float v); |
SamClarke | 1:0a034c2dbea6 | 51 | void getData(); |
SamClarke | 1:0a034c2dbea6 | 52 | Serial _UltimateGps; |
SamClarke | 1:0a034c2dbea6 | 53 | char NEMA[256]; |
SamClarke | 1:0a034c2dbea6 | 54 | }; |
SamClarke | 1:0a034c2dbea6 | 55 | #endif |
SamClarke | 1:0a034c2dbea6 | 56 | |
SamClarke | 1:0a034c2dbea6 | 57 | /* |
SamClarke | 1:0a034c2dbea6 | 58 | #define 1HZ_STREAM "$PMTK220,1000*1F\r\n" // 1.0 second interval |
SamClarke | 1:0a034c2dbea6 | 59 | #define 5HZ_STREAM "$PMTK220,200*2C\r\n" // 0.2 second interval |
SamClarke | 1:0a034c2dbea6 | 60 | #define 10HZ_STREAM "$PMTK220,100*2F\r\n" // 0.1 second interval |
SamClarke | 1:0a034c2dbea6 | 61 | |
SamClarke | 1:0a034c2dbea6 | 62 | #define OUTPUT_RMC "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n" |
SamClarke | 1:0a034c2dbea6 | 63 | #define OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n" |
SamClarke | 1:0a034c2dbea6 | 64 | #define OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28\r\n" |
SamClarke | 0:697a7215cc10 | 65 | */ |