Fork of SerialGPS that uses the SoftSerial library instead of the mbed serial device.

Fork of SerialGPS by Components

Committer:
pferland
Date:
Wed Nov 29 15:41:39 2017 +0000
Revision:
4:bc32bec014b3
Parent:
3:4e2136c38f29
Software Serial support, fixed error in longitude conversion

Who changed what in which revision?

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