From 4296a8b74e650c9c5abf6fd5dbc96a05edcd8c77 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 31 May 2017 23:09:44 -0500 Subject: [PATCH] For status scrolling, pad a short message --- Marlin/ultralcd.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 8d97a8f43..dc98d6570 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -4154,24 +4154,28 @@ void lcd_update() { } // ELAPSED(ms, next_lcd_update_ms) } -#if DISABLED(STATUS_MESSAGE_SCROLLING) - - void set_utf_strlen(char* s, uint8_t n) { - uint8_t i = 0, j = 0; - while (s[i] && (j < n)) { - if (PRINTABLE(s[i])) j++; - i++; - } - while (j++ < n) s[i++] = ' '; - s[i] = '\0'; +void pad_message_string() { + uint8_t i = 0, j = 0; + char c; + while ((c = lcd_status_message[i]) && j < LCD_WIDTH) { + if (PRINTABLE(c)) j++; + i++; } - -#endif // !STATUS_MESSAGE_SCROLLING + if (true + #if ENABLED(STATUS_MESSAGE_SCROLLING) + && j < LCD_WIDTH + #endif + ) { + // pad with spaces to fill up the line + while (j++ < LCD_WIDTH) lcd_status_message[i++] = ' '; + // chop off at the edge + lcd_status_message[i] = '\0'; + } +} void lcd_finishstatus(bool persist=false) { - #if DISABLED(STATUS_MESSAGE_SCROLLING) - set_utf_strlen(lcd_status_message, LCD_WIDTH); - #endif + + pad_message_string(); #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) UNUSED(persist);