From f38b8c5bf87858abd4bc8d96a2f0ae4fadcdbf2e Mon Sep 17 00:00:00 2001
From: Alexey Shvetsov <alexxy@gentoo.org>
Date: Wed, 5 Jul 2017 19:54:26 +0300
Subject: [PATCH] MKS 1.3+: Add pin mapping for PS_ON

This allows the use of D4 as PS_ON since MKS Gen doesn't have a PS_ON pin. However this effectively allows only 3 servos (instead of 4).

Signed-off-by: Alexey Shvetsov <alexxy@gentoo.org>
---
 Marlin/pins_MKS_13.h | 10 ++++++++++
 Marlin/pins_RAMPS.h  |  8 ++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Marlin/pins_MKS_13.h b/Marlin/pins_MKS_13.h
index 8b466c652a..07aa658116 100644
--- a/Marlin/pins_MKS_13.h
+++ b/Marlin/pins_MKS_13.h
@@ -41,6 +41,16 @@
 // Power outputs EFBF or EFBE
 #define MOSFET_D_PIN 7
 
+//
+// PSU / SERVO
+//
+// If POWER_SUPPLY is specified, always hijack Servo 3
+//
+#if POWER_SUPPLY > 0
+  #define SERVO3_PIN      -1
+  #define PS_ON_PIN        4
+#endif
+
 #include "pins_RAMPS.h"
 
 //
diff --git a/Marlin/pins_RAMPS.h b/Marlin/pins_RAMPS.h
index 91d435afb2..9b18461137 100644
--- a/Marlin/pins_RAMPS.h
+++ b/Marlin/pins_RAMPS.h
@@ -64,7 +64,9 @@
 #endif
 #define SERVO1_PIN          6
 #define SERVO2_PIN          5
-#define SERVO3_PIN          4
+#ifndef SERVO3_PIN
+  #define SERVO3_PIN        4
+#endif
 
 //
 // Limit Switches
@@ -203,7 +205,9 @@
 // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
 #define FIL_RUNOUT_PIN      4
 
-#define PS_ON_PIN          12
+#ifndef PS_ON_PIN
+  #define PS_ON_PIN        12
+#endif
 
 #if ENABLED(CASE_LIGHT_ENABLE) && !PIN_EXISTS(CASE_LIGHT) && !defined(SPINDLE_LASER_ENABLE_PIN)
   #if !defined(NUM_SERVOS) || NUM_SERVOS == 0 // try to use servo connector first