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.
Fork of GPS by
GPS.h@4:6e2d98b5cb86, 2012-12-12 (annotated)
- Committer:
- tylerjw
- Date:
- Wed Dec 12 17:22:45 2012 +0000
- Revision:
- 4:6e2d98b5cb86
- Parent:
- 3:465354a08ff8
removed serial functions
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| tylerjw | 0:3611af72bfd7 | 1 | #include "mbed.h" |
| tylerjw | 0:3611af72bfd7 | 2 | |
| tylerjw | 0:3611af72bfd7 | 3 | #ifndef MBED_GPS_H |
| tylerjw | 0:3611af72bfd7 | 4 | #define MBED_GPS_H |
| tylerjw | 0:3611af72bfd7 | 5 | |
| tylerjw | 0:3611af72bfd7 | 6 | #define NO_LOCK 1 |
| tylerjw | 0:3611af72bfd7 | 7 | #define NOT_PARSED 2 |
| tylerjw | 0:3611af72bfd7 | 8 | #define GGA 3 |
| tylerjw | 0:3611af72bfd7 | 9 | #define GLL 4 |
| tylerjw | 0:3611af72bfd7 | 10 | #define RMC 5 |
| tylerjw | 0:3611af72bfd7 | 11 | #define VTG 6 |
| tylerjw | 0:3611af72bfd7 | 12 | |
| tylerjw | 0:3611af72bfd7 | 13 | #define PI (3.141592653589793) |
| tylerjw | 0:3611af72bfd7 | 14 | |
| tylerjw | 0:3611af72bfd7 | 15 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
| tylerjw | 0:3611af72bfd7 | 16 | class GPS { |
| tylerjw | 0:3611af72bfd7 | 17 | public: |
| tylerjw | 0:3611af72bfd7 | 18 | |
| tylerjw | 0:3611af72bfd7 | 19 | /** Create the GPS interface, connected to the specified serial port |
| tylerjw | 0:3611af72bfd7 | 20 | */ |
| tylerjw | 4:6e2d98b5cb86 | 21 | GPS(); |
| tylerjw | 0:3611af72bfd7 | 22 | |
| tylerjw | 0:3611af72bfd7 | 23 | /** Sample the incoming GPS data, returning whether there is a lock |
| tylerjw | 0:3611af72bfd7 | 24 | * |
| tylerjw | 0:3611af72bfd7 | 25 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
| tylerjw | 0:3611af72bfd7 | 26 | */ |
| tylerjw | 4:6e2d98b5cb86 | 27 | int sample(char *); |
| tylerjw | 0:3611af72bfd7 | 28 | float get_nmea_longitude(); |
| tylerjw | 0:3611af72bfd7 | 29 | float get_nmea_latitude(); |
| tylerjw | 0:3611af72bfd7 | 30 | float get_dec_longitude(); |
| tylerjw | 0:3611af72bfd7 | 31 | float get_dec_latitude(); |
| tylerjw | 0:3611af72bfd7 | 32 | float get_msl_altitude(); |
| tylerjw | 0:3611af72bfd7 | 33 | float get_course_t(); |
| tylerjw | 0:3611af72bfd7 | 34 | float get_course_m(); |
| tylerjw | 0:3611af72bfd7 | 35 | float get_speed_k(); |
| tylerjw | 0:3611af72bfd7 | 36 | float get_speed_km(); |
| tylerjw | 0:3611af72bfd7 | 37 | int get_satelites(); |
| tylerjw | 0:3611af72bfd7 | 38 | float get_altitude_ft(); |
| tylerjw | 0:3611af72bfd7 | 39 | |
| tylerjw | 0:3611af72bfd7 | 40 | // navigational functions |
| tylerjw | 0:3611af72bfd7 | 41 | float calc_course_to(float, float); |
| tylerjw | 0:3611af72bfd7 | 42 | double calc_dist_to_mi(float, float); |
| tylerjw | 0:3611af72bfd7 | 43 | double calc_dist_to_ft(float, float); |
| tylerjw | 0:3611af72bfd7 | 44 | double calc_dist_to_km(float, float); |
| tylerjw | 0:3611af72bfd7 | 45 | double calc_dist_to_m(float, float); |
| tylerjw | 0:3611af72bfd7 | 46 | |
| tylerjw | 0:3611af72bfd7 | 47 | private: |
| tylerjw | 0:3611af72bfd7 | 48 | float nmea_to_dec(float, char); |
| tylerjw | 0:3611af72bfd7 | 49 | float trunc(float v); |
| tylerjw | 0:3611af72bfd7 | 50 | |
| tylerjw | 0:3611af72bfd7 | 51 | // calculated values |
| tylerjw | 0:3611af72bfd7 | 52 | float dec_longitude; |
| tylerjw | 0:3611af72bfd7 | 53 | float dec_latitude; |
| tylerjw | 0:3611af72bfd7 | 54 | float altitude_ft; |
| tylerjw | 0:3611af72bfd7 | 55 | |
| tylerjw | 0:3611af72bfd7 | 56 | // GGA - Global Positioning System Fixed Data |
| tylerjw | 0:3611af72bfd7 | 57 | float nmea_longitude; |
| tylerjw | 0:3611af72bfd7 | 58 | float nmea_latitude; |
| tylerjw | 0:3611af72bfd7 | 59 | float utc_time; |
| tylerjw | 0:3611af72bfd7 | 60 | char ns, ew; |
| tylerjw | 0:3611af72bfd7 | 61 | int lock; |
| tylerjw | 0:3611af72bfd7 | 62 | int satelites; |
| tylerjw | 0:3611af72bfd7 | 63 | float hdop; |
| tylerjw | 0:3611af72bfd7 | 64 | float msl_altitude; |
| tylerjw | 0:3611af72bfd7 | 65 | char msl_units; |
| tylerjw | 0:3611af72bfd7 | 66 | |
| tylerjw | 0:3611af72bfd7 | 67 | // RMC - Recommended Minimmum Specific GNS Data |
| tylerjw | 0:3611af72bfd7 | 68 | char rmc_status; |
| tylerjw | 0:3611af72bfd7 | 69 | float speed_k; |
| tylerjw | 0:3611af72bfd7 | 70 | float course_d; |
| tylerjw | 0:3611af72bfd7 | 71 | int date; |
| tylerjw | 0:3611af72bfd7 | 72 | |
| tylerjw | 0:3611af72bfd7 | 73 | // GLL |
| tylerjw | 0:3611af72bfd7 | 74 | char gll_status; |
| tylerjw | 0:3611af72bfd7 | 75 | |
| tylerjw | 0:3611af72bfd7 | 76 | // VTG - Course over ground, ground speed |
| tylerjw | 0:3611af72bfd7 | 77 | float course_t; // ground speed true |
| tylerjw | 0:3611af72bfd7 | 78 | char course_t_unit; |
| tylerjw | 0:3611af72bfd7 | 79 | float course_m; // magnetic |
| tylerjw | 0:3611af72bfd7 | 80 | char course_m_unit; |
| tylerjw | 0:3611af72bfd7 | 81 | char speed_k_unit; |
| tylerjw | 0:3611af72bfd7 | 82 | float speed_km; // speek km/hr |
| tylerjw | 0:3611af72bfd7 | 83 | char speed_km_unit; |
| tylerjw | 0:3611af72bfd7 | 84 | }; |
| tylerjw | 0:3611af72bfd7 | 85 | |
| tylerjw | 0:3611af72bfd7 | 86 | #endif |
