Simple IoT Board用のライブラリです。 ESP8266ライブラリの軽量化 送信のみのソフトシリアルライブラリを含んでいます。
Dependents: SITB_HttpGetSample SITB_IFTTTSample SITB_INA226PRC AmbientExampleSITB ... more
SoftSerialSendOnly/SoftSerial_Ticker.h@0:890c12951e96, 2015-11-15 (annotated)
- Committer:
- jksoft
- Date:
- Sun Nov 15 13:36:44 2015 +0000
- Revision:
- 0:890c12951e96
??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:890c12951e96 | 1 | //A modified version of the regular ticker/timeout libraries to allow us to do timeout without losing accuracy |
jksoft | 0:890c12951e96 | 2 | |
jksoft | 0:890c12951e96 | 3 | #ifndef FLEXTICKER_H |
jksoft | 0:890c12951e96 | 4 | #define FLEXTICKER_H |
jksoft | 0:890c12951e96 | 5 | |
jksoft | 0:890c12951e96 | 6 | #include "mbed.h" |
jksoft | 0:890c12951e96 | 7 | |
jksoft | 0:890c12951e96 | 8 | class FlexTicker: public TimerEvent { |
jksoft | 0:890c12951e96 | 9 | public: |
jksoft | 0:890c12951e96 | 10 | template<typename T> |
jksoft | 0:890c12951e96 | 11 | void attach(T* tptr, void (T::*mptr)(void)) { |
jksoft | 0:890c12951e96 | 12 | _function.attach(tptr, mptr); |
jksoft | 0:890c12951e96 | 13 | } |
jksoft | 0:890c12951e96 | 14 | |
jksoft | 0:890c12951e96 | 15 | /** Detach the function |
jksoft | 0:890c12951e96 | 16 | */ |
jksoft | 0:890c12951e96 | 17 | void detach() { |
jksoft | 0:890c12951e96 | 18 | remove(); |
jksoft | 0:890c12951e96 | 19 | } |
jksoft | 0:890c12951e96 | 20 | |
jksoft | 0:890c12951e96 | 21 | void setNext(int delay) { |
jksoft | 0:890c12951e96 | 22 | insert(event.timestamp + delay); |
jksoft | 0:890c12951e96 | 23 | } |
jksoft | 0:890c12951e96 | 24 | |
jksoft | 0:890c12951e96 | 25 | void prime(void) { |
jksoft | 0:890c12951e96 | 26 | event.timestamp = us_ticker_read(); |
jksoft | 0:890c12951e96 | 27 | } |
jksoft | 0:890c12951e96 | 28 | |
jksoft | 0:890c12951e96 | 29 | protected: |
jksoft | 0:890c12951e96 | 30 | virtual void handler() { |
jksoft | 0:890c12951e96 | 31 | _function.call(); |
jksoft | 0:890c12951e96 | 32 | } |
jksoft | 0:890c12951e96 | 33 | |
jksoft | 0:890c12951e96 | 34 | unsigned int _delay; |
jksoft | 0:890c12951e96 | 35 | FunctionPointer _function; |
jksoft | 0:890c12951e96 | 36 | }; |
jksoft | 0:890c12951e96 | 37 | |
jksoft | 0:890c12951e96 | 38 | #endif |