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.
Fork of SoftSerial by
SoftSerial_Ticker.h@11:a0029614de72, 2016-04-12 (annotated)
- Committer:
- SonyPony
- Date:
- Tue Apr 12 16:58:22 2016 +0000
- Revision:
- 11:a0029614de72
- Parent:
- 6:517082212c00
Fix: set read_buffer to 0 in cunstructor, it caused that first received byte was not correct
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 | |
| Sissors | 6:517082212c00 | 3 | #ifndef FLEXTICKER_H |
| Sissors | 6:517082212c00 | 4 | #define FLEXTICKER_H |
| Sissors | 6:517082212c00 | 5 | |
| Sissors | 6:517082212c00 | 6 | #include "mbed.h" |
| Sissors | 6:517082212c00 | 7 | |
| Sissors | 6:517082212c00 | 8 | class FlexTicker: 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 |
