From d71dc5cf42c0055a553ec14d1a400a8e02c334ec Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Sun, 3 Mar 2019 07:43:27 -0600
Subject: [PATCH] Fix for Ender 4 fan/case light pin

See #12731
---
 .../examples/Creality/Ender-4/Configuration_adv.h |  2 +-
 Marlin/src/pins/pins_RAMPS_ENDER_4.h              | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h b/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h
index 435e831e6c..f3cea9137f 100644
--- a/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h
+++ b/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h
@@ -267,7 +267,7 @@
  */
 #define CASE_LIGHT_ENABLE
 #if ENABLED(CASE_LIGHT_ENABLE)
-  #define CASE_LIGHT_PIN ENDER4_FAN_PIN       // Override the default pin if needed
+  //#define CASE_LIGHT_PIN 4                  // Override the default pin if needed
   #define INVERT_CASE_LIGHT false             // Set true if Case Light is ON when pin is LOW
   #define CASE_LIGHT_DEFAULT_ON false         // Set default power-up state on
   #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105   // Set default power-up brightness (0-255, requires PWM pin)
diff --git a/Marlin/src/pins/pins_RAMPS_ENDER_4.h b/Marlin/src/pins/pins_RAMPS_ENDER_4.h
index c808b68188..8d14bddc4a 100755
--- a/Marlin/src/pins/pins_RAMPS_ENDER_4.h
+++ b/Marlin/src/pins/pins_RAMPS_ENDER_4.h
@@ -28,8 +28,13 @@
 
 #include "pins_RAMPS.h"
 
-// The board only has one controllable fan connector, the others are just plain 12V connectors
-// in the default configuration, this is used to control the brightness of the LED band
-// hotend and controller fan are therefore always-on
-#define ENDER4_FAN_PIN RAMPS_D9_PIN
-#undef FAN_PIN
+// The board only has one PWM fan connector. The others are 12V always-on.
+// The default config uses this pin to control the brightness of the LED
+// band (case light). Thus the hotend and controller fans are always-on.
+
+#if ENABLED(CASE_LIGHT_ENABLE)
+  #undef FAN_PIN
+  #ifndef CASE_LIGHT_PIN
+    #define CASE_LIGHT_PIN RAMPS_D9_PIN
+  #endif
+#endif
-- 
GitLab