Library for the EM-406 GPS module with time export support added

Fork of GPS by Simon Ford

Committer:
WilliamO7
Date:
Mon Mar 05 16:17:03 2018 +0000
Revision:
5:fdac9c46157b
Parent:
3:145bdf751843
return number of satellites found

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WilliamO7 1:bc118a161471 1 /* mbed EM-406 GPS Module Library with time return support
simon 0:15611c7938a3 2 * Copyright (c) 2008-2010, sford
WilliamO7 1:bc118a161471 3 * Copyright (c) 2018 WilliamO7
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
simon 0:15611c7938a3 29 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */
simon 0:15611c7938a3 30 class GPS {
simon 0:15611c7938a3 31 public:
simon 0:15611c7938a3 32
simon 0:15611c7938a3 33 /** Create the GPS interface, connected to the specified serial port
simon 0:15611c7938a3 34 */
simon 0:15611c7938a3 35 GPS(PinName tx, PinName rx);
simon 0:15611c7938a3 36
simon 0:15611c7938a3 37 /** Sample the incoming GPS data, returning whether there is a lock
simon 0:15611c7938a3 38 *
simon 0:15611c7938a3 39 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
simon 0:15611c7938a3 40 */
simon 0:15611c7938a3 41 int sample();
simon 0:15611c7938a3 42
simon 0:15611c7938a3 43 /** The longitude (call sample() to set) */
simon 0:15611c7938a3 44 float longitude;
simon 0:15611c7938a3 45
simon 0:15611c7938a3 46 /** The latitude (call sample() to set) */
simon 0:15611c7938a3 47 float latitude;
simon 0:15611c7938a3 48
WilliamO7 1:bc118a161471 49 /** The time in UTC float format (call sample() to set) */
WilliamO7 3:145bdf751843 50 float time_utc;
WilliamO7 1:bc118a161471 51
WilliamO7 5:fdac9c46157b 52 /** Number of satellites (call sample() to set) */
WilliamO7 5:fdac9c46157b 53 int sats;
WilliamO7 5:fdac9c46157b 54
simon 0:15611c7938a3 55 private:
simon 0:15611c7938a3 56 float trunc(float v);
simon 0:15611c7938a3 57 void getline();
simon 0:15611c7938a3 58
simon 0:15611c7938a3 59 Serial _gps;
simon 0:15611c7938a3 60 char msg[256];
simon 0:15611c7938a3 61
simon 0:15611c7938a3 62 };
simon 0:15611c7938a3 63
simon 0:15611c7938a3 64 #endif