ワークショップ用に公開しているものです。

Dependencies:   mbed

Fork of Arch_Analog_Thermistor_Blinker by Yihui Xiong

Committer:
jksoft
Date:
Sat Feb 27 05:38:49 2016 +0000
Revision:
9:5a7dca00d87b
????????????

Who changed what in which revision?

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