Simpler cleanup in G28 / G29

This commit is contained in:
Scott Lahteine 2016-06-22 14:20:34 -07:00
parent 15229d988b
commit 7da3080761

View File

@ -1607,16 +1607,17 @@ static void setup_for_endstop_move() {
endstops.enable(); endstops.enable();
} }
static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("clean_up_after_endstop_or_probe_move", current_position);
#endif
feedrate = saved_feedrate;
feedrate_multiplier = saved_feedrate_multiplier;
refresh_cmd_timeout();
}
#if HAS_BED_PROBE #if HAS_BED_PROBE
static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("clean_up_after_endstop_or_probe_move", current_position);
#endif
feedrate = saved_feedrate;
feedrate_multiplier = saved_feedrate_multiplier;
refresh_cmd_timeout();
}
static void clean_up_after_endstop_move() { static void clean_up_after_endstop_move() {
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();
endstops.not_homing(); endstops.not_homing();
@ -3058,14 +3059,7 @@ inline void gcode_G28() {
#endif // !DELTA (gcode_G28) #endif // !DELTA (gcode_G28)
#if ENABLED(ENDSTOPS_ONLY_FOR_HOMING) endstops.not_homing();
endstops.enable(false);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("ENDSTOPS_ONLY_FOR_HOMING endstops.enable(false)");
}
#endif
#endif
// Enable mesh leveling again // Enable mesh leveling again
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
@ -3097,9 +3091,8 @@ inline void gcode_G28() {
} }
#endif #endif
feedrate = saved_feedrate; clean_up_after_endstop_or_probe_move();
feedrate_multiplier = saved_feedrate_multiplier;
refresh_cmd_timeout();
endstops.hit_on_purpose(); // clear endstop hit flags endstops.hit_on_purpose(); // clear endstop hit flags
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
@ -3597,8 +3590,6 @@ inline void gcode_G28() {
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif #endif
clean_up_after_endstop_or_probe_move();
#if ENABLED(DELTA) #if ENABLED(DELTA)
if (!dryrun) extrapolate_unprobed_bed_level(); if (!dryrun) extrapolate_unprobed_bed_level();
@ -3725,7 +3716,7 @@ inline void gcode_G28() {
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS], ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,
p3, verbose_level); p3, verbose_level);
clean_up_after_endstop_or_probe_move();
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3); if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
#endif // !AUTO_BED_LEVELING_GRID #endif // !AUTO_BED_LEVELING_GRID
@ -3807,6 +3798,9 @@ inline void gcode_G28() {
// Stow the probe. Servo will raise if needed. // Stow the probe. Servo will raise if needed.
stow_z_probe(); stow_z_probe();
// Restore state after probing
clean_up_after_endstop_or_probe_move();
#ifdef Z_PROBE_END_SCRIPT #ifdef Z_PROBE_END_SCRIPT
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {