Bläddra i källkod

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 år sedan
förälder
incheckning
ca0e4b4e96
3 ändrade filer med 41 tillägg och 63 borttagningar
  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 Visa fil

816
 
816
 
817
   lcd_init();
817
   lcd_init();
818
 
818
 
819
-  #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
820
-    #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
821
-  #endif
822
-
823
   #if ENABLED(SHOW_BOOTSCREEN)
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
         lcd_init();
822
         lcd_init();
834
-      #endif
835
     #endif
823
     #endif
836
   #endif
824
   #endif
837
 
825
 

+ 1
- 8
Marlin/src/lcd/ultralcd.cpp Visa fil

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/src/lcd/ultralcd_impl_DOGM.h Visa fil

278
 
278
 
279
 #if ENABLED(SHOW_BOOTSCREEN)
279
 #if ENABLED(SHOW_BOOTSCREEN)
280
 
280
 
281
-  bool show_bootscreen = true;
282
-
283
   #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
281
   #if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
284
 
282
 
283
+    #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
284
+      #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
285
+    #endif
286
+
285
     void lcd_custom_bootscreen() {
287
     void lcd_custom_bootscreen() {
286
       u8g.firstPage();
288
       u8g.firstPage();
287
       do {
289
       do {
290
           ( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
292
           ( 64 - (CUSTOM_BOOTSCREEN_BMPHEIGHT)) /2,
291
           CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
293
           CEILING(CUSTOM_BOOTSCREEN_BMPWIDTH, 8), CUSTOM_BOOTSCREEN_BMPHEIGHT, custom_start_bmp);
292
       } while (u8g.nextPage());
294
       } while (u8g.nextPage());
295
+      safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
293
     }
296
     }
294
 
297
 
295
   #endif // SHOW_CUSTOM_BOOTSCREEN
298
   #endif // SHOW_CUSTOM_BOOTSCREEN
296
 
299
 
297
   void lcd_bootscreen() {
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
       #else
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
       #endif
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
 #endif // SHOW_BOOTSCREEN
329
 #endif // SHOW_BOOTSCREEN
351
   #elif ENABLED(LCD_SCREEN_ROT_270)
354
   #elif ENABLED(LCD_SCREEN_ROT_270)
352
     u8g.setRot270();  // Rotate screen by 270°
355
     u8g.setRot270();  // Rotate screen by 270°
353
   #endif
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
 // The kill screen is displayed for unrecoverable conditions
359
 // The kill screen is displayed for unrecoverable conditions
367
 void lcd_kill_screen() {
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
 void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
373
 void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
477
       }
473
       }
478
     }
474
     }
479
   #else
475
   #else
476
+    UNUSED(blink);
480
     lcd_print_utf(lcd_status_message);
477
     lcd_print_utf(lcd_status_message);
481
   #endif
478
   #endif
482
 }
479
 }

Laddar…
Avbryt
Spara