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.
Dependencies: SoftSerial MAX14690 Buffer
Fork of rtos_threading_with_callback by
GPS.h
00001 #include "mbed.h" 00002 #include "BufferedSerial.h" 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 00013 #define PI (3.141592653589793) 00014 00015 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ 00016 class GPS { 00017 public: 00018 00019 /** Create the GPS interface, connected to the specified serial port 00020 */ 00021 GPS(PinName tx, PinName rx); 00022 00023 /** Sample the incoming GPS data, returning whether there is a lock 00024 * 00025 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 00026 */ 00027 int sample(); 00028 float get_nmea_longitude(); 00029 float get_nmea_latitude(); 00030 float get_dec_longitude(); 00031 float get_dec_latitude(); 00032 float get_msl_altitude(); 00033 float get_course_t(); 00034 float get_course_m(); 00035 float get_speed_k(); 00036 float get_speed_km(); 00037 int get_satelites(); 00038 float get_altitude_ft(); 00039 00040 // navigational functions 00041 float calc_course_to(float, float); 00042 double calc_dist_to_mi(float, float); 00043 double calc_dist_to_ft(float, float); 00044 double calc_dist_to_km(float, float); 00045 double calc_dist_to_m(float, float); 00046 00047 void onInterrupt(){ 00048 printf("%d\r\n", _gps.readable()); 00049 } 00050 #ifdef OPEN_LOG 00051 void start_log(void); 00052 void new_file(void); 00053 void stop_log(void); 00054 #endif 00055 00056 private: 00057 float nmea_to_dec(float, char); 00058 float trunc(float v); 00059 void getline(); 00060 void format_for_log(void); 00061 00062 BufferedSerial _gps; 00063 char msg[1024]; 00064 char bfr[1030]; 00065 bool is_logging; 00066 #ifdef OPEN_LOG 00067 Logger _openLog; 00068 #endif 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 hdop; 00082 float msl_altitude; 00083 char msl_units; 00084 00085 // RMC - Recommended Minimmum Specific GNS Data 00086 char rmc_status; 00087 float speed_k; 00088 float course_d; 00089 int date; 00090 00091 // GLL 00092 char gll_status; 00093 00094 // VTG - Course over ground, ground speed 00095 float course_t; // ground speed true 00096 char course_t_unit; 00097 float course_m; // magnetic 00098 char course_m_unit; 00099 char speed_k_unit; 00100 float speed_km; // speek km/hr 00101 char speed_km_unit; 00102 }; 00103 00104 #endif
Generated on Tue Sep 13 2022 05:19:36 by
1.7.2
