|
@ -28,12 +28,6 @@ |
|
|
|
|
|
|
|
|
#if ENABLED(PROBE_OFFSET_WIZARD) |
|
|
#if ENABLED(PROBE_OFFSET_WIZARD) |
|
|
|
|
|
|
|
|
#ifndef PROBE_OFFSET_START |
|
|
|
|
|
#error "PROBE_OFFSET_WIZARD requires a PROBE_OFFSET_START with a negative value." |
|
|
|
|
|
#else |
|
|
|
|
|
static_assert(PROBE_OFFSET_START < 0, "PROBE_OFFSET_START must be < 0. Please update your configuration."); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include "menu_item.h" |
|
|
#include "menu_item.h" |
|
|
#include "menu_addon.h" |
|
|
#include "menu_addon.h" |
|
|
#include "../../gcode/queue.h" |
|
|
#include "../../gcode/queue.h" |
|
@ -46,21 +40,20 @@ |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
// Global storage
|
|
|
// Global storage
|
|
|
float z_offset_backup, calculated_z_offset; |
|
|
float z_offset_backup, calculated_z_offset, z_offset_ref; |
|
|
|
|
|
|
|
|
TERN_(HAS_LEVELING, bool leveling_was_active); |
|
|
TERN_(HAS_LEVELING, bool leveling_was_active); |
|
|
|
|
|
|
|
|
void prepare_for_calibration() { |
|
|
inline void z_clearance_move() { |
|
|
z_offset_backup = probe.offset.z; |
|
|
do_z_clearance( |
|
|
|
|
|
#ifdef Z_AFTER_HOMING |
|
|
// Disable soft endstops for free Z movement
|
|
|
Z_AFTER_HOMING |
|
|
SET_SOFT_ENDSTOP_LOOSE(true); |
|
|
#elif defined(Z_HOMING_HEIGHT) |
|
|
|
|
|
Z_HOMING_HEIGHT |
|
|
// Disable leveling for raw planner motion
|
|
|
#else |
|
|
#if HAS_LEVELING |
|
|
10 |
|
|
leveling_was_active = planner.leveling_active; |
|
|
|
|
|
set_bed_leveling_enabled(false); |
|
|
|
|
|
#endif |
|
|
#endif |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void set_offset_and_go_back(const float &z) { |
|
|
void set_offset_and_go_back(const float &z) { |
|
@ -77,7 +70,7 @@ void _goto_manual_move_z(const float scale) { |
|
|
|
|
|
|
|
|
void probe_offset_wizard_menu() { |
|
|
void probe_offset_wizard_menu() { |
|
|
START_MENU(); |
|
|
START_MENU(); |
|
|
calculated_z_offset = probe.offset.z + current_position.z; |
|
|
calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref; |
|
|
|
|
|
|
|
|
if (LCD_HEIGHT >= 4) |
|
|
if (LCD_HEIGHT >= 4) |
|
|
STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); |
|
|
STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT); |
|
@ -107,47 +100,86 @@ void probe_offset_wizard_menu() { |
|
|
|
|
|
|
|
|
ACTION_ITEM(MSG_BUTTON_DONE, []{ |
|
|
ACTION_ITEM(MSG_BUTTON_DONE, []{ |
|
|
set_offset_and_go_back(calculated_z_offset); |
|
|
set_offset_and_go_back(calculated_z_offset); |
|
|
do_z_clearance(20.0 |
|
|
current_position.z = z_offset_ref; // Set Z to z_offset_ref, as we can expect it is at probe height
|
|
|
#ifdef Z_AFTER_HOMING |
|
|
sync_plan_position(); |
|
|
- 20.0 + Z_AFTER_HOMING |
|
|
z_clearance_move(); // Raise Z as if it was homed
|
|
|
#endif |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
ACTION_ITEM(MSG_BUTTON_CANCEL, []{ |
|
|
ACTION_ITEM(MSG_BUTTON_CANCEL, []{ |
|
|
set_offset_and_go_back(z_offset_backup); |
|
|
set_offset_and_go_back(z_offset_backup); |
|
|
|
|
|
// If wizard-homing was done by probe with with PROBE_OFFSET_WIZARD_START_Z
|
|
|
|
|
|
#if EITHER(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING) && defined(PROBE_OFFSET_WIZARD_START_Z) |
|
|
|
|
|
set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction
|
|
|
|
|
|
queue.inject_P(PSTR("G28Z")); |
|
|
|
|
|
#else // Otherwise do a Z clearance move like after Homing
|
|
|
|
|
|
z_clearance_move(); |
|
|
|
|
|
#endif |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
END_MENU(); |
|
|
END_MENU(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#ifdef PROBE_OFFSET_WIZARD_XY_POS |
|
|
void prepare_for_probe_offset_wizard() { |
|
|
|
|
|
if (ui.wait_for_move) return; |
|
|
|
|
|
|
|
|
#define HAS_PROBE_OFFSET_WIZARD_XY_POS 1 |
|
|
#if defined(PROBE_OFFSET_WIZARD_XY_POS) || NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING) |
|
|
|
|
|
if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_PROBE_WIZARD_PROBING)); |
|
|
|
|
|
|
|
|
inline void goto_probe_offset_wizard() { |
|
|
#ifndef PROBE_OFFSET_WIZARD_XY_POS |
|
|
if (ui.wait_for_move) return; |
|
|
#define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER |
|
|
|
|
|
#endif |
|
|
|
|
|
// Get X and Y from configuration, or use center
|
|
|
constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS; |
|
|
constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS; |
|
|
current_position = wizard_pos; |
|
|
|
|
|
|
|
|
// Probe for Z reference
|
|
|
ui.wait_for_move = true; |
|
|
ui.wait_for_move = true; |
|
|
line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY)); // Could invoke idle()
|
|
|
z_offset_ref = probe.probe_at_point(wizard_pos, PROBE_PT_STOW, 0, true); |
|
|
ui.wait_for_move = false; |
|
|
ui.wait_for_move = false; |
|
|
ui.synchronize(); |
|
|
|
|
|
prepare_for_calibration(); |
|
|
#endif |
|
|
probe.offset.z = PROBE_OFFSET_START; |
|
|
|
|
|
|
|
|
// Move Nozzle to Probing/Homing Position
|
|
|
|
|
|
ui.wait_for_move = true; |
|
|
|
|
|
current_position += probe.offset_xy; |
|
|
|
|
|
line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY)); |
|
|
|
|
|
ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING)); |
|
|
|
|
|
ui.wait_for_move = false; |
|
|
|
|
|
|
|
|
|
|
|
// Go to Calibration Menu
|
|
|
ui.goto_screen(probe_offset_wizard_menu); |
|
|
ui.goto_screen(probe_offset_wizard_menu); |
|
|
ui.defer_status_screen(); |
|
|
ui.defer_status_screen(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void goto_probe_offset_wizard() { |
|
|
|
|
|
ui.defer_status_screen(); |
|
|
|
|
|
set_all_unhomed(); |
|
|
|
|
|
|
|
|
|
|
|
// Store probe.offset.z for Case: Cancel
|
|
|
|
|
|
z_offset_backup = probe.offset.z; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef PROBE_OFFSET_WIZARD_START_Z |
|
|
|
|
|
probe.offset.z = PROBE_OFFSET_WIZARD_START_Z; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
void home_and_goto_probe_offset_wizard() { |
|
|
// Store Bed-Leveling-State and disable
|
|
|
|
|
|
#if HAS_LEVELING |
|
|
|
|
|
leveling_was_active = planner.leveling_active; |
|
|
|
|
|
set_bed_leveling_enabled(false); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// Home all axes
|
|
|
queue.inject_P(G28_STR); |
|
|
queue.inject_P(G28_STR); |
|
|
|
|
|
|
|
|
ui.goto_screen([]{ |
|
|
ui.goto_screen([]{ |
|
|
_lcd_draw_homing(); |
|
|
_lcd_draw_homing(); |
|
|
if (all_axes_homed()) |
|
|
if (all_axes_homed()) { |
|
|
ui.goto_screen(TERN(HAS_PROBE_OFFSET_WIZARD_XY_POS, goto_probe_offset_wizard, probe_offset_wizard_menu)); |
|
|
SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement
|
|
|
|
|
|
z_offset_ref = 0; // Set Z Value for Wizard Position to 0
|
|
|
|
|
|
ui.goto_screen(prepare_for_probe_offset_wizard); |
|
|
|
|
|
ui.defer_status_screen(); |
|
|
|
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endif // PROBE_OFFSET_WIZARD
|
|
|
#endif // PROBE_OFFSET_WIZARD
|
|
|