Adafruit GPS library

Dependents:   GPSLibrary

Committer:
ptcrews
Date:
Sat Dec 05 07:30:18 2015 +0000
Revision:
0:ba9ed1caafc3
Adafruit GPS library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ptcrews 0:ba9ed1caafc3 1 /***********************************
ptcrews 0:ba9ed1caafc3 2 This is the Adafruit GPS library - the ultimate GPS library
ptcrews 0:ba9ed1caafc3 3 for the ultimate GPS module!
ptcrews 0:ba9ed1caafc3 4
ptcrews 0:ba9ed1caafc3 5 Tested and works great with the Adafruit Ultimate GPS module
ptcrews 0:ba9ed1caafc3 6 using MTK33x9 chipset
ptcrews 0:ba9ed1caafc3 7 ------> http://www.adafruit.com/products/746
ptcrews 0:ba9ed1caafc3 8 Pick one up today at the Adafruit electronics shop
ptcrews 0:ba9ed1caafc3 9 and help support open source hardware & software! -ada
ptcrews 0:ba9ed1caafc3 10
ptcrews 0:ba9ed1caafc3 11 Adafruit invests time and resources providing this open source code,
ptcrews 0:ba9ed1caafc3 12 please support Adafruit and open-source hardware by purchasing
ptcrews 0:ba9ed1caafc3 13 products from Adafruit!
ptcrews 0:ba9ed1caafc3 14
ptcrews 0:ba9ed1caafc3 15 Written by Limor Fried/Ladyada for Adafruit Industries.
ptcrews 0:ba9ed1caafc3 16 BSD license, check license.txt for more information
ptcrews 0:ba9ed1caafc3 17 All text above must be included in any redistribution
ptcrews 0:ba9ed1caafc3 18 ****************************************/
ptcrews 0:ba9ed1caafc3 19 #include "mbed.h"
ptcrews 0:ba9ed1caafc3 20 #include <stdint.h>
ptcrews 0:ba9ed1caafc3 21 #include <math.h>
ptcrews 0:ba9ed1caafc3 22 #include <ctype.h>
ptcrews 0:ba9ed1caafc3 23
ptcrews 0:ba9ed1caafc3 24 #ifndef _MBED_ADAFRUIT_GPS_H
ptcrews 0:ba9ed1caafc3 25 #define _MBED_ADAFRUIT_GPS_H
ptcrews 0:ba9ed1caafc3 26
ptcrews 0:ba9ed1caafc3 27
ptcrews 0:ba9ed1caafc3 28 // different commands to set the update rate from once a second (1 Hz) to 10 times a second (10Hz)
ptcrews 0:ba9ed1caafc3 29 #define PMTK_SET_NMEA_UPDATE_1HZ "$PMTK220,1000*1F"
ptcrews 0:ba9ed1caafc3 30 #define PMTK_SET_NMEA_UPDATE_5HZ "$PMTK220,200*2C"
ptcrews 0:ba9ed1caafc3 31 #define PMTK_SET_NMEA_UPDATE_10HZ "$PMTK220,100*2F"
ptcrews 0:ba9ed1caafc3 32
ptcrews 0:ba9ed1caafc3 33
ptcrews 0:ba9ed1caafc3 34 #define PMTK_SET_BAUD_57600 "$PMTK251,57600*2C"
ptcrews 0:ba9ed1caafc3 35 #define PMTK_SET_BAUD_9600 "$PMTK251,9600*17"
ptcrews 0:ba9ed1caafc3 36
ptcrews 0:ba9ed1caafc3 37 // turn on only the second sentence (GPRMC)
ptcrews 0:ba9ed1caafc3 38 #define PMTK_SET_NMEA_OUTPUT_RMCONLY "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29"
ptcrews 0:ba9ed1caafc3 39 // turn on GPRMC and GGA
ptcrews 0:ba9ed1caafc3 40 #define PMTK_SET_NMEA_OUTPUT_RMCGGA "$PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
ptcrews 0:ba9ed1caafc3 41 // turn on ALL THE DATA
ptcrews 0:ba9ed1caafc3 42 #define PMTK_SET_NMEA_OUTPUT_ALLDATA "$PMTK314,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
ptcrews 0:ba9ed1caafc3 43 // turn off output
ptcrews 0:ba9ed1caafc3 44 #define PMTK_SET_NMEA_OUTPUT_OFF "$PMTK314,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*28"
ptcrews 0:ba9ed1caafc3 45
ptcrews 0:ba9ed1caafc3 46 // to generate your own sentences, check out the MTK command datasheet and use a checksum calculator
ptcrews 0:ba9ed1caafc3 47 // such as the awesome http://www.hhhh.org/wiml/proj/nmeaxor.html
ptcrews 0:ba9ed1caafc3 48
ptcrews 0:ba9ed1caafc3 49 #define PMTK_LOCUS_STARTLOG "$PMTK185,0*22"
ptcrews 0:ba9ed1caafc3 50 #define PMTK_LOCUS_LOGSTARTED "$PMTK001,185,3*3C"
ptcrews 0:ba9ed1caafc3 51 #define PMTK_LOCUS_QUERY_STATUS "$PMTK183*38"
ptcrews 0:ba9ed1caafc3 52 #define PMTK_LOCUS_ERASE_FLASH "$PMTK184,1*22"
ptcrews 0:ba9ed1caafc3 53 #define LOCUS_OVERLAP 0
ptcrews 0:ba9ed1caafc3 54 #define LOCUS_FULLSTOP 1
ptcrews 0:ba9ed1caafc3 55
ptcrews 0:ba9ed1caafc3 56 // standby command & boot successful message
ptcrews 0:ba9ed1caafc3 57 #define PMTK_STANDBY "$PMTK161,0*28"
ptcrews 0:ba9ed1caafc3 58 #define PMTK_STANDBY_SUCCESS "$PMTK001,161,3*36" // Not needed currently
ptcrews 0:ba9ed1caafc3 59 #define PMTK_AWAKE "$PMTK010,002*2D"
ptcrews 0:ba9ed1caafc3 60
ptcrews 0:ba9ed1caafc3 61 // ask for the release and version
ptcrews 0:ba9ed1caafc3 62 #define PMTK_Q_RELEASE "$PMTK605*31"
ptcrews 0:ba9ed1caafc3 63
ptcrews 0:ba9ed1caafc3 64 // request for updates on antenna status
ptcrews 0:ba9ed1caafc3 65 #define PGCMD_ANTENNA "$PGCMD,33,1*6C"
ptcrews 0:ba9ed1caafc3 66 #define PGCMD_NOANTENNA "$PGCMD,33,0*6D"
ptcrews 0:ba9ed1caafc3 67
ptcrews 0:ba9ed1caafc3 68 // how long to wait when we're looking for a response
ptcrews 0:ba9ed1caafc3 69 #define MAXWAITSENTENCE 5
ptcrews 0:ba9ed1caafc3 70
ptcrews 0:ba9ed1caafc3 71
ptcrews 0:ba9ed1caafc3 72
ptcrews 0:ba9ed1caafc3 73 class Adafruit_GPS {
ptcrews 0:ba9ed1caafc3 74 public:
ptcrews 0:ba9ed1caafc3 75 void begin(int baud);
ptcrews 0:ba9ed1caafc3 76
ptcrews 0:ba9ed1caafc3 77 Adafruit_GPS(Serial * ser);
ptcrews 0:ba9ed1caafc3 78
ptcrews 0:ba9ed1caafc3 79 char *lastNMEA(void);
ptcrews 0:ba9ed1caafc3 80 bool newNMEAreceived();
ptcrews 0:ba9ed1caafc3 81 void common_init(void);
ptcrews 0:ba9ed1caafc3 82 void sendCommand(char *);
ptcrews 0:ba9ed1caafc3 83 void pause(bool b);
ptcrews 0:ba9ed1caafc3 84
ptcrews 0:ba9ed1caafc3 85 bool parseNMEA(char *response);
ptcrews 0:ba9ed1caafc3 86 uint8_t parseHex(char c);
ptcrews 0:ba9ed1caafc3 87
ptcrews 0:ba9ed1caafc3 88 char read(void);
ptcrews 0:ba9ed1caafc3 89 bool parse(char * nmea);
ptcrews 0:ba9ed1caafc3 90 void interruptReads(bool r);
ptcrews 0:ba9ed1caafc3 91
ptcrews 0:ba9ed1caafc3 92 bool wakeup(void);
ptcrews 0:ba9ed1caafc3 93 bool standby(void);
ptcrews 0:ba9ed1caafc3 94
ptcrews 0:ba9ed1caafc3 95 uint8_t hour, minute, seconds, year, month, day;
ptcrews 0:ba9ed1caafc3 96 uint16_t milliseconds;
ptcrews 0:ba9ed1caafc3 97 float latitude, longitude, geoidheight, altitude;
ptcrews 0:ba9ed1caafc3 98 float speed, angle, magvariation, HDOP;
ptcrews 0:ba9ed1caafc3 99 char lat, lon, mag;
ptcrews 0:ba9ed1caafc3 100 bool fix;
ptcrews 0:ba9ed1caafc3 101 uint8_t fixquality, satellites;
ptcrews 0:ba9ed1caafc3 102
ptcrews 0:ba9ed1caafc3 103 bool waitForSentence(char *wait, uint8_t max = MAXWAITSENTENCE);
ptcrews 0:ba9ed1caafc3 104 bool LOCUS_StartLogger(void);
ptcrews 0:ba9ed1caafc3 105 bool LOCUS_ReadStatus(void);
ptcrews 0:ba9ed1caafc3 106
ptcrews 0:ba9ed1caafc3 107 uint16_t LOCUS_serial, LOCUS_records;
ptcrews 0:ba9ed1caafc3 108 uint8_t LOCUS_type, LOCUS_mode, LOCUS_config, LOCUS_interval, LOCUS_distance, LOCUS_speed, LOCUS_status, LOCUS_percent;
ptcrews 0:ba9ed1caafc3 109 private:
ptcrews 0:ba9ed1caafc3 110 bool paused;
ptcrews 0:ba9ed1caafc3 111
ptcrews 0:ba9ed1caafc3 112 Serial * gpsSerial;
ptcrews 0:ba9ed1caafc3 113 };
ptcrews 0:ba9ed1caafc3 114
ptcrews 0:ba9ed1caafc3 115 #endif