Add Stopwatch::resume method
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user