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.
Task.cpp@1:e95b703c6ad7, 2011-01-14 (annotated)
- Committer:
- Phlaphead
- Date:
- Fri Jan 14 20:04:13 2011 +0000
- Revision:
- 1:e95b703c6ad7
- Parent:
- 0:e381c3adaa04
added stop and isRunning methods
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Phlaphead | 0:e381c3adaa04 | 1 | |
| Phlaphead | 0:e381c3adaa04 | 2 | #include "Task.h" |
| Phlaphead | 0:e381c3adaa04 | 3 | |
| Phlaphead | 0:e381c3adaa04 | 4 | Task::Task() |
| Phlaphead | 0:e381c3adaa04 | 5 | { |
| Phlaphead | 0:e381c3adaa04 | 6 | interval = DEFAULT_INTERVAL; |
| Phlaphead | 0:e381c3adaa04 | 7 | } |
| Phlaphead | 0:e381c3adaa04 | 8 | |
| Phlaphead | 0:e381c3adaa04 | 9 | Task::Task(int _interval) |
| Phlaphead | 0:e381c3adaa04 | 10 | { |
| Phlaphead | 0:e381c3adaa04 | 11 | interval = _interval; |
| Phlaphead | 0:e381c3adaa04 | 12 | } |
| Phlaphead | 0:e381c3adaa04 | 13 | |
| Phlaphead | 0:e381c3adaa04 | 14 | void Task::start() |
| Phlaphead | 0:e381c3adaa04 | 15 | { |
| Phlaphead | 0:e381c3adaa04 | 16 | ticker.attach_us(this, &Task::preTick, interval); |
| Phlaphead | 1:e95b703c6ad7 | 17 | running = true; |
| Phlaphead | 0:e381c3adaa04 | 18 | } |
| Phlaphead | 0:e381c3adaa04 | 19 | |
| Phlaphead | 0:e381c3adaa04 | 20 | |
| Phlaphead | 0:e381c3adaa04 | 21 | void Task::preTick() |
| Phlaphead | 0:e381c3adaa04 | 22 | { |
| Phlaphead | 0:e381c3adaa04 | 23 | this->tick(); |
| Phlaphead | 1:e95b703c6ad7 | 24 | } |
| Phlaphead | 1:e95b703c6ad7 | 25 | |
| Phlaphead | 1:e95b703c6ad7 | 26 | void Task::stop() |
| Phlaphead | 1:e95b703c6ad7 | 27 | { |
| Phlaphead | 1:e95b703c6ad7 | 28 | ticker.detach(); |
| Phlaphead | 1:e95b703c6ad7 | 29 | running = false; |
| Phlaphead | 1:e95b703c6ad7 | 30 | } |
| Phlaphead | 1:e95b703c6ad7 | 31 |