🚸 Fix, extend X Axis Twist Compensation (#23745)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Giuseppe499
2022-03-12 00:12:03 +01:00
committed by Scott Lahteine
parent eabeac29fd
commit c6f4b38877
14 changed files with 142 additions and 34 deletions

View File

@ -213,8 +213,8 @@ void unified_bed_leveling::display_map(const uint8_t map_type) {
else if (isnan(f))
SERIAL_ECHOF(human ? F(" . ") : F("NAN"));
else if (human || csv) {
if (human && f >= 0.0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
SERIAL_ECHO_F(f, 3); // Positive: 5 digits, Negative: 6 digits
if (human && f >= 0) SERIAL_CHAR(f > 0 ? '+' : ' '); // Display sign also for positive numbers (' ' for 0)
SERIAL_DECIMAL(f); // Positive: 5 digits, Negative: 6 digits
}
if (csv && i < (GRID_MAX_POINTS_X) - 1) SERIAL_CHAR('\t');

View File

@ -63,7 +63,7 @@ void Mixer::normalize(const uint8_t tool_index) {
#ifdef MIXER_NORMALIZER_DEBUG
SERIAL_ECHOPGM("Mixer: Old relation : [ ");
MIXER_STEPPER_LOOP(i) {
SERIAL_ECHO_F(collector[i] / csum, 3);
SERIAL_DECIMAL(collector[i] / csum);
SERIAL_CHAR(' ');
}
SERIAL_ECHOLNPGM("]");

View File

@ -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;
}
@ -45,14 +45,10 @@ void XATC::print_points() {
SERIAL_ECHOLNPGM(" X-Twist Correction:");
LOOP_L_N(x, XATC_MAX_POINTS) {
SERIAL_CHAR(' ');
if (!isnan(z_offset[x])) {
if (z_offset[x] >= 0) SERIAL_CHAR('+');
SERIAL_ECHO_F(z_offset[x], 3);
}
else {
LOOP_L_N(i, 6)
SERIAL_CHAR(i ? '=' : ' ');
}
if (!isnan(z_offset[x]))
serial_offset(z_offset[x]);
else
LOOP_L_N(i, 6) SERIAL_CHAR(i ? '=' : ' ');
}
SERIAL_EOL();
}
@ -63,8 +59,7 @@ float XATC::compensation(const xy_pos_t &raw) {
if (!enabled) return 0;
if (NEAR_ZERO(spacing)) return 0;
float t = (raw.x - start) / spacing;
int i = FLOOR(t);
LIMIT(i, 0, XATC_MAX_POINTS - 2);
const int i = constrain(FLOOR(t), 0, XATC_MAX_POINTS - 2);
t -= i;
return lerp(t, z_offset[i], z_offset[i + 1]);
}