Circular scrolling of the status message

This commit is contained in:
Scott Lahteine 2017-06-10 20:05:52 -05:00
parent 83263076dc
commit 21217d53df
2 changed files with 44 additions and 11 deletions

View file

@ -407,15 +407,31 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr,
inline void lcd_implementation_status_message() { inline void lcd_implementation_status_message() {
#if ENABLED(STATUS_MESSAGE_SCROLLING) #if ENABLED(STATUS_MESSAGE_SCROLLING)
static bool last_blink = false; static bool last_blink = false;
lcd_print_utf(lcd_status_message + status_scroll_pos);
const uint8_t slen = lcd_strlen(lcd_status_message); const uint8_t slen = lcd_strlen(lcd_status_message);
if (slen > LCD_WIDTH) { const char *stat = lcd_status_message + status_scroll_pos;
const bool new_blink = lcd_blink(); if (slen <= LCD_WIDTH)
if (last_blink != new_blink) { lcd_print_utf(stat); // The string isn't scrolling
last_blink = new_blink; else {
if (status_scroll_pos <= slen - LCD_WIDTH)
lcd_print_utf(stat); // The string fills the screen
else {
uint8_t chars = LCD_WIDTH;
if (status_scroll_pos < slen) { // First string still visible
lcd_print_utf(stat); // The string leaves space
chars -= slen - status_scroll_pos; // Amount of space left
}
lcd.print('.'); // Always at 1+ spaces left, draw a dot
if (--chars) {
if (status_scroll_pos < slen + 1) // Draw a second dot if there's space
--chars, lcd.print('.');
if (chars) lcd_print_utf(lcd_status_message, chars); // Print a second copy of the message
}
}
if (last_blink != blink) {
last_blink = blink;
// Skip any non-printing bytes // Skip any non-printing bytes
while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++; if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
} }
} }
#else #else

View file

@ -841,14 +841,31 @@ static void lcd_implementation_status_screen() {
#if ENABLED(STATUS_MESSAGE_SCROLLING) #if ENABLED(STATUS_MESSAGE_SCROLLING)
static bool last_blink = false; static bool last_blink = false;
lcd_print_utf(lcd_status_message + status_scroll_pos);
const uint8_t slen = lcd_strlen(lcd_status_message); const uint8_t slen = lcd_strlen(lcd_status_message);
if (slen > LCD_WIDTH) { const char *stat = lcd_status_message + status_scroll_pos;
if (slen <= LCD_WIDTH)
lcd_print_utf(stat); // The string isn't scrolling
else {
if (status_scroll_pos <= slen - LCD_WIDTH)
lcd_print_utf(stat); // The string fills the screen
else {
uint8_t chars = LCD_WIDTH;
if (status_scroll_pos < slen) { // First string still visible
lcd_print_utf(stat); // The string leaves space
chars -= slen - status_scroll_pos; // Amount of space left
}
lcd.print('.'); // Always at 1+ spaces left, draw a dot
if (--chars) {
if (status_scroll_pos < slen + 1) // Draw a second dot if there's space
--chars, lcd.print('.');
if (chars) lcd_print_utf(lcd_status_message, chars); // Print a second copy of the message
}
}
if (last_blink != blink) { if (last_blink != blink) {
last_blink = blink; last_blink = blink;
// Skip any non-printing bytes // Skip any non-printing bytes
while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++; if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0; if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
} }
} }
#else #else