From c9891be599bd9aeaa46a457a0cda9688ae6fc762 Mon Sep 17 00:00:00 2001 From: Stefan Altheimer Date: Sun, 1 Nov 2020 18:19:17 +0100 Subject: [PATCH] Added power off timeout --- Marlin/Configuration.h | 2 ++ Marlin/src/feature/power.cpp | 1 + Marlin/src/inc/Conditionals_post.h | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 054e90d8d9..f299c1b119 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -338,6 +338,8 @@ //#define PSU_POWERUP_GCODE "M355 S1" // G-code to run after power-on (e.g., case light on) //#define PSU_POWEROFF_GCODE "M355 S0" // G-code to run before power-off (e.g., case light off) + //#define POWER_OFF_TIMEOUT 30 // (s) Delay for the shutoff of the PSU; for example used to let a cooling-fan run after print is finished + //#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin #if ENABLED(AUTO_POWER_CONTROL) #define AUTO_POWER_FANS // Turn on PSU if fans need power diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index 9427f684e7..92ceed53cf 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -122,6 +122,7 @@ void Power::power_off() { #ifdef PSU_POWEROFF_GCODE GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE)); #endif + safe_delay(SEC_TO_MS(POWER_OFF_TIMEOUT)); PSU_PIN_OFF(); } } diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index bbbcf6fb2f..9ec4c5bcd8 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -420,6 +420,10 @@ #define PSU_POWERUP_DELAY 250 #endif +#if !defined(POWER_OFF_TIMEOUT) && ENABLED(PSU_CONTROL) + #define POWER_OFF_TIMEOUT 0 +#endif + /** * Temp Sensor defines */