Dependents:   V2_GPSRTC

Committer:
joosttromp
Date:
Fri Jun 17 12:37:03 2011 +0000
Revision:
0:62fa44dd600b

        

Who changed what in which revision?

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