Apply TERN to compact code (#17619)
This commit is contained in:
@@ -34,14 +34,10 @@ millis_t Stopwatch::startTimestamp;
|
||||
millis_t Stopwatch::stopTimestamp;
|
||||
|
||||
bool Stopwatch::stop() {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("stop"));
|
||||
#endif
|
||||
Stopwatch::debug(PSTR("stop"));
|
||||
|
||||
if (isRunning() || isPaused()) {
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPrintTimerStopped();
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStopped());
|
||||
state = STOPPED;
|
||||
stopTimestamp = millis();
|
||||
return true;
|
||||
@@ -50,14 +46,10 @@ bool Stopwatch::stop() {
|
||||
}
|
||||
|
||||
bool Stopwatch::pause() {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("pause"));
|
||||
#endif
|
||||
Stopwatch::debug(PSTR("pause"));
|
||||
|
||||
if (isRunning()) {
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPrintTimerPaused();
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerPaused());
|
||||
state = PAUSED;
|
||||
stopTimestamp = millis();
|
||||
return true;
|
||||
@@ -66,13 +58,9 @@ bool Stopwatch::pause() {
|
||||
}
|
||||
|
||||
bool Stopwatch::start() {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("start"));
|
||||
#endif
|
||||
Stopwatch::debug(PSTR("start"));
|
||||
|
||||
#if ENABLED(EXTENSIBLE_UI)
|
||||
ExtUI::onPrintTimerStarted();
|
||||
#endif
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onPrintTimerStarted());
|
||||
|
||||
if (!isRunning()) {
|
||||
if (isPaused()) accumulator = duration();
|
||||
@@ -86,18 +74,14 @@ bool Stopwatch::start() {
|
||||
}
|
||||
|
||||
void Stopwatch::resume(const millis_t with_time) {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("resume"));
|
||||
#endif
|
||||
Stopwatch::debug(PSTR("resume"));
|
||||
|
||||
reset();
|
||||
if ((accumulator = with_time)) state = RUNNING;
|
||||
}
|
||||
|
||||
void Stopwatch::reset() {
|
||||
#if ENABLED(DEBUG_STOPWATCH)
|
||||
Stopwatch::debug(PSTR("reset"));
|
||||
#endif
|
||||
Stopwatch::debug(PSTR("reset"));
|
||||
|
||||
state = STOPPED;
|
||||
startTimestamp = 0;
|
||||
|
||||
Reference in New Issue
Block a user