From c867de5be5fe1936beba117bf34f555066fc5367 Mon Sep 17 00:00:00 2001 From: Vladimir Sitnikov Date: Mon, 11 Sep 2023 15:01:48 +0300 Subject: [PATCH 1/6] ADD Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX to make UIs nicer, and limit M851 XY offsets M851 would respect the limits, so the system would be safer. Fixes https://github.com/MarlinFirmware/Marlin/issues/26263 --- Marlin/Configuration.h | 18 ++++++++++++++++++ Marlin/src/gcode/probe/M851.cpp | 8 ++++---- Marlin/src/inc/SanityCheck.h | 13 +++++++++++++ .../src/lcd/extui/mks_ui/draw_number_key.cpp | 4 ++-- Marlin/src/lcd/menu/menu_advanced.cpp | 4 ++-- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index c00e59b5cd5d..cef8829f31ea 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1630,6 +1630,24 @@ #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping +// For M851 give a range for adjusting the X probe offset +#ifndef Z_PROBE_OFFSET_XRANGE_MIN + #define Z_PROBE_OFFSET_XRANGE_MIN -50 +#endif + +#ifndef Z_PROBE_OFFSET_XRANGE_MAX + #define Z_PROBE_OFFSET_XRANGE_MAX 50 +#endif + +// For M851 give a range for adjusting the Y probe offset +#ifndef Z_PROBE_OFFSET_YRANGE_MIN + #define Z_PROBE_OFFSET_YRANGE_MIN -50 +#endif + +#ifndef Z_PROBE_OFFSET_YRANGE_MAX + #define Z_PROBE_OFFSET_YRANGE_MAX 50 +#endif + // For M851 give a range for adjusting the Z probe offset #define Z_PROBE_OFFSET_RANGE_MIN -20 #define Z_PROBE_OFFSET_RANGE_MAX 20 diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index e66392acb454..e35e73da35a5 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -44,10 +44,10 @@ void GcodeSuite::M851() { if (parser.seenval('X')) { const float x = parser.value_float(); #if HAS_PROBE_XY_OFFSET - if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE)) + if (WITHIN(x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX)) offs.x = x; else { - SERIAL_ECHOLNPGM("?X out of range (-", X_BED_SIZE, " to ", X_BED_SIZE, ")"); + SERIAL_ECHOLNPGM("?X out of range (", Z_PROBE_OFFSET_XRANGE_MIN, " to ", Z_PROBE_OFFSET_XRANGE_MAX, ")"); ok = false; } #else @@ -58,10 +58,10 @@ void GcodeSuite::M851() { if (parser.seenval('Y')) { const float y = parser.value_float(); #if HAS_PROBE_XY_OFFSET - if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE)) + if (WITHIN(y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX)) offs.y = y; else { - SERIAL_ECHOLNPGM("?Y out of range (-", Y_BED_SIZE, " to ", Y_BED_SIZE, ")"); + SERIAL_ECHOLNPGM("?Y out of range (", Z_PROBE_OFFSET_YRANGE_MIN, " to ", Z_PROBE_OFFSET_YRANGE_MAX, ")"); ok = false; } #else diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b2b336bd17a7..97a1e2cc7def 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1419,6 +1419,19 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0."); #endif + #define static_assert_within(varname, x, min, max) static_assert(WITHIN(x, min, max), #varname " must be within " #min " and " #max) + + static_assert_within("Z_PROBE_OFFSET_XRANGE_MIN", Z_PROBE_OFFSET_XRANGE_MIN, -(X_BED_SIZE), X_BED_SIZE); + static_assert_within("Z_PROBE_OFFSET_XRANGE_MAX", Z_PROBE_OFFSET_XRANGE_MAX, -(X_BED_SIZE), X_BED_SIZE); + static_assert_within("Z_PROBE_OFFSET_YRANGE_MIN", Z_PROBE_OFFSET_YRANGE_MIN, -(Y_BED_SIZE), Y_BED_SIZE); + static_assert_within("Z_PROBE_OFFSET_YRANGE_MAX", Z_PROBE_OFFSET_YRANGE_MAX, -(Y_BED_SIZE), Y_BED_SIZE); + static_assert_within("Z_PROBE_OFFSET_RANGE_MIN", Z_PROBE_OFFSET_RANGE_MIN, -(Z_MAX_POS), Z_MAX_POS); + static_assert_within("Z_PROBE_OFFSET_RANGE_MAX", Z_PROBE_OFFSET_RANGE_MAX, -(Z_MAX_POS), Z_MAX_POS); + + static_assert_within("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX); + static_assert_within("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX); + static_assert_within("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + #define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)) static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large."); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index 850a409a1857..fdf42a506bfe 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -358,14 +358,14 @@ static void set_value_confirm() { case x_offset: { #if HAS_PROBE_XY_OFFSET const float x = atof(key_value); - if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE)) + if (WITHIN(x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX)) probe.offset.x = x; #endif } break; case y_offset: { #if HAS_PROBE_XY_OFFSET const float y = atof(key_value); - if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE)) + if (WITHIN(y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX)) probe.offset.y = y; #endif } break; diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 2bcd4e681b61..56da46028451 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -628,8 +628,8 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if HAS_PROBE_XY_OFFSET - EDIT_ITEM(float31sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE); - EDIT_ITEM(float31sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE); + EDIT_ITEM(float31sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX); + EDIT_ITEM(float31sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX); #endif EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); From a03d0cd2caf530e6aa8699519f8723a8da5201eb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 27 Oct 2023 23:07:05 -0500 Subject: [PATCH 2/6] rename --- Marlin/Configuration.h | 28 +++++-------------- Marlin/src/gcode/probe/M851.cpp | 12 ++++---- Marlin/src/inc/Changes.h | 2 ++ Marlin/src/inc/Conditionals_post.h | 8 +++--- Marlin/src/inc/SanityCheck.h | 20 ++++++------- Marlin/src/lcd/e3v2/creality/dwin.cpp | 2 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 2 +- .../lcd/extui/ia_creality/ia_creality_rts.cpp | 6 ++-- .../src/lcd/extui/mks_ui/draw_number_key.cpp | 6 ++-- Marlin/src/lcd/extui/ui_api.cpp | 2 +- Marlin/src/lcd/menu/menu.cpp | 2 +- Marlin/src/lcd/menu/menu.h | 2 +- Marlin/src/lcd/menu/menu_advanced.cpp | 6 ++-- Marlin/src/lcd/menu/menu_bed_leveling.cpp | 6 ++-- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_item.h | 2 +- Marlin/src/lcd/tft/ui_common.cpp | 10 +++---- 17 files changed, 53 insertions(+), 65 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index cef8829f31ea..312036169245 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1630,27 +1630,13 @@ #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping -// For M851 give a range for adjusting the X probe offset -#ifndef Z_PROBE_OFFSET_XRANGE_MIN - #define Z_PROBE_OFFSET_XRANGE_MIN -50 -#endif - -#ifndef Z_PROBE_OFFSET_XRANGE_MAX - #define Z_PROBE_OFFSET_XRANGE_MAX 50 -#endif - -// For M851 give a range for adjusting the Y probe offset -#ifndef Z_PROBE_OFFSET_YRANGE_MIN - #define Z_PROBE_OFFSET_YRANGE_MIN -50 -#endif - -#ifndef Z_PROBE_OFFSET_YRANGE_MAX - #define Z_PROBE_OFFSET_YRANGE_MAX 50 -#endif - -// For M851 give a range for adjusting the Z probe offset -#define Z_PROBE_OFFSET_RANGE_MIN -20 -#define Z_PROBE_OFFSET_RANGE_MAX 20 +// For M851 give ranges for adjusting the X, Y, and Z probe offsets +#define PROBE_OFFSET_XMIN -50 // (mm) +#define PROBE_OFFSET_XMAX 50 // (mm) +#define PROBE_OFFSET_YMIN -50 // (mm) +#define PROBE_OFFSET_YMAX 50 // (mm) +#define PROBE_OFFSET_ZMIN -20 // (mm) +#define PROBE_OFFSET_ZMAX 20 // (mm) // Enable the M48 repeatability test to test probe accuracy //#define Z_MIN_PROBE_REPEATABILITY_TEST diff --git a/Marlin/src/gcode/probe/M851.cpp b/Marlin/src/gcode/probe/M851.cpp index e35e73da35a5..ec63ff190dc0 100644 --- a/Marlin/src/gcode/probe/M851.cpp +++ b/Marlin/src/gcode/probe/M851.cpp @@ -44,10 +44,10 @@ void GcodeSuite::M851() { if (parser.seenval('X')) { const float x = parser.value_float(); #if HAS_PROBE_XY_OFFSET - if (WITHIN(x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX)) + if (WITHIN(x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX)) offs.x = x; else { - SERIAL_ECHOLNPGM("?X out of range (", Z_PROBE_OFFSET_XRANGE_MIN, " to ", Z_PROBE_OFFSET_XRANGE_MAX, ")"); + SERIAL_ECHOLNPGM("?X out of range (", PROBE_OFFSET_XMIN, " to ", PROBE_OFFSET_XMAX, ")"); ok = false; } #else @@ -58,10 +58,10 @@ void GcodeSuite::M851() { if (parser.seenval('Y')) { const float y = parser.value_float(); #if HAS_PROBE_XY_OFFSET - if (WITHIN(y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX)) + if (WITHIN(y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX)) offs.y = y; else { - SERIAL_ECHOLNPGM("?Y out of range (", Z_PROBE_OFFSET_YRANGE_MIN, " to ", Z_PROBE_OFFSET_YRANGE_MAX, ")"); + SERIAL_ECHOLNPGM("?Y out of range (", PROBE_OFFSET_YMIN, " to ", PROBE_OFFSET_YMAX, ")"); ok = false; } #else @@ -71,10 +71,10 @@ void GcodeSuite::M851() { if (parser.seenval('Z')) { const float z = parser.value_float(); - if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + if (WITHIN(z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) offs.z = z; else { - SERIAL_ECHOLNPGM("?Z out of range (", Z_PROBE_OFFSET_RANGE_MIN, " to ", Z_PROBE_OFFSET_RANGE_MAX, ")"); + SERIAL_ECHOLNPGM("?Z out of range (", PROBE_OFFSET_ZMIN, " to ", PROBE_OFFSET_ZMAX, ")"); ok = false; } } diff --git a/Marlin/src/inc/Changes.h b/Marlin/src/inc/Changes.h index 942c5303d1fd..5d5c96cb447d 100644 --- a/Marlin/src/inc/Changes.h +++ b/Marlin/src/inc/Changes.h @@ -663,6 +663,8 @@ #error "INTEGRATED_BABYSTEPPING is no longer needed and should be removed." #elif defined(FOLDER_SORTING) #error "FOLDER_SORTING is now SDSORT_FOLDERS." +#elif defined(Z_PROBE_OFFSET_RANGE_MIN) || defined(Z_PROBE_OFFSET_RANGE_MAX) + #error "Z_PROBE_OFFSET_RANGE_(MIN|MAX) is now PROBE_OFFSET_Z(MIN|MAX)." #endif // L64xx stepper drivers have been removed diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 33b42e851195..b3abd716728d 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2943,11 +2943,11 @@ * Bed Probe dependencies */ #if ANY(MESH_BED_LEVELING, HAS_BED_PROBE) - #ifndef Z_PROBE_OFFSET_RANGE_MIN - #define Z_PROBE_OFFSET_RANGE_MIN -20 + #ifndef PROBE_OFFSET_ZMIN + #define PROBE_OFFSET_ZMIN -20 #endif - #ifndef Z_PROBE_OFFSET_RANGE_MAX - #define Z_PROBE_OFFSET_RANGE_MAX 20 + #ifndef PROBE_OFFSET_ZMAX + #define PROBE_OFFSET_ZMAX 20 #endif #endif #if HAS_BED_PROBE diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 97a1e2cc7def..77b2cc1211e1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1421,16 +1421,16 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #define static_assert_within(varname, x, min, max) static_assert(WITHIN(x, min, max), #varname " must be within " #min " and " #max) - static_assert_within("Z_PROBE_OFFSET_XRANGE_MIN", Z_PROBE_OFFSET_XRANGE_MIN, -(X_BED_SIZE), X_BED_SIZE); - static_assert_within("Z_PROBE_OFFSET_XRANGE_MAX", Z_PROBE_OFFSET_XRANGE_MAX, -(X_BED_SIZE), X_BED_SIZE); - static_assert_within("Z_PROBE_OFFSET_YRANGE_MIN", Z_PROBE_OFFSET_YRANGE_MIN, -(Y_BED_SIZE), Y_BED_SIZE); - static_assert_within("Z_PROBE_OFFSET_YRANGE_MAX", Z_PROBE_OFFSET_YRANGE_MAX, -(Y_BED_SIZE), Y_BED_SIZE); - static_assert_within("Z_PROBE_OFFSET_RANGE_MIN", Z_PROBE_OFFSET_RANGE_MIN, -(Z_MAX_POS), Z_MAX_POS); - static_assert_within("Z_PROBE_OFFSET_RANGE_MAX", Z_PROBE_OFFSET_RANGE_MAX, -(Z_MAX_POS), Z_MAX_POS); - - static_assert_within("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX); - static_assert_within("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX); - static_assert_within("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + static_assert_within("PROBE_OFFSET_XMIN", PROBE_OFFSET_XMIN, -(X_BED_SIZE), X_BED_SIZE); + static_assert_within("PROBE_OFFSET_XMAX", PROBE_OFFSET_XMAX, -(X_BED_SIZE), X_BED_SIZE); + static_assert_within("PROBE_OFFSET_YMIN", PROBE_OFFSET_YMIN, -(Y_BED_SIZE), Y_BED_SIZE); + static_assert_within("PROBE_OFFSET_YMAX", PROBE_OFFSET_YMAX, -(Y_BED_SIZE), Y_BED_SIZE); + static_assert_within("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -(Z_MAX_POS), Z_MAX_POS); + static_assert_within("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -(Z_MAX_POS), Z_MAX_POS); + + static_assert_within("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX); + static_assert_within("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX); + static_assert_within("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)) static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index b21cc3085032..f99a3d0a1ab0 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -1384,7 +1384,7 @@ void hmiMoveDone(const AxisEnum axis) { dwinUpdateLCD(); return; } - LIMIT(hmiValues.offset_value, (Z_PROBE_OFFSET_RANGE_MIN) * 100, (Z_PROBE_OFFSET_RANGE_MAX) * 100); + LIMIT(hmiValues.offset_value, (PROBE_OFFSET_ZMIN) * 100, (PROBE_OFFSET_ZMAX) * 100); last_zoffset = dwin_zoffset; dwin_zoffset = hmiValues.offset_value / 100.0f; #if ANY(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 0f038a30b214..843009c27461 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2057,7 +2057,7 @@ void autoHome() { queue.inject_P(G28_STR); } #if ANY(BABYSTEP_ZPROBE_OFFSET, JUST_BABYSTEP) babystep.accum = round(planner.settings.axis_steps_per_mm[Z_AXIS] * BABY_Z_VAR); #endif - setPFloatOnClick(Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX, 2, applyZOffset, liveZOffset); + setPFloatOnClick(PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX, 2, applyZOffset, liveZOffset); } void setMoveZto0() { diff --git a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp index 6246b9f00291..2264abadd398 100644 --- a/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp +++ b/Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp @@ -791,7 +791,7 @@ void RTS::handleData() { tmp_zprobe_offset = (float(recdat.data[0]) - 65536) / 100; else tmp_zprobe_offset = float(recdat.data[0]) / 100; - if (WITHIN((tmp_zprobe_offset), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + if (WITHIN((tmp_zprobe_offset), PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) { int16_t tmpSteps = mmToWholeSteps(getZOffset_mm() - tmp_zprobe_offset, axis_t(Z)); if (tmpSteps == 0) tmpSteps = getZOffset_mm() < tmp_zprobe_offset ? 1 : -1; smartAdjustAxis_steps(-tmpSteps, axis_t(Z), false); @@ -1107,7 +1107,7 @@ void RTS::handleData() { break; } case 2: { // Z-axis to Up - if (WITHIN((getZOffset_mm() + 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + if (WITHIN((getZOffset_mm() + 0.1), PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) { smartAdjustAxis_steps(getAxisSteps_per_mm(Z) / 10, axis_t(Z), false); //setZOffset_mm(getZOffset_mm() + 0.1); sendData(getZOffset_mm() * 100, ProbeOffset_Z); @@ -1118,7 +1118,7 @@ void RTS::handleData() { break; } case 3: { // Z-axis to Down - if (WITHIN((getZOffset_mm() - 0.1), Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + if (WITHIN((getZOffset_mm() - 0.1), PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) { smartAdjustAxis_steps(-getAxisSteps_per_mm(Z) / 10, axis_t(Z), false); //babystepAxis_steps(int16_t(-getAxisSteps_per_mm(Z)) / 10, axis_t(Z)); //setZOffset_mm(getZOffset_mm() - 0.1); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index fdf42a506bfe..9bb93e333394 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -358,20 +358,20 @@ static void set_value_confirm() { case x_offset: { #if HAS_PROBE_XY_OFFSET const float x = atof(key_value); - if (WITHIN(x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX)) + if (WITHIN(x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX)) probe.offset.x = x; #endif } break; case y_offset: { #if HAS_PROBE_XY_OFFSET const float y = atof(key_value); - if (WITHIN(y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX)) + if (WITHIN(y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX)) probe.offset.y = y; #endif } break; case z_offset: { const float z = atof(key_value); - if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + if (WITHIN(z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) probe.offset.z = z; } break; #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 7f216107289a..8e67a1d41406 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -858,7 +858,7 @@ namespace ExtUI { void setZOffset_mm(const_float_t value) { #if HAS_BED_PROBE - if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) + if (WITHIN(value, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) probe.offset.z = value; #elif ENABLED(BABYSTEP_DISPLAY_TOTAL) babystep.add_mm(Z_AXIS, value - getZOffset_mm()); diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index a9574dd4d9af..d4b669141bb9 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -298,7 +298,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) { , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff , new_probe_offset ); - if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + if (WITHIN(new_offs, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) { babystep.add_steps(Z_AXIS, babystep_increment); diff --git a/Marlin/src/lcd/menu/menu.h b/Marlin/src/lcd/menu/menu.h index d4cbfd7a73d5..9db351c5254e 100644 --- a/Marlin/src/lcd/menu/menu.h +++ b/Marlin/src/lcd/menu/menu.h @@ -39,7 +39,7 @@ typedef void (*selectFunc_t)(); #define SS_INVERT 0x04 #define SS_DEFAULT SS_CENTER -#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 +#if ENABLED(BABYSTEP_ZPROBE_OFFSET) && PROBE_OFFSET_ZMIN >= -9 && PROBE_OFFSET_ZMAX <= 9 #define BABYSTEP_TO_STR(N) ftostr43sign(N) #elif ENABLED(BABYSTEPPING) #define BABYSTEP_TO_STR(N) ftostr53sign(N) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 56da46028451..90a37ed5199c 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -628,10 +628,10 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if HAS_PROBE_XY_OFFSET - EDIT_ITEM(float31sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, Z_PROBE_OFFSET_XRANGE_MIN, Z_PROBE_OFFSET_XRANGE_MAX); - EDIT_ITEM(float31sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, Z_PROBE_OFFSET_YRANGE_MIN, Z_PROBE_OFFSET_YRANGE_MAX); + EDIT_ITEM(float31sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX); + EDIT_ITEM(float31sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX); #endif - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #if ENABLED(PROBE_OFFSET_WIZARD) SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 981c51a6b056..f4d5a269af69 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -278,18 +278,18 @@ void menu_bed_leveling() { // Mesh Bed Leveling Z-Offset // #if ENABLED(MESH_BED_LEVELING) - #if WITHIN(Z_PROBE_OFFSET_RANGE_MIN, -9, 9) + #if WITHIN(PROBE_OFFSET_ZMIN, -9, 9) #define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000 #else #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 #endif - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_MESH_Z_OFFSET, &bedlevel.z_offset, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_MESH_Z_OFFSET, &bedlevel.z_offset, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #endif #if ENABLED(BABYSTEP_ZPROBE_OFFSET) SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); #elif HAS_BED_PROBE - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #endif #if ENABLED(PROBE_OFFSET_WIZARD) diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index edbf78ed7643..613ee75e9605 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -562,7 +562,7 @@ void menu_configuration() { #if ENABLED(BABYSTEP_ZPROBE_OFFSET) SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset); #elif HAS_BED_PROBE - EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); + EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #endif // diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index ecc1ac4047a7..5c29a5a9fd95 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -163,7 +163,7 @@ DEFINE_MENU_EDIT_ITEM_TYPE(long5 ,uint32_t ,ftostr5rj , 0.01f DEFINE_MENU_EDIT_ITEM_TYPE(long5_25 ,uint32_t ,ftostr5rj , 0.04f ); // 12345 right-justified (25 increment) #if HAS_BED_PROBE - #if Z_PROBE_OFFSET_RANGE_MIN >= -9 && Z_PROBE_OFFSET_RANGE_MAX <= 9 + #if WITHIN(PROBE_OFFSET_ZMIN, -9, 9) #define LCD_Z_OFFSET_TYPE float43 // Values from -9.000 to +9.000 #else #define LCD_Z_OFFSET_TYPE float42_52 // Values from -99.99 to 99.99 diff --git a/Marlin/src/lcd/tft/ui_common.cpp b/Marlin/src/lcd/tft/ui_common.cpp index 5f426294dce9..cd50ce2b9271 100644 --- a/Marlin/src/lcd/tft/ui_common.cpp +++ b/Marlin/src/lcd/tft/ui_common.cpp @@ -85,7 +85,7 @@ void moveAxis(const AxisEnum axis, const int8_t direction) { , do_probe ? new_probe_offset : hotend_offset[active_extruder].z - bsDiff , new_probe_offset ); - if (WITHIN(new_offs, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX)) { + if (WITHIN(new_offs, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX)) { babystep.add_steps(Z_AXIS, babystep_increment); if (do_probe) probe.offset.z = new_offs; @@ -100,12 +100,12 @@ void moveAxis(const AxisEnum axis, const int8_t direction) { #else // Only change probe.offset.z probe.offset.z += diff; - if (direction < 0 && current_position.z < Z_PROBE_OFFSET_RANGE_MIN) { - current_position.z = Z_PROBE_OFFSET_RANGE_MIN; + if (direction < 0 && current_position.z < PROBE_OFFSET_ZMIN) { + current_position.z = PROBE_OFFSET_ZMIN; drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } - else if (direction > 0 && current_position.z > Z_PROBE_OFFSET_RANGE_MAX) { - current_position.z = Z_PROBE_OFFSET_RANGE_MAX; + else if (direction > 0 && current_position.z > PROBE_OFFSET_ZMAX) { + current_position.z = PROBE_OFFSET_ZMAX; drawMessage(GET_TEXT_F(MSG_LCD_SOFT_ENDSTOPS)); } else From f7ecfad24d4db534061eb6f8185dba3a95b30e68 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 27 Oct 2023 23:09:04 -0500 Subject: [PATCH 3/6] defaults --- Marlin/Configuration.h | 14 +++++++------- Marlin/src/inc/Conditionals_post.h | 14 +++++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 312036169245..fd01b2fe9eb4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1630,13 +1630,13 @@ #define Z_PROBE_LOW_POINT -2 // Farthest distance below the trigger-point to go before stopping -// For M851 give ranges for adjusting the X, Y, and Z probe offsets -#define PROBE_OFFSET_XMIN -50 // (mm) -#define PROBE_OFFSET_XMAX 50 // (mm) -#define PROBE_OFFSET_YMIN -50 // (mm) -#define PROBE_OFFSET_YMAX 50 // (mm) -#define PROBE_OFFSET_ZMIN -20 // (mm) -#define PROBE_OFFSET_ZMAX 20 // (mm) +// For M851 provide ranges for adjusting the X, Y, and Z probe offsets +//#define PROBE_OFFSET_XMIN -50 // (mm) +//#define PROBE_OFFSET_XMAX 50 // (mm) +//#define PROBE_OFFSET_YMIN -50 // (mm) +//#define PROBE_OFFSET_YMAX 50 // (mm) +//#define PROBE_OFFSET_ZMIN -20 // (mm) +//#define PROBE_OFFSET_ZMAX 20 // (mm) // Enable the M48 repeatability test to test probe accuracy //#define Z_MIN_PROBE_REPEATABILITY_TEST diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index b3abd716728d..c63344dde757 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2947,10 +2947,22 @@ #define PROBE_OFFSET_ZMIN -20 #endif #ifndef PROBE_OFFSET_ZMAX - #define PROBE_OFFSET_ZMAX 20 + #define PROBE_OFFSET_ZMAX 20 #endif #endif #if HAS_BED_PROBE + #ifndef PROBE_OFFSET_XMIN + #define PROBE_OFFSET_XMIN -50 + #endif + #ifndef PROBE_OFFSET_XMAX + #define PROBE_OFFSET_XMAX 50 + #endif + #ifndef PROBE_OFFSET_YMIN + #define PROBE_OFFSET_YMIN -50 + #endif + #ifndef PROBE_OFFSET_YMAX + #define PROBE_OFFSET_YMAX 50 + #endif #if ALL(ENDSTOPPULLUPS, USE_Z_MIN_PROBE) #define ENDSTOPPULLUP_ZMIN_PROBE #endif From 9186a73fc60ec1ae4d76e50e4218aa01038a2baf Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 27 Oct 2023 23:30:10 -0500 Subject: [PATCH 4/6] smaller Z range --- Marlin/src/inc/SanityCheck.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 77b2cc1211e1..c3fae46e0e3b 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1419,14 +1419,14 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0."); #endif - #define static_assert_within(varname, x, min, max) static_assert(WITHIN(x, min, max), #varname " must be within " #min " and " #max) + #define static_assert_within(varname, x, min, max) static_assert(WITHIN(x, min, max), varname " must be within " #min " and " #max) static_assert_within("PROBE_OFFSET_XMIN", PROBE_OFFSET_XMIN, -(X_BED_SIZE), X_BED_SIZE); static_assert_within("PROBE_OFFSET_XMAX", PROBE_OFFSET_XMAX, -(X_BED_SIZE), X_BED_SIZE); static_assert_within("PROBE_OFFSET_YMIN", PROBE_OFFSET_YMIN, -(Y_BED_SIZE), Y_BED_SIZE); static_assert_within("PROBE_OFFSET_YMAX", PROBE_OFFSET_YMAX, -(Y_BED_SIZE), Y_BED_SIZE); - static_assert_within("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -(Z_MAX_POS), Z_MAX_POS); - static_assert_within("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -(Z_MAX_POS), Z_MAX_POS); + static_assert_within("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -20, 20); + static_assert_within("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -20, 20); static_assert_within("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX); static_assert_within("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX); From de862623a06dca601526694d451e62adf5e2780d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 28 Oct 2023 19:26:14 -0500 Subject: [PATCH 5/6] apply HAS_PROBE_XY_OFFSET --- Marlin/src/inc/SanityCheck.h | 45 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ff3e6eda37ed..e940c9abdb48 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1418,13 +1418,9 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #endif /** - * Check for improper NOZZLE_TO_PROBE_OFFSET + * Check for improper PROBING_MARGIN */ - constexpr xyz_pos_t sanity_nozzle_to_probe_offset = NOZZLE_TO_PROBE_OFFSET; - #if ENABLED(NOZZLE_AS_PROBE) - static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0, - "NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0."); - #elif !IS_KINEMATIC + #if NONE(NOZZLE_AS_PROBE, IS_KINEMATIC) static_assert(PROBING_MARGIN >= 0, "PROBING_MARGIN must be >= 0."); static_assert(PROBING_MARGIN_BACK >= 0, "PROBING_MARGIN_BACK must be >= 0."); static_assert(PROBING_MARGIN_FRONT >= 0, "PROBING_MARGIN_FRONT must be >= 0."); @@ -1432,18 +1428,33 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0."); #endif - #define static_assert_within(varname, x, min, max) static_assert(WITHIN(x, min, max), varname " must be within " #min " and " #max) - - static_assert_within("PROBE_OFFSET_XMIN", PROBE_OFFSET_XMIN, -(X_BED_SIZE), X_BED_SIZE); - static_assert_within("PROBE_OFFSET_XMAX", PROBE_OFFSET_XMAX, -(X_BED_SIZE), X_BED_SIZE); - static_assert_within("PROBE_OFFSET_YMIN", PROBE_OFFSET_YMIN, -(Y_BED_SIZE), Y_BED_SIZE); - static_assert_within("PROBE_OFFSET_YMAX", PROBE_OFFSET_YMAX, -(Y_BED_SIZE), Y_BED_SIZE); - static_assert_within("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -20, 20); - static_assert_within("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -20, 20); + /** + * Check for improper PROBE_OFFSET_[XYZ](MIN|MAX) + */ + #define PROBE_OFFSET_ASSERT(varname, x, min, max) static_assert(WITHIN(x, min, max), varname " must be within " STRINGIFY(min) " and " STRINGIFY(max)) + #if HAS_PROBE_XY_OFFSET + PROBE_OFFSET_ASSERT("PROBE_OFFSET_XMIN", PROBE_OFFSET_XMIN, -(X_BED_SIZE), X_BED_SIZE); + PROBE_OFFSET_ASSERT("PROBE_OFFSET_XMAX", PROBE_OFFSET_XMAX, -(X_BED_SIZE), X_BED_SIZE); + PROBE_OFFSET_ASSERT("PROBE_OFFSET_YMIN", PROBE_OFFSET_YMIN, -(Y_BED_SIZE), Y_BED_SIZE); + PROBE_OFFSET_ASSERT("PROBE_OFFSET_YMAX", PROBE_OFFSET_YMAX, -(Y_BED_SIZE), Y_BED_SIZE); + #endif + PROBE_OFFSET_ASSERT("PROBE_OFFSET_ZMIN", PROBE_OFFSET_ZMIN, -20, 20); + PROBE_OFFSET_ASSERT("PROBE_OFFSET_ZMAX", PROBE_OFFSET_ZMAX, -20, 20); - static_assert_within("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX); - static_assert_within("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX); - static_assert_within("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); + /** + * Check for improper NOZZLE_AS_PROBE or NOZZLE_TO_PROBE_OFFSET + */ + constexpr xyz_pos_t sanity_nozzle_to_probe_offset = NOZZLE_TO_PROBE_OFFSET; + #if ENABLED(NOZZLE_AS_PROBE) + static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0, + "NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0."); + #endif + #if HAS_PROBE_XY_OFFSET + PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.x", sanity_nozzle_to_probe_offset.x, PROBE_OFFSET_XMIN, PROBE_OFFSET_XMAX); + PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.y", sanity_nozzle_to_probe_offset.y, PROBE_OFFSET_YMIN, PROBE_OFFSET_YMAX); + #endif + PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); + #undef PROBE_OFFSET_ASSERT #define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)) static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); From 2243627934a5f72ced64724866c3b7f190049b57 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 28 Oct 2023 19:28:51 -0500 Subject: [PATCH 6/6] combine PROBING_MARGIN --- Marlin/src/inc/SanityCheck.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e940c9abdb48..8796ea224fdc 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1427,6 +1427,13 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L static_assert(PROBING_MARGIN_LEFT >= 0, "PROBING_MARGIN_LEFT must be >= 0."); static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0."); #endif + #define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)) + static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); + static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large."); + static_assert(PROBING_MARGIN_FRONT < _MARGIN(Y), "PROBING_MARGIN_FRONT is too large."); + static_assert(PROBING_MARGIN_LEFT < _MARGIN(X), "PROBING_MARGIN_LEFT is too large."); + static_assert(PROBING_MARGIN_RIGHT < _MARGIN(X), "PROBING_MARGIN_RIGHT is too large."); + #undef _MARGIN /** * Check for improper PROBE_OFFSET_[XYZ](MIN|MAX) @@ -1456,14 +1463,6 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L PROBE_OFFSET_ASSERT("NOZZLE_TO_PROBE_OFFSET.z", sanity_nozzle_to_probe_offset.z, PROBE_OFFSET_ZMIN, PROBE_OFFSET_ZMAX); #undef PROBE_OFFSET_ASSERT - #define _MARGIN(A) TERN(IS_KINEMATIC, PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)) - static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large."); - static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large."); - static_assert(PROBING_MARGIN_FRONT < _MARGIN(Y), "PROBING_MARGIN_FRONT is too large."); - static_assert(PROBING_MARGIN_LEFT < _MARGIN(X), "PROBING_MARGIN_LEFT is too large."); - static_assert(PROBING_MARGIN_RIGHT < _MARGIN(X), "PROBING_MARGIN_RIGHT is too large."); - #undef _MARGIN - /** * Make sure Z raise values are set */