nmea gps library
Dependents: mDot_LoRa_Connect_CSA_Light mDot_LoRa_Connect_CSA_Rain mDot_LoRa_Connect_CSA_RH_Temp mDot_LoRa_Connect_CSA_Thermistor
GPS.h@0:3611af72bfd7, 2012-07-17 (annotated)
- Committer:
- tylerjw
- Date:
- Tue Jul 17 23:30:06 2012 +0000
- Revision:
- 0:3611af72bfd7
- Child:
- 1:39d75e44b214
[mbed] converted /GPS_DataLogger/GPS
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 | #include "openLog.h" |
tylerjw | 0:3611af72bfd7 | 3 | |
tylerjw | 0:3611af72bfd7 | 4 | #ifndef MBED_GPS_H |
tylerjw | 0:3611af72bfd7 | 5 | #define MBED_GPS_H |
tylerjw | 0:3611af72bfd7 | 6 | |
tylerjw | 0:3611af72bfd7 | 7 | #define NO_LOCK 1 |
tylerjw | 0:3611af72bfd7 | 8 | #define NOT_PARSED 2 |
tylerjw | 0:3611af72bfd7 | 9 | #define GGA 3 |
tylerjw | 0:3611af72bfd7 | 10 | #define GLL 4 |
tylerjw | 0:3611af72bfd7 | 11 | #define RMC 5 |
tylerjw | 0:3611af72bfd7 | 12 | #define VTG 6 |
tylerjw | 0:3611af72bfd7 | 13 | |
tylerjw | 0:3611af72bfd7 | 14 | #define PI (3.141592653589793) |
tylerjw | 0:3611af72bfd7 | 15 | |
tylerjw | 0:3611af72bfd7 | 16 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
tylerjw | 0:3611af72bfd7 | 17 | class GPS { |
tylerjw | 0:3611af72bfd7 | 18 | public: |
tylerjw | 0:3611af72bfd7 | 19 | |
tylerjw | 0:3611af72bfd7 | 20 | /** Create the GPS interface, connected to the specified serial port |
tylerjw | 0:3611af72bfd7 | 21 | */ |
tylerjw | 0:3611af72bfd7 | 22 | GPS(PinName tx, PinName rx); |
tylerjw | 0:3611af72bfd7 | 23 | |
tylerjw | 0:3611af72bfd7 | 24 | /** Sample the incoming GPS data, returning whether there is a lock |
tylerjw | 0:3611af72bfd7 | 25 | * |
tylerjw | 0:3611af72bfd7 | 26 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
tylerjw | 0:3611af72bfd7 | 27 | */ |
tylerjw | 0:3611af72bfd7 | 28 | int sample(); |
tylerjw | 0:3611af72bfd7 | 29 | float get_nmea_longitude(); |
tylerjw | 0:3611af72bfd7 | 30 | float get_nmea_latitude(); |
tylerjw | 0:3611af72bfd7 | 31 | float get_dec_longitude(); |
tylerjw | 0:3611af72bfd7 | 32 | float get_dec_latitude(); |
tylerjw | 0:3611af72bfd7 | 33 | float get_msl_altitude(); |
tylerjw | 0:3611af72bfd7 | 34 | float get_course_t(); |
tylerjw | 0:3611af72bfd7 | 35 | float get_course_m(); |
tylerjw | 0:3611af72bfd7 | 36 | float get_speed_k(); |
tylerjw | 0:3611af72bfd7 | 37 | float get_speed_km(); |
tylerjw | 0:3611af72bfd7 | 38 | int get_satelites(); |
tylerjw | 0:3611af72bfd7 | 39 | float get_altitude_ft(); |
tylerjw | 0:3611af72bfd7 | 40 | |
tylerjw | 0:3611af72bfd7 | 41 | // navigational functions |
tylerjw | 0:3611af72bfd7 | 42 | float calc_course_to(float, float); |
tylerjw | 0:3611af72bfd7 | 43 | double calc_dist_to_mi(float, float); |
tylerjw | 0:3611af72bfd7 | 44 | double calc_dist_to_ft(float, float); |
tylerjw | 0:3611af72bfd7 | 45 | double calc_dist_to_km(float, float); |
tylerjw | 0:3611af72bfd7 | 46 | double calc_dist_to_m(float, float); |
tylerjw | 0:3611af72bfd7 | 47 | |
tylerjw | 0:3611af72bfd7 | 48 | #ifdef OPEN_LOG |
tylerjw | 0:3611af72bfd7 | 49 | void start_log(void); |
tylerjw | 0:3611af72bfd7 | 50 | void new_file(void); |
tylerjw | 0:3611af72bfd7 | 51 | void stop_log(void); |
tylerjw | 0:3611af72bfd7 | 52 | #endif |
tylerjw | 0:3611af72bfd7 | 53 | |
tylerjw | 0:3611af72bfd7 | 54 | private: |
tylerjw | 0:3611af72bfd7 | 55 | float nmea_to_dec(float, char); |
tylerjw | 0:3611af72bfd7 | 56 | float trunc(float v); |
tylerjw | 0:3611af72bfd7 | 57 | void getline(); |
tylerjw | 0:3611af72bfd7 | 58 | void format_for_log(void); |
tylerjw | 0:3611af72bfd7 | 59 | |
tylerjw | 0:3611af72bfd7 | 60 | Serial _gps; |
tylerjw | 0:3611af72bfd7 | 61 | char msg[1024]; |
tylerjw | 0:3611af72bfd7 | 62 | char bfr[1030]; |
tylerjw | 0:3611af72bfd7 | 63 | bool is_logging; |
tylerjw | 0:3611af72bfd7 | 64 | #ifdef OPEN_LOG |
tylerjw | 0:3611af72bfd7 | 65 | Logger _openLog; |
tylerjw | 0:3611af72bfd7 | 66 | #endif |
tylerjw | 0:3611af72bfd7 | 67 | // calculated values |
tylerjw | 0:3611af72bfd7 | 68 | float dec_longitude; |
tylerjw | 0:3611af72bfd7 | 69 | float dec_latitude; |
tylerjw | 0:3611af72bfd7 | 70 | float altitude_ft; |
tylerjw | 0:3611af72bfd7 | 71 | |
tylerjw | 0:3611af72bfd7 | 72 | // GGA - Global Positioning System Fixed Data |
tylerjw | 0:3611af72bfd7 | 73 | float nmea_longitude; |
tylerjw | 0:3611af72bfd7 | 74 | float nmea_latitude; |
tylerjw | 0:3611af72bfd7 | 75 | float utc_time; |
tylerjw | 0:3611af72bfd7 | 76 | char ns, ew; |
tylerjw | 0:3611af72bfd7 | 77 | int lock; |
tylerjw | 0:3611af72bfd7 | 78 | int satelites; |
tylerjw | 0:3611af72bfd7 | 79 | float hdop; |
tylerjw | 0:3611af72bfd7 | 80 | float msl_altitude; |
tylerjw | 0:3611af72bfd7 | 81 | char msl_units; |
tylerjw | 0:3611af72bfd7 | 82 | |
tylerjw | 0:3611af72bfd7 | 83 | // RMC - Recommended Minimmum Specific GNS Data |
tylerjw | 0:3611af72bfd7 | 84 | char rmc_status; |
tylerjw | 0:3611af72bfd7 | 85 | float speed_k; |
tylerjw | 0:3611af72bfd7 | 86 | float course_d; |
tylerjw | 0:3611af72bfd7 | 87 | int date; |
tylerjw | 0:3611af72bfd7 | 88 | |
tylerjw | 0:3611af72bfd7 | 89 | // GLL |
tylerjw | 0:3611af72bfd7 | 90 | char gll_status; |
tylerjw | 0:3611af72bfd7 | 91 | |
tylerjw | 0:3611af72bfd7 | 92 | // VTG - Course over ground, ground speed |
tylerjw | 0:3611af72bfd7 | 93 | float course_t; // ground speed true |
tylerjw | 0:3611af72bfd7 | 94 | char course_t_unit; |
tylerjw | 0:3611af72bfd7 | 95 | float course_m; // magnetic |
tylerjw | 0:3611af72bfd7 | 96 | char course_m_unit; |
tylerjw | 0:3611af72bfd7 | 97 | char speed_k_unit; |
tylerjw | 0:3611af72bfd7 | 98 | float speed_km; // speek km/hr |
tylerjw | 0:3611af72bfd7 | 99 | char speed_km_unit; |
tylerjw | 0:3611af72bfd7 | 100 | }; |
tylerjw | 0:3611af72bfd7 | 101 | |
tylerjw | 0:3611af72bfd7 | 102 | #endif |