Allows for a GPS module to be connected to a serial port and exposes an easy to use API to get the GPS data.
Fork of MODGPS by
GPS_Time.h@5:7f130f85d5a4, 2011-04-20 (annotated)
- Committer:
- AjK
- Date:
- Wed Apr 20 09:15:07 2011 +0000
- Revision:
- 5:7f130f85d5a4
- Parent:
- 2:8aa059e7d8b1
1.15 See ChangeLog.c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:db98027c0bbb | 1 | /* |
AjK | 0:db98027c0bbb | 2 | Copyright (c) 2010 Andy Kirkham |
AjK | 0:db98027c0bbb | 3 | |
AjK | 0:db98027c0bbb | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy |
AjK | 0:db98027c0bbb | 5 | of this software and associated documentation files (the "Software"), to deal |
AjK | 0:db98027c0bbb | 6 | in the Software without restriction, including without limitation the rights |
AjK | 0:db98027c0bbb | 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
AjK | 0:db98027c0bbb | 8 | copies of the Software, and to permit persons to whom the Software is |
AjK | 0:db98027c0bbb | 9 | furnished to do so, subject to the following conditions: |
AjK | 0:db98027c0bbb | 10 | |
AjK | 0:db98027c0bbb | 11 | The above copyright notice and this permission notice shall be included in |
AjK | 0:db98027c0bbb | 12 | all copies or substantial portions of the Software. |
AjK | 0:db98027c0bbb | 13 | |
AjK | 0:db98027c0bbb | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
AjK | 0:db98027c0bbb | 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
AjK | 0:db98027c0bbb | 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
AjK | 0:db98027c0bbb | 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
AjK | 0:db98027c0bbb | 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
AjK | 0:db98027c0bbb | 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
AjK | 0:db98027c0bbb | 20 | THE SOFTWARE. |
AjK | 0:db98027c0bbb | 21 | */ |
AjK | 0:db98027c0bbb | 22 | |
AjK | 0:db98027c0bbb | 23 | #ifndef GPS_TIME_H |
AjK | 0:db98027c0bbb | 24 | #define GPS_TIME_H |
AjK | 0:db98027c0bbb | 25 | |
AjK | 0:db98027c0bbb | 26 | #include "mbed.h" |
AjK | 0:db98027c0bbb | 27 | |
AjK | 0:db98027c0bbb | 28 | /** GPS_Time definition. |
AjK | 0:db98027c0bbb | 29 | */ |
AjK | 0:db98027c0bbb | 30 | class GPS_Time { |
AjK | 0:db98027c0bbb | 31 | public: |
AjK | 0:db98027c0bbb | 32 | |
AjK | 0:db98027c0bbb | 33 | //! The year |
AjK | 0:db98027c0bbb | 34 | int year; |
AjK | 0:db98027c0bbb | 35 | //! The month |
AjK | 0:db98027c0bbb | 36 | int month; |
AjK | 0:db98027c0bbb | 37 | //! The day |
AjK | 0:db98027c0bbb | 38 | int day; |
AjK | 0:db98027c0bbb | 39 | //! The hour |
AjK | 0:db98027c0bbb | 40 | int hour; |
AjK | 0:db98027c0bbb | 41 | //! The minute |
AjK | 0:db98027c0bbb | 42 | int minute; |
AjK | 0:db98027c0bbb | 43 | //! The second |
AjK | 0:db98027c0bbb | 44 | int second; |
AjK | 0:db98027c0bbb | 45 | //! Tenths of a second |
AjK | 0:db98027c0bbb | 46 | int tenths; |
AjK | 0:db98027c0bbb | 47 | //! Hundredths of a second |
AjK | 0:db98027c0bbb | 48 | int hundreths; |
AjK | 0:db98027c0bbb | 49 | //! Time status. |
AjK | 0:db98027c0bbb | 50 | char status; |
AjK | 2:8aa059e7d8b1 | 51 | //! The velocity (in knots) |
AjK | 2:8aa059e7d8b1 | 52 | double velocity; |
AjK | 2:8aa059e7d8b1 | 53 | //! The track (in decimal degrees true) |
AjK | 2:8aa059e7d8b1 | 54 | double track; |
AjK | 2:8aa059e7d8b1 | 55 | //! The magnetic variation direction |
AjK | 2:8aa059e7d8b1 | 56 | char magvar_dir; |
AjK | 2:8aa059e7d8b1 | 57 | //! The magnetic variation value |
AjK | 2:8aa059e7d8b1 | 58 | double magvar; |
AjK | 0:db98027c0bbb | 59 | |
AjK | 0:db98027c0bbb | 60 | GPS_Time(); |
AjK | 0:db98027c0bbb | 61 | void fractionalReset(void) { tenths = hundreths = 0; } |
AjK | 0:db98027c0bbb | 62 | void operator++(); |
AjK | 0:db98027c0bbb | 63 | void operator++(int); |
AjK | 0:db98027c0bbb | 64 | GPS_Time * timeNow(GPS_Time *n); |
AjK | 0:db98027c0bbb | 65 | GPS_Time * timeNow(void) { return timeNow(NULL); } |
AjK | 0:db98027c0bbb | 66 | void nmea_rmc(char *s); |
AjK | 2:8aa059e7d8b1 | 67 | double velocity_knots(void) { return velocity; } |
AjK | 2:8aa059e7d8b1 | 68 | double velocity_kph(void) { return (velocity * 1.852); } |
AjK | 2:8aa059e7d8b1 | 69 | double velocity_mps(void) { return velocity_kph() / 3600.0; } |
AjK | 2:8aa059e7d8b1 | 70 | double velocity_mph(void) { return velocity_kph() / 0.621371192; } |
AjK | 2:8aa059e7d8b1 | 71 | double track_over_ground(void) { return track; } |
AjK | 2:8aa059e7d8b1 | 72 | double magnetic_variation(void) { return magvar_dir == 'W' ? (magvar * -1.0) : (magvar); } |
AjK | 0:db98027c0bbb | 73 | double julian_day_number(GPS_Time *t); |
AjK | 0:db98027c0bbb | 74 | double julian_date(GPS_Time *t); |
AjK | 0:db98027c0bbb | 75 | double julian_day_number(void) { return julian_day_number(this); } |
AjK | 0:db98027c0bbb | 76 | double julian_date(void) { return julian_date(this); } |
AjK | 0:db98027c0bbb | 77 | double siderealDegrees(double jd, double longitude); |
AjK | 0:db98027c0bbb | 78 | double siderealDegrees(GPS_Time *t, double longitude); |
AjK | 0:db98027c0bbb | 79 | double siderealHA(double jd, double longitude); |
AjK | 0:db98027c0bbb | 80 | double siderealHA(GPS_Time *t, double longitude); |
AjK | 5:7f130f85d5a4 | 81 | time_t to_C_tm(bool set = false); |
AjK | 0:db98027c0bbb | 82 | }; |
AjK | 0:db98027c0bbb | 83 | |
AjK | 0:db98027c0bbb | 84 | #endif |
AjK | 0:db98027c0bbb | 85 |