Skip to content

Commit

Permalink
M423 E to set spacing as (e - s) / n
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Mar 11, 2022
1 parent 0cbda4a commit 5027ce5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/feature/x_twist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
18 changes: 14 additions & 4 deletions Marlin/src/gcode/probe/M423.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<startx>] [I<interval>] [X<index> Z<offset>]
*
* R - Reset the twist compensation data
* A<linear> - Override the X twist starting X position
* I<linear> - Override the X twist X-spacing
* A<linear> - Set the X twist starting X position
* E<linear> - Set the X twist ending X position
* I<linear> - Set the X twist X-spacing directly
* X<index> - Index of a Z value in the list
* Z<linear> - A Z value to set
*/
void GcodeSuite::M423() {

bool do_report = true;
float new_spacing = 0;

if (parser.seen_test('R')) {
do_report = false;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_x_twist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5027ce5

Please sign in to comment.