Add Stopwatch::resume method
This commit is contained in:
parent
1894b981af
commit
e76545c450
2 changed files with 26 additions and 19 deletions
|
|
@ -71,6 +71,15 @@ bool Stopwatch::start() {
|
|||
else return false;
|
||||
}
|
||||
|
||||
void Stopwatch::resume(const millis_t duration) {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("resume"));
|
||||
#endif
|
||||
|
||||
reset();
|
||||
if ((accumulator = duration)) state = RUNNING;
|
||||
}
|
||||
|
||||
void Stopwatch::reset() {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("reset"));
|
||||
|
|
@ -82,16 +91,8 @@ void Stopwatch::reset() {
|
|||
accumulator = 0;
|
||||
}
|
||||
|
||||
bool Stopwatch::isRunning() {
|
||||
return (state == RUNNING) ? true : false;
|
||||
}
|
||||
|
||||
bool Stopwatch::isPaused() {
|
||||
return (state == PAUSED) ? true : false;
|
||||
}
|
||||
|
||||
millis_t Stopwatch::duration() {
|
||||
return (((isRunning()) ? millis() : stopTimestamp)
|
||||
return ((isRunning() ? millis() : stopTimestamp)
|
||||
- startTimestamp) / 1000UL + accumulator;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue