Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto restart on power loss if PLR is enabled. #26658

Open
wants to merge 4 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,7 @@
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power-loss
#if ENABLED(BACKUP_POWER_SUPPLY)
//#define POWER_LOSS_RETRACT_LEN 10 // (mm) Length of filament to retract on fail
//#define PLR_REBOOT_TIMEOUT 60 // (seconds) Restart after power loss if UPS never lost power
#endif

// Enable if Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
Expand Down
11 changes: 10 additions & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,18 @@ void minkill(const bool steppers_off/*=false*/) {

// Reboot the board
hal.reboot();

#else

#if defined(PLR_REBOOT_TIMEOUT)
if (PrintJobRecovery::outage_counter > 0) {
for (uint16_t i = 0; i < PLR_REBOOT_TIMEOUT; i++) {
hal.watchdog_refresh();
delay(1000);
}
hal.reboot();
}
#endif

for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle

#endif
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ bool PrintJobRecovery::enabled; // Initialized by settings.load()
celsius_t PrintJobRecovery::bed_temp_threshold; // Initialized by settings.load()
#endif

#if PIN_EXISTS(POWER_LOSS)
uint8_t PrintJobRecovery::outage_counter; // = 0
#endif

MediaFile PrintJobRecovery::file;
job_recovery_info_t PrintJobRecovery::info;
const char PrintJobRecovery::filename[5] = "/PLR";
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ class PrintJobRecovery {
static void save(const bool force=ENABLED(SAVE_EACH_CMD_MODE), const float zraise=POWER_LOSS_ZRAISE, const bool raised=false);

#if PIN_EXISTS(POWER_LOSS)
static uint8_t outage_counter;
static void outage() {
static constexpr uint8_t OUTAGE_THRESHOLD = 3;
static uint8_t outage_counter = 0;
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
outage_counter++;
if (outage_counter >= OUTAGE_THRESHOLD) _outage();
Expand Down
Loading