From eb2746a34f9f7ac7039b43aff21360d01dcc31a2 Mon Sep 17 00:00:00 2001
From: Edward Patel <edward.patel@memention.com>
Date: Sat, 28 May 2016 21:05:43 +0200
Subject: [PATCH] MBL: Fix for negative x/y positions

---
 Marlin/Configuration.h     | 5 +----
 Marlin/mesh_bed_leveling.h | 4 ++++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index fe14777ea7..ae141a642f 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -519,10 +519,7 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
 //#define MESH_BED_LEVELING    // Enable mesh bed leveling.
 
 #if ENABLED(MESH_BED_LEVELING)
-  #define MESH_MIN_X 10
-  #define MESH_MAX_X (X_MAX_POS - (MESH_MIN_X))
-  #define MESH_MIN_Y 10
-  #define MESH_MAX_Y (Y_MAX_POS - (MESH_MIN_Y))
+  #define MESH_INSET 10        // Mesh inset margin on print area
   #define MESH_NUM_X_POINTS 3  // Don't use more than 7 points per axis, implementation limited.
   #define MESH_NUM_Y_POINTS 3
   #define MESH_HOME_SEARCH_Z 4  // Z after Home, bed somewhere below but above 0.0.
diff --git a/Marlin/mesh_bed_leveling.h b/Marlin/mesh_bed_leveling.h
index 7b2201fb9b..20960fdcba 100644
--- a/Marlin/mesh_bed_leveling.h
+++ b/Marlin/mesh_bed_leveling.h
@@ -24,6 +24,10 @@
 
 #if ENABLED(MESH_BED_LEVELING)
 
+  #define MESH_MIN_X (X_MIN_POS + MESH_INSET)
+  #define MESH_MAX_X (X_MAX_POS - (MESH_INSET))
+  #define MESH_MIN_Y (Y_MIN_POS + MESH_INSET)
+  #define MESH_MAX_Y (Y_MAX_POS - (MESH_INSET))
   #define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X))/(MESH_NUM_X_POINTS - 1))
   #define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y))/(MESH_NUM_Y_POINTS - 1))