diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index bce26cb80..c2d5dfa74 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -10005,16 +10005,18 @@ inline void gcode_M502() { #if HAS_BED_PROBE inline void gcode_M851() { + if (parser.seenval('Z')) { + const float value = parser.value_linear_units(); + if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + zprobe_zoffset = value; + else { + SERIAL_ERROR_START(); + SERIAL_ERRORLNPGM("?Z out of range (" STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " to " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX) ")"); + } + return; + } SERIAL_ECHO_START(); SERIAL_ECHOPGM(MSG_PROBE_Z_OFFSET); - if (parser.seen('Z')) { - const float value = parser.value_linear_units(); - if (!WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { - SERIAL_ECHOLNPGM(" " MSG_Z_MIN " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MIN) " " MSG_Z_MAX " " STRINGIFY(Z_PROBE_OFFSET_RANGE_MAX)); - return; - } - zprobe_zoffset = value; - } SERIAL_ECHOLNPAIR(": ", zprobe_zoffset); }