Parcourir la source

Circular scrolling of the status message

Scott Lahteine il y a 8 ans
Parent
révision
21217d53df
2 fichiers modifiés avec 44 ajouts et 11 suppressions
  1. 23
    7
      Marlin/ultralcd_impl_DOGM.h
  2. 21
    4
      Marlin/ultralcd_impl_HD44780.h

+ 23
- 7
Marlin/ultralcd_impl_DOGM.h Voir le fichier

@@ -407,15 +407,31 @@ FORCE_INLINE void _draw_axis_label(const AxisEnum axis, const char* const pstr,
407 407
 inline void lcd_implementation_status_message() {
408 408
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
409 409
     static bool last_blink = false;
410
-    lcd_print_utf(lcd_status_message + status_scroll_pos);
411 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 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 437
   #else

+ 21
- 4
Marlin/ultralcd_impl_HD44780.h Voir le fichier

@@ -841,14 +841,31 @@ static void lcd_implementation_status_screen() {
841 841
 
842 842
   #if ENABLED(STATUS_MESSAGE_SCROLLING)
843 843
     static bool last_blink = false;
844
-    lcd_print_utf(lcd_status_message + status_scroll_pos);
845 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 864
       if (last_blink != blink) {
848 865
         last_blink = blink;
849 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 871
   #else

Chargement…
Annuler
Enregistrer