|
@@ -44,53 +44,187 @@
|
44
|
44
|
#define LEVEL_CORNERS_HEIGHT 0.0
|
45
|
45
|
#endif
|
46
|
46
|
|
|
47
|
+#if ENABLED(LEVEL_CORNERS_USE_PROBE)
|
|
48
|
+ #include "../../module/probe.h"
|
|
49
|
+ #include "../../module/endstops.h"
|
|
50
|
+ #if ENABLED(BLTOUCH)
|
|
51
|
+ #include "../../feature/bltouch.h"
|
|
52
|
+ #endif
|
|
53
|
+ #ifndef LEVEL_CORNERS_PROBE_TOLERANCE
|
|
54
|
+ #define LEVEL_CORNERS_PROBE_TOLERANCE 0.1
|
|
55
|
+ #endif
|
|
56
|
+ #if ENABLED(LEVEL_CORNERS_AUDIO_FEEDBACK)
|
|
57
|
+ #include "../../libs/buzzer.h"
|
|
58
|
+ #define PROBE_BUZZ() BUZZ(200, 600)
|
|
59
|
+ #else
|
|
60
|
+ #define PROBE_BUZZ() NOOP
|
|
61
|
+ #endif
|
|
62
|
+ static float last_z;
|
|
63
|
+ static bool corner_probing_done;
|
|
64
|
+ static bool verify_corner;
|
|
65
|
+ static int good_points;
|
|
66
|
+#endif
|
|
67
|
+
|
47
|
68
|
static_assert(LEVEL_CORNERS_Z_HOP >= 0, "LEVEL_CORNERS_Z_HOP must be >= 0. Please update your configuration.");
|
48
|
69
|
|
|
70
|
+extern const char G28_STR[];
|
|
71
|
+
|
49
|
72
|
#if HAS_LEVELING
|
50
|
73
|
static bool leveling_was_active = false;
|
51
|
74
|
#endif
|
52
|
75
|
|
|
76
|
+static int8_t bed_corner;
|
|
77
|
+
|
53
|
78
|
|
54
|
79
|
* Level corners, starting in the front-left corner.
|
55
|
80
|
*/
|
56
|
|
-static int8_t bed_corner;
|
57
|
|
-static inline void _lcd_goto_next_corner() {
|
58
|
|
- constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
|
59
|
|
- constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] },
|
60
|
|
- rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] };
|
61
|
|
- line_to_z(LEVEL_CORNERS_Z_HOP);
|
62
|
|
- switch (bed_corner) {
|
63
|
|
- case 0: current_position = lf; break;
|
64
|
|
- case 1: current_position.x = rb.x; break;
|
65
|
|
- case 2: current_position.y = rb.y; break;
|
66
|
|
- case 3: current_position.x = lf.x; break;
|
67
|
|
- #if ENABLED(LEVEL_CENTER_TOO)
|
68
|
|
- case 4: current_position.set(X_CENTER, Y_CENTER); break;
|
|
81
|
+#if ENABLED(LEVEL_CORNERS_USE_PROBE)
|
|
82
|
+
|
|
83
|
+ static inline void _lcd_level_bed_corners_probing() {
|
|
84
|
+ ui.goto_screen([]{ MenuItem_static::draw((LCD_HEIGHT - 1) / 2, GET_TEXT(MSG_PROBING_MESH)); });
|
|
85
|
+
|
|
86
|
+ float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
|
|
87
|
+ xy_pos_t lf { (X_MIN_BED) + lfrb[0] - probe.offset_xy.x , (Y_MIN_BED) + lfrb[1] - probe.offset_xy.y },
|
|
88
|
+ rb { (X_MAX_BED) - lfrb[2] - probe.offset_xy.x , (Y_MAX_BED) - lfrb[3] - probe.offset_xy.y };
|
|
89
|
+
|
|
90
|
+ do_blocking_move_to_z(LEVEL_CORNERS_Z_HOP - probe.offset.z);
|
|
91
|
+
|
|
92
|
+ switch (bed_corner) {
|
|
93
|
+ case 0: current_position = lf; break;
|
|
94
|
+ case 1: current_position.x = rb.x; break;
|
|
95
|
+ case 2: current_position.y = rb.y; break;
|
|
96
|
+ case 3: current_position.x = lf.x; break;
|
|
97
|
+ #if ENABLED(LEVEL_CENTER_TOO)
|
|
98
|
+ case 4: current_position.set(X_CENTER - probe.offset_xy.x, Y_CENTER - probe.offset_xy.y); good_points--; break;
|
|
99
|
+ #endif
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ do_blocking_move_to_xy(current_position);
|
|
103
|
+
|
|
104
|
+ #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
|
|
105
|
+ bltouch.deploy();
|
69
|
106
|
#endif
|
|
107
|
+ TERN_(QUIET_PROBING, probe.set_probing_paused(true));
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+ do_blocking_move_to_z(last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), manual_feedrate_mm_s.z);
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+ bool probe_triggered = TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE));
|
|
114
|
+ if (!probe_triggered) {
|
|
115
|
+
|
|
116
|
+ static bool wait_for_probe;
|
|
117
|
+
|
|
118
|
+ ui.goto_screen([]{
|
|
119
|
+ MenuItem_confirm::select_screen(
|
|
120
|
+ GET_TEXT(MSG_BUTTON_DONE), GET_TEXT(MSG_BUTTON_SKIP)
|
|
121
|
+ , []{ corner_probing_done = true;
|
|
122
|
+ wait_for_probe = false;
|
|
123
|
+ TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
|
|
124
|
+ ui.goto_previous_screen_no_defer();
|
|
125
|
+ }
|
|
126
|
+ , []{ wait_for_probe = false; }
|
|
127
|
+ , GET_TEXT(MSG_LEVEL_CORNERS_RAISE)
|
|
128
|
+ , (const char*)nullptr, PSTR("")
|
|
129
|
+ );
|
|
130
|
+ });
|
|
131
|
+ ui.set_selection(true);
|
|
132
|
+
|
|
133
|
+ wait_for_probe = true;
|
|
134
|
+ while (wait_for_probe && !probe_triggered) {
|
|
135
|
+ probe_triggered = PROBE_TRIGGERED();
|
|
136
|
+ if (probe_triggered) PROBE_BUZZ();
|
|
137
|
+ idle();
|
|
138
|
+ }
|
|
139
|
+ wait_for_probe = false;
|
|
140
|
+
|
|
141
|
+ TERN_(LEVEL_CORNERS_VERIFY_RAISED, verify_corner = true);
|
|
142
|
+ }
|
|
143
|
+
|
|
144
|
+ TERN_(QUIET_PROBING, probe.set_probing_paused(false));
|
|
145
|
+
|
|
146
|
+ #if ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
|
|
147
|
+ bltouch.stow();
|
|
148
|
+ #endif
|
|
149
|
+
|
|
150
|
+ if (probe_triggered) {
|
|
151
|
+ endstops.hit_on_purpose();
|
|
152
|
+ if (!WITHIN(current_position.z, last_z - (LEVEL_CORNERS_PROBE_TOLERANCE), last_z + (LEVEL_CORNERS_PROBE_TOLERANCE))) {
|
|
153
|
+ last_z = current_position.z;
|
|
154
|
+ good_points = 0;
|
|
155
|
+ }
|
|
156
|
+ if (!verify_corner) good_points++;
|
|
157
|
+ }
|
|
158
|
+
|
|
159
|
+ if (!corner_probing_done) {
|
|
160
|
+ if (!verify_corner) bed_corner++;
|
|
161
|
+ if (bed_corner > 3) bed_corner = 0;
|
|
162
|
+ verify_corner = false;
|
|
163
|
+ if (good_points < 4)
|
|
164
|
+ _lcd_level_bed_corners_probing();
|
|
165
|
+ else {
|
|
166
|
+ ui.goto_screen([]{
|
|
167
|
+ MenuItem_confirm::confirm_screen(
|
|
168
|
+ []{ ui.goto_previous_screen_no_defer();
|
|
169
|
+ queue.inject_P(TERN(HAS_LEVELING, PSTR("G28\nG29"), G28_STR));
|
|
170
|
+ }
|
|
171
|
+ , []{ ui.goto_previous_screen_no_defer(); }
|
|
172
|
+ , GET_TEXT(MSG_LEVEL_CORNERS_IN_RANGE)
|
|
173
|
+ , (const char*)nullptr, PSTR("?")
|
|
174
|
+ );
|
|
175
|
+ });
|
|
176
|
+ ui.set_selection(true);
|
|
177
|
+ }
|
|
178
|
+ }
|
70
|
179
|
}
|
71
|
|
- line_to_current_position(manual_feedrate_mm_s.x);
|
72
|
|
- line_to_z(LEVEL_CORNERS_HEIGHT);
|
73
|
|
- if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0;
|
74
|
|
-}
|
|
180
|
+
|
|
181
|
+#else
|
|
182
|
+
|
|
183
|
+ static inline void _lcd_goto_next_corner() {
|
|
184
|
+ constexpr float lfrb[4] = LEVEL_CORNERS_INSET_LFRB;
|
|
185
|
+ constexpr xy_pos_t lf { (X_MIN_BED) + lfrb[0], (Y_MIN_BED) + lfrb[1] },
|
|
186
|
+ rb { (X_MAX_BED) - lfrb[2], (Y_MAX_BED) - lfrb[3] };
|
|
187
|
+ line_to_z(LEVEL_CORNERS_Z_HOP);
|
|
188
|
+ switch (bed_corner) {
|
|
189
|
+ case 0: current_position = lf; break;
|
|
190
|
+ case 1: current_position.x = rb.x; break;
|
|
191
|
+ case 2: current_position.y = rb.y; break;
|
|
192
|
+ case 3: current_position.x = lf.x; break;
|
|
193
|
+ #if ENABLED(LEVEL_CENTER_TOO)
|
|
194
|
+ case 4: current_position.set(X_CENTER, Y_CENTER); break;
|
|
195
|
+ #endif
|
|
196
|
+ }
|
|
197
|
+ line_to_current_position(manual_feedrate_mm_s.x);
|
|
198
|
+ line_to_z(LEVEL_CORNERS_HEIGHT);
|
|
199
|
+ if (++bed_corner > 3 + ENABLED(LEVEL_CENTER_TOO)) bed_corner = 0;
|
|
200
|
+ }
|
|
201
|
+
|
|
202
|
+#endif
|
75
|
203
|
|
76
|
204
|
static inline void _lcd_level_bed_corners_homing() {
|
77
|
205
|
_lcd_draw_homing();
|
78
|
206
|
if (all_axes_homed()) {
|
79
|
|
- bed_corner = 0;
|
80
|
|
- ui.goto_screen([]{
|
81
|
|
- MenuItem_confirm::select_screen(
|
82
|
|
- GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE)
|
83
|
|
- , _lcd_goto_next_corner
|
84
|
|
- , []{
|
85
|
|
- TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
|
86
|
|
- ui.goto_previous_screen_no_defer();
|
87
|
|
- }
|
88
|
|
- , GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER))
|
89
|
|
- , (const char*)nullptr, PSTR("?")
|
90
|
|
- );
|
91
|
|
- });
|
92
|
|
- ui.set_selection(true);
|
93
|
|
- _lcd_goto_next_corner();
|
|
207
|
+ #if ENABLED(LEVEL_CORNERS_USE_PROBE)
|
|
208
|
+ TERN_(LEVEL_CENTER_TOO, bed_corner = 4);
|
|
209
|
+ endstops.enable_z_probe(true);
|
|
210
|
+ ui.goto_screen(_lcd_level_bed_corners_probing);
|
|
211
|
+ #else
|
|
212
|
+ bed_corner = 0;
|
|
213
|
+ ui.goto_screen([]{
|
|
214
|
+ MenuItem_confirm::select_screen(
|
|
215
|
+ GET_TEXT(MSG_BUTTON_NEXT), GET_TEXT(MSG_BUTTON_DONE)
|
|
216
|
+ , _lcd_goto_next_corner
|
|
217
|
+ , []{
|
|
218
|
+ TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
|
|
219
|
+ ui.goto_previous_screen_no_defer();
|
|
220
|
+ }
|
|
221
|
+ , GET_TEXT(TERN(LEVEL_CENTER_TOO, MSG_LEVEL_BED_NEXT_POINT, MSG_NEXT_CORNER))
|
|
222
|
+ , (const char*)nullptr, PSTR("?")
|
|
223
|
+ );
|
|
224
|
+ });
|
|
225
|
+ ui.set_selection(true);
|
|
226
|
+ _lcd_goto_next_corner();
|
|
227
|
+ #endif
|
94
|
228
|
}
|
95
|
229
|
}
|
96
|
230
|
|
|
@@ -107,6 +241,13 @@ void _lcd_level_bed_corners() {
|
107
|
241
|
set_bed_leveling_enabled(false);
|
108
|
242
|
#endif
|
109
|
243
|
|
|
244
|
+ #if ENABLED(LEVEL_CORNERS_USE_PROBE)
|
|
245
|
+ last_z = LEVEL_CORNERS_HEIGHT;
|
|
246
|
+ corner_probing_done = false;
|
|
247
|
+ verify_corner = false;
|
|
248
|
+ good_points = 0;
|
|
249
|
+ #endif
|
|
250
|
+
|
110
|
251
|
ui.goto_screen(_lcd_level_bed_corners_homing);
|
111
|
252
|
}
|
112
|
253
|
|