From ae1b8eaf4da594cf0d23419fad020d54788a3165 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 19 Dec 2019 00:36:36 -0600 Subject: [PATCH] Fix checks, move to G34 file --- Marlin/src/gcode/calibrate/G34_M422.cpp | 35 ++++++++++++++++++++++--- Marlin/src/inc/SanityCheck.h | 27 ++----------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 1f7339679a20..1ce32869b031 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -45,22 +45,49 @@ #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" -// Sanity-check the count of Z_STEPPER_ALIGN_XY points -constexpr xy_pos_t sanity_arr_z_align[] = Z_STEPPER_ALIGN_XY; +// +// Sanity check G34 / M422 settings +// +constexpr xy_pos_t test_z_stepper_align_xy[] = Z_STEPPER_ALIGN_XY; + #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - static_assert(COUNT(sanity_arr_z_align) >= Z_STEPPER_COUNT, + + static_assert(COUNT(test_z_stepper_align_xy) >= Z_STEPPER_COUNT, "Z_STEPPER_ALIGN_XY requires at least three {X,Y} entries (Z, Z2, Z3, ...)." ); + + constexpr float test_z_stepper_align_stepper_xy[][XY] = Z_STEPPER_ALIGN_STEPPER_XY; + static_assert( + COUNT(test_z_stepper_align_stepper_xy) == Z_STEPPER_COUNT, + "Z_STEPPER_ALIGN_STEPPER_XY requires three {X,Y} entries (one per Z stepper)." + ); + #else - static_assert(COUNT(sanity_arr_z_align) == Z_STEPPER_COUNT, + + static_assert(COUNT(test_z_stepper_align_xy) == Z_STEPPER_COUNT, #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) "Z_STEPPER_ALIGN_XY requires three {X,Y} entries (Z, Z2, and Z3)." #else "Z_STEPPER_ALIGN_XY requires two {X,Y} entries (Z and Z2)." #endif ); + #endif +constexpr xyz_pos_t dpo = NOZZLE_TO_PROBE_OFFSET; + +#define LTEST(N) (test_z_stepper_align_xy[N].x >= _MAX(X_MIN_BED + MIN_PROBE_EDGE_LEFT, X_MIN_POS + dpo.x)) +#define RTEST(N) (test_z_stepper_align_xy[N].x <= _MIN(X_MAX_BED - MIN_PROBE_EDGE_RIGHT, X_MAX_POS + dpo.x)) +#define FTEST(N) (test_z_stepper_align_xy[N].y >= _MAX(Y_MIN_BED + MIN_PROBE_EDGE_FRONT, Y_MIN_POS + dpo.y)) +#define BTEST(N) (test_z_stepper_align_xy[N].y <= _MIN(Y_MAX_BED - MIN_PROBE_EDGE_BACK, Y_MAX_POS + dpo.y)) + +static_assert(LTEST(0) && RTEST(0), "The 1st Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); +static_assert(LTEST(1) && RTEST(1), "The 2nd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); +static_assert(LTEST(2) && RTEST(2), "The 3rd Z_STEPPER_ALIGN_XY X is unreachable with the default probe X offset."); +static_assert(FTEST(0) && BTEST(0), "The 1st Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); +static_assert(FTEST(1) && BTEST(1), "The 2nd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); +static_assert(FTEST(2) && BTEST(2), "The 3rd Z_STEPPER_ALIGN_XY Y is unreachable with the default probe Y offset."); + // // G34 / M422 shared data // diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 10b59c50c9d9..9a695918ab20 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2353,36 +2353,13 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2) #endif #if ENABLED(Z_STEPPER_AUTO_ALIGN) - #if !Z_MULTI_STEPPER_DRIVERS #error "Z_STEPPER_AUTO_ALIGN requires Z_DUAL_STEPPER_DRIVERS or Z_TRIPLE_STEPPER_DRIVERS." #elif !HAS_BED_PROBE #error "Z_STEPPER_AUTO_ALIGN requires a Z-bed probe." + #elif ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) && DISABLED(Z_TRIPLE_STEPPER_DRIVERS) + #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires Z_TRIPLE_STEPPER_DRIVERS." #endif - - #if ENABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) - #if DISABLED(Z_TRIPLE_STEPPER_DRIVERS) - #error "Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS requires Z_TRIPLE_STEPPER_DRIVERS." - #endif - constexpr float sanity_arr_screw_stepper_xy[][2] = Z_STEPPER_ALIGN_STEPPER_XY; - static_assert( - COUNT(sanity_arr_screw_stepper_xy) == Z_STEPPER_COUNT, - "Z_STEPPER_ALIGN_STEPPER_XY requires three {X,Y} entries (one per Z stepper)." - ); - #endif - - // Make sure probe points are probeable - constexpr int sanity_arr_screw_xy[][2] = Z_STEPPER_ALIGN_XY; - constexpr float sanity_arr_probe_offset[3] = NOZZLE_TO_PROBE_OFFSET; - #define SAFEX(X) (WITHIN(X, X_MIN_POS + sanity_arr_probe_offset[0], X_MAX_POS - sanity_arr_probe_offset[0])) - #define SAFEY(Y) (WITHIN(Y, Y_MIN_POS + sanity_arr_probe_offset[1], Y_MAX_POS - sanity_arr_probe_offset[1])) - #define _ARR_SCREW_XY(I) (sanity_arr_screw_xy[_MIN(I,int(COUNT(sanity_arr_screw_xy))-1)]) - #define _ARR_SCREW_XY_TEST(I) (SAFEX(_ARR_SCREW_XY(I)[0]) && SAFEY(_ARR_SCREW_XY(I)[1])) - static_assert( _ARR_SCREW_XY_TEST(0) && _ARR_SCREW_XY_TEST(1) && _ARR_SCREW_XY_TEST(2) - && _ARR_SCREW_XY_TEST(3) && _ARR_SCREW_XY_TEST(4) && _ARR_SCREW_XY_TEST(5) - && _ARR_SCREW_XY_TEST(6) && _ARR_SCREW_XY_TEST(7) && _ARR_SCREW_XY_TEST(8), - "Z_STEPPER_ALIGN_XY coordinates must be probeable (check NOZZLE_TO_PROBE_OFFSET)"); - #endif #if ENABLED(PRINTCOUNTER) && DISABLED(EEPROM_SETTINGS)