ads1115 only
Fork of mbed by
Diff: Ticker.h
- Revision:
- 89:552587b429a1
- Parent:
- 68:f37f3b9c9f0b
- Child:
- 98:8ab26030e058
diff -r 9327015d4013 -r 552587b429a1 Ticker.h --- a/Ticker.h Fri Aug 15 15:28:31 2014 +0100 +++ b/Ticker.h Fri Sep 12 16:41:52 2014 +0100 @@ -83,7 +83,7 @@ * @param fptr pointer to the function to be called * @param t the time between calls in micro-seconds */ - void attach_us(void (*fptr)(void), unsigned int t) { + void attach_us(void (*fptr)(void), timestamp_t t) { _function.attach(fptr); setup(t); } @@ -95,21 +95,26 @@ * @param t the time between calls in micro-seconds */ template<typename T> - void attach_us(T* tptr, void (T::*mptr)(void), unsigned int t) { + void attach_us(T* tptr, void (T::*mptr)(void), timestamp_t t) { _function.attach(tptr, mptr); setup(t); } + virtual ~Ticker() { + detach(); + } + /** Detach the function */ void detach(); protected: - void setup(unsigned int t); + void setup(timestamp_t t); virtual void handler(); - unsigned int _delay; - FunctionPointer _function; +protected: + timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */ + FunctionPointer _function; /**< Callback. */ }; } // namespace mbed