2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Revision:
44:0d72a8a1288a
Parent:
43:9a285515f33a
--- a/GPS/GPS.h	Thu Jan 03 19:07:20 2019 +0000
+++ b/GPS/GPS.h	Mon Jan 07 16:47:33 2019 +0000
@@ -1,48 +1,19 @@
 #ifndef __GPS_H
 #define __GPS_H
 
-/** uBlox GPS UBX Protocol Reader
- * Parses uBlox GPS binary protocol
- * 
- * @author Wayne Holder; Ported to mbed by Michael Shimniok
+/** GPS interface class for character-at-a-time parsing of GPS protocols
+ * @author Michael Shimniok
  */
-#include "mbed.h"
-
 class GPS {
 public:
-    GPS(): _callback(0) {}
-
-    /**
-     * Parse one character of protocol
-     * @param c is the character to parse
-     * @return 1 when entire packet of data obtained, 0 otherwise
-     */    
-    virtual int parse(char c) = 0;
-
-    void subscribe(Callback<void()> cb) {
-        _callback = cb;
-    }
-
-    /** Read the latest data from GPS
-     * @param lat latitude in degrees
-     * @param lon longitude in degrees
-     * @param course heading/course in degrees
-     * @param speed speed m/s
-     * @param hdop horizontal dilution of precision
-     * @param svcount is the number of sattelites being tracked
-     * @return all parameters
-     */
-    void read(double& lat, double& lon, float& course, float& speed, float& hdop, int& svcount) {
-        lat = latest.lat;
-        lon = latest.lon;
-        course = latest.course;
-        speed = latest.speed;
-        hdop = latest.hdop;
-        svcount = latest.svcount;
-    }   
-
-protected:
+    /// struct containing year, month, date, hour, minute, second, lat, lon, course, speed, hdop, svcount
     typedef struct {
+        int year;
+        int month;
+        int date;
+        int hour;
+        int minute;
+        int second;
         double lat;
         double lon;
         float course;
@@ -51,10 +22,38 @@
         int svcount;
     } gps_data_t;
 
+#ifdef __MBED__
+    GPS(): _callback(0) {}
+#else
+    GPS() {}
+#endif
+
+    /** Parse one character of protocol
+     * @param c is the character to parse
+     * @return 1 when entire packet of data obtained, 0 otherwise
+     */
+    virtual int parse(char c) = 0;
+
+#ifdef __MBED__
+    void subscribe(Callback<void()> cb) {
+        _callback = cb;
+    }
+#endif
+
+    /** Read the latest data from GPS
+     * @returns gps_data_t struct with date, time, position, course, speed, hdop, and svcount
+     */
+    gps_data_t read() {
+        return latest;
+    }
+
+protected:
     gps_data_t latest;
     gps_data_t tmp;
 
+#ifdef __MBED__
     Callback<void()> _callback;
+#endif
 };
 
 #endif