Skip to content

Commit ebd2107

Browse files
committed
Add 'M413 C' to test PLR
1 parent 6fb4a2c commit ebd2107

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Marlin/src/feature/powerloss.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
265265

266266
#endif
267267

268+
#endif // POWER_LOSS_PIN
269+
270+
#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY)
271+
268272
/**
269273
* An outage was detected by a sensor pin.
270274
* - If not SD printing, let the machine turn off on its own with no "KILL" screen
@@ -273,7 +277,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
273277
* - If backup power is available Retract E and Raise Z
274278
* - Go to the KILL screen
275279
*/
276-
void PrintJobRecovery::_outage() {
280+
void PrintJobRecovery::_outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated/*=false*/)) {
277281
#if ENABLED(BACKUP_POWER_SUPPLY)
278282
static bool lock = false;
279283
if (lock) return; // No re-entrance from idle() during retract_and_lift()
@@ -301,10 +305,16 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
301305
retract_and_lift(zraise);
302306
#endif
303307

304-
kill(GET_TEXT(MSG_OUTAGE_RECOVERY));
308+
if (TERN0(DEBUG_POWER_LOSS_RECOVERY, simulated)) {
309+
card.fileHasFinished();
310+
current_position.reset();
311+
sync_plan_position();
312+
}
313+
else
314+
kill(GET_TEXT(MSG_OUTAGE_RECOVERY));
305315
}
306316

307-
#endif
317+
#endif // POWER_LOSS_PIN || DEBUG_POWER_LOSS_RECOVERY
308318

309319
/**
310320
* Save the recovery info the recovery file

Marlin/src/feature/powerloss.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ class PrintJobRecovery {
216216
static void retract_and_lift(const_float_t zraise);
217217
#endif
218218

219-
#if PIN_EXISTS(POWER_LOSS)
219+
#if PIN_EXISTS(POWER_LOSS) || ENABLED(DEBUG_POWER_LOSS_RECOVERY)
220220
friend class GcodeSuite;
221-
static void _outage();
221+
static void _outage(TERN_(DEBUG_POWER_LOSS_RECOVERY, const bool simulated=false));
222222
#endif
223223
};
224224

Marlin/src/gcode/feature/powerloss/M413.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ void GcodeSuite::M413() {
4848
if (parser.seen_test('W')) recovery.save(true);
4949
if (parser.seen_test('P')) recovery.purge();
5050
if (parser.seen_test('D')) recovery.debug(PSTR("M413"));
51-
#if PIN_EXISTS(POWER_LOSS)
52-
if (parser.seen_test('O')) recovery._outage();
53-
#endif
51+
if (parser.seen_test('O')) recovery._outage();
52+
if (parser.seen_test('C')) recovery.check();
5453
if (parser.seen_test('E')) SERIAL_ECHOPGM_P(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n"));
5554
if (parser.seen_test('V')) SERIAL_ECHOPGM_P(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n"));
5655
#endif

0 commit comments

Comments
 (0)