From 2684d061ed559889d3f6cb17332d4e401a94c32d Mon Sep 17 00:00:00 2001 From: AnHardt Date: Fri, 31 Jul 2015 23:29:52 +0200 Subject: [PATCH] Scroll too long strings on bootscreen --- .../ultralcd_implementation_hitachi_HD44780.h | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index f7e1f83206..0c17f23050 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -414,6 +414,26 @@ char lcd_print(char* str) { unsigned lcd_print(char c) { return charset_mapper(c); } #if ENABLED(SHOW_BOOTSCREEN) + void lcd_erase_line(int line) { + lcd.setCursor(0, 3); + for (int i=0; i < LCD_WIDTH; i++) + lcd_print(' '); + } + + // scrol the PSTR'text' in a 'len' wide field for 'time' milliseconds at position col,line + void lcd_scroll(int col, int line, const char * text, int len, int time) { + int l = lcd_strlen_P(text); + char tmp[LCD_WIDTH+1] = {0}; + int n = l - len; + int t = time / ((n>1) ? n: 1); + for (int i = 0; i <= (((n-1)>0) ? n-1 : 0); i++) { + strncpy_P(tmp, text+i, min(len, LCD_WIDTH)); + lcd.setCursor(col, line); + lcd_print(tmp); + delay(t); + } + } + static void bootscreen() { show_bootscreen = false; byte top_left[8] = { @@ -469,23 +489,16 @@ unsigned lcd_print(char c) { return charset_mapper(c); } lcd_printPGM(PSTR(STRING_SPLASH_LINE1)); #endif lcd.setCursor(0, 2); lcd.print('\x02'); lcd_printPGM(PSTR( "------")); lcd.print('\x03'); - lcd.setCursor(0, 3); lcd_printPGM(PSTR("marlinfirmware.org")); - delay(2000); + + lcd_scroll(0, 3, PSTR("www.marlinfirmware.org" " "), LCD_WIDTH, 2000); #if (LCD_WIDTH <= 16) && defined(STRING_SPLASH_LINE1) - lcd.setCursor(0, 3); - lcd_printPGM(PSTR(" ")); - lcd.setCursor(0, 3); - lcd_printPGM(PSTR(STRING_SPLASH_LINE1)); - delay(1000); + lcd_erase_line(3); + lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE1 " "), LCD_WIDTH, 1000); #endif - #ifdef STRING_SPLASH_LINE2 - lcd.setCursor(0, 3); - lcd_printPGM(PSTR(" ")); - lcd.setCursor(0, 3); - lcd_printPGM(PSTR(STRING_SPLASH_LINE2)); - delay(1000); + lcd_erase_line(3); + lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2 " "), LCD_WIDTH, 1000); #endif } #endif // SHOW_BOOTSCREEN