|
|
@ -28,7 +28,10 @@ Stopwatch::Stopwatch() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stopwatch::stop() {
|
|
|
|
void Stopwatch::stop() {
|
|
|
|
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::stop()");
|
|
|
|
#if ENABLED(DEBUG_STOPWATCH)
|
|
|
|
|
|
|
|
debug(PSTR("stop"));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!this->isRunning()) return;
|
|
|
|
if (!this->isRunning()) return;
|
|
|
|
|
|
|
|
|
|
|
|
this->status = STPWTCH_STOPPED;
|
|
|
|
this->status = STPWTCH_STOPPED;
|
|
|
@ -36,7 +39,10 @@ void Stopwatch::stop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stopwatch::pause() {
|
|
|
|
void Stopwatch::pause() {
|
|
|
|
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::pause()");
|
|
|
|
#if ENABLED(DEBUG_STOPWATCH)
|
|
|
|
|
|
|
|
debug(PSTR("pause"));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!this->isRunning()) return;
|
|
|
|
if (!this->isRunning()) return;
|
|
|
|
|
|
|
|
|
|
|
|
this->status = STPWTCH_PAUSED;
|
|
|
|
this->status = STPWTCH_PAUSED;
|
|
|
@ -44,7 +50,10 @@ void Stopwatch::pause() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stopwatch::start() {
|
|
|
|
void Stopwatch::start() {
|
|
|
|
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::start()");
|
|
|
|
#if ENABLED(DEBUG_STOPWATCH)
|
|
|
|
|
|
|
|
debug(PSTR("start"));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (this->isRunning()) return;
|
|
|
|
if (this->isRunning()) return;
|
|
|
|
|
|
|
|
|
|
|
|
if (this->isPaused()) this->accumulator = this->duration();
|
|
|
|
if (this->isPaused()) this->accumulator = this->duration();
|
|
|
@ -55,7 +64,9 @@ void Stopwatch::start() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Stopwatch::reset() {
|
|
|
|
void Stopwatch::reset() {
|
|
|
|
if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::reset()");
|
|
|
|
#if ENABLED(DEBUG_STOPWATCH)
|
|
|
|
|
|
|
|
debug(PSTR("reset"));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
this->status = STPWTCH_STOPPED;
|
|
|
|
this->status = STPWTCH_STOPPED;
|
|
|
|
this->startTimestamp = 0;
|
|
|
|
this->startTimestamp = 0;
|
|
|
@ -75,3 +86,15 @@ uint16_t Stopwatch::duration() {
|
|
|
|
return (((this->isRunning()) ? millis() : this->stopTimestamp)
|
|
|
|
return (((this->isRunning()) ? millis() : this->stopTimestamp)
|
|
|
|
- this->startTimestamp) / 1000 + this->accumulator;
|
|
|
|
- this->startTimestamp) / 1000 + this->accumulator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_STOPWATCH)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Stopwatch::debug(const char func[]) {
|
|
|
|
|
|
|
|
if (DEBUGGING(INFO)) {
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("Stopwatch::");
|
|
|
|
|
|
|
|
serialprintPGM(func);
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPGM("()");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|