|
|
@ -2644,8 +2644,16 @@ inline void gcode_G28() {
|
|
|
|
* on again when homing all axis
|
|
|
|
* on again when homing all axis
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
uint8_t mbl_was_active = mbl.active;
|
|
|
|
float pre_home_z = MESH_HOME_SEARCH_Z;
|
|
|
|
mbl.active = false;
|
|
|
|
if (mbl.active()) {
|
|
|
|
|
|
|
|
// 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(current_position[X_AXIS] - home_offset[X_AXIS],
|
|
|
|
|
|
|
|
current_position[Y_AXIS] - home_offset[Y_AXIS]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mbl.set_active(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
setup_for_endstop_move();
|
|
|
|
setup_for_endstop_move();
|
|
|
@ -2945,20 +2953,31 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
|
|
// Enable mesh leveling again
|
|
|
|
// Enable mesh leveling again
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
if (mbl_was_active && home_all_axis) {
|
|
|
|
if (mbl.has_mesh()) {
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
|
|
|
if (home_all_axis || (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && homeZ)) {
|
|
|
|
sync_plan_position();
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
|
|
|
|
mbl.active = 1;
|
|
|
|
sync_plan_position();
|
|
|
|
#if ENABLED(MESH_G28_REST_ORIGIN)
|
|
|
|
mbl.set_active(true);
|
|
|
|
current_position[Z_AXIS] = 0.0;
|
|
|
|
#if ENABLED(MESH_G28_REST_ORIGIN)
|
|
|
|
set_destination_to_current();
|
|
|
|
current_position[Z_AXIS] = 0.0;
|
|
|
|
feedrate = homing_feedrate[Z_AXIS];
|
|
|
|
set_destination_to_current();
|
|
|
|
line_to_destination();
|
|
|
|
feedrate = homing_feedrate[Z_AXIS];
|
|
|
|
stepper.synchronize();
|
|
|
|
line_to_destination();
|
|
|
|
#endif
|
|
|
|
stepper.synchronize();
|
|
|
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
|
|
#else
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_POS("mbl_was_active", current_position);
|
|
|
|
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z -
|
|
|
|
#endif
|
|
|
|
mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS],
|
|
|
|
|
|
|
|
current_position[Y_AXIS] - home_offset[Y_AXIS]);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if ((axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) && (homeX || homeY)) {
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = pre_home_z;
|
|
|
|
|
|
|
|
sync_plan_position();
|
|
|
|
|
|
|
|
mbl.set_active(true);
|
|
|
|
|
|
|
|
current_position[Z_AXIS] = pre_home_z -
|
|
|
|
|
|
|
|
mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS],
|
|
|
|
|
|
|
|
current_position[Y_AXIS] - home_offset[Y_AXIS]);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
@ -2978,7 +2997,7 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
|
|
|
|
|
|
|
|
|
|
|
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset };
|
|
|
|
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet, MeshSetZOffset, MeshReset };
|
|
|
|
|
|
|
|
|
|
|
|
inline void _mbl_goto_xy(float x, float y) {
|
|
|
|
inline void _mbl_goto_xy(float x, float y) {
|
|
|
|
saved_feedrate = feedrate;
|
|
|
|
saved_feedrate = feedrate;
|
|
|
@ -3015,6 +3034,7 @@ inline void gcode_G28() {
|
|
|
|
* S2 Probe the next mesh point
|
|
|
|
* S2 Probe the next mesh point
|
|
|
|
* S3 Xn Yn Zn.nn Manually modify a single point
|
|
|
|
* S3 Xn Yn Zn.nn Manually modify a single point
|
|
|
|
* S4 Zn.nn Set z offset. Positive away from bed, negative closer to bed.
|
|
|
|
* S4 Zn.nn Set z offset. Positive away from bed, negative closer to bed.
|
|
|
|
|
|
|
|
* S5 Reset and disable mesh
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* The S0 report the points as below
|
|
|
|
* The S0 report the points as below
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -3028,8 +3048,8 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
|
|
static int probe_point = -1;
|
|
|
|
static int probe_point = -1;
|
|
|
|
MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport;
|
|
|
|
MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_short() : MeshReport;
|
|
|
|
if (state < 0 || state > 4) {
|
|
|
|
if (state < 0 || state > 5) {
|
|
|
|
SERIAL_PROTOCOLLNPGM("S out of range (0-4).");
|
|
|
|
SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -3038,8 +3058,13 @@ inline void gcode_G28() {
|
|
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
switch (state) {
|
|
|
|
case MeshReport:
|
|
|
|
case MeshReport:
|
|
|
|
if (mbl.active) {
|
|
|
|
if (mbl.has_mesh()) {
|
|
|
|
SERIAL_PROTOCOLPGM("Num X,Y: ");
|
|
|
|
SERIAL_PROTOCOLPGM("State: ");
|
|
|
|
|
|
|
|
if (mbl.active())
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("On");
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("Off");
|
|
|
|
|
|
|
|
SERIAL_PROTOCOLPGM("\nNum X,Y: ");
|
|
|
|
SERIAL_PROTOCOL(MESH_NUM_X_POINTS);
|
|
|
|
SERIAL_PROTOCOL(MESH_NUM_X_POINTS);
|
|
|
|
SERIAL_PROTOCOLCHAR(',');
|
|
|
|
SERIAL_PROTOCOLCHAR(',');
|
|
|
|
SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
|
|
|
|
SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
|
|
|
@ -3100,7 +3125,7 @@ inline void gcode_G28() {
|
|
|
|
// After recording the last point, activate the mbl and home
|
|
|
|
// After recording the last point, activate the mbl and home
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
|
|
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
|
|
|
probe_point = -1;
|
|
|
|
probe_point = -1;
|
|
|
|
mbl.active = true;
|
|
|
|
mbl.set_has_mesh(true);
|
|
|
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
|
|
|
enqueue_and_echo_commands_P(PSTR("G28"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -3147,6 +3172,19 @@ inline void gcode_G28() {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mbl.z_offset = z;
|
|
|
|
mbl.z_offset = z;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case MeshReset:
|
|
|
|
|
|
|
|
if (mbl.active()) {
|
|
|
|
|
|
|
|
current_position[Z_AXIS] +=
|
|
|
|
|
|
|
|
mbl.get_z(current_position[X_AXIS] - home_offset[X_AXIS],
|
|
|
|
|
|
|
|
current_position[Y_AXIS] - home_offset[Y_AXIS]) - MESH_HOME_SEARCH_Z;
|
|
|
|
|
|
|
|
mbl.reset();
|
|
|
|
|
|
|
|
sync_plan_position();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
mbl.reset();
|
|
|
|
|
|
|
|
|
|
|
|
} // switch(state)
|
|
|
|
} // switch(state)
|
|
|
|
|
|
|
|
|
|
|
|
report_current_position();
|
|
|
|
report_current_position();
|
|
|
@ -5944,7 +5982,7 @@ inline void gcode_M410() {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* M420: Enable/Disable Mesh Bed Leveling
|
|
|
|
* M420: Enable/Disable Mesh Bed Leveling
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
inline void gcode_M420() { if (code_seen('S') && code_has_value()) mbl.active = !!code_value_short(); }
|
|
|
|
inline void gcode_M420() { if (code_seen('S') && code_has_value()) mbl.set_has_mesh(!!code_value_short()); }
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* M421: Set a single Mesh Bed Leveling Z coordinate
|
|
|
|
* M421: Set a single Mesh Bed Leveling Z coordinate
|
|
|
@ -7335,7 +7373,7 @@ void clamp_to_software_endstops(float target[3]) {
|
|
|
|
|
|
|
|
|
|
|
|
// This function is used to split lines on mesh borders so each segment is only part of one mesh area
|
|
|
|
// This function is used to split lines on mesh borders so each segment is only part of one mesh area
|
|
|
|
void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t& extruder, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
|
|
|
|
void mesh_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t& extruder, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
|
|
|
|
if (!mbl.active) {
|
|
|
|
if (!mbl.active()) {
|
|
|
|
planner.buffer_line(x, y, z, e, feed_rate, extruder);
|
|
|
|
planner.buffer_line(x, y, z, e, feed_rate, extruder);
|
|
|
|
set_current_to_destination();
|
|
|
|
set_current_to_destination();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|