Skip to content

Commit 569bbb1

Browse files
EvilGremlinthinkyhead
authored andcommitted
🐛 Fix DOGM time overflow, alignment (MarlinFirmware#25103)
1 parent 471330b commit 569bbb1

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Marlin/src/lcd/dogm/status_screen_DOGM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
449449
static char bufferc[13];
450450

451451
static void prepare_time_string(const duration_t &time, char prefix) {
452-
char str[9];
452+
char str[13];
453453
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
454454
bufferc[0] = prefix;
455455
bufferc[1] = ':';

Marlin/src/libs/duration_t.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,17 @@ struct duration_t {
151151
* 123456789 (strlen)
152152
* 12'34
153153
* 99:59
154-
* 11d 12:33
154+
* 123:45
155+
* 1d 12:33
156+
* 9999d 12:33
155157
*/
156158
uint8_t toDigital(char *buffer, bool with_days=false) const {
157159
const uint16_t h = uint16_t(this->hour()),
158160
m = uint16_t(this->minute() % 60UL);
159161
if (with_days) {
160162
const uint16_t d = this->day();
161163
sprintf_P(buffer, PSTR("%hud %02hu:%02hu"), d, h % 24, m); // 1d 23:45
162-
return d >= 10 ? 9 : 8;
164+
return strlen_P(buffer);
163165
}
164166
else if (!h) {
165167
const uint16_t s = uint16_t(this->second() % 60UL);

0 commit comments

Comments
 (0)