read gps data
Fork of NEO-6m-GPS by
GPS.h@2:7350eda5fa8c, 2016-08-12 (annotated)
- Committer:
- sampleCode
- Date:
- Fri Aug 12 08:14:08 2016 +0000
- Revision:
- 2:7350eda5fa8c
- Parent:
- 1:1d60e6a0ffd9
k64f+neo-6mGPS
Who changed what in which revision?
User | Revision | Line number | New 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 | |
sampleCode | 2:7350eda5fa8c | 45 | |
sampleCode | 2:7350eda5fa8c | 46 | /** Beijig time format(shi,fen,miao) **/ |
sampleCode | 2:7350eda5fa8c | 47 | int hour; |
sampleCode | 2:7350eda5fa8c | 48 | int minute; |
sampleCode | 2:7350eda5fa8c | 49 | int seconed; |
sampleCode | 2:7350eda5fa8c | 50 | |
simon | 0:15611c7938a3 | 51 | /** The longitude (call sample() to set) */ |
simon | 0:15611c7938a3 | 52 | float longitude; |
sampleCode | 2:7350eda5fa8c | 53 | |
sampleCode | 2:7350eda5fa8c | 54 | /** display north/south, east/west unit**/ |
sampleCode | 2:7350eda5fa8c | 55 | char ns, ew, unit; |
sampleCode | 2:7350eda5fa8c | 56 | |
simon | 0:15611c7938a3 | 57 | /** The latitude (call sample() to set) */ |
simon | 0:15611c7938a3 | 58 | float latitude; |
simon | 0:15611c7938a3 | 59 | |
8fromPi | 1:1d60e6a0ffd9 | 60 | /** The time (call sample() to set) */ |
8fromPi | 1:1d60e6a0ffd9 | 61 | float time; |
8fromPi | 1:1d60e6a0ffd9 | 62 | |
8fromPi | 1:1d60e6a0ffd9 | 63 | /** Number of satellites received (call sample() to set) */ |
8fromPi | 1:1d60e6a0ffd9 | 64 | int sats; |
8fromPi | 1:1d60e6a0ffd9 | 65 | |
8fromPi | 1:1d60e6a0ffd9 | 66 | /** Horizontal dilusion of precision (call sample() to set) */ |
8fromPi | 1:1d60e6a0ffd9 | 67 | float hdop; |
8fromPi | 1:1d60e6a0ffd9 | 68 | |
8fromPi | 1:1d60e6a0ffd9 | 69 | /** The altitude (call sample() to set) |
8fromPi | 1:1d60e6a0ffd9 | 70 | Note that the accurate altitude is corrected by the geoid |
8fromPi | 1:1d60e6a0ffd9 | 71 | See http://homepages.slingshot.co.nz/~geoff36/datum.htm |
8fromPi | 1:1d60e6a0ffd9 | 72 | */ |
8fromPi | 1:1d60e6a0ffd9 | 73 | float alt; |
8fromPi | 1:1d60e6a0ffd9 | 74 | |
8fromPi | 1:1d60e6a0ffd9 | 75 | /** The geoid (call sample() to set) */ |
8fromPi | 1:1d60e6a0ffd9 | 76 | float geoid; |
8fromPi | 1:1d60e6a0ffd9 | 77 | |
8fromPi | 1:1d60e6a0ffd9 | 78 | /** The NMEA sentence */ |
8fromPi | 1:1d60e6a0ffd9 | 79 | char msg[256]; |
8fromPi | 1:1d60e6a0ffd9 | 80 | |
8fromPi | 1:1d60e6a0ffd9 | 81 | |
simon | 0:15611c7938a3 | 82 | private: |
simon | 0:15611c7938a3 | 83 | float trunc(float v); |
simon | 0:15611c7938a3 | 84 | void getline(); |
simon | 0:15611c7938a3 | 85 | |
sampleCode | 2:7350eda5fa8c | 86 | //create a serial object |
simon | 0:15611c7938a3 | 87 | Serial _gps; |
simon | 0:15611c7938a3 | 88 | }; |
simon | 0:15611c7938a3 | 89 | |
8fromPi | 1:1d60e6a0ffd9 | 90 | #endif |