Replace MBL Z hacking
This commit is contained in:
parent
4e53124681
commit
3e927ff204
@ -709,6 +709,11 @@
|
||||
#ifndef Z_CLEARANCE_BETWEEN_PROBES
|
||||
#define Z_CLEARANCE_BETWEEN_PROBES Z_HOMING_HEIGHT
|
||||
#endif
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
|
||||
#define MANUAL_PROBE_HEIGHT Z_CLEARANCE_BETWEEN_PROBES
|
||||
#else
|
||||
#define MANUAL_PROBE_HEIGHT Z_HOMING_HEIGHT
|
||||
#endif
|
||||
|
||||
#if IS_KINEMATIC
|
||||
// Check for this in the code instead
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -3450,7 +3450,7 @@ inline void gcode_G28() {
|
||||
stepper.synchronize();
|
||||
|
||||
// Disable the leveling matrix before homing
|
||||
#if PLANNER_LEVELING
|
||||
#if PLANNER_LEVELING || ENABLED(MESH_BED_LEVELING)
|
||||
set_bed_leveling_enabled(false);
|
||||
#endif
|
||||
|
||||
@ -3464,31 +3464,6 @@ inline void gcode_G28() {
|
||||
extruder_duplication_enabled = false;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* For mesh bed leveling deactivate the mesh calculations, will be turned
|
||||
* on again when homing all axis
|
||||
*/
|
||||
#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
|
||||
// Use known Z position if already homed
|
||||
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) {
|
||||
set_bed_leveling_enabled(false);
|
||||
pre_home_z = current_position[Z_AXIS];
|
||||
}
|
||||
else {
|
||||
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
|
||||
|
||||
setup_for_endstop_or_probe_move();
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> endstops.enable(true)");
|
||||
@ -3620,43 +3595,14 @@ 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 (mbl.reactivate()) {
|
||||
set_bed_leveling_enabled(true);
|
||||
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
|
||||
#endif
|
||||
;
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
mbl.set_active(true);
|
||||
#if ENABLED(MESH_G28_REST_ORIGIN)
|
||||
current_position[Z_AXIS] = 0.0;
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS);
|
||||
set_destination_to_current();
|
||||
line_to_destination(homing_feedrate_mm_s[Z_AXIS]);
|
||||
stepper.synchronize();
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Rest Origin", current_position);
|
||||
#endif
|
||||
#else
|
||||
planner.unapply_leveling(current_position);
|
||||
#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)) {
|
||||
current_position[Z_AXIS] = pre_home_z;
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
mbl.set_active(true);
|
||||
planner.unapply_leveling(current_position);
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) DEBUG_POS("MBL Home X or Y", current_position);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -3664,16 +3610,16 @@ inline void gcode_G28() {
|
||||
|
||||
clean_up_after_endstop_or_probe_move();
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
|
||||
#endif
|
||||
|
||||
// Restore the active tool after homing
|
||||
#if HOTENDS > 1
|
||||
tool_change(old_tool_index, 0, true);
|
||||
#endif
|
||||
|
||||
report_current_position();
|
||||
|
||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAS_PROBING_PROCEDURE
|
||||
@ -3690,25 +3636,21 @@ inline void gcode_G28() {
|
||||
|
||||
inline void _mbl_goto_xy(const float &x, const float &y) {
|
||||
const float old_feedrate_mm_s = feedrate_mm_s;
|
||||
feedrate_mm_s = homing_feedrate_mm_s[Z_AXIS];
|
||||
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
|
||||
+ Z_CLEARANCE_BETWEEN_PROBES
|
||||
#elif Z_HOMING_HEIGHT > 0
|
||||
+ Z_HOMING_HEIGHT
|
||||
#endif
|
||||
;
|
||||
line_to_current_position();
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
feedrate_mm_s = homing_feedrate_mm_s[Z_AXIS];
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
|
||||
line_to_current_position();
|
||||
#endif
|
||||
|
||||
feedrate_mm_s = MMM_TO_MMS(XY_PROBE_SPEED);
|
||||
current_position[X_AXIS] = LOGICAL_X_POSITION(x);
|
||||
current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
|
||||
line_to_current_position();
|
||||
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > 0 || Z_HOMING_HEIGHT > 0
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
feedrate_mm_s = homing_feedrate_mm_s[Z_AXIS];
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z);
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + 0.2; // just slightly over the bed
|
||||
line_to_current_position();
|
||||
#endif
|
||||
|
||||
@ -3721,7 +3663,6 @@ inline void gcode_G28() {
|
||||
|
||||
void mbl_mesh_report() {
|
||||
SERIAL_PROTOCOLLNPGM("Num X,Y: " STRINGIFY(MESH_NUM_X_POINTS) "," STRINGIFY(MESH_NUM_Y_POINTS));
|
||||
SERIAL_PROTOCOLLNPGM("Z search height: " STRINGIFY(MESH_HOME_SEARCH_Z));
|
||||
SERIAL_PROTOCOLPGM("Z offset: "); SERIAL_PROTOCOL_F(mbl.z_offset, 5);
|
||||
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
||||
for (uint8_t py = 0; py < MESH_NUM_Y_POINTS; py++) {
|
||||
@ -3757,6 +3698,10 @@ inline void gcode_G28() {
|
||||
inline void gcode_G29() {
|
||||
|
||||
static int probe_index = -1;
|
||||
#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
||||
static bool enable_soft_endstops;
|
||||
#endif
|
||||
|
||||
const MeshLevelingState state = code_seen('S') ? (MeshLevelingState)code_value_byte() : MeshReport;
|
||||
if (state < 0 || state > 5) {
|
||||
SERIAL_PROTOCOLLNPGM("S out of range (0-5).");
|
||||
@ -3788,33 +3733,34 @@ inline void gcode_G28() {
|
||||
}
|
||||
// For each G29 S2...
|
||||
if (probe_index == 0) {
|
||||
// For the initial G29 S2 make Z a positive value (e.g., 4.0)
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
||||
#if Z_HOME_DIR > 0
|
||||
+ Z_MAX_POS
|
||||
#endif
|
||||
;
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
||||
// For the initial G29 S2 save software endstop state
|
||||
enable_soft_endstops = soft_endstops_enabled;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// For G29 S2 after adjusting Z.
|
||||
mbl.set_zigzag_z(probe_index - 1, current_position[Z_AXIS]);
|
||||
#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
||||
soft_endstops_enabled = enable_soft_endstops;
|
||||
#endif
|
||||
}
|
||||
// If there's another point to sample, move there with optional lift.
|
||||
if (probe_index < (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
||||
mbl.zigzag(probe_index, px, py);
|
||||
_mbl_goto_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
|
||||
|
||||
#if ENABLED(min_software_endstops) || ENABLED(max_software_endstops)
|
||||
// Disable software endstops to allow manual adjustment
|
||||
// If G29 is not completed, they will not be re-enabled
|
||||
soft_endstops_enabled = false;
|
||||
#endif
|
||||
|
||||
probe_index++;
|
||||
}
|
||||
else {
|
||||
// One last "return to the bed" (as originally coded) at completion
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
||||
#if Z_CLEARANCE_BETWEEN_PROBES > Z_HOMING_HEIGHT
|
||||
+ Z_CLEARANCE_BETWEEN_PROBES
|
||||
#elif Z_HOMING_HEIGHT > 0
|
||||
+ Z_HOMING_HEIGHT
|
||||
#endif
|
||||
;
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
|
||||
line_to_current_position();
|
||||
stepper.synchronize();
|
||||
|
||||
@ -3822,7 +3768,12 @@ inline void gcode_G28() {
|
||||
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
||||
probe_index = -1;
|
||||
mbl.set_has_mesh(true);
|
||||
mbl.set_reactivate(true);
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
#if HAS_BUZZER
|
||||
lcd_buzz(200, 659);
|
||||
lcd_buzz(200, 698);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3871,14 +3822,8 @@ inline void gcode_G28() {
|
||||
break;
|
||||
|
||||
case MeshReset:
|
||||
if (mbl.active()) {
|
||||
current_position[Z_AXIS] -= MESH_HOME_SEARCH_Z;
|
||||
planner.apply_leveling(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS]);
|
||||
mbl.reset();
|
||||
SYNC_PLAN_POSITION_KINEMATIC();
|
||||
}
|
||||
else
|
||||
mbl.reset();
|
||||
reset_bed_level();
|
||||
break;
|
||||
|
||||
} // switch(state)
|
||||
|
||||
|
@ -130,6 +130,8 @@
|
||||
#error "Z_RAISE_PROBE_DEPLOY_STOW and Z_RAISE_BETWEEN_PROBINGS are now Z_CLEARANCE_DEPLOY_PROBE and Z_CLEARANCE_BETWEEN_PROBES. Please update your configuration."
|
||||
#elif defined(Z_PROBE_DEPLOY_HEIGHT) || defined(Z_PROBE_TRAVEL_HEIGHT)
|
||||
#error "Z_PROBE_DEPLOY_HEIGHT and Z_PROBE_TRAVEL_HEIGHT are now Z_CLEARANCE_DEPLOY_PROBE and Z_CLEARANCE_BETWEEN_PROBES. Please update your configuration."
|
||||
#elif defined(MESH_HOME_SEARCH_Z)
|
||||
#error "MESH_HOME_SEARCH_Z is now MANUAL_PROBE_Z_RANGE. Please update your configuration."
|
||||
#elif !defined(MIN_STEPS_PER_SEGMENT)
|
||||
#error Please replace "const int dropsegments" with "#define MIN_STEPS_PER_SEGMENT" (and increase by 1) in Configuration_adv.h.
|
||||
#elif defined(PREVENT_DANGEROUS_EXTRUDE)
|
||||
|
@ -164,20 +164,13 @@ enum TempState {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
enum MeshLevelingState {
|
||||
MeshReport,
|
||||
MeshStart,
|
||||
MeshNext,
|
||||
MeshSet,
|
||||
MeshSetZOffset,
|
||||
MeshReset
|
||||
};
|
||||
|
||||
enum MBLStatus {
|
||||
MBL_STATUS_NONE = 0,
|
||||
MBL_STATUS_HAS_MESH_BIT = 0,
|
||||
MBL_STATUS_ACTIVE_BIT = 1
|
||||
#if ENABLED(PROBE_MANUALLY)
|
||||
enum ABLState {
|
||||
ABLReport,
|
||||
ABLStart,
|
||||
ABLNext,
|
||||
ABLSet,
|
||||
ABLReset
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -733,9 +733,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -733,9 +733,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -742,9 +742,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -744,9 +744,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -779,9 +779,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -749,9 +749,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -765,9 +765,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -771,9 +771,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -742,9 +742,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -750,9 +750,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -853,9 +853,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -836,9 +836,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -839,9 +839,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -838,9 +838,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -842,9 +842,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -753,9 +753,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -746,9 +746,9 @@
|
||||
#define MESH_INSET 10 // Mesh inset margin on print area
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_SEARCH_Z 4 // Z after Home, bed somewhere below but above 0.0.
|
||||
#define MANUAL_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment
|
||||
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest at origin [0,0,0]
|
||||
//#define MESH_G28_REST_ORIGIN // After homing all axes ('G28' or 'G28 XYZ') rest Z at Z_MIN_POS
|
||||
|
||||
//#define MANUAL_BED_LEVELING // Add display menu option for bed leveling.
|
||||
|
||||
|
@ -23,6 +23,23 @@
|
||||
#include "Marlin.h"
|
||||
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
|
||||
enum MeshLevelingState {
|
||||
MeshReport,
|
||||
MeshStart,
|
||||
MeshNext,
|
||||
MeshSet,
|
||||
MeshSetZOffset,
|
||||
MeshReset
|
||||
};
|
||||
|
||||
enum MBLStatus {
|
||||
MBL_STATUS_NONE = 0,
|
||||
MBL_STATUS_HAS_MESH_BIT = 0,
|
||||
MBL_STATUS_ACTIVE_BIT = 1,
|
||||
MBL_STATUS_REACTIVATE_BIT = 2
|
||||
};
|
||||
|
||||
#define MESH_X_DIST ((MESH_MAX_X - (MESH_MIN_X))/(MESH_NUM_X_POINTS - 1))
|
||||
#define MESH_Y_DIST ((MESH_MAX_Y - (MESH_MIN_Y))/(MESH_NUM_Y_POINTS - 1))
|
||||
|
||||
@ -44,6 +61,8 @@
|
||||
void set_active(const bool onOff) { onOff ? SBI(status, MBL_STATUS_ACTIVE_BIT) : CBI(status, MBL_STATUS_ACTIVE_BIT); }
|
||||
bool has_mesh() const { return TEST(status, MBL_STATUS_HAS_MESH_BIT); }
|
||||
void set_has_mesh(const bool onOff) { onOff ? SBI(status, MBL_STATUS_HAS_MESH_BIT) : CBI(status, MBL_STATUS_HAS_MESH_BIT); }
|
||||
bool reactivate() { bool b = TEST(status, MBL_STATUS_REACTIVATE_BIT); CBI(status, MBL_STATUS_REACTIVATE_BIT); return b; }
|
||||
void set_reactivate(const bool onOff) { onOff ? SBI(status, MBL_STATUS_REACTIVATE_BIT) : CBI(status, MBL_STATUS_REACTIVATE_BIT); }
|
||||
|
||||
inline void zigzag(const int8_t index, int8_t &px, int8_t &py) const {
|
||||
px = index % (MESH_NUM_X_POINTS);
|
||||
|
@ -1223,18 +1223,17 @@ void kill_screen(const char* lcd_msg) {
|
||||
static uint8_t _lcd_level_bed_position;
|
||||
|
||||
// Utility to go to the next mesh point
|
||||
// A raise is added between points if Z_HOMING_HEIGHT is in use
|
||||
// Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
|
||||
// Z position will be restored with the final action, a G28
|
||||
inline void _mbl_goto_xy(float x, float y) {
|
||||
inline void _manual_probe_xy(float x, float y) {
|
||||
if (no_reentrance) return;
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT);
|
||||
line_to_current(Z_AXIS);
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
|
||||
line_to_current(Z_AXIS);
|
||||
#endif
|
||||
current_position[X_AXIS] = LOGICAL_X_POSITION(x);
|
||||
current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
|
||||
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
|
||||
#if Z_HOMING_HEIGHT > 0
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z);
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + 0.2;
|
||||
line_to_current(Z_AXIS);
|
||||
#endif
|
||||
lcd_synchronize();
|
||||
@ -1259,48 +1258,44 @@ void kill_screen(const char* lcd_msg) {
|
||||
if (encoderPosition) {
|
||||
refresh_cmd_timeout();
|
||||
current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
|
||||
NOLESS(current_position[Z_AXIS], 0);
|
||||
NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
|
||||
NOLESS(current_position[Z_AXIS], -(MANUAL_PROBE_Z_RANGE) * 0.5);
|
||||
NOMORE(current_position[Z_AXIS], (MANUAL_PROBE_Z_RANGE) * 0.5);
|
||||
line_to_current(Z_AXIS);
|
||||
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING;
|
||||
encoderPosition = 0;
|
||||
}
|
||||
|
||||
static bool debounce_click = false;
|
||||
if (lcd_clicked) {
|
||||
if (!debounce_click) {
|
||||
debounce_click = true; // ignore multiple "clicks" in a row
|
||||
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
|
||||
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
||||
lcd_goto_screen(_lcd_level_bed_done);
|
||||
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
|
||||
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
|
||||
lcd_goto_screen(_lcd_level_bed_done);
|
||||
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
|
||||
#if MANUAL_PROBE_HEIGHT > 0
|
||||
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
|
||||
line_to_current(Z_AXIS);
|
||||
lcd_synchronize();
|
||||
#endif
|
||||
|
||||
mbl.set_has_mesh(true);
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
lcd_return_to_status();
|
||||
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
|
||||
#if HAS_BUZZER
|
||||
lcd_buzz(200, 659);
|
||||
lcd_buzz(200, 698);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
lcd_goto_screen(_lcd_level_goto_next_point);
|
||||
}
|
||||
mbl.set_has_mesh(true);
|
||||
mbl.set_reactivate(true);
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
lcd_return_to_status();
|
||||
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
|
||||
#if HAS_BUZZER
|
||||
lcd_buzz(200, 659);
|
||||
lcd_buzz(200, 698);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
lcd_goto_screen(_lcd_level_goto_next_point);
|
||||
}
|
||||
}
|
||||
else {
|
||||
debounce_click = false;
|
||||
}
|
||||
|
||||
KeepDrawing:
|
||||
// Update on first display, then only on updates to Z position
|
||||
// Show message above on clicks instead
|
||||
if (lcdDrawUpdate) {
|
||||
float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
|
||||
const float v = current_position[Z_AXIS];
|
||||
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
|
||||
}
|
||||
|
||||
@ -1326,10 +1321,10 @@ KeepDrawing:
|
||||
// Set the menu to display ahead of blocking call
|
||||
lcd_goto_screen(_lcd_level_bed_moving);
|
||||
|
||||
// _mbl_goto_xy runs the menu loop until the move is done
|
||||
// _manual_probe_xy runs the menu loop until the move is done
|
||||
int8_t px, py;
|
||||
mbl.zigzag(_lcd_level_bed_position, px, py);
|
||||
_mbl_goto_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
|
||||
_manual_probe_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
|
||||
|
||||
// After the blocking function returns, change menus
|
||||
lcd_goto_screen(_lcd_level_bed_get_z);
|
||||
@ -1343,12 +1338,6 @@ KeepDrawing:
|
||||
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
|
||||
if (lcd_clicked) {
|
||||
_lcd_level_bed_position = 0;
|
||||
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
|
||||
#if Z_HOME_DIR > 0
|
||||
+ Z_MAX_POS
|
||||
#endif
|
||||
;
|
||||
planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
lcd_goto_screen(_lcd_level_goto_next_point);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user