committed by
Scott Lahteine
parent
4ec9af42b8
commit
74565890f3
@ -67,14 +67,17 @@ void GcodeSuite::M420() {
|
||||
const float x_min = probe.min_x(), x_max = probe.max_x(),
|
||||
y_min = probe.min_y(), y_max = probe.max_y();
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
bilinear_start.set(x_min, y_min);
|
||||
bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X),
|
||||
(y_max - y_min) / (GRID_MAX_CELLS_Y));
|
||||
xy_pos_t start, spacing;
|
||||
start.set(x_min, y_min);
|
||||
spacing.set((x_max - x_min) / (GRID_MAX_CELLS_X),
|
||||
(y_max - y_min) / (GRID_MAX_CELLS_Y));
|
||||
bbl.set_grid(spacing, start);
|
||||
#endif
|
||||
GRID_LOOP(x, y) {
|
||||
Z_VALUES(x, y) = 0.001 * random(-200, 200);
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
|
||||
}
|
||||
TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level());
|
||||
SERIAL_ECHOPGM("Simulated " STRINGIFY(GRID_MAX_POINTS_X) "x" STRINGIFY(GRID_MAX_POINTS_Y) " mesh ");
|
||||
SERIAL_ECHOPGM(" (", x_min);
|
||||
SERIAL_CHAR(','); SERIAL_ECHO(y_min);
|
||||
@ -178,7 +181,7 @@ void GcodeSuite::M420() {
|
||||
Z_VALUES(x, y) -= zmean;
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES(x, y)));
|
||||
}
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
||||
TERN_(AUTO_BED_LEVELING_BILINEAR, bbl.refresh_bed_level());
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -199,8 +202,7 @@ void GcodeSuite::M420() {
|
||||
#else
|
||||
if (leveling_is_valid()) {
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
print_bilinear_leveling_grid();
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
|
||||
bbl.print_leveling_grid();
|
||||
#elif ENABLED(MESH_BED_LEVELING)
|
||||
SERIAL_ECHOLNPGM("Mesh Bed Level data:");
|
||||
mbl.report_mesh();
|
||||
|
@ -124,6 +124,7 @@ public:
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
float Z_offset;
|
||||
bed_mesh_t z_values;
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
@ -308,8 +309,8 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
if (!isnan(rx) && !isnan(ry)) {
|
||||
// Get nearest i / j from rx / ry
|
||||
i = (rx - bilinear_start.x + 0.5 * abl.gridSpacing.x) / abl.gridSpacing.x;
|
||||
j = (ry - bilinear_start.y + 0.5 * abl.gridSpacing.y) / abl.gridSpacing.y;
|
||||
i = (rx - bbl.get_grid_start().x) / bbl.get_grid_spacing().x + 0.5f;
|
||||
j = (ry - bbl.get_grid_start().y) / bbl.get_grid_spacing().y + 0.5f;
|
||||
LIMIT(i, 0, (GRID_MAX_POINTS_X) - 1);
|
||||
LIMIT(j, 0, (GRID_MAX_POINTS_Y) - 1);
|
||||
}
|
||||
@ -318,8 +319,8 @@ G29_TYPE GcodeSuite::G29() {
|
||||
|
||||
if (WITHIN(i, 0, (GRID_MAX_POINTS_X) - 1) && WITHIN(j, 0, (GRID_MAX_POINTS_Y) - 1)) {
|
||||
set_bed_leveling_enabled(false);
|
||||
z_values[i][j] = rz;
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
||||
Z_VALUES_ARR[i][j] = rz;
|
||||
bbl.refresh_bed_level();
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(i, j, rz));
|
||||
set_bed_leveling_enabled(abl.reenable);
|
||||
if (abl.reenable) report_current_position();
|
||||
@ -451,19 +452,19 @@ G29_TYPE GcodeSuite::G29() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
if (TERN1(PROBE_MANUALLY, !no_action)
|
||||
&& (abl.gridSpacing != bilinear_grid_spacing || abl.probe_position_lf != bilinear_start)
|
||||
if (!abl.dryrun
|
||||
&& (abl.gridSpacing != bbl.get_grid_spacing() || abl.probe_position_lf != bbl.get_grid_start())
|
||||
) {
|
||||
// Reset grid to 0.0 or "not probed". (Also disables ABL)
|
||||
reset_bed_level();
|
||||
|
||||
// Initialize a grid with the given dimensions
|
||||
bilinear_grid_spacing = abl.gridSpacing;
|
||||
bilinear_start = abl.probe_position_lf;
|
||||
|
||||
// Can't re-enable (on error) until the new grid is written
|
||||
abl.reenable = false;
|
||||
}
|
||||
|
||||
// Pre-populate local Z values from the stored mesh
|
||||
TERN_(IS_KINEMATIC, COPY(abl.z_values, Z_VALUES_ARR));
|
||||
|
||||
#endif // AUTO_BED_LEVELING_BILINEAR
|
||||
|
||||
} // !g29_in_progress
|
||||
@ -531,7 +532,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
const float newz = abl.measured_z + abl.Z_offset;
|
||||
z_values[abl.meshCount.x][abl.meshCount.y] = newz;
|
||||
abl.z_values[abl.meshCount.x][abl.meshCount.y] = newz;
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, newz));
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM_P(PSTR("Save X"), abl.meshCount.x, SP_Y_STR, abl.meshCount.y, SP_Z_STR, abl.measured_z + abl.Z_offset);
|
||||
@ -680,7 +681,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
const float z = abl.measured_z + abl.Z_offset;
|
||||
z_values[abl.meshCount.x][abl.meshCount.y] = z;
|
||||
abl.z_values[abl.meshCount.x][abl.meshCount.y] = z;
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(abl.meshCount, z));
|
||||
|
||||
#endif
|
||||
@ -751,12 +752,16 @@ G29_TYPE GcodeSuite::G29() {
|
||||
if (!isnan(abl.measured_z)) {
|
||||
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
|
||||
|
||||
if (!abl.dryrun) extrapolate_unprobed_bed_level();
|
||||
print_bilinear_leveling_grid();
|
||||
if (abl.dryrun)
|
||||
bbl.print_leveling_grid(&abl.z_values);
|
||||
else {
|
||||
bbl.set_grid(abl.gridSpacing, abl.probe_position_lf);
|
||||
COPY(Z_VALUES_ARR, abl.z_values);
|
||||
TERN_(IS_KINEMATIC, bbl.extrapolate_unprobed_bed_level());
|
||||
bbl.refresh_bed_level();
|
||||
|
||||
refresh_bed_level();
|
||||
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, print_bilinear_leveling_grid_virt());
|
||||
bbl.print_leveling_grid();
|
||||
}
|
||||
|
||||
#elif ENABLED(AUTO_BED_LEVELING_LINEAR)
|
||||
|
||||
@ -876,7 +881,7 @@ G29_TYPE GcodeSuite::G29() {
|
||||
// Unapply the offset because it is going to be immediately applied
|
||||
// and cause compensation movement in Z
|
||||
const float fade_scaling_factor = TERN(ENABLE_LEVELING_FADE_HEIGHT, planner.fade_scaling_factor_for_z(current_position.z), 1);
|
||||
current_position.z -= fade_scaling_factor * bilinear_z_offset(current_position);
|
||||
current_position.z -= fade_scaling_factor * bbl.get_z_correction(current_position);
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" corrected Z:", current_position.z);
|
||||
}
|
||||
|
@ -58,11 +58,11 @@ void GcodeSuite::M421() {
|
||||
sy = iy >= 0 ? iy : 0, ey = iy >= 0 ? iy : GRID_MAX_POINTS_Y - 1;
|
||||
LOOP_S_LE_N(x, sx, ex) {
|
||||
LOOP_S_LE_N(y, sy, ey) {
|
||||
z_values[x][y] = zval + (hasQ ? z_values[x][y] : 0);
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, z_values[x][y]));
|
||||
Z_VALUES_ARR[x][y] = zval + (hasQ ? Z_VALUES_ARR[x][y] : 0);
|
||||
TERN_(EXTENSIBLE_UI, ExtUI::onMeshUpdate(x, y, Z_VALUES_ARR[x][y]));
|
||||
}
|
||||
}
|
||||
TERN_(ABL_BILINEAR_SUBDIVISION, bed_level_virt_interpolate());
|
||||
bbl.refresh_bed_level();
|
||||
}
|
||||
else
|
||||
SERIAL_ERROR_MSG(STR_ERR_MESH_XY);
|
||||
|
Reference in New Issue
Block a user