From 0698fcb005807bd89f1902b7b54f46e5e3017c2f Mon Sep 17 00:00:00 2001
From: tombrazier <68918209+tombrazier@users.noreply.github.com>
Date: Tue, 7 Jun 2022 01:23:55 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Mesh=20Leveling=20+=20Debu?=
 =?UTF-8?q?g=20compile=20(#24297)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/src/core/utility.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp
index 060e74d9fe6..7d33c25c3c4 100644
--- a/Marlin/src/core/utility.cpp
+++ b/Marlin/src/core/utility.cpp
@@ -132,11 +132,10 @@ void safe_delay(millis_t ms) {
         #else
           #if ENABLED(AUTO_BED_LEVELING_UBL)
             SERIAL_ECHOPGM("UBL Adjustment Z");
-            const float rz = bedlevel.get_z_correction(current_position);
           #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
             SERIAL_ECHOPGM("ABL Adjustment Z");
-            const float rz = bedlevel.get_z_correction(current_position);
           #endif
+          const float rz = bedlevel.get_z_correction(current_position);
           SERIAL_ECHO(ftostr43sign(rz, '+'));
           #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
             if (planner.z_fade_height) {
@@ -156,11 +155,13 @@ void safe_delay(millis_t ms) {
       SERIAL_ECHOPGM("Mesh Bed Leveling");
       if (planner.leveling_active) {
         SERIAL_ECHOLNPGM(" (enabled)");
-        SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(bedlevel.get_z(current_position), '+'));
+        const float z_offset = bedlevel.get_z_offset(),
+                    z_correction = bedlevel.get_z_correction(current_position);
+        SERIAL_ECHOPGM("MBL Adjustment Z", ftostr43sign(z_offset + z_correction, '+'));
         #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
           if (planner.z_fade_height) {
             SERIAL_ECHOPGM(" (", ftostr43sign(
-              bedlevel.get_z(current_position, planner.fade_scaling_factor_for_z(current_position.z)), '+'
+              z_offset + z_correction * planner.fade_scaling_factor_for_z(current_position.z), '+'
             ));
             SERIAL_CHAR(')');
           }