🚸 Universal X_AXIS_TWIST_COMPENSATION (#23828)

This commit is contained in:
tombrazier
2022-03-02 22:13:46 +00:00
committed by GitHub
parent b07a34eb6b
commit 2e39bc30fd
10 changed files with 67 additions and 31 deletions

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
//