Updated version with new commands and sleep mode

Fork of GPS by Sam Clarke

Committer:
Spilly
Date:
Sun Apr 05 01:41:34 2015 +0000
Revision:
6:af055728e564
Parent:
4:9ac674d05370
Child:
7:7aac669b0075
Added several new initialization commands and a sleep function

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 void Init();
Spilly 6:af055728e564 38 void Sleep(int sleep);
SamClarke 1:0a034c2dbea6 39 int parseData();
SamClarke 1:0a034c2dbea6 40 float time; // UTC time
SamClarke 2:dcc14e81f8be 41 int hours;
SamClarke 2:dcc14e81f8be 42 int minutes;
SamClarke 2:dcc14e81f8be 43 float seconds;
SamClarke 1:0a034c2dbea6 44 char validity,ns,ew;// RMC data status A = Data Valid; V = Data Not valid;
SamClarke 1:0a034c2dbea6 45 float latitude; //
SamClarke 1:0a034c2dbea6 46 float longitude; //
SamClarke 1:0a034c2dbea6 47 float speed; // speed in knots
SamClarke 1:0a034c2dbea6 48 float heading; // heading in degrees derived from previous & current location
SamClarke 4:9ac674d05370 49 string date; //
SamClarke 4:9ac674d05370 50 int day;
SamClarke 4:9ac674d05370 51 int month;
SamClarke 4:9ac674d05370 52 int year;
SamClarke 1:0a034c2dbea6 53 int fixtype; // 0 = no fix; 1 = fix; 2=differential fix
SamClarke 1:0a034c2dbea6 54 int satellites; // number of satellites used
SamClarke 1:0a034c2dbea6 55 float altitude; //
SamClarke 3:5cb504ce2793 56 string fix;
SamClarke 3:5cb504ce2793 57 string cardinal;
SamClarke 3:5cb504ce2793 58 float kph;
SamClarke 1:0a034c2dbea6 59
SamClarke 1:0a034c2dbea6 60 private:
SamClarke 1:0a034c2dbea6 61
SamClarke 1:0a034c2dbea6 62 float trunc ( float v);
SamClarke 1:0a034c2dbea6 63 void getData();
SamClarke 1:0a034c2dbea6 64 Serial _UltimateGps;
SamClarke 1:0a034c2dbea6 65 char NEMA[256];
SamClarke 1:0a034c2dbea6 66 };
SamClarke 1:0a034c2dbea6 67 #endif
SamClarke 1:0a034c2dbea6 68
SamClarke 1:0a034c2dbea6 69 /*
SamClarke 1:0a034c2dbea6 70 #define 1HZ_STREAM "$PMTK220,1000*1F\r\n" // 1.0 second interval
SamClarke 1:0a034c2dbea6 71 #define 5HZ_STREAM "$PMTK220,200*2C\r\n" // 0.2 second interval
SamClarke 1:0a034c2dbea6 72 #define 10HZ_STREAM "$PMTK220,100*2F\r\n" // 0.1 second interval
SamClarke 1:0a034c2dbea6 73
SamClarke 1:0a034c2dbea6 74 #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 75 #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 76 #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 77 */