![](/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
- Committer:
- shimniok
- Date:
- 2018-12-13
- Revision:
- 15:35c40765f7c3
- Parent:
- 14:1dd83e626153
- Child:
- 25:b8176ebb96c6
File content as of revision 15:35c40765f7c3:
#ifndef __UPDATER_H #define __UPDATER_H #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: /// 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 */ void gyro(int g[3], float& dt); /** Get encoder count * @return encoder count since last call */ int encoder(); private: /// Basic constructor (singleton) Updater() {} /// Update all sensors void update(); Timer *t; // timer used to measure dt int _gyro[3]; // gyro raw int _ecount; // encoder count float _dt; int _interval; int thisTime; int lastTime; }; #endif