mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-12-29 02:40:41 -07:00
🧑💻 Seconds units
This commit is contained in:
parent
5f9205ef8f
commit
a995cbef50
4 changed files with 24 additions and 25 deletions
|
|
@ -29,9 +29,9 @@
|
|||
#endif
|
||||
|
||||
Stopwatch::State Stopwatch::state;
|
||||
millis_t Stopwatch::accumulator;
|
||||
millis_t Stopwatch::startTimestamp;
|
||||
millis_t Stopwatch::stopTimestamp;
|
||||
uint32_t Stopwatch::accumulator;
|
||||
uint32_t Stopwatch::startTimestamp;
|
||||
uint32_t Stopwatch::stopTimestamp;
|
||||
|
||||
bool Stopwatch::stop() {
|
||||
debug(F("stop"));
|
||||
|
|
@ -73,7 +73,7 @@ bool Stopwatch::start() {
|
|||
else return false;
|
||||
}
|
||||
|
||||
void Stopwatch::resume(const millis_t with_time) {
|
||||
void Stopwatch::resume(const uint32_t with_time) {
|
||||
debug(F("resume"));
|
||||
|
||||
reset();
|
||||
|
|
@ -89,7 +89,7 @@ void Stopwatch::reset() {
|
|||
accumulator = 0;
|
||||
}
|
||||
|
||||
millis_t Stopwatch::duration() {
|
||||
uint32_t Stopwatch::duration() {
|
||||
return accumulator + MS_TO_SEC((isRunning() ? millis() : stopTimestamp) - startTimestamp);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@ class Stopwatch {
|
|||
enum State : char { STOPPED, RUNNING, PAUSED };
|
||||
|
||||
static Stopwatch::State state;
|
||||
static millis_t accumulator;
|
||||
static millis_t startTimestamp;
|
||||
static millis_t stopTimestamp;
|
||||
static uint32_t accumulator; // (seconds)
|
||||
static uint32_t startTimestamp;
|
||||
static uint32_t stopTimestamp;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
@ -75,7 +75,7 @@ class Stopwatch {
|
|||
* @brief Resume the stopwatch
|
||||
* @details Resume a timer from a given duration
|
||||
*/
|
||||
static void resume(const millis_t with_time);
|
||||
static void resume(const uint32_t with_time);
|
||||
|
||||
/**
|
||||
* @brief Reset the stopwatch
|
||||
|
|
@ -102,7 +102,7 @@ class Stopwatch {
|
|||
* @details Return the total number of seconds the timer has been running.
|
||||
* @return the delta since starting the stopwatch
|
||||
*/
|
||||
static millis_t duration();
|
||||
static uint32_t duration();
|
||||
|
||||
#ifdef DEBUG_STOPWATCH
|
||||
|
||||
|
|
|
|||
|
|
@ -69,12 +69,12 @@ printStatistics PrintCounter::data;
|
|||
|
||||
const PrintCounter::eeprom_address_t PrintCounter::address = STATS_EEPROM_ADDRESS;
|
||||
|
||||
millis_t PrintCounter::lastDuration;
|
||||
uint32_t PrintCounter::lastDuration;
|
||||
bool PrintCounter::loaded = false;
|
||||
|
||||
millis_t PrintCounter::deltaDuration() {
|
||||
uint32_t PrintCounter::deltaDuration() {
|
||||
TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("deltaDuration")));
|
||||
millis_t tmp = lastDuration;
|
||||
const uint32_t tmp = lastDuration;
|
||||
lastDuration = duration();
|
||||
return lastDuration - tmp;
|
||||
}
|
||||
|
|
@ -236,25 +236,24 @@ void PrintCounter::showStats() {
|
|||
void PrintCounter::tick() {
|
||||
if (!isRunning()) return;
|
||||
|
||||
millis_t now = millis();
|
||||
|
||||
const millis_t now = millis();
|
||||
static millis_t update_next; // = 0
|
||||
if (ELAPSED(now, update_next)) {
|
||||
update_next = now + updateInterval;
|
||||
|
||||
TERN_(DEBUG_PRINTCOUNTER, debug(PSTR("tick")));
|
||||
|
||||
millis_t delta = deltaDuration();
|
||||
data.printTime += delta;
|
||||
const uint32_t delta_s = deltaDuration();
|
||||
data.printTime += delta_s;
|
||||
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
data.nextService1 -= _MIN(delta, data.nextService1);
|
||||
data.nextService1 -= _MIN(delta_s, data.nextService1);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
data.nextService2 -= _MIN(delta, data.nextService2);
|
||||
data.nextService2 -= _MIN(delta_s, data.nextService2);
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_3 > 0
|
||||
data.nextService3 -= _MIN(delta, data.nextService3);
|
||||
data.nextService3 -= _MIN(delta_s, data.nextService3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,13 +35,13 @@ struct printStatistics { // 16 bytes
|
|||
//const uint8_t magic; // Magic header, it will always be 0x16
|
||||
uint16_t totalPrints; // Number of prints
|
||||
uint16_t finishedPrints; // Number of complete prints
|
||||
uint32_t printTime; // Accumulated printing time
|
||||
uint32_t longestPrint; // Longest successful print job
|
||||
uint32_t printTime; // (s) Accumulated printing time
|
||||
uint32_t longestPrint; // (s) Longest successful print job
|
||||
#if HAS_EXTRUDERS
|
||||
float filamentUsed; // Accumulated filament consumed in mm
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_1 > 0
|
||||
uint32_t nextService1; // Service intervals (or placeholders)
|
||||
uint32_t nextService1; // (s) Service intervals (or placeholders)
|
||||
#endif
|
||||
#if SERVICE_INTERVAL_2 > 0
|
||||
uint32_t nextService2;
|
||||
|
|
@ -86,7 +86,7 @@ class PrintCounter: public Stopwatch {
|
|||
* @details Store the timestamp of the last deltaDuration(), this is
|
||||
* required due to the updateInterval cycle.
|
||||
*/
|
||||
static millis_t lastDuration;
|
||||
static uint32_t lastDuration;
|
||||
|
||||
/**
|
||||
* @brief Stats were loaded from EEPROM
|
||||
|
|
@ -102,7 +102,7 @@ class PrintCounter: public Stopwatch {
|
|||
* used internally for print statistics accounting is not intended to be a
|
||||
* user callable function.
|
||||
*/
|
||||
static millis_t deltaDuration();
|
||||
static uint32_t deltaDuration();
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue