2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Mon Jan 07 16:47:33 2019 +0000
Revision:
44:0d72a8a1288a
Parent:
43:9a285515f33a
Rewrote TinyGPS -> NMEA, GPS::read() now returns struct

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 43:9a285515f33a 1 #ifndef __GPS_H
shimniok 43:9a285515f33a 2 #define __GPS_H
shimniok 43:9a285515f33a 3
shimniok 44:0d72a8a1288a 4 /** GPS interface class for character-at-a-time parsing of GPS protocols
shimniok 44:0d72a8a1288a 5 * @author Michael Shimniok
shimniok 43:9a285515f33a 6 */
shimniok 43:9a285515f33a 7 class GPS {
shimniok 43:9a285515f33a 8 public:
shimniok 44:0d72a8a1288a 9 /// struct containing year, month, date, hour, minute, second, lat, lon, course, speed, hdop, svcount
shimniok 43:9a285515f33a 10 typedef struct {
shimniok 44:0d72a8a1288a 11 int year;
shimniok 44:0d72a8a1288a 12 int month;
shimniok 44:0d72a8a1288a 13 int date;
shimniok 44:0d72a8a1288a 14 int hour;
shimniok 44:0d72a8a1288a 15 int minute;
shimniok 44:0d72a8a1288a 16 int second;
shimniok 43:9a285515f33a 17 double lat;
shimniok 43:9a285515f33a 18 double lon;
shimniok 43:9a285515f33a 19 float course;
shimniok 43:9a285515f33a 20 float speed;
shimniok 43:9a285515f33a 21 float hdop;
shimniok 43:9a285515f33a 22 int svcount;
shimniok 43:9a285515f33a 23 } gps_data_t;
shimniok 43:9a285515f33a 24
shimniok 44:0d72a8a1288a 25 #ifdef __MBED__
shimniok 44:0d72a8a1288a 26 GPS(): _callback(0) {}
shimniok 44:0d72a8a1288a 27 #else
shimniok 44:0d72a8a1288a 28 GPS() {}
shimniok 44:0d72a8a1288a 29 #endif
shimniok 44:0d72a8a1288a 30
shimniok 44:0d72a8a1288a 31 /** Parse one character of protocol
shimniok 44:0d72a8a1288a 32 * @param c is the character to parse
shimniok 44:0d72a8a1288a 33 * @return 1 when entire packet of data obtained, 0 otherwise
shimniok 44:0d72a8a1288a 34 */
shimniok 44:0d72a8a1288a 35 virtual int parse(char c) = 0;
shimniok 44:0d72a8a1288a 36
shimniok 44:0d72a8a1288a 37 #ifdef __MBED__
shimniok 44:0d72a8a1288a 38 void subscribe(Callback<void()> cb) {
shimniok 44:0d72a8a1288a 39 _callback = cb;
shimniok 44:0d72a8a1288a 40 }
shimniok 44:0d72a8a1288a 41 #endif
shimniok 44:0d72a8a1288a 42
shimniok 44:0d72a8a1288a 43 /** Read the latest data from GPS
shimniok 44:0d72a8a1288a 44 * @returns gps_data_t struct with date, time, position, course, speed, hdop, and svcount
shimniok 44:0d72a8a1288a 45 */
shimniok 44:0d72a8a1288a 46 gps_data_t read() {
shimniok 44:0d72a8a1288a 47 return latest;
shimniok 44:0d72a8a1288a 48 }
shimniok 44:0d72a8a1288a 49
shimniok 44:0d72a8a1288a 50 protected:
shimniok 43:9a285515f33a 51 gps_data_t latest;
shimniok 43:9a285515f33a 52 gps_data_t tmp;
shimniok 43:9a285515f33a 53
shimniok 44:0d72a8a1288a 54 #ifdef __MBED__
shimniok 43:9a285515f33a 55 Callback<void()> _callback;
shimniok 44:0d72a8a1288a 56 #endif
shimniok 43:9a285515f33a 57 };
shimniok 43:9a285515f33a 58
shimniok 43:9a285515f33a 59 #endif