Merge pull request #4330 from thinkyhead/rc_debug_g28_more

Debugging of MBL in G28
This commit is contained in:
Scott Lahteine 2016-07-17 11:36:19 -07:00 committed by GitHub
commit c3cc24242c

View File

@ -2908,6 +2908,9 @@ inline void gcode_G28() {
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
float pre_home_z = MESH_HOME_SEARCH_Z; float pre_home_z = MESH_HOME_SEARCH_Z;
if (mbl.active()) { if (mbl.active()) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("MBL was active");
#endif
// Save known Z position if already homed // Save known Z position if already homed
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) { if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
pre_home_z = current_position[Z_AXIS]; pre_home_z = current_position[Z_AXIS];
@ -2915,6 +2918,9 @@ inline void gcode_G28() {
} }
mbl.set_active(false); mbl.set_active(false);
current_position[Z_AXIS] = pre_home_z; 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 #endif
@ -3140,7 +3146,13 @@ inline void gcode_G28() {
// Enable mesh leveling again // Enable mesh leveling again
#if ENABLED(MESH_BED_LEVELING) #if ENABLED(MESH_BED_LEVELING)
if (mbl.has_mesh()) { 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 (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 current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
#if Z_HOME_DIR > 0 #if Z_HOME_DIR > 0
+ Z_MAX_POS + Z_MAX_POS
@ -3154,6 +3166,9 @@ inline void gcode_G28() {
feedrate = homing_feedrate[Z_AXIS]; feedrate = homing_feedrate[Z_AXIS];
line_to_destination(); line_to_destination();
stepper.synchronize(); stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Rest Origin", current_position);
#endif
#else #else
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z - current_position[Z_AXIS] = MESH_HOME_SEARCH_Z -
mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS)) mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS))
@ -3161,6 +3176,9 @@ inline void gcode_G28() {
+ Z_MAX_POS + Z_MAX_POS
#endif #endif
; ;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL adjusted MESH_HOME_SEARCH_Z", current_position);
#endif
#endif #endif
} }
else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) { else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) {
@ -3169,6 +3187,9 @@ inline void gcode_G28() {
mbl.set_active(true); mbl.set_active(true);
current_position[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.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 #endif