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