ワークショップ用のサンプルプログラムです。

Dependencies:   DHT mbed

Committer:
jksoft
Date:
Fri Apr 29 21:07:24 2016 +0000
Revision:
0:a967c8649563
??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:a967c8649563 1 //A modified version of the regular ticker/timeout libraries to allow us to do timeout without losing accuracy
jksoft 0:a967c8649563 2
jksoft 0:a967c8649563 3 #ifndef FLEXTICKER_H
jksoft 0:a967c8649563 4 #define FLEXTICKER_H
jksoft 0:a967c8649563 5
jksoft 0:a967c8649563 6 #include "mbed.h"
jksoft 0:a967c8649563 7
jksoft 0:a967c8649563 8 class FlexTicker: public TimerEvent {
jksoft 0:a967c8649563 9 public:
jksoft 0:a967c8649563 10 template<typename T>
jksoft 0:a967c8649563 11 void attach(T* tptr, void (T::*mptr)(void)) {
jksoft 0:a967c8649563 12 _function.attach(tptr, mptr);
jksoft 0:a967c8649563 13 }
jksoft 0:a967c8649563 14
jksoft 0:a967c8649563 15 /** Detach the function
jksoft 0:a967c8649563 16 */
jksoft 0:a967c8649563 17 void detach() {
jksoft 0:a967c8649563 18 remove();
jksoft 0:a967c8649563 19 }
jksoft 0:a967c8649563 20
jksoft 0:a967c8649563 21 void setNext(int delay) {
jksoft 0:a967c8649563 22 insert(event.timestamp + delay);
jksoft 0:a967c8649563 23 }
jksoft 0:a967c8649563 24
jksoft 0:a967c8649563 25 void prime(void) {
jksoft 0:a967c8649563 26 event.timestamp = us_ticker_read();
jksoft 0:a967c8649563 27 }
jksoft 0:a967c8649563 28
jksoft 0:a967c8649563 29 protected:
jksoft 0:a967c8649563 30 virtual void handler() {
jksoft 0:a967c8649563 31 _function.call();
jksoft 0:a967c8649563 32 }
jksoft 0:a967c8649563 33
jksoft 0:a967c8649563 34 unsigned int _delay;
jksoft 0:a967c8649563 35 FunctionPointer _function;
jksoft 0:a967c8649563 36 };
jksoft 0:a967c8649563 37
jksoft 0:a967c8649563 38 #endif