![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
2018 revision to classic DataBus AVC code.
Dependencies: LSM303DLM Servo SerialGraphicLCD L3G4200D IncrementalEncoder SimpleShell
Updater.h@14:1dd83e626153, 2018-12-12 (annotated)
- Committer:
- shimniok
- Date:
- Wed Dec 12 18:21:57 2018 +0000
- Revision:
- 14:1dd83e626153
- Parent:
- 13:5566df1250f1
- Child:
- 15:35c40765f7c3
Added encoder read to Updater, added documentation, added shell cmd to read encoder
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 11:8ec858b7c6d1 | 1 | #ifndef __UPDATER_H |
shimniok | 11:8ec858b7c6d1 | 2 | #define __UPDATER_H |
shimniok | 11:8ec858b7c6d1 | 3 | |
shimniok | 11:8ec858b7c6d1 | 4 | #include "mbed.h" |
shimniok | 11:8ec858b7c6d1 | 5 | #include "L3G4200D.h" |
shimniok | 11:8ec858b7c6d1 | 6 | |
shimniok | 12:3cd91e150d9c | 7 | class Updater: private mbed::NonCopyable<Updater> { |
shimniok | 11:8ec858b7c6d1 | 8 | public: |
shimniok | 14:1dd83e626153 | 9 | /** Start the updater running - cannot be exited! |
shimniok | 14:1dd83e626153 | 10 | * @param interval_ms is the interval in ms between calls to update() |
shimniok | 14:1dd83e626153 | 11 | * @note Makes use of RTOS EventQueue and Event. |
shimniok | 14:1dd83e626153 | 12 | */ |
shimniok | 11:8ec858b7c6d1 | 13 | void start(int interval_ms); |
shimniok | 14:1dd83e626153 | 14 | |
shimniok | 14:1dd83e626153 | 15 | /// Return singleton instance |
shimniok | 11:8ec858b7c6d1 | 16 | static Updater *instance(); |
shimniok | 14:1dd83e626153 | 17 | |
shimniok | 14:1dd83e626153 | 18 | /** Get gyro values |
shimniok | 14:1dd83e626153 | 19 | * @return g array of x, y, and z gyro values |
shimniok | 14:1dd83e626153 | 20 | * @return dt time since data last updated |
shimniok | 14:1dd83e626153 | 21 | */ |
shimniok | 13:5566df1250f1 | 22 | void gyro(int g[3], float& dt); |
shimniok | 14:1dd83e626153 | 23 | |
shimniok | 14:1dd83e626153 | 24 | /** Get encoder count |
shimniok | 14:1dd83e626153 | 25 | * @return encoder count since last call |
shimniok | 14:1dd83e626153 | 26 | */ |
shimniok | 14:1dd83e626153 | 27 | int encoder(); |
shimniok | 14:1dd83e626153 | 28 | |
shimniok | 11:8ec858b7c6d1 | 29 | private: |
shimniok | 14:1dd83e626153 | 30 | /// Basic constructor (singleton) |
shimniok | 14:1dd83e626153 | 31 | Updater() {} |
shimniok | 14:1dd83e626153 | 32 | |
shimniok | 14:1dd83e626153 | 33 | /// Update all sensors |
shimniok | 14:1dd83e626153 | 34 | void update(); |
shimniok | 14:1dd83e626153 | 35 | |
shimniok | 14:1dd83e626153 | 36 | Timer *t; // timer used to measure dt |
shimniok | 14:1dd83e626153 | 37 | int _gyro[3]; // gyro raw |
shimniok | 14:1dd83e626153 | 38 | int _ecount; // encoder count |
shimniok | 13:5566df1250f1 | 39 | float _dt; |
shimniok | 11:8ec858b7c6d1 | 40 | int thisTime; |
shimniok | 11:8ec858b7c6d1 | 41 | int lastTime; |
shimniok | 11:8ec858b7c6d1 | 42 | }; |
shimniok | 11:8ec858b7c6d1 | 43 | |
shimniok | 11:8ec858b7c6d1 | 44 | #endif |