Slight update to sford's GPS library. Returns more data from the NMEA sentence and allows for different serial speeds (e.g. used for the Adafruit Ultimate GPSv3 Breakout Board).

Dependents:   GPS_HelloWorld servo_sensor

Fork of GPS by Simon Ford

Committer:
8fromPi
Date:
Sat Nov 02 16:17:58 2013 +0000
Revision:
1:1d60e6a0ffd9
Parent:
0:15611c7938a3
GPS lib from sford with light modifications to get more data from the NMEA sentence and to allow for modules with different serial speeds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
8fromPi 1:1d60e6a0ffd9 1 /* mbed GPS Module Library
simon 0:15611c7938a3 2 * Copyright (c) 2008-2010, sford
8fromPi 1:1d60e6a0ffd9 3 * Copyright (c) 2013, B.Adryan
simon 0:15611c7938a3 4 *
simon 0:15611c7938a3 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
simon 0:15611c7938a3 6 * of this software and associated documentation files (the "Software"), to deal
simon 0:15611c7938a3 7 * in the Software without restriction, including without limitation the rights
simon 0:15611c7938a3 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
simon 0:15611c7938a3 9 * copies of the Software, and to permit persons to whom the Software is
simon 0:15611c7938a3 10 * furnished to do so, subject to the following conditions:
simon 0:15611c7938a3 11 *
simon 0:15611c7938a3 12 * The above copyright notice and this permission notice shall be included in
simon 0:15611c7938a3 13 * all copies or substantial portions of the Software.
simon 0:15611c7938a3 14 *
simon 0:15611c7938a3 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
simon 0:15611c7938a3 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
simon 0:15611c7938a3 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
simon 0:15611c7938a3 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
simon 0:15611c7938a3 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
simon 0:15611c7938a3 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
simon 0:15611c7938a3 21 * THE SOFTWARE.
simon 0:15611c7938a3 22 */
simon 0:15611c7938a3 23
simon 0:15611c7938a3 24 #include "mbed.h"
simon 0:15611c7938a3 25
simon 0:15611c7938a3 26 #ifndef MBED_GPS_H
simon 0:15611c7938a3 27 #define MBED_GPS_H
simon 0:15611c7938a3 28
8fromPi 1:1d60e6a0ffd9 29 /** A GPS interface for reading from a serial GPS module */
simon 0:15611c7938a3 30 class GPS {
simon 0:15611c7938a3 31 public:
simon 0:15611c7938a3 32
8fromPi 1:1d60e6a0ffd9 33 /** Create the GPS interface, connected to the specified serial port and speed.
8fromPi 1:1d60e6a0ffd9 34 * for example, GlobalSat EM406-A (e.g. on SparkFun GPS Shield) is 4800 Baud,
8fromPi 1:1d60e6a0ffd9 35 * Adafruit Ultimate GPSv3 (connected to serial) is 9600 Baud
simon 0:15611c7938a3 36 */
8fromPi 1:1d60e6a0ffd9 37 GPS(PinName tx, PinName rx, int Baud);
simon 0:15611c7938a3 38
simon 0:15611c7938a3 39 /** Sample the incoming GPS data, returning whether there is a lock
simon 0:15611c7938a3 40 *
simon 0:15611c7938a3 41 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
simon 0:15611c7938a3 42 */
simon 0:15611c7938a3 43 int sample();
simon 0:15611c7938a3 44
simon 0:15611c7938a3 45 /** The longitude (call sample() to set) */
simon 0:15611c7938a3 46 float longitude;
simon 0:15611c7938a3 47
simon 0:15611c7938a3 48 /** The latitude (call sample() to set) */
simon 0:15611c7938a3 49 float latitude;
simon 0:15611c7938a3 50
8fromPi 1:1d60e6a0ffd9 51 /** The time (call sample() to set) */
8fromPi 1:1d60e6a0ffd9 52 float time;
8fromPi 1:1d60e6a0ffd9 53
8fromPi 1:1d60e6a0ffd9 54 /** Number of satellites received (call sample() to set) */
8fromPi 1:1d60e6a0ffd9 55 int sats;
8fromPi 1:1d60e6a0ffd9 56
8fromPi 1:1d60e6a0ffd9 57 /** Horizontal dilusion of precision (call sample() to set) */
8fromPi 1:1d60e6a0ffd9 58 float hdop;
8fromPi 1:1d60e6a0ffd9 59
8fromPi 1:1d60e6a0ffd9 60 /** The altitude (call sample() to set)
8fromPi 1:1d60e6a0ffd9 61 Note that the accurate altitude is corrected by the geoid
8fromPi 1:1d60e6a0ffd9 62 See http://homepages.slingshot.co.nz/~geoff36/datum.htm
8fromPi 1:1d60e6a0ffd9 63 */
8fromPi 1:1d60e6a0ffd9 64 float alt;
8fromPi 1:1d60e6a0ffd9 65
8fromPi 1:1d60e6a0ffd9 66 /** The geoid (call sample() to set) */
8fromPi 1:1d60e6a0ffd9 67 float geoid;
8fromPi 1:1d60e6a0ffd9 68
8fromPi 1:1d60e6a0ffd9 69 /** The NMEA sentence */
8fromPi 1:1d60e6a0ffd9 70 char msg[256];
8fromPi 1:1d60e6a0ffd9 71
8fromPi 1:1d60e6a0ffd9 72
simon 0:15611c7938a3 73 private:
simon 0:15611c7938a3 74 float trunc(float v);
simon 0:15611c7938a3 75 void getline();
simon 0:15611c7938a3 76
simon 0:15611c7938a3 77 Serial _gps;
simon 0:15611c7938a3 78 };
simon 0:15611c7938a3 79
8fromPi 1:1d60e6a0ffd9 80 #endif