From bbe5b80492d4a5b04995ca43d3258838f8cd8faf Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Sun, 24 Jul 2016 10:53:58 -0700
Subject: [PATCH 1/3] Always define probe limits if there is a probe

---
 Marlin/Conditionals.h | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h
index 29d643909..e5e072a22 100644
--- a/Marlin/Conditionals.h
+++ b/Marlin/Conditionals.h
@@ -388,13 +388,11 @@
    */
   #define HAS_PROBING_PROCEDURE (ENABLED(AUTO_BED_LEVELING_FEATURE) || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
 
-  #if HAS_PROBING_PROCEDURE
-    // Boundaries for probing based on set limits
-    #define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
-    #define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
-    #define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
-    #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
-  #endif
+  // Boundaries for probing based on set limits
+  #define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
+  #define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
+  #define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
+  #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
 
   #define HAS_Z_SERVO_ENDSTOP (defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0)
 

From a6203366b60014469225740b2e3606c7f9538b46 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Sun, 24 Jul 2016 10:54:25 -0700
Subject: [PATCH 2/3] Sanitycheck: Z_SAFE_HOMING requires a probe

---
 Marlin/SanityCheck.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h
index 5eea066a6..45a9d29c0 100644
--- a/Marlin/SanityCheck.h
+++ b/Marlin/SanityCheck.h
@@ -353,6 +353,8 @@
     #error "AUTO_BED_LEVELING_FEATURE requires a probe! Define a Z Servo, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE."
   #elif ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
     #error "Z_MIN_PROBE_REPEATABILITY_TEST requires a probe! Define a Z Servo, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE."
+  #elif ENABLED(Z_SAFE_HOMING)
+    #error "Z_SAFE_HOMING currently requires a probe."
   #endif
 
 #endif

From d6c50671d3550252ff47ce27c8c7924733ec6347 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Sun, 24 Jul 2016 10:54:47 -0700
Subject: [PATCH 3/3] Sanitycheck: Z_SAFE_HOMING points are reachable

---
 Marlin/SanityCheck.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h
index 45a9d29c0..9ed8caaff 100644
--- a/Marlin/SanityCheck.h
+++ b/Marlin/SanityCheck.h
@@ -359,6 +359,17 @@
 
 #endif
 
+/**
+ * Make sure Z_SAFE_HOMING point is reachable
+ */
+#if ENABLED(Z_SAFE_HOMING)
+  #if Z_SAFE_HOMING_X_POINT < MIN_PROBE_X || Z_SAFE_HOMING_X_POINT > MAX_PROBE_X
+    #error "The given Z_SAFE_HOMING_X_POINT can't be reached by the Z probe."
+  #elif Z_SAFE_HOMING_Y_POINT < MIN_PROBE_Y || Z_SAFE_HOMING_Y_POINT > MAX_PROBE_Y
+    #error "The given Z_SAFE_HOMING_Y_POINT can't be reached by the Z probe."
+  #endif
+#endif // Z_SAFE_HOMING
+
 /**
  * Auto Bed Leveling
  */