Bladeren bron

Move last bootscreen delay to end of setup (#21665)

Scott Lahteine 3 jaren geleden
bovenliggende
commit
a29aefc9c0
No account linked to committer's email address

+ 10
- 1
Marlin/src/MarlinCore.cpp Bestand weergeven

@@ -1214,8 +1214,9 @@ void setup() {
1214 1214
     DWIN_UpdateLCD();     // Show bootscreen (first image)
1215 1215
   #else
1216 1216
     SETUP_RUN(ui.init());
1217
-    #if HAS_WIRED_LCD && ENABLED(SHOW_BOOTSCREEN)
1217
+    #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
1218 1218
       SETUP_RUN(ui.show_bootscreen());
1219
+      const millis_t bootscreen_ms = millis();
1219 1220
     #endif
1220 1221
     SETUP_RUN(ui.reset_status());     // Load welcome message early. (Retained if no errors exist.)
1221 1222
   #endif
@@ -1501,6 +1502,14 @@ void setup() {
1501 1502
     SETUP_RUN(tft_lvgl_init());
1502 1503
   #endif
1503 1504
 
1505
+  #if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
1506
+    const millis_t elapsed = millis() - bootscreen_ms;
1507
+    #if ENABLED(MARLIN_DEV_MODE)
1508
+      SERIAL_ECHOLNPAIR("elapsed=", elapsed);
1509
+    #endif
1510
+    SETUP_RUN(ui.bootscreen_completion(elapsed));
1511
+  #endif
1512
+
1504 1513
   #if ENABLED(PASSWORD_ON_STARTUP)
1505 1514
     SETUP_RUN(password.lock_machine());      // Will not proceed until correct password provided
1506 1515
   #endif

+ 12
- 0
Marlin/src/core/utility.cpp Bestand weergeven

@@ -35,6 +35,18 @@ void safe_delay(millis_t ms) {
35 35
   thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made
36 36
 }
37 37
 
38
+#if ENABLED(MARLIN_DEV_MODE)
39
+  void early_safe_delay(millis_t ms) {
40
+    while (ms > 50) {
41
+      ms -= 50;
42
+      delay(50);
43
+      watchdog_refresh();
44
+    }
45
+    delay(ms);
46
+    watchdog_refresh();
47
+  }
48
+#endif
49
+
38 50
 // A delay to provide brittle hosts time to receive bytes
39 51
 #if ENABLED(SERIAL_OVERRUN_PROTECTION)
40 52
 

+ 6
- 2
Marlin/src/core/utility.h Bestand weergeven

@@ -25,8 +25,12 @@
25 25
 #include "../core/types.h"
26 26
 #include "../core/millis_t.h"
27 27
 
28
-// Delay that ensures heaters and watchdog are kept alive
29
-void safe_delay(millis_t ms);
28
+void safe_delay(millis_t ms);           // Delay ensuring that temperatures are updated and the watchdog is kept alive.
29
+#if ENABLED(MARLIN_DEV_MODE)
30
+  void early_safe_delay(millis_t ms);   // Delay ensuring that the watchdog is kept alive. Can be used before the Temperature ISR starts.
31
+#else
32
+  inline void early_safe_delay(millis_t ms) { safe_delay(ms); }
33
+#endif
30 34
 
31 35
 #if ENABLED(SERIAL_OVERRUN_PROTECTION)
32 36
   void serial_delay(const millis_t ms);

+ 2
- 0
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Bestand weergeven

@@ -486,7 +486,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); }
486 486
         CENTER_OR_SCROLL(STRING_SPLASH_LINE3, 1500);
487 487
       #endif
488 488
     }
489
+  }
489 490
 
491
+  void MarlinUI::bootscreen_completion(const millis_t) {
490 492
     lcd.clear();
491 493
     safe_delay(100);
492 494
     set_custom_characters(CHARSET_INFO);

+ 4
- 1
Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp Bestand weergeven

@@ -397,7 +397,10 @@ static void center_text_P(PGM_P pstart, uint8_t y) {
397 397
     center_text_P(PSTR(MARLIN_WEBSITE_URL), 4);
398 398
     picBits = ICON_LOGO;
399 399
     lcd.print_screen();
400
-    safe_delay(1500);
400
+  }
401
+
402
+  void MarlinUI::bootscreen_completion(const millis_t sofar) {
403
+    if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar);
401 404
   }
402 405
 
403 406
 #endif // SHOW_BOOTSCREEN

+ 10
- 6
Marlin/src/lcd/dogm/marlinui_DOGM.cpp Bestand weergeven

@@ -160,20 +160,21 @@ bool MarlinUI::detected() { return true; }
160 160
           #endif
161 161
           u8g.firstPage();
162 162
           do { draw_custom_bootscreen(f); } while (u8g.nextPage());
163
-          if (frame_time) safe_delay(frame_time);
163
+          if (frame_time) early_safe_delay(frame_time);
164 164
         }
165 165
 
