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.h
00001 #include "mbed.h" 00002 00003 #ifndef MBED_GPS_H 00004 #define MBED_GPS_H 00005 00006 #define NO_LOCK 1 00007 #define NOT_PARSED 2 00008 #define GGA 3 00009 #define GLL 4 00010 #define RMC 5 00011 #define VTG 6 00012 #define ESTIMATE 7 00013 #define GSA 8 00014 00015 #define PI (3.141592653589793) 00016 00017 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ 00018 class GPS { 00019 public: 00020 00021 /** Create the GPS interface, connected to the specified serial port 00022 */ 00023 GPS(PinName tx, PinName rx); 00024 00025 /** Sample the incoming GPS data, returning whether there is a lock 00026 * 00027 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 00028 */ 00029 int sample(); 00030 char operating_mode; 00031 int navigation_mode; 00032 int satellites[12]; 00033 float pdop; 00034 float hdop; 00035 float vdop; 00036 char gprmc_status; 00037 00038 float get_nmea_longitude(); 00039 float get_nmea_latitude(); 00040 float get_dec_longitude(); 00041 float get_dec_latitude(); 00042 float get_msl_altitude(); 00043 float get_course_t(); 00044 float get_course_m(); 00045 float get_speed_k(); 00046 float get_speed_km(); 00047 int get_satelites(); 00048 float get_altitude_ft(); 00049 char * get_nmea_to_td(); 00050 char tdformat[32]; 00051 00052 // navigational functions 00053 float calc_course_to(float, float); 00054 double calc_dist_to_mi(float, float); 00055 double calc_dist_to_ft(float, float); 00056 double calc_dist_to_km(float, float); 00057 double calc_dist_to_m(float, float); 00058 00059 private: 00060 float nmea_to_dec(float, char); 00061 float trunc(float v); 00062 void getline(); 00063 void format_for_log(void); 00064 00065 Serial _gps; 00066 char msg[1024]; 00067 char bfr[1030]; 00068 00069 // calculated values 00070 float dec_longitude; 00071 float dec_latitude; 00072 float altitude_ft; 00073 00074 // GGA - Global Positioning System Fixed Data 00075 float nmea_longitude; 00076 float nmea_latitude; 00077 float utc_time; 00078 char ns, ew; 00079 int lock; 00080 int satelites; 00081 float msl_altitude; 00082 char msl_units; 00083 00084 // RMC - Recommended Minimmum Specific GNS Data 00085 char rmc_status; 00086 float speed_k; 00087 float course_d; 00088 int date; 00089 00090 // GLL 00091 char gll_status; 00092 00093 // VTG - Course over ground, ground speed 00094 float course_t; // ground speed true 00095 char course_t_unit; 00096 float course_m; // magnetic 00097 char course_m_unit; 00098 char speed_k_unit; 00099 float speed_km; // speek km/hr 00100 char speed_km_unit; 00101 }; 00102 00103 #endif
Generated on Wed Jul 20 2022 08:55:24 by
1.7.2