浏览代码

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 年前
父节点
当前提交
13a3fb1acc
共有 3 个文件被更改,包括 42 次插入64 次删除
  1. 3
    15
      Marlin/Marlin_main.cpp
  2. 1
    8
      Marlin/ultralcd.cpp
  3. 38
    41
      Marlin/ultralcd_impl_DOGM.h

+ 3
- 15
Marlin/Marlin_main.cpp 查看文件

13911
 
13911
 
13912
   lcd_init();
13912
   lcd_init();
13913
 
13913
 
13914
-  #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
13915
-    #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
13916
-  #endif
13917
-
13918
   #if ENABLED(SHOW_BOOTSCREEN)
13914
   #if ENABLED(SHOW_BOOTSCREEN)
13919
-    #if ENABLED(DOGLCD)                           // On DOGM the first bootscreen is already drawn
13920
-      #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
13921
-        safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);    // Custom boot screen pause
13922
-        lcd_bootscreen();                         // Show Marlin boot screen
13923
-      #endif
13924
-      safe_delay(BOOTSCREEN_TIMEOUT);             // Pause
13925
-    #elif ENABLED(ULTRA_LCD)
13926
-      lcd_bootscreen();
13927
-      #if DISABLED(SDSUPPORT)
13928
-        lcd_init();
13929
-      #endif
13915
+    lcd_bootscreen();
13916
+    #if ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
13917
+      lcd_init();
13930
     #endif
13918
     #endif
13931
   #endif
13919
   #endif
13932
 
13920
 

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

715
 void kill_screen(const char* lcd_msg) {
715
 void kill_screen(const char* lcd_msg) {
716
   lcd_init();
716
   lcd_init();
717
   lcd_setalertstatusPGM(lcd_msg);
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
 #if ENABLED(ULTIPANEL)
721
 #if ENABLED(ULTIPANEL)

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

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

正在加载...
取消
保存