Fixes for G29 / 3POINT

master
Scott Lahteine 6 years ago
parent e31923be8d
commit 4f943a73bc

@ -4490,7 +4490,7 @@ void home_all_axes() { gcode_G28(true); }
const uint8_t old_debug_flags = marlin_debug_flags; const uint8_t old_debug_flags = marlin_debug_flags;
if (query) marlin_debug_flags |= DEBUG_LEVELING; if (query) marlin_debug_flags |= DEBUG_LEVELING;
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
DEBUG_POS(">>> gcode_G29", current_position); DEBUG_POS(">>> G29", current_position);
log_machine_info(); log_machine_info();
} }
marlin_debug_flags = old_debug_flags; marlin_debug_flags = old_debug_flags;
@ -4552,12 +4552,10 @@ void home_all_axes() { gcode_G28(true); }
abl_grid_points_y = GRID_MAX_POINTS_Y; abl_grid_points_y = GRID_MAX_POINTS_Y;
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(PROBE_MANUALLY) #if ENABLED(AUTO_BED_LEVELING_LINEAR)
#if ENABLED(AUTO_BED_LEVELING_LINEAR) ABL_VAR int abl2;
ABL_VAR int abl2; #elif ENABLED(PROBE_MANUALLY) // Bilinear
#else // Bilinear int constexpr abl2 = GRID_MAX_POINTS;
int constexpr abl2 = GRID_MAX_POINTS;
#endif
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
@ -4575,7 +4573,9 @@ void home_all_axes() { gcode_G28(true); }
#elif ENABLED(AUTO_BED_LEVELING_3POINT) #elif ENABLED(AUTO_BED_LEVELING_3POINT)
int constexpr abl2 = 3; #if ENABLED(PROBE_MANUALLY)
int constexpr abl2 = 3; // used to show total points
#endif
// Probe at 3 arbitrary points // Probe at 3 arbitrary points
ABL_VAR vector_3 points[3] = { ABL_VAR vector_3 points[3] = {
@ -4624,7 +4624,7 @@ void home_all_axes() { gcode_G28(true); }
j = parser.byteval('J', -1); j = parser.byteval('J', -1);
if (!isnan(rx) && !isnan(ry)) { if (!isnan(rx) && !isnan(ry)) {
// Get nearest i / j from x / y // Get nearest i / j from rx / ry
i = (rx - bilinear_start[X_AXIS] + 0.5 * xGridSpacing) / xGridSpacing; i = (rx - bilinear_start[X_AXIS] + 0.5 * xGridSpacing) / xGridSpacing;
j = (ry - bilinear_start[Y_AXIS] + 0.5 * yGridSpacing) / yGridSpacing; j = (ry - bilinear_start[Y_AXIS] + 0.5 * yGridSpacing) / yGridSpacing;
i = constrain(i, 0, GRID_MAX_POINTS_X - 1); i = constrain(i, 0, GRID_MAX_POINTS_X - 1);
@ -4637,22 +4637,18 @@ void home_all_axes() { gcode_G28(true); }
bed_level_virt_interpolate(); bed_level_virt_interpolate();
#endif #endif
set_bed_leveling_enabled(abl_should_enable); set_bed_leveling_enabled(abl_should_enable);
report_current_position(); if (abl_should_enable) report_current_position();
} }
return; return;
} // parser.seen('W') } // parser.seen('W')
#endif #endif
#if HAS_LEVELING // Jettison bed leveling data
if (parser.seen('J')) {
// Jettison bed leveling data reset_bed_level();
if (parser.seen('J')) { return;
reset_bed_level(); }
return;
}
#endif
verbose_level = parser.intval('V'); verbose_level = parser.intval('V');
if (!WITHIN(verbose_level, 0, 4)) { if (!WITHIN(verbose_level, 0, 4)) {
@ -4682,6 +4678,7 @@ void home_all_axes() { gcode_G28(true); }
} }
abl2 = abl_grid_points_x * abl_grid_points_y; abl2 = abl_grid_points_x * abl_grid_points_y;
mean = 0;
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR) #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
@ -4734,8 +4731,9 @@ void home_all_axes() { gcode_G28(true); }
#endif // ABL_GRID #endif // ABL_GRID
if (verbose_level > 0) { if (verbose_level > 0) {
SERIAL_PROTOCOLLNPGM("G29 Auto Bed Leveling"); SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling");
if (dryrun) SERIAL_PROTOCOLLNPGM("Running in DRY-RUN mode"); if (dryrun) SERIAL_PROTOCOLPGM(" (DRYRUN)");
SERIAL_EOL();
} }
stepper.synchronize(); stepper.synchronize();
@ -4744,15 +4742,6 @@ void home_all_axes() { gcode_G28(true); }
// Be formal so G29 can be done successively without G28. // Be formal so G29 can be done successively without G28.
set_bed_leveling_enabled(false); set_bed_leveling_enabled(false);
if (!dryrun) {
// Re-orient the current position without leveling
// based on where the steppers are positioned.
set_current_from_steppers_for_axis(ALL_AXES);
// Sync the planner to where the steppers stopped
SYNC_PLAN_POSITION_KINEMATIC();
}
#if HAS_BED_PROBE #if HAS_BED_PROBE
// Deploy the probe. Probe will raise if needed. // Deploy the probe. Probe will raise if needed.
if (DEPLOY_PROBE()) { if (DEPLOY_PROBE()) {
@ -4934,9 +4923,10 @@ void home_all_axes() { gcode_G28(true); }
#elif ENABLED(AUTO_BED_LEVELING_3POINT) #elif ENABLED(AUTO_BED_LEVELING_3POINT)
// Probe at 3 arbitrary points // Probe at 3 arbitrary points
if (abl_probe_index < 3) { if (abl_probe_index < abl2) {
xProbe = points[abl_probe_index].x; xProbe = points[abl_probe_index].x;
yProbe = points[abl_probe_index].y; yProbe = points[abl_probe_index].y;
_manual_goto_xy(xProbe, yProbe);
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
// Disable software endstops to allow manual adjustment // Disable software endstops to allow manual adjustment
// If G29 is not completed, they will not be re-enabled // If G29 is not completed, they will not be re-enabled
@ -4974,6 +4964,8 @@ void home_all_axes() { gcode_G28(true); }
{ {
const bool stow_probe_after_each = parser.boolval('E'); const bool stow_probe_after_each = parser.boolval('E');
measured_z = 0;
#if ABL_GRID #if ABL_GRID
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
@ -5307,7 +5299,7 @@ void home_all_axes() { gcode_G28(true); }
if (!faux) clean_up_after_endstop_or_probe_move(); if (!faux) clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29");
#endif #endif
report_current_position(); report_current_position();

Loading…
Cancel
Save