For status scrolling, pad a short message

This commit is contained in:
Scott Lahteine 2017-05-31 23:09:44 -05:00
parent 4a96433b7e
commit 4296a8b74e

View file

@ -4154,24 +4154,28 @@ void lcd_update() {
} // ELAPSED(ms, next_lcd_update_ms) } // ELAPSED(ms, next_lcd_update_ms)
} }
#if DISABLED(STATUS_MESSAGE_SCROLLING) void pad_message_string() {
void set_utf_strlen(char* s, uint8_t n) {
uint8_t i = 0, j = 0; uint8_t i = 0, j = 0;
while (s[i] && (j < n)) { char c;
if (PRINTABLE(s[i])) j++; while ((c = lcd_status_message[i]) && j < LCD_WIDTH) {
if (PRINTABLE(c)) j++;
i++; i++;
} }
while (j++ < n) s[i++] = ' '; if (true
s[i] = '\0'; #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';
}
} }
#endif // !STATUS_MESSAGE_SCROLLING
void lcd_finishstatus(bool persist=false) { void lcd_finishstatus(bool persist=false) {
#if DISABLED(STATUS_MESSAGE_SCROLLING)
set_utf_strlen(lcd_status_message, LCD_WIDTH); pad_message_string();
#endif
#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
UNUSED(persist); UNUSED(persist);