Browse Source

Scrolling status message option

Scott Lahteine 7 years ago
parent
commit
71367fd518
26 changed files with 154 additions and 39 deletions
  1. 3
    0
      Marlin/Configuration_adv.h
  2. 3
    0
      Marlin/example_configurations/Cartesio/Configuration_adv.h
  3. 3
    0
      Marlin/example_configurations/Felix/Configuration_adv.h
  4. 3
    0
      Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h
  5. 3
    0
      Marlin/example_configurations/Hephestos/Configuration_adv.h
  6. 3
    0
      Marlin/example_configurations/Hephestos_2/Configuration_adv.h
  7. 3
    0
      Marlin/example_configurations/K8200/Configuration_adv.h
  8. 3
    0
      Marlin/example_configurations/K8400/Configuration_adv.h
  9. 3
    0
      Marlin/example_configurations/RigidBot/Configuration_adv.h
  10. 3
    0
      Marlin/example_configurations/SCARA/Configuration_adv.h
  11. 3
    0
      Marlin/example_configurations/TAZ4/Configuration_adv.h
  12. 3
    0
      Marlin/example_configurations/TinyBoy2/Configuration_adv.h
  13. 3
    0
      Marlin/example_configurations/WITBOX/Configuration_adv.h
  14. 3
    0
      Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h
  15. 3
    0
      Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h
  16. 3
    0
      Marlin/example_configurations/delta/generic/Configuration_adv.h
  17. 3
    0
      Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h
  18. 3
    0
      Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h
  19. 3
    0
      Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h
  20. 3
    0
      Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h
  21. 3
    0
      Marlin/example_configurations/makibox/Configuration_adv.h
  22. 3
    0
      Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h
  23. 3
    0
      Marlin/example_configurations/wt150/Configuration_adv.h
  24. 27
    13
      Marlin/ultralcd.cpp
  25. 33
    14
      Marlin/ultralcd_impl_DOGM.h
  26. 25
    12
      Marlin/ultralcd_impl_HD44780.h

+ 3
- 0
Marlin/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/FolgerTech-i3-2020/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

443
 // Include a page of printer information in the LCD Main Menu
443
 // Include a page of printer information in the LCD Main Menu
444
 #define LCD_INFO_MENU
444
 #define LCD_INFO_MENU
445
 
445
 
446
+// Scroll a longer status message into view
447
+//#define STATUS_MESSAGE_SCROLLING
448
+
446
 // On the Info Screen, display XY with one decimal place when possible
449
 // On the Info Screen, display XY with one decimal place when possible
447
 #define LCD_DECIMAL_SMALL_XY
450
 #define LCD_DECIMAL_SMALL_XY
448
 
451
 

+ 3
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

455
 // Include a page of printer information in the LCD Main Menu
455
 // Include a page of printer information in the LCD Main Menu
456
 //#define LCD_INFO_MENU
456
 //#define LCD_INFO_MENU
457
 
457
 
458
+// Scroll a longer status message into view
459
+//#define STATUS_MESSAGE_SCROLLING
460
+
458
 // On the Info Screen, display XY with one decimal place when possible
461
 // On the Info Screen, display XY with one decimal place when possible
459
 //#define LCD_DECIMAL_SMALL_XY
462
 //#define LCD_DECIMAL_SMALL_XY
460
 
463
 

+ 3
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/TinyBoy2/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 #define LCD_INFO_MENU
443
 #define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/delta/FLSUN/auto_calibrate/Configuration_adv.h View File

444
 // Include a page of printer information in the LCD Main Menu
444
 // Include a page of printer information in the LCD Main Menu
445
 //#define LCD_INFO_MENU
445
 //#define LCD_INFO_MENU
446
 
446
 
447
+// Scroll a longer status message into view
448
+//#define STATUS_MESSAGE_SCROLLING
449
+
447
 // On the Info Screen, display XY with one decimal place when possible
450
 // On the Info Screen, display XY with one decimal place when possible
448
 //#define LCD_DECIMAL_SMALL_XY
451
 //#define LCD_DECIMAL_SMALL_XY
449
 
452
 

+ 3
- 0
Marlin/example_configurations/delta/FLSUN/kossel_mini/Configuration_adv.h View File

444
 // Include a page of printer information in the LCD Main Menu
444
 // Include a page of printer information in the LCD Main Menu
445
 //#define LCD_INFO_MENU
445
 //#define LCD_INFO_MENU
446
 
446
 
447
+// Scroll a longer status message into view
448
+//#define STATUS_MESSAGE_SCROLLING
449
+
447
 // On the Info Screen, display XY with one decimal place when possible
450
 // On the Info Screen, display XY with one decimal place when possible
448
 //#define LCD_DECIMAL_SMALL_XY
