Add power-on/off G-code options (#19837)

Co-authored-by: Chris <chris@chrisnovoa.com>
2.0.x
Scott Lahteine 4 years ago committed by GitHub
parent 1e4691f02a
commit 7d64de646a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -335,6 +335,9 @@
//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80 //#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
//#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power //#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power
//#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 AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin //#define AUTO_POWER_CONTROL // Enable automatic control of the PS_ON pin
#if ENABLED(AUTO_POWER_CONTROL) #if ENABLED(AUTO_POWER_CONTROL)
#define AUTO_POWER_FANS // Turn on PSU if fans need power #define AUTO_POWER_FANS // Turn on PSU if fans need power

@ -33,6 +33,10 @@
#include "../module/stepper/indirection.h" #include "../module/stepper/indirection.h"
#include "../MarlinCore.h" #include "../MarlinCore.h"
#if defined(PSU_POWERUP_GCODE) || defined(PSU_POWEROFF_GCODE)
#include "../gcode/gcode.h"
#endif
#if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN) #if BOTH(USE_CONTROLLER_FAN, AUTO_POWER_CONTROLLERFAN)
#include "controllerfan.h" #include "controllerfan.h"
#endif #endif
@ -107,11 +111,19 @@ void Power::power_on() {
safe_delay(PSU_POWERUP_DELAY); safe_delay(PSU_POWERUP_DELAY);
restore_stepper_drivers(); restore_stepper_drivers();
TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY)); TERN_(HAS_TRINAMIC_CONFIG, safe_delay(PSU_POWERUP_DELAY));
#ifdef PSU_POWERUP_GCODE
GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWERUP_GCODE));
#endif
} }
} }
void Power::power_off() { void Power::power_off() {
if (powersupply_on) PSU_PIN_OFF(); if (powersupply_on) {
#ifdef PSU_POWEROFF_GCODE
GcodeSuite::process_subcommands_now_P(PSTR(PSU_POWEROFF_GCODE));
#endif
PSU_PIN_OFF();
}
} }
#endif // AUTO_POWER_CONTROL #endif // AUTO_POWER_CONTROL

Loading…
Cancel
Save