Browse Source

Merge pull request #3543 from thinkyhead/rc_better_bootscreen

Better splash screen consolidation
Scott Lahteine 8 years ago
parent
commit
09c6323b68
1 changed files with 37 additions and 11 deletions
  1. 37
    11
      Marlin/ultralcd_implementation_hitachi_HD44780.h

+ 37
- 11
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

445
     }
445
     }
446
   }
446
   }
447
 
447
 
448
-  inline void logo_lines(const char *extra) {
448
+  static void logo_lines(const char *extra) {
449
     int indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
449
     int indent = (LCD_WIDTH - 8 - lcd_strlen_P(extra)) / 2;
450
     lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------" ));  lcd.print('\x01');
450
     lcd.setCursor(indent, 0); lcd.print('\x00'); lcd_printPGM(PSTR( "------" ));  lcd.print('\x01');
451
     lcd.setCursor(indent, 1);                    lcd_printPGM(PSTR("|Marlin|"));  lcd_printPGM(extra);
451
     lcd.setCursor(indent, 1);                    lcd_printPGM(PSTR("|Marlin|"));  lcd_printPGM(extra);
503
 
503
 
504
     #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
504
     #define LCD_EXTRA_SPACE (LCD_WIDTH-8)
505
 
505
 
506
+    #define CENTER_OR_SCROLL(STRING,DELAY) \
507
+      lcd_erase_line(3); \
508
+      if (strlen(STRING) <= LCD_WIDTH) { \
509
+        lcd.setCursor((LCD_WIDTH - lcd_strlen_P(PSTR(STRING))) / 2, 3); \
510
+        lcd_printPGM(PSTR(STRING)); \
511
+        delay(DELAY); \
512
+      } \
513
+      else { \
514
+        lcd_scroll(0, 3, PSTR(STRING), LCD_WIDTH, DELAY); \
515
+      }
516
+
506
     #ifdef STRING_SPLASH_LINE1
517
     #ifdef STRING_SPLASH_LINE1
507
-      // Combine into a single splash screen if possible
518
+      //
519
+      // Show the Marlin logo with splash line 1
520
+      //
508
       if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE1) + 1) {
521
       if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE1) + 1) {
522
+        //
523
+        // Show the Marlin logo, splash line1, and splash line 2
524
+        //
509
         logo_lines(PSTR(" " STRING_SPLASH_LINE1));
525
         logo_lines(PSTR(" " STRING_SPLASH_LINE1));
510
         #ifdef STRING_SPLASH_LINE2
526
         #ifdef STRING_SPLASH_LINE2
511
-          lcd_erase_line(3);
512
-          lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2), LCD_WIDTH, 2000);
527
+          CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 2000);
513
         #else
528
         #else
514
           delay(2000);
529
           delay(2000);
515
         #endif
530
         #endif
516
       }
531
       }
517
       else {
532
       else {
533
+        //
534
+        // Show the Marlin logo with splash line 1
535
+        // After a delay show splash line 2, if it exists
536
+        //
537
+        #ifdef STRING_SPLASH_LINE2
538
+          #define _SPLASH_WAIT_1 1500
539
+        #else
540
+          #define _SPLASH_WAIT_1 2000
541
+        #endif
518
         logo_lines(PSTR(""));
542
         logo_lines(PSTR(""));
519
-        lcd_erase_line(3);
520
-        lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE1), LCD_WIDTH, 1500);
543
+        CENTER_OR_SCROLL(STRING_SPLASH_LINE1, _SPLASH_WAIT_1);
521
         #ifdef STRING_SPLASH_LINE2
544
         #ifdef STRING_SPLASH_LINE2
522
-          lcd_erase_line(3);
523
-          lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2), LCD_WIDTH, 1500);
545
+          CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 1500);
524
         #endif
546
         #endif
525
       }
547
       }
526
     #elif defined(STRING_SPLASH_LINE2)
548
     #elif defined(STRING_SPLASH_LINE2)
527
-      // Combine into a single splash screen if possible
549
+      //
550
+      // Show splash line 2 only, alongside the logo if possible
551
+      //
528
       if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE2) + 1) {
552
       if (LCD_EXTRA_SPACE >= strlen(STRING_SPLASH_LINE2) + 1) {
529
         logo_lines(PSTR(" " STRING_SPLASH_LINE2));
553
         logo_lines(PSTR(" " STRING_SPLASH_LINE2));
530
         delay(2000);
554
         delay(2000);
531
       }
555
       }
532
       else {
556
       else {
533
         logo_lines(PSTR(""));
557
         logo_lines(PSTR(""));
534
-        lcd_erase_line(3);
535
-        lcd_scroll(0, 3, PSTR(STRING_SPLASH_LINE2), LCD_WIDTH, 2000);
558
+        CENTER_OR_SCROLL(STRING_SPLASH_LINE2, 2000);
536
       }
559
       }
537
     #else
560
     #else
561
+      //
562
+      // Show only the Marlin logo
563
+      //
538
       logo_lines(PSTR(""));
564
       logo_lines(PSTR(""));
539
       delay(2000);
565
       delay(2000);
540
     #endif
566
     #endif

Loading…
Cancel
Save