Browse Source

Concatenate LCD static strings

Scott Lahteine 9 years ago
parent
commit
3a67fb77b0

+ 4
- 4
Marlin/dogm_lcd_implementation.h View File

494
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
494
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
495
       while (--pad >= 0) { lcd_print(' '); n--; }
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
       n -= lcd_print(c);
498
       n -= lcd_print(c);
499
       pstr++;
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
     while (n-- > 0) lcd_print(' ');
505
     while (n-- > 0) lcd_print(' ');
506
   }
506
   }

+ 4
- 4
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

838
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
838
       int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2;
839
       while (--pad >= 0) { lcd.print(' '); n--; }
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
       n -= lcd_print(c);
842
       n -= lcd_print(c);
843
       pstr++;
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
     while (n-- > 0) lcd.print(' ');
849
     while (n-- > 0) lcd.print(' ');
850
   }
850
   }

Loading…
Cancel
Save