浏览代码

Some cleanup around 'lcd_bootscreen()' and 'lcd_kill_screen()'

Move 'lcd_bootscreen()' from `lcd_init()` to 'setup()' where it is cexecute exactly once. Saves 'bool show_bootscreen'.
Move the call of 'lcd_custom_bootscreen()' to the begin of 'lcd_bootscreen()'.
Move the delays into the related functions.
Move the picture loop around 'lcd_kill_screen()' into the function.
AnHardt 7 年前
父节点
当前提交
ca0e4b4e96
共有 3 个文件被更改,包括 41 次插入63 次删除
  1. 2
    14
      Marlin/src/Marlin.cpp
  2. 1
    8
      Marlin/src/lcd/ultralcd.cpp
  3. 38
    41
      Marlin/src/lcd/ultralcd_impl_DOGM.h

+ 2
- 14
Marlin/src/Marlin.cpp 查看文件

@@ -816,22 +816,10 @@ void setup() {
816 816
 
817 817
   lcd_init();
818 818
 
819
-  #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
820
-    #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
821
-  #endif
822
-
823 819
   #if ENABLED(SHOW_BOOTSCREEN)
824
-    #if ENABLED(DOGLCD)                           // On DOGM the first bootscreen is already drawn
825
-      #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
826
-        safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);    // Custom boot screen pause
827
-        lcd_bootscreen();                         // Show Marlin boot screen
828
-      #endif
829
-      safe_delay(BOOTSCREEN_TIMEOUT);             // Pause
830
-    #elif ENABLED(ULTRA_LCD)
831
-      lcd_bootscreen();
832
-      #if DISABLED(SDSUPPORT)
820
+    lcd_bootscreen();
821
+    #if ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
833 822
         lcd_init();
834
-      #endif
835 823
     #endif
836 824
   #endif
837 825
 

+ 1
- 8
Marlin/src/lcd/ultralcd.cpp 查看文件

@@ -715,14 +715,7 @@ void lcd_reset_status() { lcd_setstatusPGM(PSTR(""), -1); }
715 715
 void kill_screen(const char* lcd_msg) {
716 716
   lcd_init();
717 717
   lcd_setalertstatusPGM(lcd_msg);
718
-  #if ENABLED(DOGLCD)
719
-    u8g.firstPage();
720
-    do {
721
-      lcd_kill_screen();
722
-    } while (u8g.nextPage());
723
-  #else
724
-    lcd_kill_screen();
725
-  #endif
718
+  lcd_kill_screen();
726 719
 }
727 720
 
728 721
 #if ENABLED(ULTIPANEL)

+ 38
- 41
Marlin/src/lcd/ultralcd_impl_DOGM.h 查看文件

@@ -278,10 +278,12 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
278 278
 
279 279
 #if ENABLED(SHOW_BOOTSCREEN)
280 280
 
281
-  bool show_bootscreen = true;
282
-
283 281
   #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
284 282
 
283
+    #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
284
+      #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
285
+    #endif
286
+
285 287
     void lcd_custom_bootscreen() {
286 288
       u8g.firstPage();
287 289
       do {
@@ -290,37 +292,38 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
290 292
           ( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
291 293
           CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
292 294
       } while (u8g.nextPage());
295
+      safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
293 296
     }
294 297
 
295 298
   #endif // SHOW_CUSTOM_BOOTSCREEN
296 299
 
297 300
   void lcd_bootscreen() {
301
+    #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
302
+      lcd_custom_bootscreen();
303
+    #endif
304
+
305
+    #if ENABLED(START_BMPHIGH)
306
+      constexpr uint8_t offy = 0;
307
+    #else
308
+      constexpr uint8_t offy = DOG_CHAR_HEIGHT;
309
+    #endif
298 310
 
299
-    if (show_bootscreen) {
300
-      show_bootscreen = false;
311
+    const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2,
312
+                  txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
301 313
 
302
-      #if ENABLED(START_BMPHIGH)
303
-        constexpr uint8_t offy = 0;
314
+    u8g.firstPage();
315
+    do {
316
+      u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
317
+      lcd_setFont(FONT_MENU);
318
+      #ifndef STRING_SPLASH_LINE2
319
+        u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
304 320
       #else
305
-        constexpr uint8_t offy = DOG_CHAR_HEIGHT;
321
+        const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
322
+        u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
323
+        u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
306 324
       #endif
307
-
308
-      const uint8_t offx = (u8g.getWidth() - (START_BMPWIDTH)) / 2,
309
-                    txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1) * (DOG_CHAR_WIDTH)) / 2;
310
-
311
-      u8g.firstPage();
312
-      do {
313
-        u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
314
-        lcd_setFont(FONT_MENU);
315
-        #ifndef STRING_SPLASH_LINE2
316
-          u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT), STRING_SPLASH_LINE1);
317
-        #else
318
-          const uint8_t txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1) * (DOG_CHAR_WIDTH)) / 2;
319
-          u8g.drawStr(txt1X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 3 / 2, STRING_SPLASH_LINE1);
320
-          u8g.drawStr(txt2X, u8g.getHeight() - (DOG_CHAR_HEIGHT) * 1 / 2, STRING_SPLASH_LINE2);
321
-        #endif
322
-      } while (u8g.nextPage());
323
-    }
325
+    } while (u8g.nextPage());
326
+    safe_delay(BOOTSCREEN_TIMEOUT);
324 327
   }
325 328
 
326 329
 #endif // SHOW_BOOTSCREEN
@@ -351,27 +354,20 @@ static void lcd_implementation_init() {
351 354
   #elif ENABLED(LCD_SCREEN_ROT_270)
352 355
     u8g.setRot270();  // Rotate screen by 270°
353 356
   #endif
354
-
355
-  #if ENABLED(SHOW_BOOTSCREEN)
356
-    if (show_bootscreen) {
357
-      #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
358
-        lcd_custom_bootscreen();
359
-      #else
360
-        lcd_bootscreen();
361
-      #endif
362
-    }
363
-  #endif
364 357
 }
365 358
 
366 359
 // The kill screen is displayed for unrecoverable conditions
367 360
 void lcd_kill_screen() {
368
-  lcd_setFont(FONT_MENU);
369
-  u8g.setPrintPos(0, u8g.getHeight()/4*1);
370
-  lcd_print_utf(lcd_status_message);
371
-  u8g.setPrintPos(0, u8g.getHeight()/4*2);
372
-  lcd_printPGM(PSTR(MSG_HALTED));
373
-  u8g.setPrintPos(0, u8g.getHeight()/4*3);
374
-  lcd_printPGM(PSTR(MSG_PLEASE_RESET));
361
+  u8g.firstPage();
362
+  do {
363
+    lcd_setFont(FONT_MENU);
364
+    u8g.setPrintPos(0, u8g.getHeight()/4*1);
365
+    lcd_print_utf(lcd_status_message);
366
+    u8g.setPrintPos(0, u8g.getHeight()/4*2);
367
+    lcd_printPGM(PSTR(MSG_HALTED));
368
+    u8g.setPrintPos(0, u8g.getHeight()/4*3);
369
+    lcd_printPGM(PSTR(MSG_PLEASE_RESET));
370
+  } while (u8g.nextPage());
375 371
 }
376 372
 
377 373
 void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
@@ -477,6 +473,7 @@ inline void lcd_implementation_status_message(const bool blink) {
477 473
       }
478 474
     }
479 475
   #else
476
+    UNUSED(blink);
480 477
     lcd_print_utf(lcd_status_message);
481 478
   #endif
482 479
 }

正在加载...
取消
保存