mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-25 16:47:29 +08:00
Auto reboot only on power loss.
This commit is contained in:
parent
935b3c669c
commit
ca7752acc8
@ -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_STATE HIGH // State of pin indicating power-loss
|
||||
#endif
|
||||
//#define POWER_LOSS_PULLUP // Set pullup / pulldown as appropriate for your sensor
|
||||
//#define POWER_LOSS_PULLDOWN
|
||||
|
||||
|
@ -936,17 +936,18 @@ void minkill(const bool steppers_off/*=false*/) {
|
||||
|
||||
// Reboot the board
|
||||
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
|
||||
|
||||
#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
|
||||
|
@ -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";
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user