0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-25 15:42:42 +00:00

Auto reboot only on power loss.

This commit is contained in:
vovodroid 2024-01-20 14:44:04 +02:00
parent 935b3c669c
commit ca7752acc8
4 changed files with 15 additions and 11 deletions

View file

@ -1750,7 +1750,6 @@
//#define POWER_LOSS_PIN 44 // Pin to detect power-loss. Set to -1 to disable default pin on boards without module, or comment to use board default. //#define POWER_LOSS_PIN 44 // Pin to detect power-loss. Set to -1 to disable default pin on boards without module, or comment to use board default.
//#define POWER_LOSS_STATE HIGH // State of pin indicating power-loss //#define POWER_LOSS_STATE HIGH // State of pin indicating power-loss
#endif
//#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor //#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor
//#define POWER_LOSS_PULLDOWN //#define POWER_LOSS_PULLDOWN

View file

@ -936,17 +936,18 @@ void minkill(const bool steppers_off/*=false*/) {
// Reboot the board // Reboot the board
hal.reboot(); hal.reboot();
#elif defined(PLR_REBOOT_TIMEOUT)
for (uint16_t i = 0; i < PLR_REBOOT_TIMEOUT; i++) {
hal.watchdog_refresh();
delay(1000);
}
hal.reboot();
#else #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 for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle
#endif #endif

View file

@ -41,6 +41,10 @@ bool PrintJobRecovery::enabled; // Initialized by settings.load()
celsius_t PrintJobRecovery::bed_temp_threshold; // Initialized by settings.load() celsius_t PrintJobRecovery::bed_temp_threshold; // Initialized by settings.load()
#endif #endif
#if PIN_EXISTS(POWER_LOSS)
uint8_t PrintJobRecovery::outage_counter; // = 0
#endif
MediaFile PrintJobRecovery::file; MediaFile PrintJobRecovery::file;
job_recovery_info_t PrintJobRecovery::info; job_recovery_info_t PrintJobRecovery::info;
const char PrintJobRecovery::filename[5] = "/PLR"; const char PrintJobRecovery::filename[5] = "/PLR";

View file

@ -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); 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) #if PIN_EXISTS(POWER_LOSS)
static uint8_t outage_counter;
static void outage() { static void outage() {
static constexpr uint8_t OUTAGE_THRESHOLD = 3; static constexpr uint8_t OUTAGE_THRESHOLD = 3;
static uint8_t outage_counter = 0;
if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) { if (enabled && READ(POWER_LOSS_PIN) == POWER_LOSS_STATE) {
outage_counter++; outage_counter++;
if (outage_counter >= OUTAGE_THRESHOLD) _outage(); if (outage_counter >= OUTAGE_THRESHOLD) _outage();