소스 검색

Scroll too long strings on bootscreen

AnHardt 10 년 전
부모
커밋
2684d061ed
1개의 변경된 파일26개의 추가작업 그리고 13개의 파일을 삭제
  1. 26
    13
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 26
- 13
Marlin/ultralcd_implementation_hitachi_HD44780.h 파일 보기

@@ -414,6 +414,26 @@ char lcd_print(char* str) {
414 414
 unsigned lcd_print(char c) { return charset_mapper(c); }
415 415
 
416 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 437
   static void bootscreen() {
418 438
     show_bootscreen = false;
419 439
     byte top_left[8] = {
@@ -469,23 +489,16 @@ unsigned lcd_print(char c) { return charset_mapper(c); }
469 489
        lcd_printPGM(PSTR(STRING_SPLASH_LINE1));
470 490
     #endif
471 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 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 498
     #endif
482
-
483 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 502
     #endif
490 503
   }
491 504
 #endif // SHOW_BOOTSCREEN

Loading…
취소
저장