2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Ublox6.h@23:5e61cf4a8c34, 2018-12-18 (annotated)
- Committer:
- shimniok
- Date:
- Tue Dec 18 17:09:38 2018 +0000
- Revision:
- 23:5e61cf4a8c34
- Parent:
- 20:043987d06f8d
implemented callback for gps data ready
Who changed what in which revision?
User | Revision | Line number | New 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 | 19:0d1728091519 | 14 | // TODO 3 move this somewhere else? |
shimniok | 16:eb28d0f64a9b | 15 | static const int lag=40; // number of updater steps by which gps output lags reality |
shimniok | 16:eb28d0f64a9b | 16 | |
shimniok | 18:3f8a8f6e3cc1 | 17 | Ublox6(); |
shimniok | 18:3f8a8f6e3cc1 | 18 | |
shimniok | 16:eb28d0f64a9b | 19 | /** |
shimniok | 16:eb28d0f64a9b | 20 | * UBX protocol parser (Wayne Holder) |
shimniok | 16:eb28d0f64a9b | 21 | * @param cc is the character to parse |
shimniok | 19:0d1728091519 | 22 | * @return 1 when entire packet of data obtained, 0 otherwise |
shimniok | 16:eb28d0f64a9b | 23 | */ |
shimniok | 20:043987d06f8d | 24 | int parse(int cc); |
shimniok | 16:eb28d0f64a9b | 25 | |
shimniok | 23:5e61cf4a8c34 | 26 | void subscribe(Callback<void()> cb); |
shimniok | 23:5e61cf4a8c34 | 27 | |
shimniok | 19:0d1728091519 | 28 | /** Read the latest data from GPS |
shimniok | 19:0d1728091519 | 29 | * @param lat latitude in degrees |
shimniok | 19:0d1728091519 | 30 | * @param lon longitude in degrees |
shimniok | 19:0d1728091519 | 31 | * @param course heading/course in degrees |
shimniok | 19:0d1728091519 | 32 | * @param speed speed m/s |
shimniok | 19:0d1728091519 | 33 | * @return all parameters |
shimniok | 16:eb28d0f64a9b | 34 | */ |
shimniok | 19:0d1728091519 | 35 | void read(double& lat, double& lon, float& course, float& speed, float& hdop, int& svcount); |
shimniok | 16:eb28d0f64a9b | 36 | |
shimniok | 16:eb28d0f64a9b | 37 | private: |
shimniok | 18:3f8a8f6e3cc1 | 38 | typedef struct { |
shimniok | 18:3f8a8f6e3cc1 | 39 | double lat; |
shimniok | 18:3f8a8f6e3cc1 | 40 | double lon; |
shimniok | 18:3f8a8f6e3cc1 | 41 | float course; |
shimniok | 18:3f8a8f6e3cc1 | 42 | float speed; |
shimniok | 18:3f8a8f6e3cc1 | 43 | float hdop; |
shimniok | 18:3f8a8f6e3cc1 | 44 | int svcount; |
shimniok | 18:3f8a8f6e3cc1 | 45 | } gps_data_t; |
shimniok | 18:3f8a8f6e3cc1 | 46 | |
shimniok | 18:3f8a8f6e3cc1 | 47 | gps_data_t tmp; |
shimniok | 18:3f8a8f6e3cc1 | 48 | gps_data_t latest; |
shimniok | 18:3f8a8f6e3cc1 | 49 | |
shimniok | 18:3f8a8f6e3cc1 | 50 | int _ready; // is data ready to be copied? |
shimniok | 18:3f8a8f6e3cc1 | 51 | bool _available; // |
shimniok | 18:3f8a8f6e3cc1 | 52 | |
shimniok | 23:5e61cf4a8c34 | 53 | Callback<void()> _callback; |
shimniok | 23:5e61cf4a8c34 | 54 | |
shimniok | 18:3f8a8f6e3cc1 | 55 | /* |
shimniok | 16:eb28d0f64a9b | 56 | float _latitude; // temp storage, latitude |
shimniok | 16:eb28d0f64a9b | 57 | float _longitude; // temp storage, longitude |
shimniok | 16:eb28d0f64a9b | 58 | float _hdop; // horiz dilution of precision |
shimniok | 16:eb28d0f64a9b | 59 | float _course_deg; // course in degrees |
shimniok | 16:eb28d0f64a9b | 60 | float _speed_mps; // speed in m/s |
shimniok | 18:3f8a8f6e3cc1 | 61 | int _svcount; // space vehicle (satellite) count |
shimniok | 18:3f8a8f6e3cc1 | 62 | */ |
shimniok | 16:eb28d0f64a9b | 63 | }; |
shimniok | 16:eb28d0f64a9b | 64 | |
shimniok | 16:eb28d0f64a9b | 65 | #endif |