🚸 Universal X_AXIS_TWIST_COMPENSATION (#23828)

This commit is contained in:
tombrazier
2022-03-02 22:13:46 +00:00
committed by Scott Lahteine
parent 43d4e30668
commit 575c3150f9
10 changed files with 67 additions and 31 deletions

View File

@ -81,6 +81,10 @@
#include "../feature/probe_temp_comp.h"
#endif
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
#include "../feature/x_twist.h"
#endif
#if ENABLED(EXTENSIBLE_UI)
#include "../lcd/extui/ui_api.h"
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
@ -808,6 +812,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
if (!deploy()) {
measured_z = run_z_probe(sanity_check) + offset.z;
TERN_(HAS_PTC, ptc.apply_compensation(measured_z));
TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy));
}
if (!isnan(measured_z)) {
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;

View File

@ -64,7 +64,7 @@
#if HAS_LEVELING
#include "../feature/bedlevel/bedlevel.h"
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
#include "../feature/bedlevel/abl/x_twist.h"
#include "../feature/x_twist.h"
#endif
#endif
@ -269,13 +269,17 @@ typedef struct SettingsDataStruct {
xy_pos_t bilinear_grid_spacing, bilinear_start; // G29 L F
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
bed_mesh_t z_values; // G29
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
XATC xatc; // TBD
#endif
#else
float z_values[3][3];
#endif
//
// X_AXIS_TWIST_COMPENSATION
//
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
XATC xatc; // TBD
#endif
//
// AUTO_BED_LEVELING_UBL
//
@ -298,7 +302,7 @@ typedef struct SettingsDataStruct {
int16_t z_offsets_bed[COUNT(ptc.z_offsets_bed)]; // M871 B I V
#endif
#if ENABLED(PTC_HOTEND)
int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V
int16_t z_offsets_hotend[COUNT(ptc.z_offsets_hotend)]; // M871 E I V
#endif
#endif
@ -873,9 +877,6 @@ void MarlinSettings::postprocess() {
sizeof(z_values) == (GRID_MAX_POINTS) * sizeof(z_values[0][0]),
"Bilinear Z array is the wrong size."
);
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
static_assert(COUNT(xatc.z_offset) == XATC_MAX_POINTS, "XATC Z-offset mesh is the wrong size.");
#endif
#else
const xy_pos_t bilinear_start{0}, bilinear_grid_spacing{0};
#endif
@ -889,15 +890,20 @@ void MarlinSettings::postprocess() {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
EEPROM_WRITE(z_values); // 9-256 floats
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
EEPROM_WRITE(xatc);
#endif
#else
dummyf = 0;
for (uint16_t q = grid_max_x * grid_max_y; q--;) EEPROM_WRITE(dummyf);
#endif
}
//
// X Axis Twist Compensation
//
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
_FIELD_TEST(xatc);
EEPROM_WRITE(xatc);
#endif
//
// Unified Bed Leveling
//
@ -1785,9 +1791,6 @@ void MarlinSettings::postprocess() {
EEPROM_READ(bilinear_grid_spacing); // 2 ints
EEPROM_READ(bilinear_start); // 2 ints
EEPROM_READ(z_values); // 9 to 256 floats
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
EEPROM_READ(xatc);
#endif
}
else // EEPROM data is stale
#endif // AUTO_BED_LEVELING_BILINEAR
@ -1800,6 +1803,13 @@ void MarlinSettings::postprocess() {
}
}
//
// X Axis Twist Compensation
//
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
EEPROM_READ(xatc);
#endif
//
// Unified Bed Leveling active state
//
@ -2849,6 +2859,14 @@ void MarlinSettings::reset() {
TERN_(ENABLE_LEVELING_FADE_HEIGHT, new_z_fade_height = (DEFAULT_LEVELING_FADE_HEIGHT));
TERN_(HAS_LEVELING, reset_bed_level());
//
// X Axis Twist Compensation
//
TERN_(X_AXIS_TWIST_COMPENSATION, xatc.reset());
//
// Nozzle-to-probe Offset
//
#if HAS_BED_PROBE
constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
static_assert(COUNT(dpo) == LINEAR_AXES, "NOZZLE_TO_PROBE_OFFSET must contain offsets for each linear axis X, Y, Z....");
@ -3313,14 +3331,14 @@ void MarlinSettings::reset() {
}
}
// TODO: Create G-code for settings
//#if ENABLED(X_AXIS_TWIST_COMPENSATION)
// CONFIG_ECHO_START();
// xatc.print_points();
//#endif
#endif
// TODO: Create G-code for settings
//#if ENABLED(X_AXIS_TWIST_COMPENSATION)
// CONFIG_ECHO_START();
// xatc.print_points();
//#endif
#endif // HAS_LEVELING
//