🧑‍💻 Handle PLR in manage_media

This commit is contained in:
Scott Lahteine 2022-04-17 21:19:50 -05:00
parent aaf5bf0218
commit fd082df077
4 changed files with 18 additions and 11 deletions

View file

@ -108,13 +108,18 @@ void PrintJobRecovery::changed() {
* *
* If a saved state exists send 'M1000 S' to initiate job recovery. * If a saved state exists send 'M1000 S' to initiate job recovery.
*/ */
void PrintJobRecovery::check() { bool PrintJobRecovery::check() {
//if (!card.isMounted()) card.mount(); //if (!card.isMounted()) card.mount();
bool success = false;
if (card.isMounted()) { if (card.isMounted()) {
load(); load();
if (!valid()) return cancel(); success = valid();
if (!success)
cancel();
else
queue.inject(F("M1000S")); queue.inject(F("M1000S"));
} }
return success;
} }
/** /**

View file

@ -176,11 +176,11 @@ class PrintJobRecovery {
static void open(const bool read) { card.openJobRecoveryFile(read); } static void open(const bool read) { card.openJobRecoveryFile(read); }
static void close() { file.close(); } static void close() { file.close(); }
static void check(); static bool check();
static void resume(); static void resume();
static void purge(); static void purge();
static void cancel() { purge(); IF_DISABLED(NO_SD_AUTOSTART, card.autofile_begin()); } static void cancel() { purge(); }
static void load(); static void load();
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false); static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);

View file

@ -49,7 +49,7 @@ void GcodeSuite::M413() {
if (parser.seen_test('P')) recovery.purge(); if (parser.seen_test('P')) recovery.purge();
if (parser.seen_test('D')) recovery.debug(F("M413")); if (parser.seen_test('D')) recovery.debug(F("M413"));
if (parser.seen_test('O')) recovery._outage(true); if (parser.seen_test('O')) recovery._outage(true);
if (parser.seen_test('C')) recovery.check(); if (parser.seen_test('C')) (void)recovery.check();
if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n")); if (parser.seen_test('E')) SERIAL_ECHOF(recovery.exists() ? F("PLR Exists\n") : F("No PLR\n"));
if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n")); if (parser.seen_test('V')) SERIAL_ECHOF(recovery.valid() ? F("Valid\n") : F("Invalid\n"));
#endif #endif

View file

@ -514,11 +514,13 @@ void CardReader::manage_media() {
DEBUG_ECHOLNPGM("First mount."); DEBUG_ECHOLNPGM("First mount.");
#if ENABLED(POWER_LOSS_RECOVERY) bool do_auto = true; UNUSED(do_auto);
recovery.check(); // Check for PLR file. (If not there then call autofile_begin)
#elif DISABLED(NO_SD_AUTOSTART) // Check for PLR file.
autofile_begin(); // Look for auto0.g on the next loop TERN_(POWER_LOSS_RECOVERY, if (recovery.check()) do_auto = false);
#endif
// Look for auto0.g on the next idle()
IF_DISABLED(NO_SD_AUTOSTART, if (do_auto) autofile_begin());
} }
/** /**