Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ab624a3
Fix for G34 probing due to "dirty trick"
Apr 3, 2023
4cde421
Adds current height back to the after probe lift
Apr 4, 2023
f6e0156
reduce extra HS clearance to nozzle probe Z offset
Apr 4, 2023
1293471
+Current pos makes safe clearance unnecessary
Apr 4, 2023
4256267
G28 double lift fix (and also G28 Rx now relative)
Apr 5, 2023
3b26539
Typo correction
Apr 5, 2023
985ff7a
Correct homing z lift after M84
Apr 5, 2023
f165ac0
cleanup
thinkyhead Apr 5, 2023
98ec0be
BLTOUCH HS clearance 7mm
thinkyhead Apr 5, 2023
3435a7a
Use do_z_clearance
thinkyhead Apr 5, 2023
14e463a
Reverted to previous state - likely unnecessary
Apr 6, 2023
e19a6d4
Move to safe clearance height after probing
Apr 6, 2023
cdc9973
Finish Homing at Z_CLEARANCE_BETWEEN_PROBES
Apr 6, 2023
ac8dd62
cleanup
thinkyhead Apr 7, 2023
af22e68
Obey Z_HOMING_HEIGHT
thinkyhead Apr 7, 2023
294a3ba
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 7, 2023
f46256a
Only relevant when HOMING_Z_WITH_PROBE
thinkyhead Apr 7, 2023
0bfe0b5
cleanup
thinkyhead Apr 7, 2023
37d9118
Consider sensorless max offset
thinkyhead Apr 7, 2023
9db784d
tweak
thinkyhead Apr 7, 2023
3cb855c
Explain Z raise in G28
thinkyhead Apr 7, 2023
ac7ff3f
probe_at_point() lift is absolute
Apr 7, 2023
dd5dca5
Raise above probe.offset.z
thinkyhead Apr 10, 2023
0c2f410
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 10, 2023
9561551
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 11, 2023
f6e8a9d
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 11, 2023
ca219cf
standard clearance
thinkyhead Apr 11, 2023
1bb632f
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 11, 2023
f178234
Describe G34
thinkyhead Apr 11, 2023
5b8d2d0
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 11, 2023
15a5019
tweak probe_at_point
thinkyhead Apr 11, 2023
35f9b81
more fun adjustments
thinkyhead Apr 11, 2023
b0fef3a
📝 Improve G30 description
thinkyhead Apr 11, 2023
bc643ca
stow on probe error?
thinkyhead Apr 11, 2023
0948fb8
📝 Improve G30 description
thinkyhead Apr 11, 2023
0039a92
BLTOUCH_HS_EXTRA_CLEARANCE
thinkyhead Apr 11, 2023
87d29d3
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 11, 2023
57688d5
trust probe error in homeaxis ?
thinkyhead Apr 11, 2023
7a3dab9
trust probe error in homeaxis ?
thinkyhead Apr 11, 2023
8bd3149
use Z_PROBE_SAFE_CLEARANCE for UBL
thinkyhead Apr 11, 2023
b59c5c3
Merge branch 'bugfix-2.1.x' of https://github.com/jamespearson04/Marl…
Apr 11, 2023
df7f8c4
use Z_PROBE_SAFE_CLEARANCE for UBL
thinkyhead Apr 11, 2023
c588797
Merge branch 'bugfix-2.1.x' of https://github.com/jamespearson04/Marl…
Apr 11, 2023
c944425
Multi probe lift relative
Apr 11, 2023
043212a
Make probe lift relative
Apr 11, 2023
a4689ca
Revert "Make probe lift relative"
Apr 11, 2023
af50b53
Revert "Multi probe lift relative"
Apr 11, 2023
ae4a262
🚸 Proposed fix for `G34` - Needs Tweak
thinkyhead Apr 11, 2023
4baf95b
Merge branch 'bugfix-2.1.x' of https://github.com/jamespearson04/Marl…
Apr 12, 2023
cb2533b
Add min probe height override parameter
Apr 14, 2023
f3d4929
CAUTION: Remove G34 dirty trick - untested
Apr 14, 2023
bbd0186
Add missing BLTOUCH include
Apr 14, 2023
c317b5b
Revert "Add missing BLTOUCH include" - unnecessary
Apr 14, 2023
2c2b5ca
Revert "Revert "Add missing BLTOUCH include""
Apr 14, 2023
a20bd25
Multi probe lift consistency
Apr 14, 2023
b2f826a
probe_at_point Clearance Parameter
Apr 16, 2023
8ad106f
G34 use probe Z clearance parameter
Apr 16, 2023
20cc6ee
0 not suitable as undef value
Apr 17, 2023
b3b6faf
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
Apr 18, 2023
4e94aa0
Remove extra lift at end of G34
Apr 18, 2023
92f5f05
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 20, 2023
e9b6835
misc adjust
thinkyhead Apr 20, 2023
de09495
Do G28 post move after resetting endstops etc.
Apr 23, 2023
09b21c4
clarify
thinkyhead Apr 26, 2023
282d207
remove [ \t]+$
thinkyhead Apr 26, 2023
4bf5540
Tweak G28 final actions
thinkyhead Apr 26, 2023
9ccb8c4
Fix 4bf5540
Apr 27, 2023
aaf63b2
Same as prev.
Apr 27, 2023
0e62852
Remove override of Z_CLEARANCE_DEPLOY_PROBE
Apr 28, 2023
108b144
Make untrusted z probe min relative to specd value
Apr 28, 2023
a1cf215
Add probe_at_point() lift_relative argument
Apr 28, 2023
e61bcec
Make G33 probe lift relative
Apr 28, 2023
2069bb4
typo
Apr 28, 2023
7cf29d2
misc.
thinkyhead Apr 28, 2023
4d74832
Merge branch 'bugfix-2.1.x' into pr/25631
thinkyhead Apr 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@
//#define Z_CLEARANCE_FOR_HOMING 4 // (mm) Minimal Z height before homing (G28) for Z clearance above the bed, clamps, ...
// Be sure to have this much clearance over your Z_MAX_POS to prevent grinding.