451
 //#define LCD_DECIMAL_SMALL_XY
449
 
452
 

+ 3
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

444
 // Include a page of printer information in the LCD Main Menu
444
 // Include a page of printer information in the LCD Main Menu
445
 //#define LCD_INFO_MENU
445
 //#define LCD_INFO_MENU
446
 
446
 
447
+// Scroll a longer status message into view
448
+//#define STATUS_MESSAGE_SCROLLING
449
+
447
 // On the Info Screen, display XY with one decimal place when possible
450
 // On the Info Screen, display XY with one decimal place when possible
448
 //#define LCD_DECIMAL_SMALL_XY
451
 //#define LCD_DECIMAL_SMALL_XY
449
 
452
 

+ 3
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

444
 // Include a page of printer information in the LCD Main Menu
444
 // Include a page of printer information in the LCD Main Menu
445
 //#define LCD_INFO_MENU
445
 //#define LCD_INFO_MENU
446
 
446
 
447
+// Scroll a longer status message into view
448
+//#define STATUS_MESSAGE_SCROLLING
449
+
447
 // On the Info Screen, display XY with one decimal place when possible
450
 // On the Info Screen, display XY with one decimal place when possible
448
 //#define LCD_DECIMAL_SMALL_XY
451
 //#define LCD_DECIMAL_SMALL_XY
449
 
452
 

+ 3
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

449
 // Include a page of printer information in the LCD Main Menu
449
 // Include a page of printer information in the LCD Main Menu
450
 //#define LCD_INFO_MENU
450
 //#define LCD_INFO_MENU
451
 
451
 
452
+// Scroll a longer status message into view
453
+//#define STATUS_MESSAGE_SCROLLING
454
+
452
 // On the Info Screen, display XY with one decimal place when possible
455
 // On the Info Screen, display XY with one decimal place when possible
453
 //#define LCD_DECIMAL_SMALL_XY
456
 //#define LCD_DECIMAL_SMALL_XY
454
 
457
 

+ 3
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

444
 // Include a page of printer information in the LCD Main Menu
444
 // Include a page of printer information in the LCD Main Menu
445
 //#define LCD_INFO_MENU
445
 //#define LCD_INFO_MENU
446
 
446
 
447
+// Scroll a longer status message into view
448
+//#define STATUS_MESSAGE_SCROLLING
449
+
447
 // On the Info Screen, display XY with one decimal place when possible
450
 // On the Info Screen, display XY with one decimal place when possible
448
 //#define LCD_DECIMAL_SMALL_XY
451
 //#define LCD_DECIMAL_SMALL_XY
449
 
452
 

+ 3
- 0
Marlin/example_configurations/gCreate_gMax1.5+/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 //#define LCD_INFO_MENU
443
 //#define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 3
- 0
Marlin/example_configurations/wt150/Configuration_adv.h View File

442
 // Include a page of printer information in the LCD Main Menu
442
 // Include a page of printer information in the LCD Main Menu
443
 #define LCD_INFO_MENU
443
 #define LCD_INFO_MENU
444
 
444
 
445
+// Scroll a longer status message into view
446
+//#define STATUS_MESSAGE_SCROLLING
447
+
445
 // On the Info Screen, display XY with one decimal place when possible
448
 // On the Info Screen, display XY with one decimal place when possible
446
 //#define LCD_DECIMAL_SMALL_XY
449
 //#define LCD_DECIMAL_SMALL_XY
447
 
450
 

+ 27
- 13
Marlin/ultralcd.cpp View File

60
 
60
 
61
 uint8_t lcd_status_message_level;
61
 uint8_t lcd_status_message_level;
62
 char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
62
 char lcd_status_message[3 * (LCD_WIDTH) + 1] = WELCOME_MSG; // worst case is kana with up to 3*LCD_WIDTH+1
63
+#if ENABLED(STATUS_MESSAGE_SCROLLING)
64
+  uint8_t status_scroll_pos = 0;
65
+#endif
63
 
66
 
64
 #if ENABLED(DOGLCD)
67
 #if ENABLED(DOGLCD)
65
   #include "ultralcd_impl_DOGM.h"
68
   #include "ultralcd_impl_DOGM.h"
3961
   } // ELAPSED(ms, next_lcd_update_ms)
3964
   } // ELAPSED(ms, next_lcd_update_ms)
3962
 }
3965
 }
3963
 
3966
 
