Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion Marlin/src/gcode/bedlevel/M420.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ void GcodeSuite::M420() {

#if ENABLED(MARLIN_DEV_MODE)
if (parser.intval('S') == 2) {
// Farthest XY coordinates that the probe can reach
const float x_min = probe.min_x(), x_max = probe.max_x(),
y_min = probe.min_y(), y_max = probe.max_y();
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
xy_pos_t start, spacing;
start.set(x_min, y_min);
spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X),
(y_max - y_min) / (GRID_MAX_CELLS_Y));
bedlevel.set_grid(spacing, start);
// Shift the grid bounds by the probe offset because...?
bedlevel.set_grid(spacing, Probe::tool_xy_for_probe_xy(start));
#endif
GRID_LOOP(x, y) {
bedlevel.z_values[x][y] = 0.001 * random(-200, 200);
Expand Down
6 changes: 4 additions & 2 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ G29_TYPE GcodeSuite::G29() {
#endif

#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (!abl.dryrun && (abl.gridSpacing != bedlevel.grid_spacing || abl.probe_position_lf != bedlevel.grid_start)) {
// Convert the probe-space grid origin to the motion/nozzle coordinate
const xy_pos_t grid_start = Probe::tool_xy_for_probe_xy(abl.probe_position_lf);
if (!abl.dryrun && (abl.gridSpacing != bedlevel.grid_spacing || grid_start != bedlevel.grid_start)) {
reset_bed_level(); // Reset grid to 0.0 or "not probed". (Also disables ABL)
abl.reenable = false; // Can't re-enable (on error) until the new grid is written
}
Expand Down Expand Up @@ -880,7 +882,7 @@ G29_TYPE GcodeSuite::G29() {
if (abl.dryrun)
bedlevel.print_leveling_grid(&abl.z_values);
else {
bedlevel.set_grid(abl.gridSpacing, abl.probe_position_lf);
bedlevel.set_grid(abl.gridSpacing, Probe::tool_xy_for_probe_xy(abl.probe_position_lf));
COPY(bedlevel.z_values, abl.z_values);
TERN_(IS_KINEMATIC, bedlevel.extrapolate_unprobed_bed_level());
bedlevel.refresh_bed_level();
Expand Down
12 changes: 12 additions & 0 deletions Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ class Probe {
static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
#endif

// Input: A coordinate destination for the probe.
// Return: The tool position that will put the probe there.
// Also adjusted for the tool offset unless PROBING_TOOL is used.
// With PROBING_TOOL the probe offsets are presumed relative to that tool, not T0.
static xy_pos_t tool_xy_for_probe_xy(const xy_pos_t &probe_xy) {
xy_pos_t nozPos = DIFF_TERN(HAS_PROBE_XY_OFFSET, probe_xy, offset_xy);
#if DISABLED(DO_TOOLCHANGE_FOR_PROBING)
nozPos += xy_pos_t(motion.active_hotend_offset());
#endif
return nozPos;
}

static bool deploy(const bool no_return=false) { return set_deployed(true, no_return); }
static bool stow(const bool no_return=false) { return set_deployed(false, no_return); }

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3190,7 +3190,7 @@ void MarlinSettings::postprocess() {
#define MESH_STORE_SIZE sizeof(TERN(OPTIMIZED_MESH_STORAGE, mesh_store_t, bedlevel.z_values))

uint16_t MarlinSettings::calc_num_meshes() {
return MIN(MAX_SAVED_MESHES, (meshes_end - meshes_start_index()) / MESH_STORE_SIZE);
return _MIN(MAX_SAVED_MESHES, (meshes_end - meshes_start_index()) / MESH_STORE_SIZE);
}

int MarlinSettings::mesh_slot_offset(const int8_t slot) {
Expand Down
Loading