//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing Z
//#define Z_AFTER_HOMING 10 // (mm) Height to move to after homing (if Z was homed)

// Direction of endstops when homing; 1=MAX, -1=MIN
// :[-1,1]
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@

//#define QUICK_HOME // If G28 contains XY do a diagonal move first
//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
//#define HOME_Z_FIRST // Home Z first. Requires a Z-MIN endstop (not a probe).
//#define HOME_Z_FIRST // Home Z first. Requires a real endstop (not a probe).
//#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first

// @section bltouch
Expand Down
19 changes: 8 additions & 11 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
* If omitted, the nozzle will raise by Z_CLEARANCE_BETWEEN_PROBES.
*
* H # Offset With P4, 'H' specifies the Offset above the mesh height to place the nozzle.
* If omitted, Z_CLEARANCE_BETWEEN_PROBES will be used.
* If omitted, Z_TWEEN_SAFE_CLEARANCE will be used.
*
* I # Invalidate Invalidate the specified number of Mesh Points near the given 'X' 'Y'. If X or Y are omitted,
* the nozzle location is used. If no 'I' value is given, only the point nearest to the location
Expand Down Expand Up @@ -790,10 +790,7 @@ void unified_bed_leveling::shift_mesh_height() {

if (best.pos.x >= 0) { // mesh point found and is reachable by probe
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_START));
const float measured_z = probe.probe_at_point(
best.meshpos(),
stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity
);
const float measured_z = probe.probe_at_point(best.meshpos(), stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, param.V_verbosity);
z_values[best.pos.x][best.pos.y] = measured_z;
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onMeshUpdate(best.pos, ExtUI::G29_POINT_FINISH);
Expand Down Expand Up @@ -1034,9 +1031,9 @@ void set_message_with_feedback(FSTR_P const fstr) {
save_ubl_active_state_and_disable();

LCD_MESSAGE(MSG_UBL_FINE_TUNE_MESH);
ui.capture(); // Take over control of the LCD encoder
ui.capture(); // Take over control of the LCD encoder

do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES); // Move to the given XY with probe clearance
do_blocking_move_to_xy_z(pos, Z_TWEEN_SAFE_CLEARANCE); // Move to the given XY with probe clearance

