Skip to content

Commit

Permalink
🩹 Safe Bed Leveling updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Feb 9, 2023
1 parent 23e2cb0 commit 7e79fc5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 14 deletions.
34 changes: 28 additions & 6 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ void unified_bed_leveling::G29() {
TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true));

// Position bed horizontally and Z probe vertically.
#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
#if HAS_SAFE_BED_LEVELING
xyze_pos_t safe_position = current_position;
#ifdef SAFE_BED_LEVELING_START_X
safe_position.x = SAFE_BED_LEVELING_START_X;
Expand Down Expand Up @@ -351,7 +349,7 @@ void unified_bed_leveling::G29() {
#endif

do_blocking_move_to(safe_position);
#endif
#endif // HAS_SAFE_BED_LEVELING
}

// Invalidate one or more nearby mesh points, possibly all.
Expand Down Expand Up @@ -887,8 +885,32 @@ void set_message_with_feedback(FSTR_P const fstr) {
ui.capture();
save_ubl_active_state_and_disable(); // Disable bed level correction for probing

do_blocking_move_to(0.5f * (MESH_MAX_X - (MESH_MIN_X)), 0.5f * (MESH_MAX_Y - (MESH_MIN_Y)), MANUAL_PROBE_START_Z);
//, _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f);
do_blocking_move_to(
NUM_AXIS_LIST(
0.5f * ((MESH_MAX_X) - (MESH_MIN_X)),
0.5f * ((MESH_MAX_Y) - (MESH_MIN_Y)),
MANUAL_PROBE_START_Z
#ifdef SAFE_BED_LEVELING_START_I
, SAFE_BED_LEVELING_START_I
#endif
#ifdef SAFE_BED_LEVELING_START_J
, SAFE_BED_LEVELING_START_J
#endif
#ifdef SAFE_BED_LEVELING_START_K
, SAFE_BED_LEVELING_START_K
#endif
#ifdef SAFE_BED_LEVELING_START_U
, SAFE_BED_LEVELING_START_U
#endif
#ifdef SAFE_BED_LEVELING_START_V
, SAFE_BED_LEVELING_START_V
#endif
#ifdef SAFE_BED_LEVELING_START_W
, SAFE_BED_LEVELING_START_W
#endif
)
//, _MIN(planner.settings.max_feedrate_mm_s[X_AXIS], planner.settings.max_feedrate_mm_s[Y_AXIS]) * 0.5f
);
planner.synchronize();

SERIAL_ECHOPGM("Place shim under nozzle");
Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,7 @@ G29_TYPE GcodeSuite::G29() {
}

// Position bed horizontally and Z probe vertically.
#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
#if HAS_SAFE_BED_LEVELING
xyze_pos_t safe_position = current_position;
#ifdef SAFE_BED_LEVELING_START_X
safe_position.x = SAFE_BED_LEVELING_START_X;
Expand Down Expand Up @@ -486,7 +484,7 @@ G29_TYPE GcodeSuite::G29() {
#endif

do_blocking_move_to(safe_position);
#endif
#endif // HAS_SAFE_BED_LEVELING

// Disable auto bed leveling during G29.
// Be formal so G29 can be done successively without G28.
Expand Down
6 changes: 2 additions & 4 deletions Marlin/src/gcode/bedlevel/mbl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ void GcodeSuite::G29() {
TERN_(DWIN_LCD_PROUI, DWIN_LevelingStart());

// Position bed horizontally and Z probe vertically.
#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
#if HAS_SAFE_BED_LEVELING
xyze_pos_t safe_position = current_position;
#ifdef SAFE_BED_LEVELING_START_X
safe_position.x = SAFE_BED_LEVELING_START_X;
Expand Down Expand Up @@ -141,7 +139,7 @@ void GcodeSuite::G29() {
#endif

do_blocking_move_to(safe_position);
#endif
#endif // HAS_SAFE_BED_LEVELING

return;
}
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,12 @@
#endif
#endif

#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
#define HAS_SAFE_BED_LEVELING 1
#endif

//
// SD Card connection methods
// Defined here so pins and sanity checks can use them
Expand Down
21 changes: 21 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,27 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
static_assert(WITHIN(Z_SAFE_HOMING_Y_POINT, Y_MIN_POS, Y_MAX_POS), "Z_SAFE_HOMING_Y_POINT can't be reached by the nozzle.");
#endif

// Check Safe Bed Leveling settings
#if HAS_SAFE_BED_LEVELING
#if defined(SAFE_BED_LEVELING_START_Y) && !defined(SAFE_BED_LEVELING_START_X)
#error "If SAFE_BED_LEVELING_START_Y is defined, SAFE_BED_LEVELING_START_X must also be defined."
#elif defined(SAFE_BED_LEVELING_START_Z) && !defined(SAFE_BED_LEVELING_START_Y)
#error "If SAFE_BED_LEVELING_START_Z is defined, SAFE_BED_LEVELING_START_Y must also be defined."
#elif defined(SAFE_BED_LEVELING_START_I) && !defined(SAFE_BED_LEVELING_START_Z)
#error "If SAFE_BED_LEVELING_START_I is defined, SAFE_BED_LEVELING_START_Z must also be defined."
#elif defined(SAFE_BED_LEVELING_START_J) && !defined(SAFE_BED_LEVELING_START_I)
#error "If SAFE_BED_LEVELING_START_J is defined, SAFE_BED_LEVELING_START_I must also be defined."
#elif defined(SAFE_BED_LEVELING_START_K) && !defined(SAFE_BED_LEVELING_START_J)
#error "If SAFE_BED_LEVELING_START_K is defined, SAFE_BED_LEVELING_START_J must also be defined."
#elif defined(SAFE_BED_LEVELING_START_U) && !defined(SAFE_BED_LEVELING_START_K)
#error "If SAFE_BED_LEVELING_START_U is defined, SAFE_BED_LEVELING_START_K must also be defined."
#elif defined(SAFE_BED_LEVELING_START_V) && !defined(SAFE_BED_LEVELING_START_U)
#error "If SAFE_BED_LEVELING_START_V is defined, SAFE_BED_LEVELING_START_U must also be defined."
#elif defined(SAFE_BED_LEVELING_START_W) && !defined(SAFE_BED_LEVELING_START_V)
#error "If SAFE_BED_LEVELING_START_W is defined, SAFE_BED_LEVELING_START_V must also be defined."
#endif
#endif

/**
* Make sure DISABLE_[XYZ] compatible with selected homing options
*/
Expand Down

0 comments on commit 7e79fc5

Please sign in to comment.