From e55e65d1e430355a971df027fc3245f84ecc2c77 Mon Sep 17 00:00:00 2001
From: CONSULitAS <info@consulitas.de>
Date: Mon, 18 May 2015 22:26:17 +0200
Subject: [PATCH] =?UTF-8?q?planner.cpp:=20Add=20FAN=5FMIN=5FPWM=20for=20sl?=
 =?UTF-8?q?ow=20fan=20stopping=20issue=20=E2=80=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

@CONSULitAS

planner.cpp: Add FAN_MIN_PWM for slow fan stopping issue (V2.1 with
macro and linear scaling)

@thinkyhead thanks for idea on linear scaling
---
 Marlin/planner.cpp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp
index 0a45ff38d9..4ecd459999 100644
--- a/Marlin/planner.cpp
+++ b/Marlin/planner.cpp
@@ -440,12 +440,17 @@ void check_axes_activity() {
         } else {
           fan_kick_end = 0;
         }
-    #endif//FAN_KICKSTART_TIME
-    #ifdef FAN_SOFT_PWM
-      fanSpeedSoftPwm = tail_fan_speed;
+    #endif //FAN_KICKSTART_TIME
+	#ifdef FAN_MIN_PWM
+      #define CALC_FAN_SPEED (tail_fan_speed ? ( FAN_MIN_PWM + (tail_fan_speed * (255 - FAN_MIN_PWM)) / 255 ) : 0)
     #else
-      analogWrite(FAN_PIN, tail_fan_speed);
-    #endif //!FAN_SOFT_PWM
+      #define CALC_FAN_SPEED tail_fan_speed
+    #endif // FAN_MIN_PWM
+    #ifdef FAN_SOFT_PWM
+      fanSpeedSoftPwm = CALC_FAN_SPEED;
+    #else
+      analogWrite(FAN_PIN, CALC_FAN_SPEED);
+    #endif // FAN_SOFT_PWM
   #endif // HAS_FAN
 
   #ifdef AUTOTEMP