Junichi Katsu
/
MilkcocoaSampleESP8266
データの保存、更新、取得ができるWebサービス「milkcocoa」に接続し、データのプッシュ、送信、取得ができるライブラリを使ったサンプルです。ESP8266版 https://mlkcca.com/
SoftSerialSendOnly/SoftSerial_Ticker.h@4:d40cc9301d1e, 2016-02-29 (annotated)
- Committer:
- jksoft
- Date:
- Mon Feb 29 09:19:56 2016 +0000
- Revision:
- 4:d40cc9301d1e
- Parent:
- 0:82d5445a9461
????????????????; Milkcocoa????????
Who changed what in which revision?
User | Revision | Line number | New 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 |