2018 revision to classic DataBus AVC code.

Dependencies:   LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell

Committer:
shimniok
Date:
Fri Dec 14 00:36:06 2018 +0000
Revision:
18:3f8a8f6e3cc1
Parent:
16:eb28d0f64a9b
Child:
19:0d1728091519
add cmd to read gps; fixed gps flag bug, changed gps interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 16:eb28d0f64a9b 1 #ifndef __UBLOX6_H
shimniok 16:eb28d0f64a9b 2 #define __UBLOX6_H
shimniok 16:eb28d0f64a9b 3
shimniok 16:eb28d0f64a9b 4 /** uBlox GPS UBX Protocol Reader
shimniok 16:eb28d0f64a9b 5 * Parses uBlox GPS binary protocol
shimniok 16:eb28d0f64a9b 6 *
shimniok 16:eb28d0f64a9b 7 * @author Wayne Holder; Ported to mbed by Michael Shimniok
shimniok 16:eb28d0f64a9b 8 */
shimniok 16:eb28d0f64a9b 9 #include "mbed.h"
shimniok 16:eb28d0f64a9b 10
shimniok 16:eb28d0f64a9b 11 class Ublox6 {
shimniok 16:eb28d0f64a9b 12 public:
shimniok 16:eb28d0f64a9b 13 // TODO 3 convert this to time units
shimniok 16:eb28d0f64a9b 14 static const int lag=40; // number of updater steps by which gps output lags reality
shimniok 16:eb28d0f64a9b 15
shimniok 18:3f8a8f6e3cc1 16 Ublox6();
shimniok 18:3f8a8f6e3cc1 17
shimniok 16:eb28d0f64a9b 18 /**
shimniok 16:eb28d0f64a9b 19 * UBX protocol parser (Wayne Holder)
shimniok 16:eb28d0f64a9b 20 * @param cc is the character to parse
shimniok 16:eb28d0f64a9b 21 * @note stores parsed gps data in member variables and sets _available
shimniok 16:eb28d0f64a9b 22 * to true to indicate gps data is waiting.
shimniok 16:eb28d0f64a9b 23 */
shimniok 16:eb28d0f64a9b 24 void parse(unsigned char cc);
shimniok 16:eb28d0f64a9b 25
shimniok 18:3f8a8f6e3cc1 26 void read(double& lat, double& lon, float& course, float& speed, float& hdop, int& svcount);
shimniok 18:3f8a8f6e3cc1 27
shimniok 16:eb28d0f64a9b 28 /**
shimniok 16:eb28d0f64a9b 29 * get latitude
shimniok 16:eb28d0f64a9b 30 */
shimniok 16:eb28d0f64a9b 31 double latitude(void);
shimniok 16:eb28d0f64a9b 32
shimniok 16:eb28d0f64a9b 33 /**
shimniok 16:eb28d0f64a9b 34 * get longitude
shimniok 16:eb28d0f64a9b 35 */
shimniok 16:eb28d0f64a9b 36 double longitude(void);
shimniok 16:eb28d0f64a9b 37
shimniok 16:eb28d0f64a9b 38 /**
shimniok 16:eb28d0f64a9b 39 * Get Horizontal Dilution of Precision
shimniok 16:eb28d0f64a9b 40 * @return float horizontal dilution of precision
shimniok 16:eb28d0f64a9b 41 */
shimniok 16:eb28d0f64a9b 42 float hdop(void);
shimniok 16:eb28d0f64a9b 43
shimniok 16:eb28d0f64a9b 44 /**
shimniok 16:eb28d0f64a9b 45 * get count of active satellites
shimniok 16:eb28d0f64a9b 46 */
shimniok 16:eb28d0f64a9b 47 int sat_count(void);
shimniok 16:eb28d0f64a9b 48
shimniok 16:eb28d0f64a9b 49 /**
shimniok 16:eb28d0f64a9b 50 * get speed in m/s
shimniok 16:eb28d0f64a9b 51 */
shimniok 16:eb28d0f64a9b 52 float speed_mps(void);
shimniok 16:eb28d0f64a9b 53
shimniok 16:eb28d0f64a9b 54 /**
shimniok 16:eb28d0f64a9b 55 * get heading in degrees
shimniok 16:eb28d0f64a9b 56 */
shimniok 16:eb28d0f64a9b 57 float heading_deg(void);
shimniok 16:eb28d0f64a9b 58
shimniok 16:eb28d0f64a9b 59 /**
shimniok 16:eb28d0f64a9b 60 * determine if data is available to be used
shimniok 16:eb28d0f64a9b 61 */
shimniok 16:eb28d0f64a9b 62 bool available(void);
shimniok 16:eb28d0f64a9b 63
shimniok 16:eb28d0f64a9b 64 /**
shimniok 16:eb28d0f64a9b 65 * reset the data available flag
shimniok 16:eb28d0f64a9b 66 */
shimniok 16:eb28d0f64a9b 67 void reset_available(void);
shimniok 16:eb28d0f64a9b 68
shimniok 16:eb28d0f64a9b 69 private:
shimniok 18:3f8a8f6e3cc1 70 typedef struct {
shimniok 18:3f8a8f6e3cc1 71 double lat;
shimniok 18:3f8a8f6e3cc1 72 double lon;
shimniok 18:3f8a8f6e3cc1 73 float course;
shimniok 18:3f8a8f6e3cc1 74 float speed;
shimniok 18:3f8a8f6e3cc1 75 float hdop;
shimniok 18:3f8a8f6e3cc1 76 int svcount;
shimniok 18:3f8a8f6e3cc1 77 } gps_data_t;
shimniok 18:3f8a8f6e3cc1 78
shimniok 18:3f8a8f6e3cc1 79 gps_data_t tmp;
shimniok 18:3f8a8f6e3cc1 80 gps_data_t latest;
shimniok 18:3f8a8f6e3cc1 81
shimniok 18:3f8a8f6e3cc1 82 int _ready; // is data ready to be copied?
shimniok 18:3f8a8f6e3cc1 83 bool _available; //
shimniok 18:3f8a8f6e3cc1 84
shimniok 18:3f8a8f6e3cc1 85 /*
shimniok 16:eb28d0f64a9b 86 float _latitude; // temp storage, latitude
shimniok 16:eb28d0f64a9b 87 float _longitude; // temp storage, longitude
shimniok 16:eb28d0f64a9b 88 float _hdop; // horiz dilution of precision
shimniok 16:eb28d0f64a9b 89 float _course_deg; // course in degrees
shimniok 16:eb28d0f64a9b 90 float _speed_mps; // speed in m/s
shimniok 18:3f8a8f6e3cc1 91 int _svcount; // space vehicle (satellite) count
shimniok 18:3f8a8f6e3cc1 92 */
shimniok 16:eb28d0f64a9b 93 };
shimniok 16:eb28d0f64a9b 94
shimniok 16:eb28d0f64a9b 95 #endif