From 208200a3ccd4e4d4b22569459a4785de7af5406b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Jan 2021 17:51:46 -0600 Subject: [PATCH] G34/M422 cleanup --- Marlin/src/gcode/calibrate/G34_M422.cpp | 33 +++++++------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 840d04f29e..0bcf954faf 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -320,7 +320,6 @@ void GcodeSuite::G34() { }; #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - // Check if the applied corrections go in the correct direction. // Calculate the sum of the absolute deviations from the mean of the probe measurements. // Compare to the last iteration to ensure it's getting better. @@ -478,32 +477,18 @@ void GcodeSuite::M422() { const bool is_probe_point = parser.seen('S'); - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - if (is_probe_point && parser.seen('W')) { - SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); - return; - } - #endif + if (TERN0(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, is_probe_point && parser.seen('W'))) { + SERIAL_ECHOLNPGM("?(S) and (W) may not be combined."); + return; + } xy_pos_t *pos_dest = ( - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - !is_probe_point ? z_stepper_align.stepper_xy : - #endif + TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !is_probe_point ? z_stepper_align.stepper_xy :) z_stepper_align.xy ); - if (!is_probe_point - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - && !parser.seen('W') - #endif - ) { - SERIAL_ECHOLNPGM( - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - "?(S) or (W) is required." - #else - "?(S) is required." - #endif - ); + if (!is_probe_point && TERN1(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, !parser.seen('W'))) { + SERIAL_ECHOLNPGM("?(S)" TERN_(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS, " or (W)") " is required."); return; } @@ -512,7 +497,7 @@ void GcodeSuite::M422() { if (is_probe_point) { position_index = parser.intval('S') - 1; if (!WITHIN(position_index, 0, int8_t(NUM_Z_STEPPER_DRIVERS) - 1)) { - SERIAL_ECHOLNPGM("?(S) Z-ProbePosition index invalid."); + SERIAL_ECHOLNPGM("?(S) Probe-position index invalid."); return; } } @@ -520,7 +505,7 @@ void GcodeSuite::M422() { #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) position_index = parser.intval('W') - 1; if (!WITHIN(position_index, 0, NUM_Z_STEPPER_DRIVERS - 1)) { - SERIAL_ECHOLNPGM("?(W) Z-Stepper index invalid."); + SERIAL_ECHOLNPGM("?(W) Z-stepper index invalid."); return; } #endif