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 Andy K

Revision:
7:049436bc2225
Parent:
5:7f130f85d5a4
--- a/GPS_Time.cpp	Thu Apr 21 14:06:17 2011 +0000
+++ b/GPS_Time.cpp	Sat Sep 29 20:31:31 2018 +0000
@@ -22,8 +22,7 @@
 
 #include "GPS_Time.h"
 
-GPS_Time::GPS_Time() 
-{
+GPS_Time::GPS_Time() {
     year = 2000;
     month = 1;
     day = 1;
@@ -39,9 +38,7 @@
     magvar = 0;
 }
 
-time_t
-GPS_Time::to_C_tm(bool set) 
-{
+time_t GPS_Time::to_C_tm(bool set) {
     GPS_Time t;
     tm       ct;
     time_t   q;
@@ -62,10 +59,9 @@
     return q;
 }
 
-GPS_Time *
-GPS_Time::timeNow(GPS_Time *n)
-{
-    if (n == NULL) n = new GPS_Time;
+GPS_Time * GPS_Time::timeNow(GPS_Time *n) {
+    if (n == NULL) 
+        n = new GPS_Time;
     
     do {
         memcpy(n, this, sizeof(GPS_Time));
@@ -74,9 +70,7 @@
     return n;    
 }
 
-void
-GPS_Time::operator++()
-{
+void GPS_Time::operator++() {
     hundreths++;
     if (hundreths == 10) {
         hundreths = 0;
@@ -87,9 +81,7 @@
     }
 }
 
-void
-GPS_Time::operator++(int)
-{
+void GPS_Time::operator++(int) {
     const int days[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
     bool dateInc = false;
     
@@ -126,9 +118,7 @@
 }
 
 // $GPRMC,112709.735,A,5611.5340,N,00302.0306,W,000.0,307.0,150411,,,A*70
-void 
-GPS_Time::nmea_rmc(char *s)
-{
+void GPS_Time::nmea_rmc(char *s) {
     char *token;
     int  token_counter = 0;
     char *time   = (char *)NULL;
@@ -169,14 +159,12 @@
     }    
 }
 
-double 
-GPS_Time::julian_day_number(GPS_Time *t) {
+double GPS_Time::julian_day_number(GPS_Time *t) {
     double wikipedia_jdn = (double)(1461 * ((int)t->year + 4800 + ((int)t->month - 14) / 12)) / 4 + (367 * ((int)t->month - 2 - 12 * (((int)t->month - 14) / 12))) / 12 - (3 * (((int)t->year + 4900 + ((int)t->month - 14) / 12 ) / 100)) / 4 + (int)t->day - 32075;    
     return wikipedia_jdn;
 }
 
-double 
-GPS_Time::julian_date(GPS_Time *t) {
+double GPS_Time::julian_date(GPS_Time *t) {
     double hour, minute, second, jd;
     hour   = (double)t->hour;
     minute = (double)t->minute;
@@ -190,8 +178,7 @@
     return jd;
 }
 
-double 
-GPS_Time::siderealDegrees(double jd, double longitude) {
+double GPS_Time::siderealDegrees(double jd, double longitude) {
     double sidereal, gmst, lmst;
     double T  = jd - 2451545.0;
     double T1 = T / 36525.0;
@@ -210,20 +197,17 @@
     return lmst;
 }
 
-double 
-GPS_Time::siderealDegrees(GPS_Time *t, double longitude) {
+double GPS_Time::siderealDegrees(GPS_Time *t, double longitude) {
     if (t == NULL) t = new GPS_Time;
     return siderealDegrees(julian_date(t), longitude);
 }
 
-double 
-GPS_Time::siderealHA(double jd, double longitude) {
+double GPS_Time::siderealHA(double jd, double longitude) {
     double lmst = siderealDegrees(jd, longitude);
     return lmst / 360.0 * 24.0;
 }
 
-double 
-GPS_Time::siderealHA(GPS_Time *t, double longitude) {
+double GPS_Time::siderealHA(GPS_Time *t, double longitude) {
     double lmst = siderealDegrees(t, longitude);
     return lmst / 360.0 * 24.0;
 }