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@5:8444ec4245e7, 2012-02-23 (annotated)
- Committer:
- tylerjw
- Date:
- Thu Feb 23 05:40:54 2012 +0000
- Revision:
- 5:8444ec4245e7
- Parent:
- 4:d47805009bbd
- Child:
- 6:204487243310
0.3 - openLog working and nmea files convert to earth files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tylerjw | 0:ce5f06c3895f | 1 | #include "mbed.h" |
tylerjw | 5:8444ec4245e7 | 2 | #include "openLog.h" |
tylerjw | 0:ce5f06c3895f | 3 | |
tylerjw | 0:ce5f06c3895f | 4 | #ifndef MBED_GPS_H |
tylerjw | 0:ce5f06c3895f | 5 | #define MBED_GPS_H |
tylerjw | 0:ce5f06c3895f | 6 | |
tylerjw | 1:2ace7946a246 | 7 | #define NO_LOCK 1 |
tylerjw | 1:2ace7946a246 | 8 | #define NOT_PARSED 2 |
tylerjw | 3:9cba44dd2f2b | 9 | #define GGA 3 |
tylerjw | 3:9cba44dd2f2b | 10 | #define GLL 4 |
tylerjw | 3:9cba44dd2f2b | 11 | #define RMC 5 |
tylerjw | 3:9cba44dd2f2b | 12 | #define VTG 6 |
tylerjw | 1:2ace7946a246 | 13 | |
tylerjw | 0:ce5f06c3895f | 14 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
tylerjw | 0:ce5f06c3895f | 15 | class GPS { |
tylerjw | 0:ce5f06c3895f | 16 | public: |
tylerjw | 0:ce5f06c3895f | 17 | |
tylerjw | 0:ce5f06c3895f | 18 | /** Create the GPS interface, connected to the specified serial port |
tylerjw | 0:ce5f06c3895f | 19 | */ |
tylerjw | 0:ce5f06c3895f | 20 | GPS(PinName tx, PinName rx); |
tylerjw | 0:ce5f06c3895f | 21 | |
tylerjw | 0:ce5f06c3895f | 22 | /** Sample the incoming GPS data, returning whether there is a lock |
tylerjw | 0:ce5f06c3895f | 23 | * |
tylerjw | 0:ce5f06c3895f | 24 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
tylerjw | 0:ce5f06c3895f | 25 | */ |
tylerjw | 0:ce5f06c3895f | 26 | int sample(); |
tylerjw | 0:ce5f06c3895f | 27 | float get_nmea_longitude(); |
tylerjw | 0:ce5f06c3895f | 28 | float get_nmea_latitude(); |
tylerjw | 0:ce5f06c3895f | 29 | float get_dec_longitude(); |
tylerjw | 0:ce5f06c3895f | 30 | float get_dec_latitude(); |
tylerjw | 0:ce5f06c3895f | 31 | float get_msl_altitude(); |
tylerjw | 3:9cba44dd2f2b | 32 | float get_course_t(); |
tylerjw | 3:9cba44dd2f2b | 33 | float get_course_m(); |
tylerjw | 3:9cba44dd2f2b | 34 | float get_speed_k(); |
tylerjw | 3:9cba44dd2f2b | 35 | float get_speed_km(); |
tylerjw | 0:ce5f06c3895f | 36 | int get_satelites(); |
tylerjw | 0:ce5f06c3895f | 37 | |
tylerjw | 4:d47805009bbd | 38 | #ifdef OPEN_LOG |
tylerjw | 5:8444ec4245e7 | 39 | void start_log(void); |
tylerjw | 4:d47805009bbd | 40 | void new_file(void); |
tylerjw | 4:d47805009bbd | 41 | void stop_log(void); |
tylerjw | 4:d47805009bbd | 42 | #endif |
tylerjw | 0:ce5f06c3895f | 43 | |
tylerjw | 0:ce5f06c3895f | 44 | private: |
tylerjw | 0:ce5f06c3895f | 45 | float nmea_to_dec(float, char); |
tylerjw | 0:ce5f06c3895f | 46 | float trunc(float v); |
tylerjw | 0:ce5f06c3895f | 47 | void getline(); |
tylerjw | 0:ce5f06c3895f | 48 | |
tylerjw | 0:ce5f06c3895f | 49 | Serial _gps; |
tylerjw | 5:8444ec4245e7 | 50 | char msg[1024]; |
tylerjw | 4:d47805009bbd | 51 | bool is_logging; |
tylerjw | 4:d47805009bbd | 52 | #ifdef OPEN_LOG |
tylerjw | 4:d47805009bbd | 53 | Logger _openLog; |
tylerjw | 4:d47805009bbd | 54 | #endif |
tylerjw | 0:ce5f06c3895f | 55 | // calculated values |
tylerjw | 0:ce5f06c3895f | 56 | float dec_longitude; |
tylerjw | 0:ce5f06c3895f | 57 | float dec_latitude; |
tylerjw | 0:ce5f06c3895f | 58 | |
tylerjw | 0:ce5f06c3895f | 59 | // GGA - Global Positioning System Fixed Data |
tylerjw | 0:ce5f06c3895f | 60 | float nmea_longitude; |
tylerjw | 0:ce5f06c3895f | 61 | float nmea_latitude; |
tylerjw | 0:ce5f06c3895f | 62 | float utc_time; |
tylerjw | 0:ce5f06c3895f | 63 | char ns, ew; |
tylerjw | 0:ce5f06c3895f | 64 | int lock; |
tylerjw | 0:ce5f06c3895f | 65 | int satelites; |
tylerjw | 0:ce5f06c3895f | 66 | float hdop; |
tylerjw | 0:ce5f06c3895f | 67 | float msl_altitude; |
tylerjw | 0:ce5f06c3895f | 68 | char msl_units; |
tylerjw | 0:ce5f06c3895f | 69 | |
tylerjw | 0:ce5f06c3895f | 70 | // RMC - Recommended Minimmum Specific GNS Data |
tylerjw | 0:ce5f06c3895f | 71 | char rmc_status; |
tylerjw | 2:0c9ade531a5b | 72 | float speed_k; |
tylerjw | 2:0c9ade531a5b | 73 | float course_d; |
tylerjw | 0:ce5f06c3895f | 74 | int date; |
tylerjw | 2:0c9ade531a5b | 75 | |
tylerjw | 2:0c9ade531a5b | 76 | // GLL |
tylerjw | 2:0c9ade531a5b | 77 | char gll_status; |
tylerjw | 2:0c9ade531a5b | 78 | |
tylerjw | 2:0c9ade531a5b | 79 | // VTG - Course over ground, ground speed |
tylerjw | 2:0c9ade531a5b | 80 | float course_t; // ground speed true |
tylerjw | 2:0c9ade531a5b | 81 | char course_t_unit; |
tylerjw | 2:0c9ade531a5b | 82 | float course_m; // magnetic |
tylerjw | 2:0c9ade531a5b | 83 | char course_m_unit; |
tylerjw | 2:0c9ade531a5b | 84 | char speed_k_unit; |
tylerjw | 2:0c9ade531a5b | 85 | float speed_km; // speek km/hr |
tylerjw | 2:0c9ade531a5b | 86 | char speed_km_unit; |
tylerjw | 0:ce5f06c3895f | 87 | }; |
tylerjw | 0:ce5f06c3895f | 88 | |
tylerjw | 0:ce5f06c3895f | 89 | #endif |