A basic library for the Adafruit Ultimate GPS module. (MTK3339) http://www.adafruit.com/products/746

Fork of GPS by Sam Clarke

Committer:
SamClarke
Date:
Sat Oct 06 22:41:59 2012 +0000
Revision:
0:697a7215cc10
Child:
1:0a034c2dbea6
Basic version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SamClarke 0:697a7215cc10 1 /******************************************************
SamClarke 0:697a7215cc10 2 * A basic mbed library for the Adafruit ultimate *
SamClarke 0:697a7215cc10 3 * GPS module NOTE: the LOCUS functions are yet to be *
SamClarke 0:697a7215cc10 4 * implemented *
SamClarke 0:697a7215cc10 5 * *
SamClarke 0:697a7215cc10 6 * Written by: Sam Clarke *
SamClarke 0:697a7215cc10 7 ******************************************************/
SamClarke 0:697a7215cc10 8
SamClarke 0:697a7215cc10 9 #include "mbed.h"
SamClarke 0:697a7215cc10 10 #include <string>
SamClarke 0:697a7215cc10 11
SamClarke 0:697a7215cc10 12 #ifndef GPS_H
SamClarke 0:697a7215cc10 13 #define GPS_H
SamClarke 0:697a7215cc10 14
SamClarke 0:697a7215cc10 15 // EXAMPLE OUTPUTS
SamClarke 0:697a7215cc10 16 //
SamClarke 0:697a7215cc10 17 // $GPRMC,064951.000,A,2307.1256,N,12016.4438,E,0.03,165.48,260406,3.05,W,A*2C
SamClarke 0:697a7215cc10 18 // $GPRMC, time, status, latitude, N/S, longitude, E/W, speed(knots), heading, date, N/A, N/A, MODE*CHECKSUM
SamClarke 0:697a7215cc10 19 //
SamClarke 0:697a7215cc10 20 // $GPGGA,064951.000,2307.1256,N,12016.4438,E,1,8,0.95,39.9,M,17.8,M,,*65
SamClarke 0:697a7215cc10 21 // $GPGGA, time, latitude, N/S, longitude, E/W, fix, satellites, hdop, altitude, M, geoidal sep , M,,*CHECKSUM
SamClarke 0:697a7215cc10 22 // $GPGGA, %f, %*f, %*c, %*f, %*c, %d, %d, %*f, %*f, %*c, %*f , %*c,,%*c%*c%*c0
SamClarke 0:697a7215cc10 23
SamClarke 0:697a7215cc10 24 class GPS
SamClarke 0:697a7215cc10 25 {
SamClarke 0:697a7215cc10 26 public:
SamClarke 0:697a7215cc10 27
SamClarke 0:697a7215cc10 28 GPS(PinName tx, PinName rx);
SamClarke 0:697a7215cc10 29 void Init();
SamClarke 0:697a7215cc10 30 int parseData();
SamClarke 0:697a7215cc10 31 float time; // UTC time
SamClarke 0:697a7215cc10 32 char validity,ns,ew;// RMC data status A = Data Valid; V = Data Not valid;
SamClarke 0:697a7215cc10 33 float latitude; //
SamClarke 0:697a7215cc10 34 float longitude; //
SamClarke 0:697a7215cc10 35 float speed; // speed in knots
SamClarke 0:697a7215cc10 36 float heading; // heading in degrees derived from previous & current location
SamClarke 0:697a7215cc10 37 int date; //
SamClarke 0:697a7215cc10 38 int fixtype; // 0 = no fix; 1 = fix; 2=differential fix
SamClarke 0:697a7215cc10 39 int satellites; // number of satellites used
SamClarke 0:697a7215cc10 40 float altitude; //
SamClarke 0:697a7215cc10 41 string fixname;
SamClarke 0:697a7215cc10 42
SamClarke 0:697a7215cc10 43 private:
SamClarke 0:697a7215cc10 44
SamClarke 0:697a7215cc10 45 float trunc ( float v);
SamClarke 0:697a7215cc10 46 void getData();
SamClarke 0:697a7215cc10 47 Serial _UltimateGps;
SamClarke 0:697a7215cc10 48 char NEMA[256];
SamClarke 0:697a7215cc10 49 string posfix;
SamClarke 0:697a7215cc10 50 string diffix;
SamClarke 0:697a7215cc10 51
SamClarke 0:697a7215cc10 52 };
SamClarke 0:697a7215cc10 53 #endif
SamClarke 0:697a7215cc10 54
SamClarke 0:697a7215cc10 55 /*
SamClarke 0:697a7215cc10 56 #define 1HZ_STREAM "$PMTK220,1000*1F\r\n" // 1.0 second interval
SamClarke 0:697a7215cc10 57 #define 5HZ_STREAM "$PMTK220,200*2C\r\n" // 0.2 second interval
SamClarke 0:697a7215cc10 58 #define 10HZ_STREAM "$PMTK220,100*2F\r\n" // 0.1 second interval
SamClarke 0:697a7215cc10 59
SamClarke 0:697a7215cc10 60 #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 0:697a7215cc10 61 #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 0:697a7215cc10 62 #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 63 */