Przeglądaj źródła

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 6 lat temu
rodzic
commit
13a3fb1acc
3 zmienionych plików z 42 dodań i 64 usunięć
  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 Wyświetl plik

@@ -13911,22 +13911,10 @@ void setup() {
13911 13911
 
13912 13912
   lcd_init();
13913 13913
 
13914
-  #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
13915
-    #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
13916
-  #endif
13917
-
13918 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 13918
     #endif
13931 13919
   #endif
13932 13920
 

+ 1
- 8
Marlin/ultralcd.cpp Wyświetl plik

@@ -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/ultralcd_impl_DOGM.h Wyświetl plik

@@ -277,10 +277,12 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
277 277
 
278 278
 #if ENABLED(SHOW_BOOTSCREEN)
279 279
 
280
-  bool show_bootscreen = true;
281
-
282 280
   #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
283 281
 
282
+    #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
283
+      #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
284
+    #endif
285
+
284 286
     void lcd_custom_bootscreen() {
285 287
       u8g.firstPage();
286 288
       do {
@@ -289,37 +291,38 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
289 291
           ( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
290 292
           CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
291 293
       } while (u8g.nextPage());
294
+      safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
292 295
     }
293 296
 
294 297
   #endif // SHOW_CUSTOM_BOOTSCREEN
295 298
 
296 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 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 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 328
 #endif // SHOW_BOOTSCREEN
@@ -350,27 +353,20 @@ static void lcd_implementation_init() {
350 353
   #elif ENABLED(LCD_SCREEN_ROT_270)
351 354
     u8g.setRot270();  // Rotate screen by 270°
352 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 358
 // The kill screen is displayed for unrecoverable conditions
366 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 372
 void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
@@ -476,6 +472,7 @@ inline void lcd_implementation_status_message(const bool blink) {
476 472
       }
477 473
     }
478 474
   #else
475
+    UNUSED(blink);
479 476
     lcd_print_utf(lcd_status_message);
480 477
   #endif
481 478
 }

Ładowanie…
Anuluj
Zapisz