This commit is contained in:
Vovodroid 2024-11-24 18:55:42 -06:00 committed by GitHub
commit 9436036855
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 2 deletions

View File

@ -1782,6 +1782,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!

View File

@ -952,9 +952,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

View File

@ -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";

View File

@ -210,9 +210,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();