From acd1b6e9c043086e16eacd0b178439d17f808cf2 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Sun, 11 Sep 2016 20:56:16 -0500
Subject: [PATCH] Rename delta_grid spacing for general nonlinear

---
 Marlin/Marlin.h        |  9 +++++----
 Marlin/Marlin_main.cpp | 21 +++++++++++----------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h
index e4fe48b0df..fbea4dc8b9 100644
--- a/Marlin/Marlin.h
+++ b/Marlin/Marlin.h
@@ -313,10 +313,6 @@ float code_value_temp_diff();
   extern float delta_diagonal_rod_trim_tower_3;
   void inverse_kinematics(const float cartesian[XYZ]);
   void recalc_delta_settings(float radius, float diagonal_rod);
-  #if ENABLED(AUTO_BED_LEVELING_FEATURE)
-    extern int delta_grid_spacing[2];
-    void adjust_delta(float cartesian[XYZ]);
-  #endif
 #elif IS_SCARA
   extern float delta[ABC];
   extern float axis_scaling[ABC];  // Build size scaling
@@ -324,6 +320,11 @@ float code_value_temp_diff();
   void forward_kinematics_SCARA(float f_scara[ABC]);
 #endif
 
+#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
+  extern int nonlinear_grid_spacing[2];
+  void adjust_delta(float cartesian[XYZ]);
+#endif
+
 #if ENABLED(Z_DUAL_ENDSTOPS)
   extern float z_endstop_adj;
 #endif
diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp
index 9c4da6b509..4badd7792b 100644
--- a/Marlin/Marlin_main.cpp
+++ b/Marlin/Marlin_main.cpp
@@ -486,11 +486,6 @@ static uint8_t target_extruder;
         delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND,
         delta_clip_start_height = Z_MAX_POS;
 
-  #if ENABLED(AUTO_BED_LEVELING_FEATURE)
-    int delta_grid_spacing[2] = { 0, 0 };
-    float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
-  #endif
-
   float delta_safe_distance_from_top();
   void set_cartesian_from_steppers();
 
@@ -500,6 +495,11 @@ static uint8_t target_extruder;
 
 #endif
 
+#if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
+  int nonlinear_grid_spacing[2] = { 0 };
+  float bed_level[AUTO_BED_LEVELING_GRID_POINTS][AUTO_BED_LEVELING_GRID_POINTS];
+#endif
+
 #if IS_SCARA
   // Float constants for SCARA calculations
   const float L1 = SCARA_LINKAGE_1, L2 = SCARA_LINKAGE_2,
@@ -3442,8 +3442,9 @@ inline void gcode_G28() {
                   yGridSpacing = (back_probe_bed_position - front_probe_bed_position) / (auto_bed_leveling_grid_points - 1);
 
       #if ENABLED(AUTO_BED_LEVELING_NONLINEAR)
-        delta_grid_spacing[X_AXIS] = xGridSpacing;
-        delta_grid_spacing[Y_AXIS] = yGridSpacing;
+
+        nonlinear_grid_spacing[X_AXIS] = xGridSpacing;
+        nonlinear_grid_spacing[Y_AXIS] = yGridSpacing;
         float zoffset = zprobe_zoffset;
         if (code_seen('Z')) zoffset += code_value_axis_units(Z_AXIS);
 
@@ -7803,12 +7804,12 @@ void ok_to_send() {
 
     // Adjust print surface height by linear interpolation over the bed_level array.
     void adjust_delta(float cartesian[XYZ]) {
-      if (delta_grid_spacing[X_AXIS] == 0 || delta_grid_spacing[Y_AXIS] == 0) return; // G29 not done!
+      if (nonlinear_grid_spacing[X_AXIS] == 0 || nonlinear_grid_spacing[Y_AXIS] == 0) return; // G29 not done!
 
       int half = (AUTO_BED_LEVELING_GRID_POINTS - 1) / 2;
       float h1 = 0.001 - half, h2 = half - 0.001,
-            grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / delta_grid_spacing[X_AXIS])),
-            grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / delta_grid_spacing[Y_AXIS]));
+            grid_x = max(h1, min(h2, RAW_X_POSITION(cartesian[X_AXIS]) / nonlinear_grid_spacing[X_AXIS])),
+            grid_y = max(h1, min(h2, RAW_Y_POSITION(cartesian[Y_AXIS]) / nonlinear_grid_spacing[Y_AXIS]));
       int floor_x = floor(grid_x), floor_y = floor(grid_y);
       float ratio_x = grid_x - floor_x, ratio_y = grid_y - floor_y,
             z1 = bed_level[floor_x + half][floor_y + half],