|
@@ -24,11 +24,14 @@
|
24
|
24
|
#include "stopwatch.h"
|
25
|
25
|
|
26
|
26
|
Stopwatch::Stopwatch() {
|
27
|
|
- this->reset();
|
28
|
|
- }
|
|
27
|
+ this->reset();
|
|
28
|
+}
|
29
|
29
|
|
30
|
30
|
void Stopwatch::stop() {
|
31
|
|
- if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::stop()");
|
|
31
|
+ #if ENABLED(DEBUG_STOPWATCH)
|
|
32
|
+ debug(PSTR("stop"));
|
|
33
|
+ #endif
|
|
34
|
+
|
32
|
35
|
if (!this->isRunning()) return;
|
33
|
36
|
|
34
|
37
|
this->status = STPWTCH_STOPPED;
|
|
@@ -36,7 +39,10 @@ void Stopwatch::stop() {
|
36
|
39
|
}
|
37
|
40
|
|
38
|
41
|
void Stopwatch::pause() {
|
39
|
|
- if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::pause()");
|
|
42
|
+ #if ENABLED(DEBUG_STOPWATCH)
|
|
43
|
+ debug(PSTR("pause"));
|
|
44
|
+ #endif
|
|
45
|
+
|
40
|
46
|
if (!this->isRunning()) return;
|
41
|
47
|
|
42
|
48
|
this->status = STPWTCH_PAUSED;
|
|
@@ -44,7 +50,10 @@ void Stopwatch::pause() {
|
44
|
50
|
}
|
45
|
51
|
|
46
|
52
|
void Stopwatch::start() {
|
47
|
|
- if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::start()");
|
|
53
|
+ #if ENABLED(DEBUG_STOPWATCH)
|
|
54
|
+ debug(PSTR("start"));
|
|
55
|
+ #endif
|
|
56
|
+
|
48
|
57
|
if (this->isRunning()) return;
|
49
|
58
|
|
50
|
59
|
if (this->isPaused()) this->accumulator = this->duration();
|
|
@@ -55,7 +64,9 @@ void Stopwatch::start() {
|
55
|
64
|
}
|
56
|
65
|
|
57
|
66
|
void Stopwatch::reset() {
|
58
|
|
- if (DEBUGGING(INFO)) SERIAL_ECHOLNPGM("Stopwatch::reset()");
|
|
67
|
+ #if ENABLED(DEBUG_STOPWATCH)
|
|
68
|
+ debug(PSTR("reset"));
|
|
69
|
+ #endif
|
59
|
70
|
|
60
|
71
|
this->status = STPWTCH_STOPPED;
|
61
|
72
|
this->startTimestamp = 0;
|
|
@@ -75,3 +86,15 @@ uint16_t Stopwatch::duration() {
|
75
|
86
|
return (((this->isRunning()) ? millis() : this->stopTimestamp)
|
76
|
87
|
- this->startTimestamp) / 1000 + this->accumulator;
|
77
|
88
|
}
|
|
89
|
+
|
|
90
|
+#if ENABLED(DEBUG_STOPWATCH)
|
|
91
|
+
|
|
92
|
+ void Stopwatch::debug(const char func[]) {
|
|
93
|
+ if (DEBUGGING(INFO)) {
|
|
94
|
+ SERIAL_ECHOPGM("Stopwatch::");
|
|
95
|
+ serialprintPGM(func);
|
|
96
|
+ SERIAL_ECHOLNPGM("()");
|
|
97
|
+ }
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+#endif
|