43
43
#define BED_TRAMMING_HEIGHT 0.0
44
44
#endif
45
45
46
+ #if BOTH(HAS_STOWABLE_PROBE, BED_TRAMMING_USE_PROBE) && DISABLED(BLTOUCH)
47
+ #define NEEDS_PROBE_DEPLOY 1
48
+ #endif
49
+
46
50
#if ENABLED(BED_TRAMMING_USE_PROBE)
47
51
#include " ../../module/probe.h"
48
52
#include " ../../module/endstops.h"
@@ -97,62 +101,68 @@ constexpr xy_pos_t lf { (X_MIN_BED) + inset_lfrb[0], (Y_MIN_BED) + inset_lfrb[1]
97
101
static int8_t bed_corner;
98
102
99
103
/* *
100
- * Select next corner coordinates
104
+ * Move to the next corner coordinates
101
105
*/
102
- static void _lcd_bed_tramming_get_next_position () {
106
+ static void _lcd_goto_next_corner () {
107
+ xy_pos_t corner_point = lf; // Left front
103
108
104
109
if (tramming_3_points) {
105
110
if (bed_corner >= available_points) bed_corner = 0 ; // Above max position -> move back to first corner
106
111
switch (bed_corner) {
107
112
case 0 ... 1 :
108
113
// First two corners set explicitly by the configuration
109
- current_position = lf; // Left front
110
114
switch (lco[bed_corner]) {
111
- case RF: current_position .x = rb.x ; break ; // Right Front
112
- case RB: current_position = rb; break ; // Right Back
113
- case LB: current_position .y = rb.y ; break ; // Left Back
115
+ case RF: corner_point .x = rb.x ; break ; // Right Front
116
+ case RB: corner_point = rb; break ; // Right Back
117
+ case LB: corner_point .y = rb.y ; break ; // Left Back
114
118
}
115
119
break ;
116
120
117
121
case 2 :
118
122
// Determine which edge to probe for 3rd point
119
- current_position .set (lf.x + (rb.x - lf.x ) / 2 , lf.y + (rb.y - lf.y ) / 2 );
120
- if ((lco[0 ] == LB && lco[1 ] == RB) || (lco[0 ] == RB && lco[1 ] == LB)) current_position .y = lf.y ; // Front Center
121
- if ((lco[0 ] == LF && lco[1 ] == LB) || (lco[0 ] == LB && lco[1 ] == LF)) current_position .x = rb.x ; // Center Right
122
- if ((lco[0 ] == RF && lco[1 ] == RB) || (lco[0 ] == RB && lco[1 ] == RF)) current_position .x = lf.x ; // Left Center
123
- if ((lco[0 ] == LF && lco[1 ] == RF) || (lco[0 ] == RF && lco[1 ] == LF)) current_position .y = rb.y ; // Center Back
124
- #if DISABLED(BED_TRAMMING_INCLUDE_CENTER ) && ENABLED(BED_TRAMMING_USE_PROBE )
123
+ corner_point .set (lf.x + (rb.x - lf.x ) / 2 , lf.y + (rb.y - lf.y ) / 2 );
124
+ if ((lco[0 ] == LB && lco[1 ] == RB) || (lco[0 ] == RB && lco[1 ] == LB)) corner_point .y = lf.y ; // Front Center
125
+ if ((lco[0 ] == LF && lco[1 ] == LB) || (lco[0 ] == LB && lco[1 ] == LF)) corner_point .x = rb.x ; // Center Right
126
+ if ((lco[0 ] == RF && lco[1 ] == RB) || (lco[0 ] == RB && lco[1 ] == RF)) corner_point .x = lf.x ; // Left Center
127
+ if ((lco[0 ] == LF && lco[1 ] == RF) || (lco[0 ] == RF && lco[1 ] == LF)) corner_point .y = rb.y ; // Center Back
128
+ #if ENABLED(BED_TRAMMING_USE_PROBE ) && DISABLED(BED_TRAMMING_INCLUDE_CENTER )
125
129
bed_corner++; // Must increment the count to ensure it resets the loop if the 3rd point is out of tolerance
126
130
#endif
127
131
break ;
128
132
129
133
#if ENABLED(BED_TRAMMING_INCLUDE_CENTER)
130
134
case 3 :
131
- current_position .set (X_CENTER, Y_CENTER);
135
+ corner_point .set (X_CENTER, Y_CENTER);
132
136
break ;
133
137
#endif
134
138
}
135
139
}
136
140
else {
137
141
// Four-Corner Bed Tramming with optional center
138
142
if (TERN0 (BED_TRAMMING_INCLUDE_CENTER, bed_corner == center_index)) {
139
- current_position.set (X_CENTER, Y_CENTER);
140
- TERN_ (BED_TRAMMING_USE_PROBE, good_points--); // Decrement to allow one additional probe point
143
+ corner_point.set (X_CENTER, Y_CENTER);
141
144
}
142
145
else {
143
- current_position = lf; // Left front
144
146
switch (lco[bed_corner]) {
145
- case RF: current_position .x = rb.x ; break ; // Right Front
146
- case RB: current_position = rb; break ; // Right Back
147
- case LB: current_position .y = rb.y ; break ; // Left Back
147
+ case RF: corner_point .x = rb.x ; break ; // Right Front
148
+ case RB: corner_point = rb; break ; // Right Back
149
+ case LB: corner_point .y = rb.y ; break ; // Left Back
148
150
}
149
151
}
150
152
}
153
+
154
+ float z = BED_TRAMMING_Z_HOP;
155
+ #if BOTH(BED_TRAMMING_USE_PROBE, BLTOUCH)
156
+ z += bltouch.z_extra_clearance ();
157
+ #endif
158
+ line_to_z (z);
159
+ do_blocking_move_to_xy (DIFF_TERN (BED_TRAMMING_USE_PROBE, corner_point, probe.offset_xy ), manual_feedrate_mm_s.x );
160
+ #if DISABLED(BED_TRAMMING_USE_PROBE)
161
+ line_to_z (BED_TRAMMING_HEIGHT);
162
+ if (++bed_corner >= available_points) bed_corner = 0 ;
163
+ #endif
151
164
}
152
165
153
- /* *
154
- * Level corners, starting in the front-left corner.
155
- */
156
166
#if ENABLED(BED_TRAMMING_USE_PROBE)
157
167
158
168
#define VALIDATE_POINT (X, Y, STR ) static_assert(Probe::build_time::can_reach((X), (Y)), \
@@ -210,13 +220,21 @@ static void _lcd_bed_tramming_get_next_position() {
210
220
MenuItem_confirm::select_screen (
211
221
GET_TEXT_F (TERN (HAS_LEVELING, MSG_BUTTON_LEVEL, MSG_BUTTON_DONE))
212
222
, TERN (HAS_LEVELING, GET_TEXT_F (MSG_BUTTON_BACK), nullptr )
213
- , []{ queue.inject (TERN (HAS_LEVELING, F (" G29N" ), FPSTR (G28_STR))); ui.return_to_status (); }
214
- , TERN (HAS_LEVELING, ui.goto_previous_screen_no_defer , []{})
223
+ , []{
224
+ tramming_done = true ;
225
+ queue.inject (TERN (HAS_LEVELING, F (" G29N" ), FPSTR (G28_STR)));
226
+ ui.goto_previous_screen_no_defer ();
227
+ }
228
+ , []{
229
+ tramming_done = true ;
230
+ TERN_ (HAS_LEVELING, ui.goto_previous_screen_no_defer ());
231
+ TERN_ (NEEDS_PROBE_DEPLOY, probe.stow (true ));
232
+ }
215
233
, GET_TEXT_F (MSG_BED_TRAMMING_IN_RANGE)
216
234
);
217
235
}
218
236
219
- bool _lcd_bed_tramming_probe (bool verify=false ) {
237
+ bool _lcd_bed_tramming_probe (const bool verify=false ) {
220
238
if (verify) line_to_z (BED_TRAMMING_Z_HOP); // do clearance if needed
221
239
TERN_ (BLTOUCH, if (!bltouch.high_speed_mode ) bltouch.deploy ()); // Deploy in LOW SPEED MODE on every probe action
222
240
do_blocking_move_to_z (last_z - BED_TRAMMING_PROBE_TOLERANCE, MMM_TO_MMS (Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
@@ -232,6 +250,11 @@ static void _lcd_bed_tramming_get_next_position() {
232
250
last_z = current_position.z ; // Above tolerance. Set a new Z for subsequent corners.
233
251
good_points = 0 ; // ...and start over
234
252
}
253
+
254
+ // Raise the probe after the last point to give clearance for stow
255
+ if (TERN0 (NEEDS_PROBE_DEPLOY, good_points == nr_edge_points - 1 ))
256
+ line_to_z (BED_TRAMMING_Z_HOP);
257
+
235
258
return true ; // probe triggered
236
259
}
237
260
line_to_z (last_z); // go back to tolerance middle point before raise
@@ -267,11 +290,7 @@ static void _lcd_bed_tramming_get_next_position() {
267
290
ui.refresh (LCDVIEW_REDRAW_NOW);
268
291
_lcd_draw_probing (); // update screen with # of good points
269
292
270
- line_to_z (current_position.z + BED_TRAMMING_Z_HOP + TERN0 (BLTOUCH, bltouch.z_extra_clearance ())); // clearance
271
-
272
- _lcd_bed_tramming_get_next_position (); // Select next corner coordinates
273
- current_position -= probe.offset_xy ; // Account for probe offsets
274
- do_blocking_move_to_xy (current_position); // Goto corner
293
+ _lcd_goto_next_corner (); // Goto corner
275
294
276
295
TERN_ (BLTOUCH, if (bltouch.high_speed_mode ) bltouch.deploy ()); // Deploy in HIGH SPEED MODE
277
296
if (!_lcd_bed_tramming_probe ()) { // Probe down to tolerance
@@ -306,31 +325,26 @@ static void _lcd_bed_tramming_get_next_position() {
306
325
ui.set_selection (true );
307
326
}
308
327
309
- #else // !BED_TRAMMING_USE_PROBE
310
-
311
- static void _lcd_goto_next_corner () {
312
- line_to_z (BED_TRAMMING_Z_HOP);
313
-
314
- // Select next corner coordinates
315
- _lcd_bed_tramming_get_next_position ();
316
-
317
- line_to_current_position (manual_feedrate_mm_s.x );
318
- line_to_z (BED_TRAMMING_HEIGHT);
319
- if (++bed_corner >= available_points) bed_corner = 0 ;
320
- }
321
-
322
- #endif // !BED_TRAMMING_USE_PROBE
328
+ #endif // BED_TRAMMING_USE_PROBE
323
329
324
330
void _lcd_bed_tramming_homing () {
325
- _lcd_draw_homing ();
326
- if (!all_axes_homed ()) return ;
331
+ if (!all_axes_homed () && TERN1 (NEEDS_PROBE_DEPLOY, probe.deploy ())) return ;
332
+
333
+ #if HAS_LEVELING // Disable leveling so the planner won't mess with us
334
+ menu_leveling_was_active = planner.leveling_active ;
335
+ set_bed_leveling_enabled (false );
336
+ #endif
327
337
328
338
#if ENABLED(BED_TRAMMING_USE_PROBE)
329
339
330
- _lcd_test_corners ();
331
- if (tramming_done) ui.goto_previous_screen_no_defer ();
340
+ if (!tramming_done) _lcd_test_corners (); // May set tramming_done
341
+ if (tramming_done) {
342
+ ui.goto_previous_screen_no_defer ();
343
+ TERN_ (NEEDS_PROBE_DEPLOY, probe.stow (true ));
344
+ }
345
+ tramming_done = true ;
332
346
TERN_ (HAS_LEVELING, set_bed_leveling_enabled (menu_leveling_was_active));
333
- endstops.enable_z_probe (false );
347
+ TERN_ (BLTOUCH, endstops.enable_z_probe (false ) );
334
348
335
349
#else // !BED_TRAMMING_USE_PROBE
336
350
@@ -354,20 +368,28 @@ void _lcd_bed_tramming_homing() {
354
368
#endif // !BED_TRAMMING_USE_PROBE
355
369
}
356
370
357
- void _lcd_bed_tramming () {
358
- ui.defer_status_screen ();
359
- if (!all_axes_trusted ()) {
360
- set_all_unhomed ();
361
- queue.inject_P (G28_STR);
371
+ #if NEEDS_PROBE_DEPLOY
372
+
373
+ void deploy_probe () {
374
+ if (!tramming_done) probe.deploy (true );
375
+ ui.goto_screen ([]{
376
+ if (ui.should_draw ()) MenuItem_static::draw ((LCD_HEIGHT - 1 ) / 2 , GET_TEXT_F (MSG_MANUAL_DEPLOY));
377
+ if (!probe.deploy () && !tramming_done) _lcd_bed_tramming_homing ();
378
+ });
362
379
}
363
380
364
- // Disable leveling so the planner won't mess with us
365
- #if HAS_LEVELING
366
- menu_leveling_was_active = planner.leveling_active ;
367
- set_bed_leveling_enabled (false );
368
- #endif
381
+ #endif // NEEDS_PROBE_DEPLOY
369
382
370
- ui.goto_screen (_lcd_bed_tramming_homing);
383
+ void _lcd_bed_tramming () {
384
+ TERN_ (BED_TRAMMING_USE_PROBE, tramming_done = false );
385
+ ui.defer_status_screen ();
386
+ set_all_unhomed ();
387
+ queue.inject (TERN (CAN_SET_LEVELING_AFTER_G28, F (" G28L0" ), FPSTR (G28_STR)));
388
+ ui.goto_screen ([]{
389
+ _lcd_draw_homing ();
390
+ if (!all_axes_homed ()) return ;
391
+ TERN (NEEDS_PROBE_DEPLOY, deploy_probe (), ui.goto_screen (_lcd_bed_tramming_homing));
392
+ });
371
393
}
372
394
373
395
#endif // HAS_MARLINUI_MENU && LCD_BED_TRAMMING
0 commit comments