Generation 3 of the Harp project
Dependencies: Servo TMP36 GZ buffered-serial1 chan_fatfs_sd nmea_parser watchdog mbed-rtos mbed
Fork of HARP2 by
GPS/GPS.h@2:0c9ade531a5b, 2012-02-22 (annotated)
- Committer:
- tylerjw
- Date:
- Wed Feb 22 04:37:13 2012 +0000
- Revision:
- 2:0c9ade531a5b
- Parent:
- 1:2ace7946a246
- Child:
- 3:9cba44dd2f2b
VTG parsing - no access
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tylerjw | 0:ce5f06c3895f | 1 | /* mbed EM-406 GPS Module Library |
tylerjw | 0:ce5f06c3895f | 2 | * Copyright (c) 2008-2010, sford |
tylerjw | 0:ce5f06c3895f | 3 | * |
tylerjw | 0:ce5f06c3895f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
tylerjw | 0:ce5f06c3895f | 5 | * of this software and associated documentation files (the "Software"), to deal |
tylerjw | 0:ce5f06c3895f | 6 | * in the Software without restriction, including without limitation the rights |
tylerjw | 0:ce5f06c3895f | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
tylerjw | 0:ce5f06c3895f | 8 | * copies of the Software, and to permit persons to whom the Software is |
tylerjw | 0:ce5f06c3895f | 9 | * furnished to do so, subject to the following conditions: |
tylerjw | 0:ce5f06c3895f | 10 | * |
tylerjw | 0:ce5f06c3895f | 11 | * The above copyright notice and this permission notice shall be included in |
tylerjw | 0:ce5f06c3895f | 12 | * all copies or substantial portions of the Software. |
tylerjw | 0:ce5f06c3895f | 13 | * |
tylerjw | 0:ce5f06c3895f | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
tylerjw | 0:ce5f06c3895f | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
tylerjw | 0:ce5f06c3895f | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
tylerjw | 0:ce5f06c3895f | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
tylerjw | 0:ce5f06c3895f | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
tylerjw | 0:ce5f06c3895f | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
tylerjw | 0:ce5f06c3895f | 20 | * THE SOFTWARE. |
tylerjw | 0:ce5f06c3895f | 21 | */ |
tylerjw | 0:ce5f06c3895f | 22 | |
tylerjw | 0:ce5f06c3895f | 23 | #include "mbed.h" |
tylerjw | 0:ce5f06c3895f | 24 | |
tylerjw | 0:ce5f06c3895f | 25 | #ifndef MBED_GPS_H |
tylerjw | 0:ce5f06c3895f | 26 | #define MBED_GPS_H |
tylerjw | 0:ce5f06c3895f | 27 | |
tylerjw | 1:2ace7946a246 | 28 | #define NO_LOCK 1 |
tylerjw | 1:2ace7946a246 | 29 | #define NOT_PARSED 2 |
tylerjw | 1:2ace7946a246 | 30 | #define PARSED 3 |
tylerjw | 1:2ace7946a246 | 31 | |
tylerjw | 0:ce5f06c3895f | 32 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
tylerjw | 0:ce5f06c3895f | 33 | class GPS { |
tylerjw | 0:ce5f06c3895f | 34 | public: |
tylerjw | 0:ce5f06c3895f | 35 | |
tylerjw | 0:ce5f06c3895f | 36 | /** Create the GPS interface, connected to the specified serial port |
tylerjw | 0:ce5f06c3895f | 37 | */ |
tylerjw | 0:ce5f06c3895f | 38 | GPS(PinName tx, PinName rx); |
tylerjw | 0:ce5f06c3895f | 39 | |
tylerjw | 0:ce5f06c3895f | 40 | /** Sample the incoming GPS data, returning whether there is a lock |
tylerjw | 0:ce5f06c3895f | 41 | * |
tylerjw | 0:ce5f06c3895f | 42 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
tylerjw | 0:ce5f06c3895f | 43 | */ |
tylerjw | 0:ce5f06c3895f | 44 | int sample(); |
tylerjw | 0:ce5f06c3895f | 45 | float get_nmea_longitude(); |
tylerjw | 0:ce5f06c3895f | 46 | float get_nmea_latitude(); |
tylerjw | 0:ce5f06c3895f | 47 | float get_dec_longitude(); |
tylerjw | 0:ce5f06c3895f | 48 | float get_dec_latitude(); |
tylerjw | 0:ce5f06c3895f | 49 | float get_msl_altitude(); |
tylerjw | 0:ce5f06c3895f | 50 | int get_satelites(); |
tylerjw | 0:ce5f06c3895f | 51 | |
tylerjw | 0:ce5f06c3895f | 52 | |
tylerjw | 0:ce5f06c3895f | 53 | private: |
tylerjw | 0:ce5f06c3895f | 54 | float nmea_to_dec(float, char); |
tylerjw | 0:ce5f06c3895f | 55 | float trunc(float v); |
tylerjw | 0:ce5f06c3895f | 56 | void getline(); |
tylerjw | 0:ce5f06c3895f | 57 | |
tylerjw | 0:ce5f06c3895f | 58 | Serial _gps; |
tylerjw | 0:ce5f06c3895f | 59 | char msg[256]; |
tylerjw | 0:ce5f06c3895f | 60 | |
tylerjw | 0:ce5f06c3895f | 61 | // calculated values |
tylerjw | 0:ce5f06c3895f | 62 | float dec_longitude; |
tylerjw | 0:ce5f06c3895f | 63 | float dec_latitude; |
tylerjw | 0:ce5f06c3895f | 64 | |
tylerjw | 0:ce5f06c3895f | 65 | // GGA - Global Positioning System Fixed Data |
tylerjw | 0:ce5f06c3895f | 66 | float nmea_longitude; |
tylerjw | 0:ce5f06c3895f | 67 | float nmea_latitude; |
tylerjw | 0:ce5f06c3895f | 68 | float utc_time; |
tylerjw | 0:ce5f06c3895f | 69 | char ns, ew; |
tylerjw | 0:ce5f06c3895f | 70 | int lock; |
tylerjw | 0:ce5f06c3895f | 71 | int satelites; |
tylerjw | 0:ce5f06c3895f | 72 | float hdop; |
tylerjw | 0:ce5f06c3895f | 73 | float msl_altitude; |
tylerjw | 0:ce5f06c3895f | 74 | char msl_units; |
tylerjw | 0:ce5f06c3895f | 75 | |
tylerjw | 0:ce5f06c3895f | 76 | // RMC - Recommended Minimmum Specific GNS Data |
tylerjw | 0:ce5f06c3895f | 77 | char rmc_status; |
tylerjw | 2:0c9ade531a5b | 78 | float speed_k; |
tylerjw | 2:0c9ade531a5b | 79 | float course_d; |
tylerjw | 0:ce5f06c3895f | 80 | int date; |
tylerjw | 2:0c9ade531a5b | 81 | |
tylerjw | 2:0c9ade531a5b | 82 | // GLL |
tylerjw | 2:0c9ade531a5b | 83 | char gll_status; |
tylerjw | 2:0c9ade531a5b | 84 | |
tylerjw | 2:0c9ade531a5b | 85 | // VTG - Course over ground, ground speed |
tylerjw | 2:0c9ade531a5b | 86 | float course_t; // ground speed true |
tylerjw | 2:0c9ade531a5b | 87 | char course_t_unit; |
tylerjw | 2:0c9ade531a5b | 88 | float course_m; // magnetic |
tylerjw | 2:0c9ade531a5b | 89 | char course_m_unit; |
tylerjw | 2:0c9ade531a5b | 90 | char speed_k_unit; |
tylerjw | 2:0c9ade531a5b | 91 | float speed_km; // speek km/hr |
tylerjw | 2:0c9ade531a5b | 92 | char speed_km_unit; |
tylerjw | 0:ce5f06c3895f | 93 | }; |
tylerjw | 0:ce5f06c3895f | 94 | |
tylerjw | 0:ce5f06c3895f | 95 | #endif |