From 2d749d490baba907499cdf83a8222a26354b78ce Mon Sep 17 00:00:00 2001 From: Bob-the-Kuhn Date: Fri, 16 Feb 2018 02:18:50 -0600 Subject: [PATCH] Fix / complete USE_CONTROLLER_FAN (#9666) --- Marlin/src/Marlin.h | 4 ++++ Marlin/src/feature/controllerfan.cpp | 3 +++ Marlin/src/feature/power.cpp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index b8e4ea150..bf56c79d8 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -208,6 +208,10 @@ extern millis_t max_inactive_time, stepper_inactive_time; #endif #endif +#if ENABLED(USE_CONTROLLER_FAN) + extern uint8_t controllerFanSpeed; +#endif + #if ENABLED(PID_EXTRUSION_SCALING) extern int lpq_len; #endif diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 916c9b746..6a770b660 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -27,6 +27,8 @@ #include "../module/stepper_indirection.h" #include "../module/temperature.h" +uint8_t controllerFanSpeed; + void controllerfan_update() { static millis_t lastMotorOn = 0, // Last time a motor was turned on nextMotorCheck = 0; // Last time the state was checked @@ -56,6 +58,7 @@ void controllerfan_update() { // Fan off if no steppers have been enabled for CONTROLLERFAN_SECS seconds uint8_t speed = (!lastMotorOn || ELAPSED(ms, lastMotorOn + (CONTROLLERFAN_SECS) * 1000UL)) ? 0 : CONTROLLERFAN_SPEED; + controllerFanSpeed = speed; // allows digital or PWM fan output to be used (see M42 handling) WRITE(CONTROLLER_FAN_PIN, speed); diff --git a/Marlin/src/feature/power.cpp b/Marlin/src/feature/power.cpp index c72d7100e..d4bda257f 100644 --- a/Marlin/src/feature/power.cpp +++ b/Marlin/src/feature/power.cpp @@ -46,7 +46,7 @@ bool Power::is_power_needed() { HOTEND_LOOP() if (thermalManager.autofan_speed[e] > 0) return true; #endif - #if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLER_FAN + #if ENABLED(AUTO_POWER_CONTROLLERFAN) && HAS_CONTROLLER_FAN && ENABLED(USE_CONTROLLER_FAN) if (controllerFanSpeed > 0) return true; #endif