Browse Source

Concatenate LCD static strings

Scott Lahteine 8 years ago
parent
commit
3a67fb77b0

+ 4
- 4
Marlin/dogm_lcd_implementation.h View File

@@ -494,13 +494,13 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) {
494 494
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
495 495
       while (--pad >= 0) { lcd_print(' '); n--; }
496 496
     }
497
-    while (c = pgm_read_byte(pstr)) {
497
+    while (n > 0 && (c = pgm_read_byte(pstr))) {
498 498
       n -= lcd_print(c);
499 499
       pstr++;
500 500
     }
501
-    if (valstr) {
502
-      lcd_print(valstr);
503
-      n -= lcd_strlen(valstr);
501
+    if (valstr) while (n > 0 && (c = *valstr)) {
502
+      n -= lcd_print(c);
503
+      valstr++;
504 504
     }
505 505
     while (n-- > 0) lcd_print(' ');
506 506
   }

+ 4
- 4
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -838,13 +838,13 @@ static void lcd_implementation_status_screen() {
838 838
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
839 839
       while (--pad >= 0) { lcd.print(' '); n--; }
840 840
     }
841
-    while ((c = pgm_read_byte(pstr)) && n > 0) {
841
+    while (n > 0 && (c = pgm_read_byte(pstr))) {
842 842
       n -= lcd_print(c);
843 843
       pstr++;
844 844
     }
845
-    if (valstr) {
846
-      lcd_print(valstr);
847
-      n -= lcd_strlen(valstr);
845
+    if (valstr) while (n > 0 && (c = *valstr)) {
846
+      n -= lcd_print(c);
847
+      valstr++;
848 848
     }
849 849
     while (n-- > 0) lcd.print(' ');
850 850
   }

Loading…
Cancel
Save