mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
Circular scrolling of the status message
This commit is contained in:
parent
83263076dc
commit
21217d53df
@ -407,15 +407,31 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr,
|
||||
inline void lcd_implementation_status_message() {
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
||||
static bool last_blink = false;
|
||||
lcd_print_utf(lcd_status_message + status_scroll_pos);
|
||||
const uint8_t slen = lcd_strlen(lcd_status_message);
|
||||
if (slen > LCD_WIDTH) {
|
||||
const bool new_blink = lcd_blink();
|
||||
if (last_blink != new_blink) {
|
||||
last_blink = new_blink;
|
||||
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) {
|
||||
last_blink = blink;
|
||||
// Skip any non-printing bytes
|
||||
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) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
|
||||
if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -841,14 +841,31 @@ static void lcd_implementation_status_screen() {
|
||||
|
||||
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
||||
static bool last_blink = false;
|
||||
lcd_print_utf(lcd_status_message + status_scroll_pos);
|
||||
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) {
|
||||
last_blink = blink;
|
||||
// Skip any non-printing bytes
|
||||
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) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
|
||||
if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user