Skip to content

Commit

Permalink
Merge pull request #4330 from thinkyhead/rc_debug_g28_more
Browse files Browse the repository at this point in the history
Debugging of MBL in G28
  • Loading branch information
thinkyhead authored Jul 17, 2016
2 parents f8973a7 + 8f24e0a commit c3cc242
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2908,13 +2908,19 @@ inline void gcode_G28() {
#if ENABLED(MESH_BED_LEVELING)
float pre_home_z = MESH_HOME_SEARCH_Z;
if (mbl.active()) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("MBL was active");
#endif
// Save known Z position if already homed
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
pre_home_z = current_position[Z_AXIS];
pre_home_z += mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS));
}
mbl.set_active(false);
current_position[Z_AXIS] = pre_home_z;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Set Z to pre_home_z", current_position);
#endif
}
#endif

Expand Down Expand Up @@ -3140,7 +3146,13 @@ inline void gcode_G28() {
// Enable mesh leveling again
#if ENABLED(MESH_BED_LEVELING)
if (mbl.has_mesh()) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("MBL has mesh");
#endif
if (home_all_axis || (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && homeZ)) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("MBL Z homing");
#endif
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
#if Z_HOME_DIR > 0
+ Z_MAX_POS
Expand All @@ -3154,13 +3166,19 @@ inline void gcode_G28() {
feedrate = homing_feedrate[Z_AXIS];
line_to_destination();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Rest Origin", current_position);
#endif
#else
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z -
mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS))
#if Z_HOME_DIR > 0
+ Z_MAX_POS
#endif
;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL adjusted MESH_HOME_SEARCH_Z", current_position);
#endif
#endif
}
else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) {
Expand All @@ -3169,6 +3187,9 @@ inline void gcode_G28() {
mbl.set_active(true);
current_position[Z_AXIS] = pre_home_z -
mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS));
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Home X or Y", current_position);
#endif
}
}
#endif
Expand Down

0 comments on commit c3cc242

Please sign in to comment.