From d96c769fd6c8dcbe33b376ecbce19bd8c3c163cc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 19 Apr 2020 01:11:56 -0500 Subject: [PATCH] Move Power Loss Recovery check --- Marlin/src/MarlinCore.cpp | 4 ---- Marlin/src/feature/powerloss.cpp | 4 ++-- Marlin/src/sd/cardreader.cpp | 9 +++++++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1b78d45a01..8539114488 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1161,10 +1161,6 @@ void setup() { SETUP_RUN(est_init()); #endif - #if ENABLED(POWER_LOSS_RECOVERY) - SETUP_RUN(recovery.check()); - #endif - #if ENABLED(USE_WATCHDOG) SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call #endif diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 77d0047a5c..397b88d362 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -100,10 +100,10 @@ void PrintJobRecovery::changed() { * If a saved state exists send 'M1000 S' to initiate job recovery. */ void PrintJobRecovery::check() { - if (!card.isMounted()) card.mount(); + //if (!card.isMounted()) card.mount(); if (card.isMounted()) { load(); - if (!valid()) return purge(); + if (!valid()) return cancel(); queue.inject_P(PSTR("M1000 S")); } } diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 389ef110b3..25a0bd479e 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -408,8 +408,13 @@ void CardReader::manage_media() { ui.media_changed(old_stat, stat); // Update the UI - if (stat && old_stat == 2) // First mount? - beginautostart(); // Look for autostart files soon + if (stat && old_stat == 2) { // First mount? + #if ENABLED(POWER_LOSS_RECOVERY) + recovery.check(); + #else + beginautostart(); // Look for autostart files soon + #endif + } } }