Skip to content

Commit

Permalink
🐛 Fix DOGM time overflow, alignment (MarlinFirmware#25103)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilGremlin authored and thinkyhead committed Dec 18, 2022
1 parent 471330b commit 569bbb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
static char bufferc[13];

static void prepare_time_string(const duration_t &time, char prefix) {
char str[9];
char str[13];
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
bufferc[0] = prefix;
bufferc[1] = ':';
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/libs/duration_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,17 @@ struct duration_t {
* 123456789 (strlen)
* 12'34
* 99:59
* 11d 12:33
* 123:45
* 1d 12:33
* 9999d 12:33
*/
uint8_t toDigital(char *buffer, bool with_days=false) const {
const uint16_t h = uint16_t(this->hour()),
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); // 1d 23:45
return d >= 10 ? 9 : 8;
return strlen_P(buffer);
}
else if (!h) {
const uint16_t s = uint16_t(this->second() % 60UL);
Expand Down

0 comments on commit 569bbb1

Please sign in to comment.