mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-01-18 23:49:49 +00:00
🚸 Refinements for UBL G29 J (tilt mesh) (#25486)
This commit is contained in:
parent
ae4fa0ab68
commit
89e8257008
5 changed files with 47 additions and 16 deletions
|
@ -2054,6 +2054,9 @@
|
|||
|
||||
//#define UBL_HILBERT_CURVE // Use Hilbert distribution for less travel when probing multiple points
|
||||
|
||||
//#define UBL_TILT_ON_MESH_POINTS // Use nearest mesh points with G29 J for better Z reference
|
||||
//#define UBL_TILT_ON_MESH_POINTS_3POINT // Use nearest mesh points with G29 J0 (3-point)
|
||||
|
||||
#define UBL_MESH_EDIT_MOVES_Z // Sophisticated users prefer no movement of nozzle
|
||||
#define UBL_SAVE_ACTIVE_ON_M500 // Save the currently active mesh in the current slot on M500
|
||||
|
||||
|
|
|
@ -1489,6 +1489,14 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
xy_float_t points[3];
|
||||
probe.get_three_points(points);
|
||||
|
||||
#if ENABLED(UBL_TILT_ON_MESH_POINTS_3POINT)
|
||||
mesh_index_pair cpos[3];
|
||||
LOOP_L_N(ix, 3) { // Convert points to coordinates of mesh points
|
||||
cpos[ix] = find_closest_mesh_point_of_type(REAL, points[ix], true);
|
||||
points[ix] = cpos[ix].meshpos();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(VALIDATE_MESH_TILT)
|
||||
float gotz[3]; // Used for algorithm validation below
|
||||
#endif
|
||||
|
@ -1500,7 +1508,7 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
measured_z = probe.probe_at_point(points[i], i < 2 ? PROBE_PT_RAISE : PROBE_PT_LAST_STOW, param.V_verbosity);
|
||||
if ((abort_flag = isnan(measured_z))) break;
|
||||
|
||||
measured_z -= get_z_correction(points[i]);
|
||||
measured_z -= TERN(UBL_TILT_ON_MESH_POINTS_3POINT, z_values[cpos[i].pos.x][cpos[i].pos.y], get_z_correction(points[i]));
|
||||
TERN_(VALIDATE_MESH_TILT, gotz[i] = measured_z);
|
||||
|
||||
if (param.V_verbosity > 3) { serial_spaces(16); SERIAL_ECHOLNPGM("Corrected_Z=", measured_z); }
|
||||
|
@ -1518,16 +1526,14 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
}
|
||||
else { // !do_3_pt_leveling
|
||||
|
||||
#ifdef G29J_MESH_TILT_MARGIN
|
||||
const float x_min = _MAX(probe.min_x() + (G29J_MESH_TILT_MARGIN), X_MIN_POS),
|
||||
x_max = _MIN(probe.max_x() - (G29J_MESH_TILT_MARGIN), X_MAX_POS),
|
||||
y_min = _MAX(probe.min_y() + (G29J_MESH_TILT_MARGIN), Y_MIN_POS),
|
||||
y_max = _MIN(probe.max_y() - (G29J_MESH_TILT_MARGIN), Y_MAX_POS);
|
||||
#else
|
||||
const float x_min = probe.min_x(), x_max = probe.max_x(),
|
||||
y_min = probe.min_y(), y_max = probe.max_y();
|
||||
#ifndef G29J_MESH_TILT_MARGIN
|
||||
#define G29J_MESH_TILT_MARGIN 0
|
||||
#endif
|
||||
const float dx = (x_max - x_min) / (param.J_grid_size - 1),
|
||||
const float x_min = _MAX((X_MIN_POS) + (G29J_MESH_TILT_MARGIN), MESH_MIN_X, probe.min_x()),
|
||||
x_max = _MIN((X_MAX_POS) - (G29J_MESH_TILT_MARGIN), MESH_MAX_X, probe.max_x()),
|
||||
y_min = _MAX((Y_MIN_POS) + (G29J_MESH_TILT_MARGIN), MESH_MIN_Y, probe.min_y()),
|
||||
y_max = _MIN((Y_MAX_POS) - (G29J_MESH_TILT_MARGIN), MESH_MAX_Y, probe.max_y()),
|
||||
dx = (x_max - x_min) / (param.J_grid_size - 1),
|
||||
dy = (y_max - y_min) / (param.J_grid_size - 1);
|
||||
|
||||
bool zig_zag = false;
|
||||
|
@ -1541,6 +1547,17 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
LOOP_L_N(iy, param.J_grid_size) {
|
||||
rpos.y = y_min + dy * (zig_zag ? param.J_grid_size - 1 - iy : iy);
|
||||
|
||||
#if ENABLED(UBL_TILT_ON_MESH_POINTS)
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
xy_pos_t oldRpos;
|
||||
if (DEBUGGING(LEVELING)) oldRpos = rpos;
|
||||
#endif
|
||||
mesh_index_pair cpos;
|
||||
rpos -= probe.offset;
|
||||
cpos = find_closest_mesh_point_of_type(REAL, rpos, true);
|
||||
rpos = cpos.meshpos();
|
||||
#endif
|
||||
|
||||
SERIAL_ECHOLNPGM("Tilting mesh point ", point_num, "/", total_points, "\n");
|
||||
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points));
|
||||
|
||||
|
@ -1548,11 +1565,17 @@ void unified_bed_leveling::smart_fill_mesh() {
|
|||
|
||||
if ((abort_flag = isnan(measured_z))) break;
|
||||
|
||||
const float zcorr = get_z_correction(rpos);
|
||||
const float zcorr = TERN(UBL_TILT_ON_MESH_POINTS, z_values[cpos.pos.x][cpos.pos.y], get_z_correction(rpos));
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) {
|
||||
const xy_pos_t lpos = rpos.asLogical();
|
||||
#if ENABLED(UBL_TILT_ON_MESH_POINTS)
|
||||
const xy_pos_t oldLpos = oldRpos.asLogical();
|
||||
DEBUG_ECHOPGM("Calculated point: ("); DEBUG_ECHO_F(oldRpos.x, 7); DEBUG_CHAR(','); DEBUG_ECHO_F(oldRpos.y, 7);
|
||||
DEBUG_ECHOPAIR_F(") logical: (", oldLpos.x, 7); DEBUG_CHAR(','); DEBUG_ECHO_F(oldLpos.y, 7);
|
||||
DEBUG_ECHOPGM(")\nSelected mesh point: ");
|
||||
#endif
|
||||
DEBUG_CHAR('('); DEBUG_ECHO_F(rpos.x, 7); DEBUG_CHAR(','); DEBUG_ECHO_F(rpos.y, 7);
|
||||
DEBUG_ECHOPAIR_F(") logical: (", lpos.x, 7); DEBUG_CHAR(','); DEBUG_ECHO_F(lpos.y, 7);
|
||||
DEBUG_ECHOPAIR_F(") measured: ", measured_z, 7);
|
||||
|
|
|
@ -3156,14 +3156,14 @@
|
|||
// Probing points may be verified at compile time within the radius
|
||||
// using static_assert(HYPOT2(X2-X1,Y2-Y1)<=sq(PRINTABLE_RADIUS),"bad probe point!")
|
||||
// so that may be added to SanityCheck.h in the future.
|
||||
#define _MESH_MIN_X (X_MIN_BED + MESH_INSET)
|
||||
#define _MESH_MIN_Y (Y_MIN_BED + MESH_INSET)
|
||||
#define _MESH_MIN_X (X_MIN_BED + (MESH_INSET))
|
||||
#define _MESH_MIN_Y (Y_MIN_BED + (MESH_INSET))
|
||||
#define _MESH_MAX_X (X_MAX_BED - (MESH_INSET))
|
||||
#define _MESH_MAX_Y (Y_MAX_BED - (MESH_INSET))
|
||||
#else
|
||||
// Boundaries for Cartesian probing based on set limits
|
||||
#define _MESH_MIN_X (_MAX(X_MIN_BED + MESH_INSET, X_MIN_POS)) // UBL is careful not to probe off the bed. It does not
|
||||
#define _MESH_MIN_Y (_MAX(Y_MIN_BED + MESH_INSET, Y_MIN_POS)) // need NOZZLE_TO_PROBE_OFFSET in the mesh dimensions
|
||||
#define _MESH_MIN_X (_MAX(X_MIN_BED + (MESH_INSET), X_MIN_POS)) // UBL is careful not to probe off the bed. It doesn't
|
||||
#define _MESH_MIN_Y (_MAX(Y_MIN_BED + (MESH_INSET), Y_MIN_POS)) // need NOZZLE_TO_PROBE_OFFSET in the mesh dimensions.
|
||||
#define _MESH_MAX_X (_MIN(X_MAX_BED - (MESH_INSET), X_MAX_POS))
|
||||
#define _MESH_MAX_Y (_MIN(Y_MAX_BED - (MESH_INSET), Y_MAX_POS))
|
||||
#endif
|
||||
|
|
|
@ -307,6 +307,10 @@ public:
|
|||
points[0] = xy_float_t({ (X_CENTER) + probe_radius() * COS0, (Y_CENTER) + probe_radius() * SIN0 });
|
||||
points[1] = xy_float_t({ (X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120 });
|
||||
points[2] = xy_float_t({ (X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240 });
|
||||
#elif ENABLED(AUTO_BED_LEVELING_UBL)
|
||||
points[0] = xy_float_t({ _MAX(MESH_MIN_X, min_x()), _MAX(MESH_MIN_Y, min_y()) });
|
||||
points[1] = xy_float_t({ _MIN(MESH_MAX_X, max_x()), _MAX(MESH_MIN_Y, min_y()) });
|
||||
points[2] = xy_float_t({ (_MAX(MESH_MIN_X, min_x()) + _MIN(MESH_MAX_X, max_x())) / 2, _MIN(MESH_MAX_Y, max_y()) });
|
||||
#else
|
||||
points[0] = xy_float_t({ min_x(), min_y() });
|
||||
points[1] = xy_float_t({ max_x(), min_y() });
|
||||
|
|
|
@ -44,7 +44,8 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \
|
|||
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
|
||||
SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \
|
||||
SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \
|
||||
Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \
|
||||
Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE UBL_TILT_ON_MESH_POINTS UBL_TILT_ON_MESH_POINTS_3POINT \
|
||||
RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \
|
||||
EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \
|
||||
MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \
|
||||
NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL \
|
||||
|
|
Loading…
Reference in a new issue