From b5e92f4f908461ca2c78a86eefe069b85af0a2dc Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 6 Feb 2018 00:22:30 -0600 Subject: [PATCH] [2.0.x] Enable / disable PSU automatically (#9503) --- Marlin/Configuration.h | 9 ++ Marlin/src/Marlin.cpp | 4 +- Marlin/src/Marlin.h | 9 ++ Marlin/src/config/default/Configuration.h | 9 ++ .../AlephObjects/TAZ4/Configuration.h | 9 ++ .../AliExpress/CL-260/Configuration.h | 9 ++ .../config/examples/Anet/A6/Configuration.h | 9 ++ .../config/examples/Anet/A8/Configuration.h | 9 ++ .../examples/Azteeg/X5GT/Configuration.h | 9 ++ .../examples/BIBO/TouchX/Configuration.h | 9 ++ .../examples/BQ/Hephestos/Configuration.h | 9 ++ .../examples/BQ/Hephestos_2/Configuration.h | 9 ++ .../config/examples/BQ/WITBOX/Configuration.h | 9 ++ .../config/examples/Cartesio/Configuration.h | 9 ++ .../examples/Creality/CR-10/Configuration.h | 9 ++ .../examples/Creality/CR-10S/Configuration.h | 9 ++ .../examples/Creality/Ender/Configuration.h | 9 ++ .../src/config/examples/Felix/Configuration.h | 9 ++ .../examples/Felix/DUAL/Configuration.h | 9 ++ .../FolgerTech/i3-2020/Configuration.h | 9 ++ .../examples/Geeetech/GT2560/Configuration.h | 9 ++ .../Geeetech/I3_Pro_X-GT2560/Configuration.h | 9 ++ .../examples/Infitary/i3-M508/Configuration.h | 9 ++ .../examples/JGAurora/A5/Configuration.h | 9 ++ .../examples/MakerParts/Configuration.h | 9 ++ .../examples/Malyan/M150/Configuration.h | 9 ++ .../examples/Malyan/M200/Configuration.h | 9 ++ .../Micromake/C1/basic/Configuration.h | 9 ++ .../Micromake/C1/enhanced/Configuration.h | 9 ++ .../config/examples/Mks/Sbase/Configuration.h | 9 ++ .../RepRapWorld/Megatronics/Configuration.h | 9 ++ .../config/examples/RigidBot/Configuration.h | 9 ++ .../src/config/examples/SCARA/Configuration.h | 9 ++ .../config/examples/STM32F10/Configuration.h | 9 ++ .../examples/Sanguinololu/Configuration.h | 9 ++ .../config/examples/TheBorg/Configuration.h | 9 ++ .../config/examples/TinyBoy2/Configuration.h | 9 ++ .../config/examples/Tronxy/X1/Configuration.h | 9 ++ .../UltiMachine/Archim2/Configuration.h | 9 ++ .../examples/Velleman/K8200/Configuration.h | 9 ++ .../examples/Velleman/K8400/Configuration.h | 9 ++ .../Velleman/K8400/Dual-head/Configuration.h | 9 ++ .../Wanhao/Duplicator 6/Configuration.h | 9 ++ .../examples/adafruit/ST7565/Configuration.h | 9 ++ .../FLSUN/auto_calibrate/Configuration.h | 9 ++ .../delta/FLSUN/kossel/Configuration.h | 9 ++ .../delta/FLSUN/kossel_mini/Configuration.h | 9 ++ .../examples/delta/generic/Configuration.h | 9 ++ .../delta/kossel_mini/Configuration.h | 9 ++ .../examples/delta/kossel_pro/Configuration.h | 9 ++ .../examples/delta/kossel_xl/Configuration.h | 9 ++ .../examples/gCreate/gMax1.5+/Configuration.h | 9 ++ .../config/examples/makibox/Configuration.h | 9 ++ .../examples/stm32f103ret6/Configuration.h | 9 ++ .../examples/tvrrug/Round2/Configuration.h | 9 ++ .../src/config/examples/wt150/Configuration.h | 9 ++ Marlin/src/feature/power.cpp | 96 +++++++++++++++++++ Marlin/src/feature/power.h | 42 ++++++++ Marlin/src/gcode/control/M80_M81.cpp | 8 +- Marlin/src/module/temperature.cpp | 8 ++ Marlin/src/module/temperature.h | 15 +++ 61 files changed, 664 insertions(+), 4 deletions(-) create mode 100644 Marlin/src/feature/power.cpp create mode 100644 Marlin/src/feature/power.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index cf0b3abe2..fce919845 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 8e867cad4..fd46690aa 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -236,9 +236,9 @@ void setup_powerhold() { #endif #if HAS_POWER_SWITCH #if ENABLED(PS_DEFAULT_OFF) - OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); + PSU_OFF(); #else - OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); + PSU_ON(); #endif #endif } diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 3f1ad9357..b8e4ea150 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -42,6 +42,15 @@ void idle( void manage_inactivity(bool ignore_stepper_queue = false); +// Auto Power Control +#if ENABLED(AUTO_POWER_CONTROL) + #define PSU_ON() powerManager.power_on() + #define PSU_OFF() powerManager.power_off() +#else + #define PSU_ON() OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE) + #define PSU_OFF() OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP) +#endif + #if HAS_X2_ENABLE #define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0) #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0) diff --git a/Marlin/src/config/default/Configuration.h b/Marlin/src/config/default/Configuration.h index 68db8a94d..4e9fa7f37 100644 --- a/Marlin/src/config/default/Configuration.h +++ b/Marlin/src/config/default/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h index 879844b71..a29d23634 100644 --- a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h +++ b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/AliExpress/CL-260/Configuration.h b/Marlin/src/config/examples/AliExpress/CL-260/Configuration.h index 8d7e67e49..9770b9d56 100644 --- a/Marlin/src/config/examples/AliExpress/CL-260/Configuration.h +++ b/Marlin/src/config/examples/AliExpress/CL-260/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Anet/A6/Configuration.h b/Marlin/src/config/examples/Anet/A6/Configuration.h index 33b084aaf..12c955f67 100644 --- a/Marlin/src/config/examples/Anet/A6/Configuration.h +++ b/Marlin/src/config/examples/Anet/A6/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Anet/A8/Configuration.h b/Marlin/src/config/examples/Anet/A8/Configuration.h index 643e87ed1..7bda51838 100644 --- a/Marlin/src/config/examples/Anet/A8/Configuration.h +++ b/Marlin/src/config/examples/Anet/A8/Configuration.h @@ -246,6 +246,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Azteeg/X5GT/Configuration.h b/Marlin/src/config/examples/Azteeg/X5GT/Configuration.h index 7d661c132..d21ede454 100644 --- a/Marlin/src/config/examples/Azteeg/X5GT/Configuration.h +++ b/Marlin/src/config/examples/Azteeg/X5GT/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/BIBO/TouchX/Configuration.h b/Marlin/src/config/examples/BIBO/TouchX/Configuration.h index 5ebe3aec9..03fce5e91 100644 --- a/Marlin/src/config/examples/BIBO/TouchX/Configuration.h +++ b/Marlin/src/config/examples/BIBO/TouchX/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/BQ/Hephestos/Configuration.h b/Marlin/src/config/examples/BQ/Hephestos/Configuration.h index 611c692c8..41b6b0aa2 100644 --- a/Marlin/src/config/examples/BQ/Hephestos/Configuration.h +++ b/Marlin/src/config/examples/BQ/Hephestos/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h index e49ca9bc1..f189ce0b1 100644 --- a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h +++ b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration.h @@ -244,6 +244,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/BQ/WITBOX/Configuration.h b/Marlin/src/config/examples/BQ/WITBOX/Configuration.h index d9dd60034..8e4359ce1 100644 --- a/Marlin/src/config/examples/BQ/WITBOX/Configuration.h +++ b/Marlin/src/config/examples/BQ/WITBOX/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Cartesio/Configuration.h b/Marlin/src/config/examples/Cartesio/Configuration.h index ca5f58276..e4a01571c 100644 --- a/Marlin/src/config/examples/Cartesio/Configuration.h +++ b/Marlin/src/config/examples/Cartesio/Configuration.h @@ -246,6 +246,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Creality/CR-10/Configuration.h b/Marlin/src/config/examples/Creality/CR-10/Configuration.h index a14ae1a6f..90963a4a8 100755 --- a/Marlin/src/config/examples/Creality/CR-10/Configuration.h +++ b/Marlin/src/config/examples/Creality/CR-10/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Creality/CR-10S/Configuration.h b/Marlin/src/config/examples/Creality/CR-10S/Configuration.h index f225a567e..b8a72bef8 100644 --- a/Marlin/src/config/examples/Creality/CR-10S/Configuration.h +++ b/Marlin/src/config/examples/Creality/CR-10S/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Creality/Ender/Configuration.h b/Marlin/src/config/examples/Creality/Ender/Configuration.h index 3613bb724..62920529f 100644 --- a/Marlin/src/config/examples/Creality/Ender/Configuration.h +++ b/Marlin/src/config/examples/Creality/Ender/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Felix/Configuration.h b/Marlin/src/config/examples/Felix/Configuration.h index a84d6b7d9..1ec473096 100644 --- a/Marlin/src/config/examples/Felix/Configuration.h +++ b/Marlin/src/config/examples/Felix/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. #define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Felix/DUAL/Configuration.h b/Marlin/src/config/examples/Felix/DUAL/Configuration.h index 28801fd41..6ece777a7 100644 --- a/Marlin/src/config/examples/Felix/DUAL/Configuration.h +++ b/Marlin/src/config/examples/Felix/DUAL/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. #define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h index a289210c5..f8840146b 100644 --- a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h +++ b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration.h @@ -246,6 +246,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Geeetech/GT2560/Configuration.h b/Marlin/src/config/examples/Geeetech/GT2560/Configuration.h index 0272440ff..eef4f92d0 100644 --- a/Marlin/src/config/examples/Geeetech/GT2560/Configuration.h +++ b/Marlin/src/config/examples/Geeetech/GT2560/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h b/Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h index 152bcb7d7..fb21dca48 100644 --- a/Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h +++ b/Marlin/src/config/examples/Geeetech/I3_Pro_X-GT2560/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Infitary/i3-M508/Configuration.h b/Marlin/src/config/examples/Infitary/i3-M508/Configuration.h index af692937b..1eb1d601d 100644 --- a/Marlin/src/config/examples/Infitary/i3-M508/Configuration.h +++ b/Marlin/src/config/examples/Infitary/i3-M508/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/JGAurora/A5/Configuration.h b/Marlin/src/config/examples/JGAurora/A5/Configuration.h index f5219f4f3..2a1ca0d02 100644 --- a/Marlin/src/config/examples/JGAurora/A5/Configuration.h +++ b/Marlin/src/config/examples/JGAurora/A5/Configuration.h @@ -250,6 +250,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/MakerParts/Configuration.h b/Marlin/src/config/examples/MakerParts/Configuration.h index 660589e5e..85cc3f7a3 100644 --- a/Marlin/src/config/examples/MakerParts/Configuration.h +++ b/Marlin/src/config/examples/MakerParts/Configuration.h @@ -256,6 +256,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Malyan/M150/Configuration.h b/Marlin/src/config/examples/Malyan/M150/Configuration.h index 0b4187ec8..1b4b09788 100644 --- a/Marlin/src/config/examples/Malyan/M150/Configuration.h +++ b/Marlin/src/config/examples/Malyan/M150/Configuration.h @@ -250,6 +250,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Malyan/M200/Configuration.h b/Marlin/src/config/examples/Malyan/M200/Configuration.h index f8561e52a..02eb5690c 100644 --- a/Marlin/src/config/examples/Malyan/M200/Configuration.h +++ b/Marlin/src/config/examples/Malyan/M200/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Micromake/C1/basic/Configuration.h b/Marlin/src/config/examples/Micromake/C1/basic/Configuration.h index 16a360dae..e1b155d61 100644 --- a/Marlin/src/config/examples/Micromake/C1/basic/Configuration.h +++ b/Marlin/src/config/examples/Micromake/C1/basic/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h index 4c406d42d..35c2c449c 100644 --- a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h +++ b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Mks/Sbase/Configuration.h b/Marlin/src/config/examples/Mks/Sbase/Configuration.h index 26ed5a39a..9e4ca132b 100644 --- a/Marlin/src/config/examples/Mks/Sbase/Configuration.h +++ b/Marlin/src/config/examples/Mks/Sbase/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. #define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h b/Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h index 1f5ce2ddc..e39942316 100644 --- a/Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/src/config/examples/RepRapWorld/Megatronics/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/RigidBot/Configuration.h b/Marlin/src/config/examples/RigidBot/Configuration.h index 4eeb3ad7d..5c358acd2 100644 --- a/Marlin/src/config/examples/RigidBot/Configuration.h +++ b/Marlin/src/config/examples/RigidBot/Configuration.h @@ -248,6 +248,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/SCARA/Configuration.h b/Marlin/src/config/examples/SCARA/Configuration.h index 6f780bd14..6331a7835 100644 --- a/Marlin/src/config/examples/SCARA/Configuration.h +++ b/Marlin/src/config/examples/SCARA/Configuration.h @@ -275,6 +275,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/STM32F10/Configuration.h b/Marlin/src/config/examples/STM32F10/Configuration.h index abdb91b33..87489235e 100644 --- a/Marlin/src/config/examples/STM32F10/Configuration.h +++ b/Marlin/src/config/examples/STM32F10/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Sanguinololu/Configuration.h b/Marlin/src/config/examples/Sanguinololu/Configuration.h index c142dca7d..fc9132843 100644 --- a/Marlin/src/config/examples/Sanguinololu/Configuration.h +++ b/Marlin/src/config/examples/Sanguinololu/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/TheBorg/Configuration.h b/Marlin/src/config/examples/TheBorg/Configuration.h index 3bd316e8d..e40560ea7 100644 --- a/Marlin/src/config/examples/TheBorg/Configuration.h +++ b/Marlin/src/config/examples/TheBorg/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/TinyBoy2/Configuration.h b/Marlin/src/config/examples/TinyBoy2/Configuration.h index 741b87f21..1a4002fa3 100644 --- a/Marlin/src/config/examples/TinyBoy2/Configuration.h +++ b/Marlin/src/config/examples/TinyBoy2/Configuration.h @@ -267,6 +267,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Tronxy/X1/Configuration.h b/Marlin/src/config/examples/Tronxy/X1/Configuration.h index d4ee1db11..982bd2ff9 100644 --- a/Marlin/src/config/examples/Tronxy/X1/Configuration.h +++ b/Marlin/src/config/examples/Tronxy/X1/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h index 06fa5e8c0..3508a3edc 100644 --- a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h +++ b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Velleman/K8200/Configuration.h b/Marlin/src/config/examples/Velleman/K8200/Configuration.h index decd31aed..f6d8b2382 100644 --- a/Marlin/src/config/examples/Velleman/K8200/Configuration.h +++ b/Marlin/src/config/examples/Velleman/K8200/Configuration.h @@ -265,6 +265,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Velleman/K8400/Configuration.h b/Marlin/src/config/examples/Velleman/K8400/Configuration.h index 2eef06ed6..73e65e4cb 100644 --- a/Marlin/src/config/examples/Velleman/K8400/Configuration.h +++ b/Marlin/src/config/examples/Velleman/K8400/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h b/Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h index a618668e4..bb0d8357b 100644 --- a/Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h +++ b/Marlin/src/config/examples/Velleman/K8400/Dual-head/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h index 28b0ebf85..0887fc401 100644 --- a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h +++ b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/adafruit/ST7565/Configuration.h b/Marlin/src/config/examples/adafruit/ST7565/Configuration.h index fd7f89003..e29e0bb41 100644 --- a/Marlin/src/config/examples/adafruit/ST7565/Configuration.h +++ b/Marlin/src/config/examples/adafruit/ST7565/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h index b08e1669a..83d519336 100644 --- a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h +++ b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h index 29548ab9e..b81aa9b8e 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration.h @@ -236,6 +236,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h index 41944bd3f..83a70ab1c 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/generic/Configuration.h b/Marlin/src/config/examples/delta/generic/Configuration.h index ab90bff6a..8b708daa0 100644 --- a/Marlin/src/config/examples/delta/generic/Configuration.h +++ b/Marlin/src/config/examples/delta/generic/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/kossel_mini/Configuration.h b/Marlin/src/config/examples/delta/kossel_mini/Configuration.h index 7b8291104..3e0db35e2 100644 --- a/Marlin/src/config/examples/delta/kossel_mini/Configuration.h +++ b/Marlin/src/config/examples/delta/kossel_mini/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/kossel_pro/Configuration.h b/Marlin/src/config/examples/delta/kossel_pro/Configuration.h index b4cd4179f..5570ced40 100644 --- a/Marlin/src/config/examples/delta/kossel_pro/Configuration.h +++ b/Marlin/src/config/examples/delta/kossel_pro/Configuration.h @@ -249,6 +249,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/delta/kossel_xl/Configuration.h b/Marlin/src/config/examples/delta/kossel_xl/Configuration.h index 606916708..02d644809 100644 --- a/Marlin/src/config/examples/delta/kossel_xl/Configuration.h +++ b/Marlin/src/config/examples/delta/kossel_xl/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. #define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h index e2a0be901..0a17ef543 100644 --- a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h +++ b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration.h @@ -250,6 +250,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/makibox/Configuration.h b/Marlin/src/config/examples/makibox/Configuration.h index 17e755fd1..dfeb076ba 100644 --- a/Marlin/src/config/examples/makibox/Configuration.h +++ b/Marlin/src/config/examples/makibox/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/stm32f103ret6/Configuration.h b/Marlin/src/config/examples/stm32f103ret6/Configuration.h index 31432799b..ec6ed2799 100644 --- a/Marlin/src/config/examples/stm32f103ret6/Configuration.h +++ b/Marlin/src/config/examples/stm32f103ret6/Configuration.h @@ -217,6 +217,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/tvrrug/Round2/Configuration.h b/Marlin/src/config/examples/tvrrug/Round2/Configuration.h index ce598e4e7..44698d73b 100644 --- a/Marlin/src/config/examples/tvrrug/Round2/Configuration.h +++ b/Marlin/src/config/examples/tvrrug/Round2/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/config/examples/wt150/Configuration.h b/Marlin/src/config/examples/wt150/Configuration.h index 056f64e06..65dd5e91d 100644 --- a/Marlin/src/config/examples/wt150/Configuration.h +++ b/Marlin/src/config/examples/wt150/Configuration.h @@ -245,6 +245,15 @@ // Enable this option to leave the PSU off at startup. // Power to steppers and heaters will need to be turned on with M80. //#define PS_DEFAULT_OFF + + //#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 + #define AUTO_POWER_E_FANS + #define AUTO_POWER_CONTROLLERFAN + #define POWER_TIMEOUT 30 + #endif + #endif // @section temperature diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp new file mode 100644 index 000000000..ce452aa0d --- /dev/null +++ b/Marlin/src/feature/power.cpp @@ -0,0 +1,96 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * power.cpp - power control + */ + +#include "../inc/MarlinConfig.h" + +#if ENABLED(AUTO_POWER_CONTROL) + +#include "power.h" +#include "temperature.h" +#include "stepper_indirection.h" + +Power powerManager; + +millis_t Power::lastPowerOn; + +bool Power::is_power_needed() { + #if ENABLED(AUTO_POWER_FANS) + for (uint8_t i = 0; i < FAN_COUNT; i++) if (fanSpeeds[i] > 0) return true; + #endif + + #if ENABLED(AUTO_POWER_E_FANS) + HOTEND_LOOP() if (thermalManager.autofan_speed[e] > 0) return true; + #endif + + #if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLERFAN + if (controllerFanSpeed > 0) return true; + #endif + + if (X_ENABLE_READ == X_ENABLE_ON || Y_ENABLE_READ == Y_ENABLE_ON || Z_ENABLE_READ == Z_ENABLE_ON || + thermalManager.soft_pwm_bed > 0 + || E0_ENABLE_READ == E_ENABLE_ON // If any of the drivers are enabled... + #if E_STEPPERS > 1 + || E1_ENABLE_READ == E_ENABLE_ON + #if HAS_X2_ENABLE + || X2_ENABLE_READ == X_ENABLE_ON + #endif + #if E_STEPPERS > 2 + || E2_ENABLE_READ == E_ENABLE_ON + #if E_STEPPERS > 3 + || E3_ENABLE_READ == E_ENABLE_ON + #endif + #endif + #endif + ) return true; + + HOTEND_LOOP() if (thermalManager.degTargetHotend(e) > 0) return true; + if (thermalManager.degTargetBed() > 0) return true; + + return false; +} + +void Power::check() { + static millis_t nextPowerCheck = 0; + millis_t ms = millis(); + if (ELAPSED(ms, nextPowerCheck)) { + nextPowerCheck = ms + 2500UL; + if (is_power_needed()) + power_on(); + else if (!lastPowerOn || ELAPSED(ms, lastPowerOn + (POWER_TIMEOUT) * 1000UL)) + power_off(); + } +} + +void Power::power_on() { + lastPowerOn = millis(); + OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); +} + +void Power::power_off() { + OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); +} + +#endif // AUTO_POWER_CONTROL diff --git a/Marlin/src/feature/power.h b/Marlin/src/feature/power.h new file mode 100644 index 000000000..c61c64e6f --- /dev/null +++ b/Marlin/src/feature/power.h @@ -0,0 +1,42 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * power.h - power control + */ + +#ifndef POWER_H +#define POWER_H + +class Power { + public: + static void check(); + static void power_on(); + static void power_off(); + private: + static millis_t lastPowerOn; + static bool is_power_needed(); +}; + +extern Power powerManager; + +#endif // POWER_H diff --git a/Marlin/src/gcode/control/M80_M81.cpp b/Marlin/src/gcode/control/M80_M81.cpp index f8ad85da1..10846fc09 100644 --- a/Marlin/src/gcode/control/M80_M81.cpp +++ b/Marlin/src/gcode/control/M80_M81.cpp @@ -36,6 +36,10 @@ #if HAS_POWER_SWITCH + #if ENABLED(AUTO_POWER_CONTROL) + #include "../../feature/power.h" + #endif + // Could be moved to a feature, but this is all the data bool powersupply_on = #if ENABLED(PS_DEFAULT_OFF) @@ -61,7 +65,7 @@ return; } - OUT_WRITE(PS_ON_PIN, PS_ON_AWAKE); // GND + PSU_ON(); /** * If you have a switch on suicide pin, this is useful @@ -114,7 +118,7 @@ void GcodeSuite::M81() { stepper.synchronize(); suicide(); #elif HAS_POWER_SWITCH - OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); + PSU_OFF(); powersupply_on = false; #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 224fbcfce..824d77fb9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -63,10 +63,15 @@ Temperature thermalManager; float Temperature::current_temperature[HOTENDS] = { 0.0 }, Temperature::current_temperature_bed = 0.0; + int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 }, Temperature::target_temperature[HOTENDS] = { 0 }, Temperature::current_temperature_bed_raw = 0; +#if ENABLED(AUTO_POWER_E_FANS) + int16_t Temperature::autofan_speed[HOTENDS] = { 0 }; +#endif + #if HAS_HEATER_BED int16_t Temperature::target_temperature_bed = 0; #endif @@ -529,6 +534,9 @@ int Temperature::getHeaterPower(int heater) { const uint8_t bit = pgm_read_byte(&fanBit[f]); if (pin >= 0 && !TEST(fanDone, bit)) { uint8_t newFanSpeed = TEST(fanState, bit) ? EXTRUDER_AUTO_FAN_SPEED : 0; + #if ENABLED(AUTO_POWER_E_FANS) + autofan_speed[f] = newFanSpeed; + #endif // this idiom allows both digital and PWM fan outputs (see M42 handling). digitalWrite(pin, newFanSpeed); analogWrite(pin, newFanSpeed); diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 167c6d2df..49019ebfe 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -28,11 +28,16 @@ #define TEMPERATURE_H #include "thermistor/thermistors.h" +#include "../inc/MarlinConfig.h" #if ENABLED(BABYSTEPPING) extern bool axis_known_position[XYZ]; #endif +#if ENABLED(AUTO_POWER_CONTROL) + #include "power.h" +#endif + #if ENABLED(PID_EXTRUSION_SCALING) #include "stepper.h" #endif @@ -113,6 +118,10 @@ class Temperature { target_temperature[HOTENDS], current_temperature_bed_raw; + #if ENABLED(AUTO_POWER_E_FANS) + static int16_t autofan_speed[HOTENDS]; + #endif + #if HAS_HEATER_BED static int16_t target_temperature_bed; #endif @@ -393,6 +402,9 @@ class Temperature { else if (target_temperature[HOTEND_INDEX] == 0) start_preheat_time(HOTEND_INDEX); #endif + #if ENABLED(AUTO_POWER_CONTROL) + powerManager.power_on(); + #endif target_temperature[HOTEND_INDEX] = celsius; #if WATCH_HOTENDS start_watching_heater(HOTEND_INDEX); @@ -401,6 +413,9 @@ class Temperature { static void setTargetBed(const int16_t celsius) { #if HAS_HEATER_BED + #if ENABLED(AUTO_POWER_CONTROL) + powerManager.power_on(); + #endif target_temperature_bed = #ifdef BED_MAXTEMP min(celsius, BED_MAXTEMP)