Skip to content

Commit

Permalink
Fix checks, move to G34 file
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 19, 2019
1 parent 4225966 commit ae1b8ea
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
35 changes: 31 additions & 4 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
27 changes: 2 additions & 25 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae1b8ea

Please sign in to comment.