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

@ -612,31 +612,24 @@ void MarlinUI::draw_status_message(const bool blink) {
if (slen <= LCD_WIDTH) {
// The string fits within the line. Print with no scrolling
lcd_put_u8str(status_message);
for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' ');
while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
}
else {
// String is longer than the available space
// 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_PIXEL_WIDTH);
// Get the string remaining length
const uint8_t rlen = utf8_strlen(stat);
if (rlen >= LCD_WIDTH) {
// The remaining string fills the screen - Print it
lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
}
else {
// The remaining string does not completely fill the screen
lcd_put_u8str_max(stat, LCD_PIXEL_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) {
// Print a second copy of the message
if (--chars) { // Print a second copy of the message
lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
lcd_put_wchar(' ');
}
@ -644,15 +637,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();
}
}

View File

@ -627,43 +627,27 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
if (slen <= LCD_WIDTH) {
// String fits the LCD, so just print it
write_str(str);
for (; slen < LCD_WIDTH; ++slen) write_byte(' ');
while (slen < LCD_WIDTH) { write_byte(' '); ++slen; }
}
else {
// String is larger than the available space in screen.
// Get a pointer to the next valid UTF8 character
const char *stat = str + ui.status_scroll_offset;
// 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
write_str(stat, LCD_WIDTH);
}
else {
// The remaining string does not completely fill the screen
write_str(stat); // The string leaves space
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
// and the string remaining length
uint8_t rlen;
const char *stat = ui.status_and_len(rlen);
write_str(stat, LCD_WIDTH);
// If the remaining string doesn't completely fill the screen
if (rlen < LCD_WIDTH) {
write_byte('.'); // 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
write_byte('.');
if (--chars)
write_str(str, chars); // Print a second copy of the message
if (--chars) write_str(str, chars); // Print a second copy of the message
}
}
// Adjust by complete UTF8 characters
if (ui.status_scroll_offset < slen) {
ui.status_scroll_offset++;
while (!START_OF_UTF8_CHAR(str[ui.status_scroll_offset]))
ui.status_scroll_offset++;
}
else
ui.status_scroll_offset = 0;
ui.advance_status_scroll();
}
#else