Sfoglia il codice sorgente

Scroll too long strings on bootscreen

AnHardt 10 anni fa
parent
commit
2684d061ed
1 ha cambiato i file con 26 aggiunte e 13 eliminazioni
  1. 26
    13
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 26
- 13
Marlin/ultralcd_implementation_hitachi_HD44780.h Vedi File

414
 unsigned lcd_print(char c) { return charset_mapper(c); }
414
 unsigned lcd_print(char c) { return charset_mapper(c); }
415
 
415
 
416
 #if ENABLED(SHOW_BOOTSCREEN)
416
 #if ENABLED(SHOW_BOOTSCREEN)
417
+  void lcd_erase_line(int line) {
418
+    lcd.setCursor(0, 3);
419
+    for (int i=0; i < LCD_WIDTH; i++)
420
+      lcd_print(' ');
421
+  }
422
+
423
+  // scrol the PSTR'text' in a 'len' wide field for 'time' milliseconds at position col,line
424
+  void lcd_scroll(int col, int line, const char * text, int len, int time) {
425
+    int l = lcd_strlen_P(text);
426
+    char tmp[LCD_WIDTH+1] = {0};
427
+    int n = l - len;
428
+    int t = time / ((n>1) ? n: 1);
429
+    for (int i = 0; i <= (((n-1)>0) ? n-1 : 0); i++) {
430
+      strncpy_P(tmp, text+i, min(len, LCD_WIDTH));
431
+      lcd.setCursor(col, line);
432
+      lcd_print(tmp);
433
+      delay(t);
434
+    }
435
+  }
436
+
417
   static void bootscreen() {
437
   static void bootscreen() {
418
     show_bootscreen = false;
438
     show_bootscreen = false;
419
     byte top_left[8] = {
439
     byte top_left[8] = {
469
        lcd_printPGM(PSTR(STRING_SPLASH_LINE1));
489
        lcd_printPGM(PSTR(STRING_SPLASH_LINE1));
470
     #endif
490
     #endif
471
     lcd.setCursor(0, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------"));  lcd.print('\x03');
491
     lcd.setCursor(0, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------"));  lcd.print('\x03');
472
-    lcd.setCursor(0, 3);                    lcd_printPGM(PSTR("marlinfirmware.org"));
473
-    delay(2000);
492
+
493
+    lcd_scroll(0, 3, PSTR("www.marlinfirmware.org" " "), LCD_WIDTH, 2000);
474
 
494
 
475
     #if (LCD_WIDTH <= 16) && defined(STRING_SPLASH_LINE1)
495
     #if (LCD_WIDTH <= 16) && defined(STRING_SPLASH_LINE1)
476
-      lcd.setCursor(0, 3);
477
-      lcd_printPGM(PSTR("                  "));
478
-      lcd.setCursor(0, 3);
479
-      lcd_printPGM(PSTR(STRING_SPLASH_LINE1));
480
-      delay(1000);
496
+      lcd_erase_line(3);
497
+      lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE1 " "), LCD_WIDTH, 1000);
481
     #endif
498
     #endif
482
-
483
     #ifdef STRING_SPLASH_LINE2
499
     #ifdef STRING_SPLASH_LINE2
484
-      lcd.setCursor(0, 3);
485
-      lcd_printPGM(PSTR("                  "));
486
-      lcd.setCursor(0, 3);
487
-      lcd_printPGM(PSTR(STRING_SPLASH_LINE2));
488
-      delay(1000);
500
+      lcd_erase_line(3);
501
+      lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2 " "), LCD_WIDTH, 1000);
489
     #endif
502
     #endif
490
   }
503
   }
491
 #endif // SHOW_BOOTSCREEN
504
 #endif // SHOW_BOOTSCREEN

Loading…
Annulla
Salva