Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TestVirtualisation Bf_SoftSerial_IR
SoftSerial_Ticker_IR.h@12:79d63607bbb1, 2018-12-17 (annotated)
- Committer:
- kenjiArai
- Date:
- Mon Dec 17 03:38:12 2018 +0000
- Revision:
- 12:79d63607bbb1
- Parent:
- SoftSerial_Ticker.h@6:517082212c00
- Child:
- 13:2b5649a1278a
change only for Infra-Red LED & IR-Remote
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Sissors | 6:517082212c00 | 1 | //A modified version of the regular ticker/timeout libraries to allow us to do timeout without losing accuracy |
| Sissors | 6:517082212c00 | 2 | |
| kenjiArai | 12:79d63607bbb1 | 3 | #ifndef FLEXTICKERIR_H |
| kenjiArai | 12:79d63607bbb1 | 4 | #define FLEXTICKERIR_H |
| Sissors | 6:517082212c00 | 5 | |
| Sissors | 6:517082212c00 | 6 | #include "mbed.h" |
| Sissors | 6:517082212c00 | 7 | |
| kenjiArai | 12:79d63607bbb1 | 8 | class FlexTicker_IR: public TimerEvent { |
| Sissors | 6:517082212c00 | 9 | public: |
| Sissors | 6:517082212c00 | 10 | template<typename T> |
| Sissors | 6:517082212c00 | 11 | void attach(T* tptr, void (T::*mptr)(void)) { |
| Sissors | 6:517082212c00 | 12 | _function.attach(tptr, mptr); |
| Sissors | 6:517082212c00 | 13 | } |
| Sissors | 6:517082212c00 | 14 | |
| Sissors | 6:517082212c00 | 15 | /** Detach the function |
| Sissors | 6:517082212c00 | 16 | */ |
| Sissors | 6:517082212c00 | 17 | void detach() { |
| Sissors | 6:517082212c00 | 18 | remove(); |
| Sissors | 6:517082212c00 | 19 | } |
| Sissors | 6:517082212c00 | 20 | |
| Sissors | 6:517082212c00 | 21 | void setNext(int delay) { |
| Sissors | 6:517082212c00 | 22 | insert(event.timestamp + delay); |
| Sissors | 6:517082212c00 | 23 | } |
| Sissors | 6:517082212c00 | 24 | |
| Sissors | 6:517082212c00 | 25 | void prime(void) { |
| Sissors | 6:517082212c00 | 26 | event.timestamp = us_ticker_read(); |
| Sissors | 6:517082212c00 | 27 | } |
| Sissors | 6:517082212c00 | 28 | |
| Sissors | 6:517082212c00 | 29 | protected: |
| Sissors | 6:517082212c00 | 30 | virtual void handler() { |
| Sissors | 6:517082212c00 | 31 | _function.call(); |
| Sissors | 6:517082212c00 | 32 | } |
| Sissors | 6:517082212c00 | 33 | |
| Sissors | 6:517082212c00 | 34 | unsigned int _delay; |
| Sissors | 6:517082212c00 | 35 | FunctionPointer _function; |
| Sissors | 6:517082212c00 | 36 | }; |
| Sissors | 6:517082212c00 | 37 | |
| Sissors | 6:517082212c00 | 38 | #endif |