From 304e0f8945f8a25b9c08b5047dc8530a10f66975 Mon Sep 17 00:00:00 2001
From: Scott Lahteine <github@thinkyhead.com>
Date: Thu, 15 Feb 2018 22:22:06 -0600
Subject: [PATCH] Followup to 21e60fd

`ENABLED` only works for flag-type options. Floats must use `#ifdef`.
---
 Marlin/src/feature/bedlevel/ubl/ubl.h         | 38 +++++++++----------
 .../src/feature/bedlevel/ubl/ubl_motion.cpp   | 12 +++---
 2 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.h b/Marlin/src/feature/bedlevel/ubl/ubl.h
index bc4df7f442..e6832bb2f7 100644
--- a/Marlin/src/feature/bedlevel/ubl/ubl.h
+++ b/Marlin/src/feature/bedlevel/ubl/ubl.h
@@ -224,15 +224,14 @@ class unified_bed_leveling {
           }
         #endif
 
-        /**
-         * The requested location is off the mesh.  Check if UBL_Z_RAISE_WHEN_OFF_MESH
-         * is specified. If so, that value is returned.
-         */
-        #if ENABLED(UBL_Z_RAISE_WHEN_OFF_MESH)
-          return UBL_Z_RAISE_WHEN_OFF_MESH;
-        #else
-          return NAN;
-        #endif
+        // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
+        return (
+          #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
+            UBL_Z_RAISE_WHEN_OFF_MESH
+          #else
+            NAN
+          #endif
+        );
       }
 
       const float xratio = (rx0 - mesh_index_to_xpos(x1_i)) * (1.0 / (MESH_X_DIST)),
@@ -259,15 +258,14 @@ class unified_bed_leveling {
           }
         #endif
 
-        /**
-         * The requested location is off the mesh.  Check if UBL_Z_RAISE_WHEN_OFF_MESH
-         * is specified. If so, that value is returned.
-         */
-        #if ENABLED(UBL_Z_RAISE_WHEN_OFF_MESH)
-          return UBL_Z_RAISE_WHEN_OFF_MESH;
-        #else
-          return NAN;
-        #endif
+        // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
+        return (
+          #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
+            UBL_Z_RAISE_WHEN_OFF_MESH
+          #else
+            NAN
+          #endif
+        );
       }
 
       const float yratio = (ry0 - mesh_index_to_ypos(y1_i)) * (1.0 / (MESH_Y_DIST)),
@@ -292,9 +290,9 @@ class unified_bed_leveling {
        * Check if the requested location is off the mesh.  If so, and
        * UBL_Z_RAISE_WHEN_OFF_MESH is specified, that value is returned.
        */
-      #if ENABLED(UBL_Z_RAISE_WHEN_OFF_MESH)
+      #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
         if (!WITHIN(rx0, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(ry0, 0, GRID_MAX_POINTS_Y - 1))
-          return UBL_Z_RAISE_WHEN_OFF_MESHH;
+          return UBL_Z_RAISE_WHEN_OFF_MESH;
       #endif
 
       const float z1 = calc_z0(rx0,
diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
index c265e4ade1..5b83f49ce1 100644
--- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
+++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp
@@ -86,13 +86,13 @@
       if (!WITHIN(cell_dest_xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(cell_dest_yi, 0, GRID_MAX_POINTS_Y - 1)) {
 
         // Note: There is no Z Correction in this case. We are off the grid and don't know what
-        // a reasonable correction would be.  If the user has specified a UBL_Z_RAISE_WHEN_OFF_MESH 
+        // a reasonable correction would be.  If the user has specified a UBL_Z_RAISE_WHEN_OFF_MESH
         // value, that will be used instead of a calculated (Bi-Linear interpolation) correction.
-
-        float z_raise = 0.0;
-        #if ENABLED(UBL_Z_RAISE_WHEN_OFF_MESH)
-          z_raise = UBL_Z_RAISE_WHEN_OFF_MESH;
-        #endif
+        const float z_raise = 0.0
+          #ifdef UBL_Z_RAISE_WHEN_OFF_MESH
+            + UBL_Z_RAISE_WHEN_OFF_MESH
+          #endif
+        ;
         planner.buffer_segment(end[X_AXIS], end[Y_AXIS], end[Z_AXIS] + z_raise, end[E_AXIS], feed_rate, extruder);
         set_current_from_destination();
 
-- 
GitLab