Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GPS/GPS.h@0:feaa05d35ccf, 2012-03-07 (annotated)
- Committer:
- AlexAllen
- Date:
- Wed Mar 07 20:02:35 2012 +0000
- Revision:
- 0:feaa05d35ccf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AlexAllen | 0:feaa05d35ccf | 1 | /* mbed EM-406 GPS Module Library |
AlexAllen | 0:feaa05d35ccf | 2 | * Copyright (c) 2008-2010, sford |
AlexAllen | 0:feaa05d35ccf | 3 | * |
AlexAllen | 0:feaa05d35ccf | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
AlexAllen | 0:feaa05d35ccf | 5 | * of this software and associated documentation files (the "Software"), to deal |
AlexAllen | 0:feaa05d35ccf | 6 | * in the Software without restriction, including without limitation the rights |
AlexAllen | 0:feaa05d35ccf | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
AlexAllen | 0:feaa05d35ccf | 8 | * copies of the Software, and to permit persons to whom the Software is |
AlexAllen | 0:feaa05d35ccf | 9 | * furnished to do so, subject to the following conditions: |
AlexAllen | 0:feaa05d35ccf | 10 | * |
AlexAllen | 0:feaa05d35ccf | 11 | * The above copyright notice and this permission notice shall be included in |
AlexAllen | 0:feaa05d35ccf | 12 | * all copies or substantial portions of the Software. |
AlexAllen | 0:feaa05d35ccf | 13 | * |
AlexAllen | 0:feaa05d35ccf | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
AlexAllen | 0:feaa05d35ccf | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
AlexAllen | 0:feaa05d35ccf | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
AlexAllen | 0:feaa05d35ccf | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
AlexAllen | 0:feaa05d35ccf | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
AlexAllen | 0:feaa05d35ccf | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
AlexAllen | 0:feaa05d35ccf | 20 | * THE SOFTWARE. |
AlexAllen | 0:feaa05d35ccf | 21 | */ |
AlexAllen | 0:feaa05d35ccf | 22 | |
AlexAllen | 0:feaa05d35ccf | 23 | #include "mbed.h" |
AlexAllen | 0:feaa05d35ccf | 24 | |
AlexAllen | 0:feaa05d35ccf | 25 | #ifndef MBED_GPS_H |
AlexAllen | 0:feaa05d35ccf | 26 | #define MBED_GPS_H |
AlexAllen | 0:feaa05d35ccf | 27 | |
AlexAllen | 0:feaa05d35ccf | 28 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
AlexAllen | 0:feaa05d35ccf | 29 | class GPS { |
AlexAllen | 0:feaa05d35ccf | 30 | public: |
AlexAllen | 0:feaa05d35ccf | 31 | |
AlexAllen | 0:feaa05d35ccf | 32 | /** Create the GPS interface, connected to the specified serial port |
AlexAllen | 0:feaa05d35ccf | 33 | */ |
AlexAllen | 0:feaa05d35ccf | 34 | GPS(PinName tx, PinName rx); |
AlexAllen | 0:feaa05d35ccf | 35 | |
AlexAllen | 0:feaa05d35ccf | 36 | /** Sample the incoming GPS data, returning whether there is a lock |
AlexAllen | 0:feaa05d35ccf | 37 | * |
AlexAllen | 0:feaa05d35ccf | 38 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
AlexAllen | 0:feaa05d35ccf | 39 | */ |
AlexAllen | 0:feaa05d35ccf | 40 | int sample(); |
AlexAllen | 0:feaa05d35ccf | 41 | |
AlexAllen | 0:feaa05d35ccf | 42 | /** The longitude (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 43 | float longitude; |
AlexAllen | 0:feaa05d35ccf | 44 | |
AlexAllen | 0:feaa05d35ccf | 45 | /** The latitude (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 46 | float latitude; |
AlexAllen | 0:feaa05d35ccf | 47 | |
AlexAllen | 0:feaa05d35ccf | 48 | /** The altitude (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 49 | float altitude; |
AlexAllen | 0:feaa05d35ccf | 50 | |
AlexAllen | 0:feaa05d35ccf | 51 | /** The time (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 52 | float time; |
AlexAllen | 0:feaa05d35ccf | 53 | |
AlexAllen | 0:feaa05d35ccf | 54 | /** North/south east/west (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 55 | char ns, ew; |
AlexAllen | 0:feaa05d35ccf | 56 | |
AlexAllen | 0:feaa05d35ccf | 57 | /** The number of satillites (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 58 | int satillites; |
AlexAllen | 0:feaa05d35ccf | 59 | |
AlexAllen | 0:feaa05d35ccf | 60 | /** Horizontal dilution of precision (call sample() to set) */ |
AlexAllen | 0:feaa05d35ccf | 61 | float HDOP; |
AlexAllen | 0:feaa05d35ccf | 62 | |
AlexAllen | 0:feaa05d35ccf | 63 | /** Message that comes back from the GPS */ |
AlexAllen | 0:feaa05d35ccf | 64 | char msg[256]; |
AlexAllen | 0:feaa05d35ccf | 65 | |
AlexAllen | 0:feaa05d35ccf | 66 | /** Does the gps have a lock */ |
AlexAllen | 0:feaa05d35ccf | 67 | int lock; |
AlexAllen | 0:feaa05d35ccf | 68 | |
AlexAllen | 0:feaa05d35ccf | 69 | |
AlexAllen | 0:feaa05d35ccf | 70 | |
AlexAllen | 0:feaa05d35ccf | 71 | private: |
AlexAllen | 0:feaa05d35ccf | 72 | float trunc(float v); |
AlexAllen | 0:feaa05d35ccf | 73 | void getline(); |
AlexAllen | 0:feaa05d35ccf | 74 | |
AlexAllen | 0:feaa05d35ccf | 75 | Serial _gps; |
AlexAllen | 0:feaa05d35ccf | 76 | |
AlexAllen | 0:feaa05d35ccf | 77 | }; |
AlexAllen | 0:feaa05d35ccf | 78 | |
AlexAllen | 0:feaa05d35ccf | 79 | #endif |