3964
-void set_utf_strlen(char* s, uint8_t n) {
3965
-  uint8_t i = 0, j = 0;
3966
-  while (s[i] && (j < n)) {
3967
-    #if ENABLED(MAPPER_NON)
3968
-      j++;
3969
-    #else
3970
-      if ((s[i] & 0xC0u) != 0x80u) j++;
3971
-    #endif
3972
-    i++;
3967
+#if DISABLED(STATUS_MESSAGE_SCROLLING)
3968
+
3969
+  void set_utf_strlen(char* s, uint8_t n) {
3970
+    uint8_t i = 0, j = 0;
3971
+    while (s[i] && (j < n)) {
3972
+      #if ENABLED(MAPPER_NON)
3973
+        j++;
3974
+      #else
3975
+        if ((s[i] & 0xC0u) != 0x80u) j++;
3976
+      #endif
3977
+      i++;
3978
+    }
3979
+    while (j++ < n) s[i++] = ' ';
3980
+    s[i] = '\0';
3973
   }
3981
   }
3974
-  while (j++ < n) s[i++] = ' ';
3975
-  s[i] = '\0';
3976
-}
3982
+
3983
+#endif // !STATUS_MESSAGE_SCROLLING
3977
 
3984
 
3978
 void lcd_finishstatus(bool persist=false) {
3985
 void lcd_finishstatus(bool persist=false) {
3979
-  set_utf_strlen(lcd_status_message, LCD_WIDTH);
3986
+  #if DISABLED(STATUS_MESSAGE_SCROLLING)
3987
+    set_utf_strlen(lcd_status_message, LCD_WIDTH);
3988
+  #endif
3989
+
3980
   #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
3990
   #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
3981
     UNUSED(persist);
3991
     UNUSED(persist);
3982
   #endif
3992
   #endif
3992
   #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
4002
   #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
3993
     previous_lcd_status_ms = millis();  //get status message to show up for a while
4003
     previous_lcd_status_ms = millis();  //get status message to show up for a while
3994
   #endif
4004
   #endif
4005
+
4006
+  #if ENABLED(STATUS_MESSAGE_SCROLLING)
4007
+    status_scroll_pos = 0;
4008
+  #endif
3995
 }
4009
 }
3996
 
4010
 
3997
 #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
4011
 #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0

+ 33
- 14
Marlin/ultralcd_impl_DOGM.h View File

234
   else return charset_mapper(c);
234
   else return charset_mapper(c);
235
 }
235
 }
236
 
236
 
237
-void lcd_print(const char* const str) {
238
-  for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c);
237
+/**
238
+ * Core LCD printing functions
239
+ * On DOGM all strings go through a filter for utf
240
+ * But only use lcd_print_utf and lcd_printPGM_utf for translated text
241
+ */
242
+void lcd_print(const char* const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd_print(c); }
243
+void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd_print(c); }
244
+
245
+void lcd_print_utf(const char* const str, const uint8_t maxLength=LCD_WIDTH) {
246
+  char c;
247
+  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
248
+    n -= charset_mapper(c);
239
 }
249
 }
240
 
250
 
241
-/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
242
-void lcd_printPGM(const char* str) {
243
-  for (; char c = pgm_read_byte(str); ++str) lcd_print(c);
251
+void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) {
252
+  char c;
253
+  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
254
+    n -= charset_mapper(c);
244
 }
255
 }
245
 
256
 
246
 // Initialize or re-initialize the LCD
257
 // Initialize or re-initialize the LCD
320
 void lcd_kill_screen() {
331
 void lcd_kill_screen() {
321
   lcd_setFont(FONT_MENU);
332
   lcd_setFont(FONT_MENU);
322
   u8g.setPrintPos(0, u8g.getHeight()/4*1);
333
   u8g.setPrintPos(0, u8g.getHeight()/4*1);
323
-  lcd_print(lcd_status_message);
334
+  lcd_print_utf(lcd_status_message);
324
   u8g.setPrintPos(0, u8g.getHeight()/4*2);
335
   u8g.setPrintPos(0, u8g.getHeight()/4*2);
325
   lcd_printPGM(PSTR(MSG_HALTED));
336
   lcd_printPGM(PSTR(MSG_HALTED));
326
   u8g.setPrintPos(0, u8g.getHeight()/4*3);
337
   u8g.setPrintPos(0, u8g.getHeight()/4*3);
395
   }
406
   }
396
 }
407
 }
397
 
408
 
409
+inline void lcd_implementation_status_message() {
410
+  #if ENABLED(STATUS_MESSAGE_SCROLLING)
411
+    lcd_print_utf(lcd_status_message + status_scroll_pos);
412
+    const uint8_t slen = lcd_strlen(lcd_status_message);
413
+    if (slen > LCD_WIDTH) {
414
+      // Skip any non-printing bytes
415
+      while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos;
416
+      if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0;
417
+    }
418
+  #else
419
+    lcd_print_utf(lcd_status_message);
420
+  #endif
421
+}
422
+
398
 //#define DOGM_SD_PERCENT
