ワークショップ用のサンプル

Dependencies:   Milkcocoa mbed

Fork of MilkcocoaSampleESP8266 by Junichi Katsu

Committer:
jksoft
Date:
Sat Feb 27 00:12:32 2016 +0000
Revision:
2:d2e4e7ce7a65
Parent:
0:82d5445a9461
??

Who changed what in which revision?

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