Updated version with new commands and sleep mode

Fork of GPS by Sam Clarke

Committer:
Spilly
Date:
Wed Apr 29 18:09:53 2015 +0000
Revision:
10:a73736c18332
Parent:
8:2476bea153a1
Updated comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Spilly 6:af055728e564 1 /**************************************************************************************************************************************************************
Spilly 6:af055728e564 2 // This is a modified version of mbed /users/SamClarke/code/GPS/ for MTK3339 GPS module
Spilly 6:af055728e564 3 //
Spilly 6:af055728e564 4 // Changes made by Ryan Spillman:
Spilly 6:af055728e564 5 // added commands to the initialization function to set baud rate, set update rate, enabled DGPS WAAS, and set minimum navigation speed
Spilly 6:af055728e564 6 // added a function to put the unit into sleep mode
Spilly 6:af055728e564 7 // added several zeros after the decimal places to fix weird rounding errors
Spilly 6:af055728e564 8 // added information about checksums
Spilly 6:af055728e564 9 //
Spilly 6:af055728e564 10 // IMPORTANT:
Spilly 6:af055728e564 11 // Any changes made to commands sent to GPS unit require corresponding changes to the
Spilly 6:af055728e564 12 // checksum at the end of the command
Spilly 6:af055728e564 13 // Here is a tool for calculating the checksum:
Spilly 6:af055728e564 14 // http://siliconsparrow.com/demos/nmeachecksum.php
Spilly 6:af055728e564 15 **************************************************************************************************************************************************************/
SamClarke 1:0a034c2dbea6 16
SamClarke 1:0a034c2dbea6 17 #include "mbed.h"
SamClarke 1:0a034c2dbea6 18 #include <string>
SamClarke 1:0a034c2dbea6 19
SamClarke 1:0a034c2dbea6 20 #ifndef GPS_H
SamClarke 1:0a034c2dbea6 21 #define GPS_H
SamClarke 1:0a034c2dbea6 22
SamClarke 1:0a034c2dbea6 23 // EXAMPLE OUTPUTS
SamClarke 1:0a034c2dbea6 24 //
SamClarke 1:0a034c2dbea6 25 // $GPRMC,064951.000,A,2307.1256,N,12016.4438,E,0.03,165.48,260406,3.05,W,A*2C
SamClarke 1:0a034c2dbea6 26 // $GPRMC, time, status, latitude, N/S, longitude, E/W, speed(knots), heading, date, N/A, N/A, MODE*CHECKSUM
SamClarke 1:0a034c2dbea6 27 //
SamClarke 1:0a034c2dbea6 28 // $GPGGA,064951.000,2307.1256,N,12016.4438,E,1,8,0.95,39.9,M,17.8,M,,*65
SamClarke 1:0a034c2dbea6 29 // $GPGGA, time, latitude, N/S, longitude, E/W, fix, satellites, hdop, altitude, M, geoidal sep , M,,*CHECKSUM
SamClarke 1:0a034c2dbea6 30 // $GPGGA, %f, %*f, %*c, %*f, %*c, %d, %d, %*f, %*f, %*c, %*f , %*c,,%*c%*c%*c0
SamClarke 1:0a034c2dbea6 31
SamClarke 1:0a034c2dbea6 32 class GPS
SamClarke 1:0a034c2dbea6 33 {
SamClarke 1:0a034c2dbea6 34 public:
SamClarke 1:0a034c2dbea6 35
SamClarke 1:0a034c2dbea6 36 GPS(PinName tx, PinName rx);
SamClarke 1:0a034c2dbea6 37 int parseData();
SamClarke 1:0a034c2dbea6 38 float time; // UTC time
SamClarke 2:dcc14e81f8be 39 int hours;
SamClarke 2:dcc14e81f8be 40 int minutes;
SamClarke 2:dcc14e81f8be 41 float seconds;
SamClarke 1:0a034c2dbea6 42 char validity,ns,ew;// RMC data status A = Data Valid; V = Data Not valid;
SamClarke 1:0a034c2dbea6 43 float latitude; //
SamClarke 1:0a034c2dbea6 44 float longitude; //
SamClarke 1:0a034c2dbea6 45 float speed; // speed in knots
SamClarke 1:0a034c2dbea6 46 float heading; // heading in degrees derived from previous & current location
SamClarke 4:9ac674d05370 47 string date; //
SamClarke 4:9ac674d05370 48 int day;
SamClarke 4:9ac674d05370 49 int month;
SamClarke 4:9ac674d05370 50 int year;
SamClarke 1:0a034c2dbea6 51 int fixtype; // 0 = no fix; 1 = fix; 2=differential fix
SamClarke 1:0a034c2dbea6 52 int satellites; // number of satellites used
SamClarke 1:0a034c2dbea6 53 float altitude; //
SamClarke 3:5cb504ce2793 54 string fix;
SamClarke 3:5cb504ce2793 55 string cardinal;
SamClarke 3:5cb504ce2793 56 float kph;
Spilly 7:7aac669b0075 57
Spilly 7:7aac669b0075 58 //added by Ryan
Spilly 8:2476bea153a1 59 Serial _UltimateGps;
Spilly 7:7aac669b0075 60 int getGPRMC();
Spilly 7:7aac669b0075 61 int getGPGSA();
Spilly 7:7aac669b0075 62 int getGPGGA();
Spilly 7:7aac669b0075 63 void Init();
Spilly 7:7aac669b0075 64 void Sleep(int sleep);
Spilly 7:7aac669b0075 65 void coldStart();
Spilly 8:2476bea153a1 66 bool getData();
Spilly 7:7aac669b0075 67 char mode; //manual or automatic
Spilly 7:7aac669b0075 68 int status; //same as fixtype
Spilly 8:2476bea153a1 69 int NEMACount;
Spilly 8:2476bea153a1 70 int sentenceCount;
Spilly 8:2476bea153a1 71 int recordFlag;
Spilly 7:7aac669b0075 72 float PDOP; //Position Dilution of Precision
Spilly 7:7aac669b0075 73 float HDOP; //Horizontal Dilution of Precision
Spilly 7:7aac669b0075 74 float VDOP; //Vertical Dilution of Precision
Spilly 7:7aac669b0075 75 double degLat; //degrees latitude
Spilly 7:7aac669b0075 76 double degLon; //degrees longitude
SamClarke 1:0a034c2dbea6 77 private:
SamClarke 1:0a034c2dbea6 78
SamClarke 1:0a034c2dbea6 79 float trunc ( float v);
Spilly 8:2476bea153a1 80 //void getData();
Spilly 8:2476bea153a1 81 //Serial _UltimateGps;
SamClarke 1:0a034c2dbea6 82 char NEMA[256];
SamClarke 1:0a034c2dbea6 83 };
SamClarke 1:0a034c2dbea6 84 #endif
SamClarke 1:0a034c2dbea6 85
SamClarke 1:0a034c2dbea6 86 /*
SamClarke 1:0a034c2dbea6 87 #define 1HZ_STREAM "$PMTK220,1000*1F\r\n" // 1.0 second interval
SamClarke 1:0a034c2dbea6 88 #define 5HZ_STREAM "$PMTK220,200*2C\r\n" // 0.2 second interval
SamClarke 1:0a034c2dbea6 89 #define 10HZ_STREAM "$PMTK220,100*2F\r\n" // 0.1 second interval
SamClarke 1:0a034c2dbea6 90
SamClarke 1:0a034c2dbea6 91 #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 92 #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 93 #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 94 */