diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 3d7897f95a0a..385a57202915 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -35,6 +35,18 @@ void safe_delay(millis_t ms) { thermalManager.manage_heater(); // This keeps us safe if too many small safe_delay() calls are made } +#if ENABLED(MARLIN_DEV_MODE) + void early_safe_delay(millis_t ms) { + while (ms > 50) { + ms -= 50; + delay(50); + watchdog_refresh(); + } + delay(ms); + watchdog_refresh(); + } +#endif + // A delay to provide brittle hosts time to receive bytes #if ENABLED(SERIAL_OVERRUN_PROTECTION) diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index d774b007b6d5..0e1c109be1ac 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -26,6 +26,11 @@ #include "../core/millis_t.h" void safe_delay(millis_t ms); // Delay ensuring that temperatures are updated and the watchdog is kept alive. +#if ENABLED(MARLIN_DEV_MODE) + void early_safe_delay(millis_t ms); // Delay ensuring that the watchdog is kept alive. Can be used before the Temperature ISR starts. +#else + inline void early_safe_delay(millis_t ms) { safe_delay(ms); } +#endif #if ENABLED(SERIAL_OVERRUN_PROTECTION) void serial_delay(const millis_t ms); diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index b0aebfb5bdd7..f0aad769383e 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -160,14 +160,14 @@ bool MarlinUI::detected() { return true; } #endif u8g.firstPage(); do { draw_custom_bootscreen(f); } while (u8g.nextPage()); - if (frame_time) safe_delay(frame_time); + if (frame_time) early_safe_delay(frame_time); } #ifndef CUSTOM_BOOTSCREEN_TIMEOUT #define CUSTOM_BOOTSCREEN_TIMEOUT 2500 #endif #if CUSTOM_BOOTSCREEN_TIMEOUT - safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); + early_safe_delay(CUSTOM_BOOTSCREEN_TIMEOUT); #endif } #endif // SHOW_CUSTOM_BOOTSCREEN @@ -226,7 +226,7 @@ bool MarlinUI::detected() { return true; } constexpr millis_t frame_time = MARLIN_BOOTSCREEN_FRAME_TIME; LOOP_L_N(f, COUNT(marlin_bootscreen_animation)) { draw_bootscreen_bmp((uint8_t*)pgm_read_ptr(&marlin_bootscreen_animation[f])); - if (frame_time) safe_delay(frame_time); + if (frame_time) early_safe_delay(frame_time); } #endif } @@ -235,7 +235,7 @@ bool MarlinUI::detected() { return true; } void MarlinUI::show_marlin_bootscreen() { for (uint8_t q = bootscreen_pages; q--;) { draw_marlin_bootscreen(q == 0); - if (q) safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); + if (q) early_safe_delay((BOOTSCREEN_TIMEOUT) / bootscreen_pages); } }