Browse Source

Merge pull request #7030 from thinkyhead/bf_circular_scroll

Circular scrolling of the status message
Scott Lahteine 8 years ago
parent
commit
5bdb4bbc5e
2 changed files with 44 additions and 11 deletions
  1. 23
    7
      Marlin/ultralcd_impl_DOGM.h
  2. 21
    4
      Marlin/ultralcd_impl_HD44780.h

+ 23
- 7
Marlin/ultralcd_impl_DOGM.h View File

407
 inline void lcd_implementation_status_message() {
407
 inline void lcd_implementation_status_message() {
408
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
408
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
409
     static bool last_blink = false;
409
     static bool last_blink = false;
410
-    lcd_print_utf(lcd_status_message + status_scroll_pos);
411
     const uint8_t slen = lcd_strlen(lcd_status_message);
410
     const uint8_t slen = lcd_strlen(lcd_status_message);
412
-    if (slen > LCD_WIDTH) {
413
-      const bool new_blink = lcd_blink();
414
-      if (last_blink != new_blink) {
415
-        last_blink = new_blink;
411
+    const char *stat = lcd_status_message + status_scroll_pos;
412
+    if (slen <= LCD_WIDTH)
413
+      lcd_print_utf(stat);                                      // The string isn't scrolling
414
+    else {
415
+      if (status_scroll_pos <= slen - LCD_WIDTH)
416
+        lcd_print_utf(stat);                                    // The string fills the screen
417
+      else {
418
+        uint8_t chars = LCD_WIDTH;
419
+        if (status_scroll_pos < slen) {                         // First string still visible
420
+          lcd_print_utf(stat);                                  // The string leaves space
421
+          chars -= slen - status_scroll_pos;                    // Amount of space left
422
+        }
423
+        lcd.print('.');                                         // Always at 1+ spaces left, draw a dot
424
+        if (--chars) {
425
+          if (status_scroll_pos < slen + 1)                     // Draw a second dot if there's space
426
+            --chars, lcd.print('.');
427
+          if (chars) lcd_print_utf(lcd_status_message, chars);  // Print a second copy of the message
428
+        }
429
+      }
430
+      if (last_blink != blink) {
431
+        last_blink = blink;
416
         // Skip any non-printing bytes
432
         // Skip any non-printing bytes
417
-        while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
418
-        if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0;
433
+        if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
434
+        if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
419
       }
435
       }
420
     }
436
     }
421
   #else
437
   #else

+ 21
- 4
Marlin/ultralcd_impl_HD44780.h View File

841
 
841
 
842
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
842
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
843
     static bool last_blink = false;
843
     static bool last_blink = false;
844
-    lcd_print_utf(lcd_status_message + status_scroll_pos);
845
     const uint8_t slen = lcd_strlen(lcd_status_message);
844
     const uint8_t slen = lcd_strlen(lcd_status_message);
846
-    if (slen > LCD_WIDTH) {
845
+    const char *stat = lcd_status_message + status_scroll_pos;
846
+    if (slen <= LCD_WIDTH)
847
+      lcd_print_utf(stat);                                      // The string isn't scrolling
848
+    else {
849
+      if (status_scroll_pos <= slen - LCD_WIDTH)
850
+        lcd_print_utf(stat);                                    // The string fills the screen
851
+      else {
852
+        uint8_t chars = LCD_WIDTH;
853
+        if (status_scroll_pos < slen) {                         // First string still visible
854
+          lcd_print_utf(stat);                                  // The string leaves space
855
+          chars -= slen - status_scroll_pos;                    // Amount of space left
856
+        }
857
+        lcd.print('.');                                         // Always at 1+ spaces left, draw a dot
858
+        if (--chars) {
859
+          if (status_scroll_pos < slen + 1)                     // Draw a second dot if there's space
860
+            --chars, lcd.print('.');
861
+          if (chars) lcd_print_utf(lcd_status_message, chars);  // Print a second copy of the message
862
+        }
863
+      }
847
       if (last_blink != blink) {
864
       if (last_blink != blink) {
848
         last_blink = blink;
865
         last_blink = blink;
849
         // Skip any non-printing bytes
866
         // Skip any non-printing bytes
850
-        while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
851
-        if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0;
867
+        if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
868
+        if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;
852
       }
869
       }
853
     }
870
     }
854
   #else
871
   #else

Loading…
Cancel
Save