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: DetectFreqAboveTH RN41
myTimer.cpp@2:3060a6604f13, 2015-10-06 (annotated)
- Committer:
- AkinoriHashimoto
- Date:
- Tue Oct 06 06:53:16 2015 +0000
- Revision:
- 2:3060a6604f13
- Parent:
- 1:685c0f37a569
- Child:
- 3:de4737751df6
start() adj.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AkinoriHashimoto | 0:04c9087b9ca9 | 1 | #include "myTimer.h" |
| AkinoriHashimoto | 0:04c9087b9ca9 | 2 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 3 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 4 | myTimer::myTimer() |
| AkinoriHashimoto | 0:04c9087b9ca9 | 5 | { |
| AkinoriHashimoto | 0:04c9087b9ca9 | 6 | this->stop(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 7 | this->reset(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 8 | } |
| AkinoriHashimoto | 0:04c9087b9ca9 | 9 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 10 | void myTimer::stop() |
| AkinoriHashimoto | 0:04c9087b9ca9 | 11 | { |
| AkinoriHashimoto | 0:04c9087b9ca9 | 12 | this->timer.stop(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 13 | return; |
| AkinoriHashimoto | 0:04c9087b9ca9 | 14 | } |
| AkinoriHashimoto | 0:04c9087b9ca9 | 15 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 16 | void myTimer::reset() |
| AkinoriHashimoto | 0:04c9087b9ca9 | 17 | { |
| AkinoriHashimoto | 0:04c9087b9ca9 | 18 | this->timer.reset(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 19 | return; |
| AkinoriHashimoto | 0:04c9087b9ca9 | 20 | } |
| AkinoriHashimoto | 0:04c9087b9ca9 | 21 | |
| AkinoriHashimoto | 2:3060a6604f13 | 22 | void myTimer::start(bool _RESET) |
| AkinoriHashimoto | 0:04c9087b9ca9 | 23 | { |
| AkinoriHashimoto | 2:3060a6604f13 | 24 | if(_RESET) |
| AkinoriHashimoto | 2:3060a6604f13 | 25 | this->reset(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 26 | this->timer.start(); |
| AkinoriHashimoto | 0:04c9087b9ca9 | 27 | return; |
| AkinoriHashimoto | 0:04c9087b9ca9 | 28 | } |
| AkinoriHashimoto | 0:04c9087b9ca9 | 29 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 30 | int myTimer::read_ms(bool _START, bool _RESET, bool _STOP) |
| AkinoriHashimoto | 0:04c9087b9ca9 | 31 | { |
| AkinoriHashimoto | 0:04c9087b9ca9 | 32 | int ans= 0; |
| AkinoriHashimoto | 0:04c9087b9ca9 | 33 | if(_STOP) |
| AkinoriHashimoto | 0:04c9087b9ca9 | 34 | this->stop(); |
| AkinoriHashimoto | 2:3060a6604f13 | 35 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 36 | ans= this->timer.read_ms(); |
| AkinoriHashimoto | 2:3060a6604f13 | 37 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 38 | if(_RESET) |
| AkinoriHashimoto | 0:04c9087b9ca9 | 39 | this->reset(); |
| AkinoriHashimoto | 2:3060a6604f13 | 40 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 41 | if(_START) |
| AkinoriHashimoto | 0:04c9087b9ca9 | 42 | this->start(); |
| AkinoriHashimoto | 2:3060a6604f13 | 43 | |
| AkinoriHashimoto | 0:04c9087b9ca9 | 44 | return ans; |
| AkinoriHashimoto | 1:685c0f37a569 | 45 | } |
| AkinoriHashimoto | 1:685c0f37a569 | 46 | |
| AkinoriHashimoto | 1:685c0f37a569 | 47 | void myTimer::wait_ms(int waitTime, bool _START, bool _RESET, bool _STOP) |
| AkinoriHashimoto | 1:685c0f37a569 | 48 | { |
| AkinoriHashimoto | 1:685c0f37a569 | 49 | int wt= waitTime- this->read_ms(_START, _RESET, _STOP); |
| AkinoriHashimoto | 1:685c0f37a569 | 50 | if(wt <= 0) |
| AkinoriHashimoto | 1:685c0f37a569 | 51 | return; |
| AkinoriHashimoto | 1:685c0f37a569 | 52 | wait_ms(wt); |
| AkinoriHashimoto | 1:685c0f37a569 | 53 | return; |
| AkinoriHashimoto | 0:04c9087b9ca9 | 54 | } |