![](/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
Diff: Updater.h
- Revision:
- 15:35c40765f7c3
- Parent:
- 14:1dd83e626153
- Child:
- 25:b8176ebb96c6
diff -r 1dd83e626153 -r 35c40765f7c3 Updater.h --- a/Updater.h Wed Dec 12 18:21:57 2018 +0000 +++ b/Updater.h Thu Dec 13 00:30:59 2018 +0000 @@ -4,17 +4,28 @@ #include "mbed.h" #include "L3G4200D.h" +/** Periodically reads sensor data + * This class executes an update function at a configurable interval to read + * and update sensor data. The class makes use of EventQueue and Event for + * task scheduling and runs events on the mbed_highprio_event_queue + */ class Updater: private mbed::NonCopyable<Updater> { public: - /** Start the updater running - cannot be exited! - * @param interval_ms is the interval in ms between calls to update() - * @note Makes use of RTOS EventQueue and Event. - */ - void start(int interval_ms); - /// Return singleton instance static Updater *instance(); + /** Sets the interval for running updater() + * @param interval_ms is the interval in milliseconds + */ + void setInterval(int interval_ms); + + /** Start the updater running + * @note Makes use of RTOS EventQueue and Event. The function runs in an + * infinite loop so best to start in a separate thread or from main thread + * when done with everything else. + */ + void start(); + /** Get gyro values * @return g array of x, y, and z gyro values * @return dt time since data last updated @@ -37,6 +48,7 @@ int _gyro[3]; // gyro raw int _ecount; // encoder count float _dt; + int _interval; int thisTime; int lastTime; };