From cd5a717afb0305975bb42f5e5c22be65d5671828 Mon Sep 17 00:00:00 2001 From: MrAlvin Date: Wed, 22 Dec 2021 14:21:20 +0100 Subject: [PATCH 1/3] PRINTJOB_TIME shows mm:ss about the duration of a print during the first 1 hour of a print PRINTJOB_TIME only used to show hh:mm of the duration of a print. Now it shows mm:ss during the first hour of a print --- Marlin/src/libs/duration_t.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index 2528bcdbff89..90259739d209 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -154,12 +154,17 @@ struct duration_t { */ uint8_t toDigital(char *buffer, bool with_days=false) const { uint16_t h = uint16_t(this->hour()), - m = uint16_t(this->minute() % 60UL); + m = uint16_t(this->minute() % 60UL), + s = uint16_t(this->second() % 60UL); if (with_days) { uint16_t d = this->day(); sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); return d >= 10 ? 9 : 8; } + else if (h < 1) { + sprintf_P(buffer, PSTR("%02hu:%02hu"), m, s); + return 5; + } else if (h < 100) { sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); return 5; From 5c78411778bc56f710849f5791b6fc2311da38bb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Dec 2021 02:28:11 -0600 Subject: [PATCH 2/3] replace tabs, other adjustments --- Marlin/src/libs/duration_t.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index 90259739d209..48f0b589a183 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -127,11 +127,11 @@ struct duration_t { * 59s */ char* toString(char * const buffer) const { - int y = this->year(), - d = this->day() % 365, - h = this->hour() % 24, - m = this->minute() % 60, - s = this->second() % 60; + const uint16_t y = this->year(), + d = this->day() % 365, + h = this->hour() % 24, + m = this->minute() % 60, + s = this->second() % 60; if (y) sprintf_P(buffer, PSTR("%iy %id %ih %im %is"), y, d, h, m, s); else if (d) sprintf_P(buffer, PSTR("%id %ih %im %is"), d, h, m, s); @@ -153,18 +153,18 @@ struct duration_t { * 11d 12:33 */ uint8_t toDigital(char *buffer, bool with_days=false) const { - uint16_t h = uint16_t(this->hour()), - m = uint16_t(this->minute() % 60UL), - s = uint16_t(this->second() % 60UL); + const uint16_t h = uint16_t(this->hour()), + m = uint16_t(this->minute() % 60UL); if (with_days) { - uint16_t d = this->day(); + const uint16_t d = this->day(); sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); return d >= 10 ? 9 : 8; } - else if (h < 1) { + else if (!h) { + const uint16_t s = uint16_t(this->second() % 60UL); sprintf_P(buffer, PSTR("%02hu:%02hu"), m, s); return 5; - } + } else if (h < 100) { sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); return 5; From 10e105fa376254a4803db0a583774f829ceee581 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Dec 2021 02:44:23 -0600 Subject: [PATCH 3/3] minute symbol hint --- Marlin/src/libs/duration_t.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Marlin/src/libs/duration_t.h b/Marlin/src/libs/duration_t.h index 48f0b589a183..df2c9cd099c1 100644 --- a/Marlin/src/libs/duration_t.h +++ b/Marlin/src/libs/duration_t.h @@ -149,6 +149,7 @@ struct duration_t { * * Output examples: * 123456789 (strlen) + * 12'34 * 99:59 * 11d 12:33 */ @@ -157,20 +158,20 @@ struct duration_t { m = uint16_t(this->minute() % 60UL); if (with_days) { const uint16_t d = this->day(); - sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); + sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45 return d >= 10 ? 9 : 8; } else if (!h) { const uint16_t s = uint16_t(this->second() % 60UL); - sprintf_P(buffer, PSTR("%02hu:%02hu"), m, s); + sprintf_P(buffer, PSTR("%02hu'%02hu"), m, s); // 12'34 return 5; } else if (h < 100) { - sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); + sprintf_P(buffer, PSTR("%02hu:%02hu"), h, m); // 12:34 return 5; } else { - sprintf_P(buffer, PSTR("%hu:%02hu"), h, m); + sprintf_P(buffer, PSTR("%hu:%02hu"), h, m); // 123:45 return 6; } }