Unify status scrolling further

This commit is contained in:
Scott Lahteine
2019-03-17 05:32:12 -05:00
parent c4443f885e
commit 58bca67883
5 changed files with 56 additions and 89 deletions

View File

@ -660,33 +660,22 @@ void MarlinUI::draw_status_message(const bool blink) {
lcd_put_u8str(status_message);
// Fill the rest with spaces
while (slen < LCD_WIDTH) {
lcd_put_wchar(' ');
++slen;
}
while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
}
else {
// String is larger than the available space in screen.
// Get a pointer to the next valid UTF8 character
const char *stat = status_message + status_scroll_offset;
// and the string remaining length
uint8_t rlen;
const char *stat = status_and_len(rlen);
lcd_put_u8str_max(stat, LCD_WIDTH); // The string leaves space
// Get the string remaining length
const uint8_t rlen = utf8_strlen(stat);
// If we have enough characters to display
if (rlen >= LCD_WIDTH) {
// The remaining string fills the screen - Print it
lcd_put_u8str_max(stat, LCD_WIDTH);
}
else {
// The remaining string does not completely fill the screen
lcd_put_u8str_max(stat, LCD_WIDTH); // The string leaves space
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
if (--chars) { // Draw a second dot if there's space
// If the remaining string doesn't completely fill the screen
if (rlen < LCD_WIDTH) {
lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
if (--chars) { // Draw a second dot if there's space
lcd_put_wchar('.');
if (--chars)
lcd_put_u8str_max(status_message, chars); // Print a second copy of the message
@ -694,15 +683,7 @@ void MarlinUI::draw_status_message(const bool blink) {
}
if (last_blink != blink) {
last_blink = blink;
// Adjust by complete UTF8 characters
if (status_scroll_offset < slen) {
status_scroll_offset++;
while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
status_scroll_offset++;
}
else
status_scroll_offset = 0;
advance_status_scroll();
}
}
#else