Преглед на файлове

Fix LCD printing of progmem strings

Scott Lahteine преди 7 години
родител
ревизия
8d69394ae1
променени са 2 файла, в които са добавени 12 реда и са изтрити 16 реда
  1. 6
    8
      Marlin/ultralcd_impl_DOGM.h
  2. 6
    8
      Marlin/ultralcd_impl_HD44780.h

+ 6
- 8
Marlin/ultralcd_impl_DOGM.h Целия файл

@@ -239,19 +239,17 @@ char lcd_print_and_count(const char c) {
239 239
  * On DOGM all strings go through a filter for utf
240 240
  * But only use lcd_print_utf and lcd_printPGM_utf for translated text
241 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); }
242
+void lcd_print(const char *str) { while (*str) lcd_print(*str++); }
243
+void lcd_printPGM(const char *str) { while (const char c = pgm_read_byte(str)) lcd_print(c), ++str; }
244 244
 
245
-void lcd_print_utf(const char* const str, const uint8_t maxLength=LCD_WIDTH) {
245
+void lcd_print_utf(const char *str, uint8_t n=LCD_WIDTH) {
246 246
   char c;
247
-  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
248
-    n -= charset_mapper(c);
247
+  while (n && (c = *str)) n -= charset_mapper(c), ++str;
249 248
 }
250 249
 
251
-void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) {
250
+void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
252 251
   char c;
253
-  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
254
-    n -= charset_mapper(c);
252
+  while (n && (c = pgm_read_byte(str))) n -= charset_mapper(c), ++str;
255 253
 }
256 254
 
257 255
 // Initialize or re-initialize the LCD

+ 6
- 8
Marlin/ultralcd_impl_HD44780.h Целия файл

@@ -382,19 +382,17 @@ void lcd_implementation_clear() { lcd.clear(); }
382 382
 
383 383
 void lcd_print(const char c) { charset_mapper(c); }
384 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); }
385
+void lcd_print(const char *str) { while (*str) lcd.print(*str++); }
386
+void lcd_printPGM(const char *str) { while (const char c = pgm_read_byte(str)) lcd.print(c), ++str; }
387 387
 
388
-void lcd_print_utf(const char * const str, const uint8_t maxLength=LCD_WIDTH) {
388
+void lcd_print_utf(const char *str, uint8_t n=LCD_WIDTH) {
389 389
   char c;
390
-  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
391
-    n -= charset_mapper(c);
390
+  while (n && (c = *str)) n -= charset_mapper(c), ++str;
392 391
 }
393 392
 
394
-void lcd_printPGM_utf(const char* str, const uint8_t maxLength=LCD_WIDTH) {
393
+void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
395 394
   char c;
396
-  for (uint8_t i = 0, n = maxLength; n && (c = str[i]); ++i)
397
-    n -= charset_mapper(c);
395
+  while (n && (c = pgm_read_byte(str))) n -= charset_mapper(c), ++str;
398 396
 }
399 397
 
400 398
 #if ENABLED(SHOW_BOOTSCREEN)

Loading…
Отказ
Запис