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@14:dc766032cdd6, 2018-12-28 (annotated)
- Committer:
- kenjiArai
- Date:
- Fri Dec 28 10:03:35 2018 +0000
- Revision:
- 14:dc766032cdd6
- Parent:
- 13:2b5649a1278a
- Child:
- 15:8d343be3382d
public release
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| kenjiArai | 13:2b5649a1278a | 1 | // Apply for Infrared LED and IR-Detector |
| kenjiArai | 14:dc766032cdd6 | 2 | // Modified by JH1PJL Dec. 28th, 2018 |
| kenjiArai | 13:2b5649a1278a | 3 | |
| kenjiArai | 13:2b5649a1278a | 4 | // A modified version of the regular ticker/timeout libraries |
| kenjiArai | 13:2b5649a1278a | 5 | // to allow us to do timeout without losing accuracy |
| Sissors | 6:517082212c00 | 6 | |
| kenjiArai | 12:79d63607bbb1 | 7 | #ifndef FLEXTICKERIR_H |
| kenjiArai | 12:79d63607bbb1 | 8 | #define FLEXTICKERIR_H |
| Sissors | 6:517082212c00 | 9 | |
| Sissors | 6:517082212c00 | 10 | #include "mbed.h" |
| Sissors | 6:517082212c00 | 11 | |
| kenjiArai | 12:79d63607bbb1 | 12 | class FlexTicker_IR: public TimerEvent { |
| Sissors | 6:517082212c00 | 13 | public: |
| Sissors | 6:517082212c00 | 14 | template<typename T> |
| Sissors | 6:517082212c00 | 15 | void attach(T* tptr, void (T::*mptr)(void)) { |
| Sissors | 6:517082212c00 | 16 | _function.attach(tptr, mptr); |
| Sissors | 6:517082212c00 | 17 | } |
| Sissors | 6:517082212c00 | 18 | |
| Sissors | 6:517082212c00 | 19 | /** Detach the function |
| Sissors | 6:517082212c00 | 20 | */ |
| Sissors | 6:517082212c00 | 21 | void detach() { |
| Sissors | 6:517082212c00 | 22 | remove(); |
| Sissors | 6:517082212c00 | 23 | } |
| Sissors | 6:517082212c00 | 24 | |
| Sissors | 6:517082212c00 | 25 | void setNext(int delay) { |
| Sissors | 6:517082212c00 | 26 | insert(event.timestamp + delay); |
| Sissors | 6:517082212c00 | 27 | } |
| Sissors | 6:517082212c00 | 28 | |
| kenjiArai | 13:2b5649a1278a | 29 | void prime(uint32_t offset) { |
| kenjiArai | 13:2b5649a1278a | 30 | event.timestamp = us_ticker_read() - offset; |
| Sissors | 6:517082212c00 | 31 | } |
| Sissors | 6:517082212c00 | 32 | |
| Sissors | 6:517082212c00 | 33 | protected: |
| Sissors | 6:517082212c00 | 34 | virtual void handler() { |
| Sissors | 6:517082212c00 | 35 | _function.call(); |
| Sissors | 6:517082212c00 | 36 | } |
| Sissors | 6:517082212c00 | 37 | |
| Sissors | 6:517082212c00 | 38 | unsigned int _delay; |
| Sissors | 6:517082212c00 | 39 | FunctionPointer _function; |
| Sissors | 6:517082212c00 | 40 | }; |
| Sissors | 6:517082212c00 | 41 | |
| Sissors | 6:517082212c00 | 42 | #endif |