|
@@ -28,12 +28,6 @@
|
28
|
28
|
|
29
|
29
|
#if ENABLED(PROBE_OFFSET_WIZARD)
|
30
|
30
|
|
31
|
|
-#ifndef PROBE_OFFSET_START
|
32
|
|
- #error "PROBE_OFFSET_WIZARD requires a PROBE_OFFSET_START with a negative value."
|
33
|
|
-#else
|
34
|
|
- static_assert(PROBE_OFFSET_START < 0, "PROBE_OFFSET_START must be < 0. Please update your configuration.");
|
35
|
|
-#endif
|
36
|
|
-
|
37
|
31
|
#include "menu_item.h"
|
38
|
32
|
#include "menu_addon.h"
|
39
|
33
|
#include "../../gcode/queue.h"
|
|
@@ -46,21 +40,20 @@
|
46
|
40
|
#endif
|
47
|
41
|
|
48
|
42
|
// Global storage
|
49
|
|
-float z_offset_backup, calculated_z_offset;
|
|
43
|
+float z_offset_backup, calculated_z_offset, z_offset_ref;
|
50
|
44
|
|
51
|
45
|
TERN_(HAS_LEVELING, bool leveling_was_active);
|
52
|
46
|
|
53
|
|
-void prepare_for_calibration() {
|
54
|
|
- z_offset_backup = probe.offset.z;
|
55
|
|
-
|
56
|
|
- // Disable soft endstops for free Z movement
|
57
|
|
- SET_SOFT_ENDSTOP_LOOSE(true);
|
58
|
|
-
|
59
|
|
- // Disable leveling for raw planner motion
|
60
|
|
- #if HAS_LEVELING
|
61
|
|
- leveling_was_active = planner.leveling_active;
|
62
|
|
- set_bed_leveling_enabled(false);
|
63
|
|
- #endif
|
|
47
|
+inline void z_clearance_move() {
|
|
48
|
+ do_z_clearance(
|
|
49
|
+ #ifdef Z_AFTER_HOMING
|
|
50
|
+ Z_AFTER_HOMING
|
|
51
|
+ #elif defined(Z_HOMING_HEIGHT)
|
|
52
|
+ Z_HOMING_HEIGHT
|
|
53
|
+ #else
|
|
54
|
+ 10
|
|
55
|
+ #endif
|
|
56
|
+ );
|
64
|
57
|
}
|
65
|
58
|
|
66
|
59
|
void set_offset_and_go_back(const float &z) {
|
|
@@ -77,7 +70,7 @@ void _goto_manual_move_z(const float scale) {
|
77
|
70
|
|
78
|
71
|
void probe_offset_wizard_menu() {
|
79
|
72
|
START_MENU();
|
80
|
|
- calculated_z_offset = probe.offset.z + current_position.z;
|
|
73
|
+ calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref;
|
81
|
74
|
|
82
|
75
|
if (LCD_HEIGHT >= 4)
|
83
|
76
|
STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT);
|
|
@@ -92,7 +85,7 @@ void probe_offset_wizard_menu() {
|
92
|
85
|
char tmp[20], numstr[10];
|
93
|
86
|
// Determine digits needed right of decimal
|
94
|
87
|
const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
|
95
|
|
- !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
|
|
88
|
+ !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
|
96
|
89
|
sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
|
97
|
90
|
#if DISABLED(HAS_GRAPHICAL_TFT)
|
98
|
91
|
extern const char NUL_STR[];
|
|
@@ -107,47 +100,86 @@ void probe_offset_wizard_menu() {
|
107
|
100
|
|
108
|
101
|
ACTION_ITEM(MSG_BUTTON_DONE, []{
|
109
|
102
|
set_offset_and_go_back(calculated_z_offset);
|
110
|
|
- do_z_clearance(20.0
|
111
|
|
- #ifdef Z_AFTER_HOMING
|
112
|
|
- - 20.0 + Z_AFTER_HOMING
|
113
|
|
- #endif
|
114
|
|
- );
|
|
103
|
+ current_position.z = z_offset_ref; // Set Z to z_offset_ref, as we can expect it is at probe height
|
|
104
|
+ sync_plan_position();
|
|
105
|
+ z_clearance_move(); // Raise Z as if it was homed
|
115
|
106
|
});
|
116
|
107
|
|
117
|
108
|
ACTION_ITEM(MSG_BUTTON_CANCEL, []{
|
118
|
109
|
set_offset_and_go_back(z_offset_backup);
|
|
110
|
+ // If wizard-homing was done by probe with with PROBE_OFFSET_WIZARD_START_Z
|
|
111
|
+ #if EITHER(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING) && defined(PROBE_OFFSET_WIZARD_START_Z)
|
|
112
|
+ set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction
|
|
113
|
+ queue.inject_P(PSTR("G28Z"));
|
|
114
|
+ #else // Otherwise do a Z clearance move like after Homing
|
|
115
|
+ z_clearance_move();
|
|
116
|
+ #endif
|
119
|
117
|
});
|
120
|
118
|
|
121
|
119
|
END_MENU();
|
122
|
120
|
}
|
123
|
121
|
|
124
|
|
-#ifdef PROBE_OFFSET_WIZARD_XY_POS
|
|
122
|
+void prepare_for_probe_offset_wizard() {
|
|
123
|
+ if (ui.wait_for_move) return;
|
125
|
124
|
|
126
|
|
- #define HAS_PROBE_OFFSET_WIZARD_XY_POS 1
|
|
125
|
+ #if defined(PROBE_OFFSET_WIZARD_XY_POS) || NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING)
|
|
126
|
+ if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_PROBE_WIZARD_PROBING));
|
127
|
127
|
|
128
|
|
- inline void goto_probe_offset_wizard() {
|
129
|
|
- if (ui.wait_for_move) return;
|
|
128
|
+ #ifndef PROBE_OFFSET_WIZARD_XY_POS
|
|
129
|
+ #define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER
|
|
130
|
+ #endif
|
|
131
|
+ // Get X and Y from configuration, or use center
|
130
|
132
|
constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS;
|
131
|
|
- current_position = wizard_pos;
|
|
133
|
+
|
|
134
|
+ // Probe for Z reference
|
132
|
135
|
ui.wait_for_move = true;
|
133
|
|
- line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY)); // Could invoke idle()
|
|
136
|
+ z_offset_ref = probe.probe_at_point(wizard_pos, PROBE_PT_STOW, 0, true);
|
134
|
137
|
ui.wait_for_move = false;
|
135
|
|
- ui.synchronize();
|
136
|
|
- prepare_for_calibration();
|
137
|
|
- probe.offset.z = PROBE_OFFSET_START;
|
138
|
|
- ui.goto_screen(probe_offset_wizard_menu);
|
139
|
|
- ui.defer_status_screen();
|
140
|
|
- }
|
141
|
138
|
|
142
|
|
-#endif
|
|
139
|
+ #endif
|
|
140
|
+
|
|
141
|
+ // Move Nozzle to Probing/Homing Position
|
|
142
|
+ ui.wait_for_move = true;
|
|
143
|
+ current_position += probe.offset_xy;
|
|
144
|
+ line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY));
|
|
145
|
+ ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING));
|
|
146
|
+ ui.wait_for_move = false;
|
|
147
|
+
|
|
148
|
+ // Go to Calibration Menu
|
|
149
|
+ ui.goto_screen(probe_offset_wizard_menu);
|
|
150
|
+ ui.defer_status_screen();
|
|
151
|
+}
|
|
152
|
+
|
|
153
|
+void goto_probe_offset_wizard() {
|
|
154
|
+ ui.defer_status_screen();
|
|
155
|
+ set_all_unhomed();
|
|
156
|
+
|
|
157
|
+ // Store probe.offset.z for Case: Cancel
|
|
158
|
+ z_offset_backup = probe.offset.z;
|
|
159
|
+
|
|
160
|
+ #ifdef PROBE_OFFSET_WIZARD_START_Z
|
|
161
|
+ probe.offset.z = PROBE_OFFSET_WIZARD_START_Z;
|
|
162
|
+ #endif
|
|
163
|
+
|
|
164
|
+ // Store Bed-Leveling-State and disable
|
|
165
|
+ #if HAS_LEVELING
|
|
166
|
+ leveling_was_active = planner.leveling_active;
|
|
167
|
+ set_bed_leveling_enabled(false);
|
|
168
|
+ #endif
|
143
|
169
|
|
144
|
|
-void home_and_goto_probe_offset_wizard() {
|
|
170
|
+ // Home all axes
|
145
|
171
|
queue.inject_P(G28_STR);
|
|
172
|
+
|
146
|
173
|
ui.goto_screen([]{
|
147
|
174
|
_lcd_draw_homing();
|
148
|
|
- if (all_axes_homed())
|
149
|
|
- ui.goto_screen(TERN(HAS_PROBE_OFFSET_WIZARD_XY_POS, goto_probe_offset_wizard, probe_offset_wizard_menu));
|
|
175
|
+ if (all_axes_homed()) {
|
|
176
|
+ SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement
|
|
177
|
+ z_offset_ref = 0; // Set Z Value for Wizard Position to 0
|
|
178
|
+ ui.goto_screen(prepare_for_probe_offset_wizard);
|
|
179
|
+ ui.defer_status_screen();
|
|
180
|
+ }
|
150
|
181
|
});
|
|
182
|
+
|
151
|
183
|
}
|
152
|
184
|
|
153
|
185
|
#endif // PROBE_OFFSET_WIZARD
|