![](/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.cpp
- Revision:
- 15:35c40765f7c3
- Parent:
- 14:1dd83e626153
- Child:
- 25:b8176ebb96c6
diff -r 1dd83e626153 -r 35c40765f7c3 Updater.cpp --- a/Updater.cpp Wed Dec 12 18:21:57 2018 +0000 +++ b/Updater.cpp Thu Dec 13 00:30:59 2018 +0000 @@ -2,24 +2,6 @@ #include "pinouts.h" #include "IncrementalEncoder.h" -void Updater::gyro(int g[3], float& dt) -{ - for (int i=0; i < 3; i++) { - g[i] = _gyro[i]; - } - dt = _dt; - - return; -} - -int Updater::encoder() -{ - int result=_ecount; - _ecount = 0; - - return result; -} - Updater *Updater::instance() { static Updater instance; @@ -28,7 +10,14 @@ } -void Updater::start(int interval_ms) +void Updater::setInterval(int interval_ms) +{ + _interval = interval_ms; + return; +} + + +void Updater::start() { Timer timer; @@ -36,12 +25,13 @@ lastTime = 0; t = &timer; t->start(); - + EventQueue *queue = mbed_highprio_event_queue(); Event<void()> event(queue, callback(this, &Updater::update)); - event.period(interval_ms); + event.period(_interval); event.post(); queue->dispatch_forever(); + return; } @@ -77,4 +67,25 @@ led2 = !led2; return; -} \ No newline at end of file +} + + +void Updater::gyro(int g[3], float& dt) +{ + for (int i=0; i < 3; i++) { + g[i] = _gyro[i]; + } + dt = _dt; + + return; +} + + +int Updater::encoder() +{ + int result=_ecount; + _ecount = 0; + + return result; +} +