MeshFlags done_flags{0};
const xy_int8_t &lpos = location.pos;
Expand All @@ -1053,7 +1050,7 @@ void set_message_with_feedback(FSTR_P const fstr) {

done_flags.mark(lpos); // Mark this location as 'adjusted' so a new
// location is used on the next loop
const xyz_pos_t raw = { get_mesh_x(lpos.x), get_mesh_y(lpos.y), Z_CLEARANCE_BETWEEN_PROBES };
const xyz_pos_t raw = { get_mesh_x(lpos.x), get_mesh_y(lpos.y), Z_TWEEN_SAFE_CLEARANCE };

if (!position_is_reachable(raw)) break; // SHOULD NOT OCCUR (find_closest_mesh_point_of_type only returns reachable)

Expand All @@ -1063,7 +1060,7 @@ void set_message_with_feedback(FSTR_P const fstr) {

KEEPALIVE_STATE(PAUSED_FOR_USER);

if (do_ubl_mesh_map) display_map(param.T_map_type); // Display the current point
if (do_ubl_mesh_map) display_map(param.T_map_type); // Display the current point

#if IS_TFTGLCD_PANEL
ui.ubl_plot(lpos.x, lpos.y); // update plot screen
Expand Down Expand Up @@ -1093,7 +1090,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
// Button held down? Abort editing
if (_click_and_hold([]{
ui.return_to_status();
do_z_clearance(Z_CLEARANCE_BETWEEN_PROBES);
do_z_clearance(Z_TWEEN_SAFE_CLEARANCE);
set_message_with_feedback(GET_TEXT_F(MSG_EDITING_STOPPED));
})) break;

Expand All @@ -1113,7 +1110,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
if (do_ubl_mesh_map) display_map(param.T_map_type);
restore_ubl_active_state_and_leave();

do_blocking_move_to_xy_z(pos, Z_CLEARANCE_BETWEEN_PROBES);
do_blocking_move_to_xy_z(pos, Z_TWEEN_SAFE_CLEARANCE);

LCD_MESSAGE(MSG_UBL_DONE_EDITING_MESH);
SERIAL_ECHOLNPGM("Done Editing Mesh");
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void GcodeSuite::G35() {

// Probe all positions
LOOP_L_N(i, G35_PROBE_COUNT) {
const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true);
const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE);
if (isnan(z_probed_height)) {
SERIAL_ECHOPGM("G35 failed at point ", i + 1, " (");
SERIAL_ECHOPGM_P((char *)pgm_read_ptr(&tramming_point_name[i]));
Expand Down
41 changes: 26 additions & 15 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ void GcodeSuite::G28() {

endstops.enable(true); // Enable endstops for next homing move

bool finalRaiseZ = false;

#if ENABLED(DELTA)

constexpr bool doZ = true; // for NANODLP_Z_SYNC if your DLP is on a DELTA
Expand Down Expand Up @@ -407,8 +409,9 @@ void GcodeSuite::G28() {

UNUSED(needZ); UNUSED(homeZZ);

// Z may home first, e.g., when homing away from the bed
TERN_(HOME_Z_FIRST, if (doZ) homeaxis(Z_AXIS));
// Z may home first, e.g., when homing away from the bed.
// This is also permitted when homing with a Z endstop.
if (TERN0(HOME_Z_FIRST, doZ)) homeaxis(Z_AXIS);

// 'R' to specify a specific raise. 'R0' indicates no raise, e.g., for recovery.resume
// When 'R0' is used, there should already be adequate clearance, e.g., from homing Z to max.
Expand Down Expand Up @@ -517,7 +520,10 @@ void GcodeSuite::G28() {
#else
homeaxis(Z_AXIS);
#endif
do_move_after_z_homing();

#if EITHER(Z_HOME_TO_MIN, ALLOW_Z_AFTER_HOMING)
finalRaiseZ = true;
#endif
}
#endif

Expand Down Expand Up @@ -575,18 +581,6 @@ void GcodeSuite::G28() {
// Clear endstop state for polled stallGuard endstops
TERN_(SPI_ENDSTOPS, endstops.clear_endstop_state());

// Move to a height where we can use the full xy-area
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));

TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());

restore_feedrate_and_scaling();

// Restore the active tool after homing
#if HAS_MULTI_HOTEND && (DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE))
tool_change(old_tool_index, TERN(PARKING_EXTRUDER, !pe_final_change_must_unpark, DISABLED(DUAL_X_CARRIAGE))); // Do move if one of these
#endif

#if HAS_HOMING_CURRENT
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Restore driver current...");
#if HAS_CURRENT_HOME(X)
Expand Down Expand Up @@ -627,6 +621,23 @@ void GcodeSuite::G28() {
#endif
#endif // HAS_HOMING_CURRENT

// Move to a height where we can use the full xy-area
TERN_(DELTA_HOME_TO_SAFE_ZONE, do_blocking_move_to_z(delta_clip_start_height));

// Move to the configured Z only if Z was homed to MIN, because machines that
// home to MAX historically expect 'G28 Z' to be safe to use at the end of a
// print, and do_move_after_z_homing is not very nuanced.
if (finalRaiseZ) do_move_after_z_homing();

TERN_(CAN_SET_LEVELING_AFTER_G28, if (leveling_restore_state) set_bed_leveling_enabled());

// Restore the active tool after homing
#if HAS_MULTI_HOTEND && (DISABLED(DELTA) || ENABLED(DELTA_HOME_TO_SAFE_ZONE))
tool_change(old_tool_index, TERN(PARKING_EXTRUDER, !pe_final_change_must_unpark, DISABLED(DUAL_X_CARRIAGE))); // Do move if one of these
#endif

restore_feedrate_and_scaling();

ui.refresh();

TERN_(HAS_DWIN_E3V2_BASIC, DWIN_HomingDone());
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool
*/
static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool probe_at_offset) {
#if HAS_BED_PROBE
return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, probe_at_offset, false);
return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, probe_at_offset, false, Z_PROBE_LOW_POINT, Z_TWEEN_SAFE_CLEARANCE, true);
#else
UNUSED(stow);
return lcd_probe_pt(xy);
Expand Down
27 changes: 8 additions & 19 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void GcodeSuite::G34() {
const xy_pos_t diff = z_stepper_align.xy[i] - z_stepper_align.xy[j];
return HYPOT2(diff.x, diff.y);
};
float z_probe = (Z_PROBE_SAFE_CLEARANCE) + (G34_MAX_GRADE) * 0.01f * SQRT(_MAX(0, magnitude2(0, 1)
const float zoffs = (probe.offset.z < 0) ? -probe.offset.z : 0.0f;
float z_probe = (Z_TWEEN_SAFE_CLEARANCE + zoffs) + (G34_MAX_GRADE) * 0.01f * SQRT(_MAX(0, magnitude2(0, 1)
#if TRIPLE_Z
, magnitude2(2, 1), magnitude2(2, 0)
#if QUAD_Z
Expand All @@ -165,12 +166,6 @@ void GcodeSuite::G34() {
// Home before the alignment procedure
home_if_needed();

// Move the Z coordinate realm towards the positive - dirty trick
current_position.z += z_probe * 0.5f;
sync_plan_position();
// Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error.
// This hack is un-done at the end of G34 - either by re-homing, or by using the probed heights of the last iteration.

#if !HAS_Z_STEPPER_ALIGN_STEPPER_XY
float last_z_align_move[NUM_Z_STEPPERS] = ARRAY_N_1(NUM_Z_STEPPERS, 10000.0f);
#else
Expand Down Expand Up @@ -213,28 +208,24 @@ void GcodeSuite::G34() {
// iteration odd/even --> downward / upward stepper sequence
const uint8_t iprobe = (iteration & 1) ? NUM_Z_STEPPERS - 1 - i : i;

// Safe clearance even on an incline
if ((iteration == 0 || i > 0) && z_probe > current_position.z) do_blocking_move_to_z(z_probe);

xy_pos_t &ppos = z_stepper_align.xy[iprobe];

if (DEBUGGING(LEVELING))
DEBUG_ECHOLNPGM_P(PSTR("Probing X"), ppos.x, SP_Y_STR, ppos.y);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(PSTR("Probing X"), ppos.x, SP_Y_STR, ppos.y);

// Probe a Z height for each stepper.
// Probing sanity check is disabled, as it would trigger even in normal cases because
// current_position.z has been manually altered in the "dirty trick" above.
const float z_probed_height = probe.probe_at_point(DIFF_TERN(HAS_HOME_OFFSET, ppos, xy_pos_t(home_offset)), raise_after, 0, true, false);
const float z_probed_height = probe.probe_at_point(DIFF_TERN(HAS_HOME_OFFSET, ppos, xy_pos_t(home_offset)), raise_after, 0, true, false, (Z_PROBE_LOW_POINT) - z_probe * 0.5f, z_probe * 0.5f);
if (isnan(z_probed_height)) {
SERIAL_ECHOLNPGM("Probing failed");
SERIAL_ECHOLNPGM(STR_ERR_PROBING_FAILED);
LCD_MESSAGE(MSG_LCD_PROBING_FAILED);
err_break = true;
break;
}

// Add height to each value, to provide a more useful target height for
// the next iteration of probing. This allows adjustments to be made away from the bed.
z_measured[iprobe] = z_probed_height + (Z_CLEARANCE_BETWEEN_PROBES);
z_measured[iprobe] = z_probed_height + (Z_TWEEN_SAFE_CLEARANCE + zoffs); //do we need to add the clearance to this?

if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]);

Expand All @@ -248,7 +239,7 @@ void GcodeSuite::G34() {
// Adapt the next probe clearance height based on the new measurements.
// Safe_height = lowest distance to bed (= highest measurement) plus highest measured misalignment.
z_maxdiff = z_measured_max - z_measured_min;
z_probe = (Z_PROBE_SAFE_CLEARANCE) + z_measured_max + z_maxdiff;
z_probe = (Z_TWEEN_SAFE_CLEARANCE + zoffs) + z_measured_max + z_maxdiff; //Not sure we need z_maxdiff, but leaving it in for safety.

#if HAS_Z_STEPPER_ALIGN_STEPPER_XY
// Replace the initial values in z_measured with calculated heights at
Expand Down Expand Up @@ -428,15 +419,13 @@ void GcodeSuite::G34() {
IF_DISABLED(TOUCH_MI_PROBE, probe.stow());

#if ENABLED(HOME_AFTER_G34)
// After this operation the z position needs correction
set_axis_never_homed(Z_AXIS);
// Home Z after the alignment procedure
process_subcommands_now(F("G28Z"));
#else
// Use the probed height from the last iteration to determine the Z height.
// z_measured_min is used, because all steppers are aligned to z_measured_min.
// Ideally, this would be equal to the 'z_probe * 0.5f' which was added earlier.
current_position.z -= z_measured_min - float(Z_CLEARANCE_BETWEEN_PROBES);
current_position.z -= z_measured_min - (Z_TWEEN_SAFE_CLEARANCE + zoffs); //we shouldn't want to subtract the clearance from here right? (Depends if we added it further up)
sync_plan_position();
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void GcodeSuite::M48() {
} // n_legs

// Probe a single point
const float pz = probe.probe_at_point(test_position, raise_after, 0);
const float pz = probe.probe_at_point(test_position, raise_after);

// Break the loop if the probe fails
probing_good = !isnan(pz);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/probe/G30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void GcodeSuite::G30() {
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;

TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
const float measured_z = probe.probe_at_point(probepos, raise_after, 1);
const float measured_z = probe.probe_at_point(probepos, raise_after);
TERN_(HAS_PTC, ptc.set_enabled(true));
if (!isnan(measured_z)) {
SERIAL_ECHOLNPGM("Bed X: ", probepos.asLogical().x, " Y: ", probepos.asLogical().y, " Z: ", measured_z);
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2350,6 +2350,10 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "HOME_Z_FIRST can't be used when homing Z with a probe."
#endif

#if Z_HOME_TO_MAX && defined(Z_AFTER_HOMING) && DISABLED(ALLOW_Z_AFTER_HOMING)
#error "Z_AFTER_HOMING shouldn't be used with Z max homing to keep 'G28 Z' safe for end-of-print usage. Define ALLOW_Z_AFTER_HOMING to allow this at your own risk."
#endif

// Dual/multiple endstops requirements
#if ENABLED(X_DUAL_ENDSTOPS)
#if ENABLED(DELTA)
Expand Down
36 changes: 23 additions & 13 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,13 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
static float mlev_z_pos = 0;
static bool use_probe = false;

#if HAS_BED_PROBE
constexpr float probe_x_min = _MAX(0 + corner_pos, X_MIN_POS + probe.offset.x, X_MIN_POS + PROBING_MARGIN) - probe.offset.x,
probe_x_max = _MIN((X_BED_SIZE + X_MIN_POS) - corner_pos, X_MAX_POS + probe.offset.x, X_MAX_POS - PROBING_MARGIN) - probe.offset.x,
probe_y_min = _MAX(0 + corner_pos, Y_MIN_POS + probe.offset.y, Y_MIN_POS + PROBING_MARGIN) - probe.offset.y,
probe_y_max = _MIN((Y_BED_SIZE + Y_MIN_POS) - corner_pos, Y_MAX_POS + probe.offset.y, Y_MAX_POS - PROBING_MARGIN) - probe.offset.y;
#endif

switch (item) {
case MLEVEL_BACK:
if (draw)
Expand All @@ -1425,19 +1432,22 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
Draw_Checkbox(row, use_probe);
}
else {
use_probe = !use_probe;
use_probe ^= true;
Draw_Checkbox(row, use_probe);
if (use_probe) {
Popup_Handler(Level);
constexpr struct { xy_pos_t p, ProbePtRaise r } points[] = {
{ { probe_x_min, probe_y_min }, PROBE_PT_RAISE },
{ { probe_x_min, probe_y_max }, PROBE_PT_RAISE },
{ { probe_x_max, probe_y_max }, PROBE_PT_RAISE },
{ { probe_x_max, probe_y_min }, PROBE_PT_STOW }
};
corner_avg = 0;
#define PROBE_X_MIN _MAX(0 + corner_pos, X_MIN_POS + probe.offset.x, X_MIN_POS + PROBING_MARGIN) - probe.offset.x
#define PROBE_X_MAX _MIN((X_BED_SIZE + X_MIN_POS) - corner_pos, X_MAX_POS + probe.offset.x, X_MAX_POS - PROBING_MARGIN) - probe.offset.x
#define PROBE_Y_MIN _MAX(0 + corner_pos, Y_MIN_POS + probe.offset.y, Y_MIN_POS + PROBING_MARGIN) - probe.offset.y
#define PROBE_Y_MAX _MIN((Y_BED_SIZE + Y_MIN_POS) - corner_pos, Y_MAX_POS + probe.offset.y, Y_MAX_POS - PROBING_MARGIN) - probe.offset.y
corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MIN, PROBE_PT_RAISE, 0, false);
corner_avg += probe.probe_at_point(PROBE_X_MIN, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false);
corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MAX, PROBE_PT_RAISE, 0, false);
corner_avg += probe.probe_at_point(PROBE_X_MAX, PROBE_Y_MIN, PROBE_PT_STOW, 0, false);
for (uint8_t i = 0; i < COUNT(points); i++) {
const float mz = probe.probe_at_point(points[i].p, points[i].r, 0, false);
if (isnan(mz)) { corner_avg = 0; break; }
corner_avg += mz;
}
corner_avg /= 4;
Redraw_Menu();
}
Expand All @@ -1451,7 +1461,7 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
Popup_Handler(MoveWait);
if (use_probe) {
#if HAS_BED_PROBE
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2));
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(probe_x_min, 1, 3, str_1), dtostrf(probe_y_min, 1, 3, str_2));
gcode.process_subcommands_now(cmd);
planner.synchronize();
Popup_Handler(ManualProbing);
Expand All @@ -1472,7 +1482,7 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
Popup_Handler(MoveWait);
if (use_probe) {
#if HAS_BED_PROBE
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MIN, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2));
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(probe_x_min, 1, 3, str_1), dtostrf(probe_y_max, 1, 3, str_2));
gcode.process_subcommands_now(cmd);
planner.synchronize();
Popup_Handler(ManualProbing);
Expand All @@ -1493,7 +1503,7 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
Popup_Handler(MoveWait);
if (use_probe) {
#if HAS_BED_PROBE
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MAX, 1, 3, str_2));
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(probe_x_max, 1, 3, str_1), dtostrf(probe_y_max, 1, 3, str_2));
gcode.process_subcommands_now(cmd);
planner.synchronize();
Popup_Handler(ManualProbing);
Expand All @@ -1514,7 +1524,7 @@ void CrealityDWINClass::Menu_Item_Handler(const uint8_t menu, const uint8_t item
Popup_Handler(MoveWait);
if (use_probe) {
#if HAS_BED_PROBE
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(PROBE_X_MAX, 1, 3, str_1), dtostrf(PROBE_Y_MIN, 1, 3, str_2));
sprintf_P(cmd, PSTR("G0 F4000\nG0 Z10\nG0 X%s Y%s"), dtostrf(probe_x_max, 1, 3, str_1), dtostrf(probe_y_min, 1, 3, str_2));
gcode.process_subcommands_now(cmd);
planner.synchronize();
Popup_Handler(ManualProbing);
Expand Down
Loading