GPS
Fork of GPS by
GPS.h@7:1440e1e56a15, 2015-03-04 (annotated)
- Committer:
- Spilly
- Date:
- Wed Mar 04 17:47:53 2015 +0000
- Revision:
- 7:1440e1e56a15
- Parent:
- 4:9ac674d05370
Modified
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 | 4:9ac674d05370 | 40 | string date; // |
SamClarke | 4:9ac674d05370 | 41 | int day; |
SamClarke | 4:9ac674d05370 | 42 | int month; |
SamClarke | 4:9ac674d05370 | 43 | int year; |
SamClarke | 1:0a034c2dbea6 | 44 | int fixtype; // 0 = no fix; 1 = fix; 2=differential fix |
SamClarke | 1:0a034c2dbea6 | 45 | int satellites; // number of satellites used |
SamClarke | 1:0a034c2dbea6 | 46 | float altitude; // |
SamClarke | 3:5cb504ce2793 | 47 | string fix; |
SamClarke | 3:5cb504ce2793 | 48 | string cardinal; |
SamClarke | 3:5cb504ce2793 | 49 | float kph; |
SamClarke | 1:0a034c2dbea6 | 50 | |
SamClarke | 1:0a034c2dbea6 | 51 | private: |
SamClarke | 1:0a034c2dbea6 | 52 | |
SamClarke | 1:0a034c2dbea6 | 53 | float trunc ( float v); |
SamClarke | 1:0a034c2dbea6 | 54 | void getData(); |
SamClarke | 1:0a034c2dbea6 | 55 | Serial _UltimateGps; |
SamClarke | 1:0a034c2dbea6 | 56 | char NEMA[256]; |
SamClarke | 1:0a034c2dbea6 | 57 | }; |
SamClarke | 1:0a034c2dbea6 | 58 | #endif |
SamClarke | 1:0a034c2dbea6 | 59 | |
SamClarke | 1:0a034c2dbea6 | 60 | /* |
SamClarke | 1:0a034c2dbea6 | 61 | #define 1HZ_STREAM "$PMTK220,1000*1F\r\n" // 1.0 second interval |
SamClarke | 1:0a034c2dbea6 | 62 | #define 5HZ_STREAM "$PMTK220,200*2C\r\n" // 0.2 second interval |
SamClarke | 1:0a034c2dbea6 | 63 | #define 10HZ_STREAM "$PMTK220,100*2F\r\n" // 0.1 second interval |
SamClarke | 1:0a034c2dbea6 | 64 | |
SamClarke | 1:0a034c2dbea6 | 65 | #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 | 66 | #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 | 67 | #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 | 68 | */ |