From 5027ce5973f094ebc18ec472b9b72dd94d630731 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Mar 2022 15:45:40 -0600 Subject: [PATCH] M423 E to set spacing as (e - s) / n --- Marlin/src/feature/x_twist.cpp | 4 ++-- Marlin/src/gcode/probe/M423.cpp | 18 ++++++++++++++---- Marlin/src/lcd/menu/menu_x_twist.cpp | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/x_twist.cpp b/Marlin/src/feature/x_twist.cpp index 891009123986e..ce637de5aeeef 100644 --- a/Marlin/src/feature/x_twist.cpp +++ b/Marlin/src/feature/x_twist.cpp @@ -36,8 +36,8 @@ void XATC::reset() { constexpr float xzo[] = XATC_Z_OFFSETS; static_assert(COUNT(xzo) == XATC_MAX_POINTS, "XATC_Z_OFFSETS is the wrong size."); COPY(z_offset, xzo); - xatc.spacing = (probe.max_x() - probe.min_x()) / (XATC_MAX_POINTS - 1); - xatc.start = probe.min_x(); + start = probe.min_x(); + spacing = (probe.max_x() - start) / (XATC_MAX_POINTS - 1); enabled = true; } diff --git a/Marlin/src/gcode/probe/M423.cpp b/Marlin/src/gcode/probe/M423.cpp index 61b5db33069df..4d02feb119dc5 100644 --- a/Marlin/src/gcode/probe/M423.cpp +++ b/Marlin/src/gcode/probe/M423.cpp @@ -30,20 +30,23 @@ #include "../gcode.h" #include "../../feature/x_twist.h" +#include "../../module/probe.h" /** * M423: Set a Z offset for X-Twist (added to the mesh on future G29). * M423 [R] [A] [I] [X Z] * * R - Reset the twist compensation data - * A - Override the X twist starting X position - * I - Override the X twist X-spacing + * A - Set the X twist starting X position + * E - Set the X twist ending X position + * I - Set the X twist X-spacing directly * X - Index of a Z value in the list * Z - A Z value to set */ void GcodeSuite::M423() { bool do_report = true; + float new_spacing = 0; if (parser.seen_test('R')) { do_report = false; @@ -52,11 +55,18 @@ void GcodeSuite::M423() { if (parser.seenval('A')) { do_report = false; xatc.start = parser.value_float(); + new_spacing = (probe.max_x() - xatc.start) / (XATC_MAX_POINTS - 1); } - if (parser.seenval('I')) { + if (parser.seenval('E')) { do_report = false; - xatc.spacing = parser.value_float(); + new_spacing = (parser.value_float() - xatc.start) / (XATC_MAX_POINTS - 1); } + else if (parser.seenval('I')) { + do_report = false; + new_spacing = parser.value_float(); + } + + if (new_spacing) xatx.spacing = new_spacing; if (parser.seenval('X')) { do_report = false; diff --git a/Marlin/src/lcd/menu/menu_x_twist.cpp b/Marlin/src/lcd/menu/menu_x_twist.cpp index 93f8de07ad465..ce46053dfc346 100644 --- a/Marlin/src/lcd/menu/menu_x_twist.cpp +++ b/Marlin/src/lcd/menu/menu_x_twist.cpp @@ -153,7 +153,7 @@ void xatc_wizard_goto_next_point() { measured_z = probe.probe_at_point(x, XATC_Y_POSITION, PROBE_PT_STOW); xatc.set_enabled(true); current_position += probe.offset_xy; - current_position.z = XATC_START_Z - probe.offset.z + measured_z; + current_position.z = (XATC_START_Z) - probe.offset.z + measured_z; line_to_current_position(MMM_TO_MMS(XY_PROBE_FEEDRATE)); ui.wait_for_move = false; }