423
 //#define DOGM_SD_PERCENT
399
 
424
 
400
 static void lcd_implementation_status_screen() {
425
 static void lcd_implementation_status_screen() {
645
 
670
 
646
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
671
     #if ENABLED(FILAMENT_LCD_DISPLAY) && ENABLED(SDSUPPORT)
647
       if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) {  //Display both Status message line and Filament display on the last line
672
       if (PENDING(millis(), previous_lcd_status_ms + 5000UL)) {  //Display both Status message line and Filament display on the last line
648
-        const char *str = lcd_status_message;
649
-        uint8_t i = LCD_WIDTH;
650
-        char c;
651
-        while (i-- && (c = *str++)) lcd_print(c);
673
+        lcd_implementation_status_message();
652
       }
674
       }
653
       else {
675
       else {
654
         lcd_printPGM(PSTR(LCD_STR_FILAM_DIA));
676
         lcd_printPGM(PSTR(LCD_STR_FILAM_DIA));
660
         u8g.print('%');
682
         u8g.print('%');
661
       }
683
       }
662
     #else
684
     #else
663
-      const char *str = lcd_status_message;
664
-      uint8_t i = LCD_WIDTH;
665
-      char c;
666
-      while (i-- && (c = *str++)) lcd_print(c);
685
+      lcd_implementation_status_message();
667
     #endif
686
     #endif
668
   }
687
   }
669
 }
688
 }

+ 25
- 12
Marlin/ultralcd_impl_HD44780.h View File

380
 
380
 
381
 void lcd_implementation_clear() { lcd.clear(); }
381
 void lcd_implementation_clear() { lcd.clear(); }
382
 
382
 
383
-/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
384
-void lcd_printPGM(const char *str) {
385
-  for (; char c = pgm_read_byte(str); ++str) charset_mapper(c);
386
-}
383
+void lcd_print(const char c) { charset_mapper(c); }
384
+
385
+void lcd_print(const char * const str) { for (uint8_t i = 0; char c = str[i]; ++i) lcd.print(c); }
386
+void lcd_printPGM(const char* str) { for (; char c = pgm_read_byte(str); ++str) lcd.print(c); }
387
 
387
 
388
-void lcd_print(const char* const str) {
389
-  for (uint8_t i = 0; const char c = str[i]; ++i) charset_mapper(c);
388
+void lcd_print_utf(const char * const str, const uint8_t maxLength=LCD_WIDTH) {
389
+  char c;
390
+  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
391
+    n -= charset_mapper(c);
390
 }
392
 }
391
 
393
 
392
-void lcd_print(const char c) { charset_mapper(c); }
394
+void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) {
395
+  char c;
396
+  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
397
+    n -= charset_mapper(c);
398
+}
393
 
399
 
394
 #if ENABLED(SHOW_BOOTSCREEN)
400
 #if ENABLED(SHOW_BOOTSCREEN)
395
 
401
 
545
 
551
 
546
 void lcd_kill_screen() {
552
 void lcd_kill_screen() {
547
   lcd.setCursor(0, 0);
553
   lcd.setCursor(0, 0);
548
-  lcd_print(lcd_status_message);
554
+  lcd_print_utf(lcd_status_message);
549
   #if LCD_HEIGHT < 4
555
   #if LCD_HEIGHT < 4
550
     lcd.setCursor(0, 2);
556
     lcd.setCursor(0, 2);
551
   #else
557
   #else
818
 
824
 
819
   #endif // FILAMENT_LCD_DISPLAY && SDSUPPORT
825
   #endif // FILAMENT_LCD_DISPLAY && SDSUPPORT
820
 
826
 
821
-  const char *str = lcd_status_message;
822
-  uint8_t i = LCD_WIDTH;
823
-  char c;
824
-  while (i-- && (c = *str++)) lcd_print(c);
827
+  #if ENABLED(STATUS_MESSAGE_SCROLLING)
828
+    lcd_print_utf(lcd_status_message + status_scroll_pos);
829
+    const uint8_t slen = lcd_strlen(lcd_status_message);
830
+    if (slen > LCD_WIDTH) {
831
+      // Skip any non-printing bytes
832
+      while (!charset_mapper(lcd_status_message[status_scroll_pos])) ++status_scroll_pos;
833
+      if (++status_scroll_pos > slen - LCD_WIDTH) status_scroll_pos = 0;
834
+    }
835
+  #else
836
+    lcd_print_utf(lcd_status_message);
837
+  #endif
825
 }
838
 }
826
 
839
 
827
 #if ENABLED(ULTIPANEL)
840
 #if ENABLED(ULTIPANEL)

Loading…
Cancel
Save