From 3a67fb77b08e6b7d51a5aae274f4a6b9ca79158a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 8 Jul 2016 18:14:31 -0700 Subject: [PATCH] Concatenate LCD static strings --- Marlin/dogm_lcd_implementation.h | 8 ++++---- Marlin/ultralcd_implementation_hitachi_HD44780.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 16c48e7be4..bfb18589e8 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -494,13 +494,13 @@ static void lcd_implementation_mark_as_selected(uint8_t row, bool isSelected) { int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; while (--pad >= 0) { lcd_print(' '); n--; } } - while (c = pgm_read_byte(pstr)) { + while (n > 0 && (c = pgm_read_byte(pstr))) { n -= lcd_print(c); pstr++; } - if (valstr) { - lcd_print(valstr); - n -= lcd_strlen(valstr); + if (valstr) while (n > 0 && (c = *valstr)) { + n -= lcd_print(c); + valstr++; } while (n-- > 0) lcd_print(' '); } diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 7f7bee5492..f1838a6f7d 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -838,13 +838,13 @@ static void lcd_implementation_status_screen() { int8_t pad = (LCD_WIDTH - lcd_strlen_P(pstr)) / 2; while (--pad >= 0) { lcd.print(' '); n--; } } - while ((c = pgm_read_byte(pstr)) && n > 0) { + while (n > 0 && (c = pgm_read_byte(pstr))) { n -= lcd_print(c); pstr++; } - if (valstr) { - lcd_print(valstr); - n -= lcd_strlen(valstr); + if (valstr) while (n > 0 && (c = *valstr)) { + n -= lcd_print(c); + valstr++; } while (n-- > 0) lcd.print(' '); }