166 166
       #ifndef CUSTOM_BOOTSCREEN_TIMEOUT
167 167
         #define CUSTOM_BOOTSCREEN_TIMEOUT 2500
168 168
       #endif
169 169
       #if CUSTOM_BOOTSCREEN_TIMEOUT
170
-        safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
170
+        early_safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT);
171 171
       #endif
172 172
     }
173 173
   #endif // SHOW_CUSTOM_BOOTSCREEN
174 174
 
175 175
   // Two-part needed to display all info
176 176
   constexpr bool two_part = ((LCD_PIXEL_HEIGHT) - (START_BMPHEIGHT)) < ((MENU_FONT_ASCENT) * 2);
177
+  constexpr uint8_t bootscreen_pages = 1 + two_part;
177 178
 
178 179
   // Draw the static Marlin bootscreen from a u8g loop
179 180
   // or the animated boot screen within its own u8g loop
@@ -225,17 +226,16 @@ bool MarlinUI::detected() { return true; }
225 226
       constexpr millis_t frame_time = MARLIN_BOOTSCREEN_FRAME_TIME;
226 227
       LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) {
227 228
         draw_bootscreen_bmp((uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f]));
228
-        if (frame_time) safe_delay(frame_time);
229
+        if (frame_time) early_safe_delay(frame_time);
229 230
       }
230 231
     #endif
231 232
   }
232 233
 
233 234
   // Show the Marlin bootscreen, with the u8g loop and delays
234 235
   void MarlinUI::show_marlin_bootscreen() {
235
-    constexpr uint8_t pages = two_part ? 2 : 1;
236
-    for (uint8_t q = pages; q--;) {
236
+    for (uint8_t q = bootscreen_pages; q--;) {
237 237
       draw_marlin_bootscreen(q == 0);
238
-      safe_delay((BOOTSCREEN_TIMEOUT) / pages);
238
+      if (q) early_safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages);
239 239
     }
240 240
   }
241 241
 
@@ -244,6 +244,10 @@ bool MarlinUI::detected() { return true; }
244 244
     show_marlin_bootscreen();
245 245
   }
246 246
 
247
+  void MarlinUI::bootscreen_completion(const millis_t sofar) {
248
+    if ((BOOTSCREEN_TIMEOUT) / bootscreen_pages > sofar) safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages - sofar);
249
+  }
250
+
247 251
 #endif // SHOW_BOOTSCREEN
248 252
 
249 253
 #if ENABLED(LIGHTWEIGHT_UI)

+ 1
- 0
Marlin/src/lcd/marlinui.h Bestand weergeven

@@ -337,6 +337,7 @@ public:
337 337
         static void draw_marlin_bootscreen(const bool line2=false);
338 338
         static void show_marlin_bootscreen();
339 339
         static void show_bootscreen();
340
+        static void bootscreen_completion(const millis_t sofar);
340 341
       #endif
341 342
 
342 343
       #if HAS_MARLINUI_U8GLIB

+ 6
- 1
Marlin/src/lcd/tft/ui_320x240.cpp Bestand weergeven

@@ -60,6 +60,7 @@ void MarlinUI::tft_idle() {
60 60
 }
61 61
 
62 62
 #if ENABLED(SHOW_BOOTSCREEN)
63
+
63 64
   void MarlinUI::show_bootscreen() {
64 65
     tft.queue.reset();
65 66
 
@@ -81,9 +82,13 @@ void MarlinUI::tft_idle() {
81 82
     #endif
82 83
 
83 84
     tft.queue.sync();
84
-    safe_delay(BOOTSCREEN_TIMEOUT);
85
+  }
86
+
87
+  void MarlinUI::bootscreen_completion(const millis_t sofar) {
88
+    if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar);
85 89
     clear_lcd();
86 90
   }
91
+
87 92
 #endif
88 93
 
89 94
 void MarlinUI::draw_kill_screen() {

+ 6
- 1
Marlin/src/lcd/tft/ui_480x320.cpp Bestand weergeven

@@ -60,6 +60,7 @@ void MarlinUI::tft_idle() {
60 60
 }
61 61
 
62 62
 #if ENABLED(SHOW_BOOTSCREEN)
63
+
63 64
   void MarlinUI::show_bootscreen() {
64 65
     tft.queue.reset();
65 66
 
@@ -81,9 +82,13 @@ void MarlinUI::tft_idle() {
81 82
     #endif
82 83
 
83 84
     tft.queue.sync();
84
-    safe_delay(BOOTSCREEN_TIMEOUT);
85
+  }
86
+
87
+  void MarlinUI::bootscreen_completion(const millis_t sofar) {
88
+    if ((BOOTSCREEN_TIMEOUT) > sofar) safe_delay((BOOTSCREEN_TIMEOUT) - sofar);
85 89
     clear_lcd();
86 90
   }
91
+
87 92
 #endif
88 93
 
89 94
 void MarlinUI::draw_kill_screen() {

Laden…
Annuleren
Opslaan