|
@@ -62,6 +62,12 @@
|
62
|
62
|
#endif
|
63
|
63
|
#endif
|
64
|
64
|
|
|
65
|
+#if ENABLED(G29_RETRY_AND_RECOVER)
|
|
66
|
+ #define G29_RETURN(b) return b;
|
|
67
|
+#else
|
|
68
|
+ #define G29_RETURN(b) return;
|
|
69
|
+#endif
|
|
70
|
+
|
65
|
71
|
/**
|
66
|
72
|
* G29: Detailed Z probe, probes the bed at 3 or more points.
|
67
|
73
|
* Will fail if the printer has not been homed with G28.
|
|
@@ -136,7 +142,7 @@
|
136
|
142
|
* There's no extra effect if you have a fixed Z probe.
|
137
|
143
|
*
|
138
|
144
|
*/
|
139
|
|
-void GcodeSuite::G29() {
|
|
145
|
+G29_TYPE GcodeSuite::G29() {
|
140
|
146
|
|
141
|
147
|
#if ENABLED(DEBUG_LEVELING_FEATURE) || ENABLED(PROBE_MANUALLY)
|
142
|
148
|
const bool seenQ = parser.seen('Q');
|
|
@@ -154,7 +160,7 @@ void GcodeSuite::G29() {
|
154
|
160
|
}
|
155
|
161
|
marlin_debug_flags = old_debug_flags;
|
156
|
162
|
#if DISABLED(PROBE_MANUALLY)
|
157
|
|
- if (seenQ) return;
|
|
163
|
+ if (seenQ) G29_RETURN(false);
|
158
|
164
|
#endif
|
159
|
165
|
#endif
|
160
|
166
|
|
|
@@ -174,7 +180,7 @@ void GcodeSuite::G29() {
|
174
|
180
|
;
|
175
|
181
|
|
176
|
182
|
// Don't allow auto-leveling without homing first
|
177
|
|
- if (axis_unhomed_error()) return;
|
|
183
|
+ if (axis_unhomed_error()) G29_RETURN(false);
|
178
|
184
|
|
179
|
185
|
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
|
180
|
186
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
|
@@ -183,7 +189,7 @@ void GcodeSuite::G29() {
|
183
|
189
|
SERIAL_ECHOLNPGM("<<< G29");
|
184
|
190
|
}
|
185
|
191
|
#endif
|
186
|
|
- return;
|
|
192
|
+ G29_RETURN(false);
|
187
|
193
|
}
|
188
|
194
|
|
189
|
195
|
// Define local vars 'static' for manual probing, 'auto' otherwise
|
|
@@ -285,14 +291,14 @@ void GcodeSuite::G29() {
|
285
|
291
|
if (!leveling_is_valid()) {
|
286
|
292
|
SERIAL_ERROR_START();
|
287
|
293
|
SERIAL_ERRORLNPGM("No bilinear grid");
|
288
|
|
- return;
|
|
294
|
+ G29_RETURN(false);
|
289
|
295
|
}
|
290
|
296
|
|
291
|
297
|
const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position[Z_AXIS];
|
292
|
298
|
if (!WITHIN(rz, -10, 10)) {
|
293
|
299
|
SERIAL_ERROR_START();
|
294
|
300
|
SERIAL_ERRORLNPGM("Bad Z value");
|
295
|
|
- return;
|
|
301
|
+ G29_RETURN(false);
|
296
|
302
|
}
|
297
|
303
|
|
298
|
304
|
const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
|
|
@@ -316,7 +322,7 @@ void GcodeSuite::G29() {
|
316
|
322
|
set_bed_leveling_enabled(abl_should_enable);
|
317
|
323
|
if (abl_should_enable) report_current_position();
|
318
|
324
|
}
|
319
|
|
- return;
|
|
325
|
+ G29_RETURN(false);
|
320
|
326
|
} // parser.seen('W')
|
321
|
327
|
|
322
|
328
|
#else
|
|
@@ -328,13 +334,13 @@ void GcodeSuite::G29() {
|
328
|
334
|
// Jettison bed leveling data
|
329
|
335
|
if (!seen_w && parser.seen('J')) {
|
330
|
336
|
reset_bed_level();
|
331
|
|
- return;
|
|
337
|
+ G29_RETURN(false);
|
332
|
338
|
}
|
333
|
339
|
|
334
|
340
|
verbose_level = parser.intval('V');
|
335
|
341
|
if (!WITHIN(verbose_level, 0, 4)) {
|
336
|
342
|
SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-4).");
|
337
|
|
- return;
|
|
343
|
+ G29_RETURN(false);
|
338
|
344
|
}
|
339
|
345
|
|
340
|
346
|
dryrun = parser.boolval('D')
|
|
@@ -355,11 +361,11 @@ void GcodeSuite::G29() {
|
355
|
361
|
|
356
|
362
|
if (!WITHIN(abl_grid_points_x, 2, GRID_MAX_POINTS_X)) {
|
357
|
363
|
SERIAL_PROTOCOLLNPGM("?Probe points (X) is implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ").");
|
358
|
|
- return;
|
|
364
|
+ G29_RETURN(false);
|
359
|
365
|
}
|
360
|
366
|
if (!WITHIN(abl_grid_points_y, 2, GRID_MAX_POINTS_Y)) {
|
361
|
367
|
SERIAL_PROTOCOLLNPGM("?Probe points (Y) is implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
|
362
|
|
- return;
|
|
368
|
+ G29_RETURN(false);
|
363
|
369
|
}
|
364
|
370
|
|
365
|
371
|
abl_points = abl_grid_points_x * abl_grid_points_y;
|
|
@@ -392,7 +398,7 @@ void GcodeSuite::G29() {
|
392
|
398
|
#endif
|
393
|
399
|
) {
|
394
|
400
|
SERIAL_PROTOCOLLNPGM("? (L,R,F,B) out of bounds.");
|
395
|
|
- return;
|
|
401
|
+ G29_RETURN(false);
|
396
|
402
|
}
|
397
|
403
|
|
398
|
404
|
// probe at the points of a lattice grid
|
|
@@ -417,7 +423,7 @@ void GcodeSuite::G29() {
|
417
|
423
|
// Deploy the probe. Probe will raise if needed.
|
418
|
424
|
if (DEPLOY_PROBE()) {
|
419
|
425
|
set_bed_leveling_enabled(abl_should_enable);
|
420
|
|
- return;
|
|
426
|
+ G29_RETURN(false);
|
421
|
427
|
}
|
422
|
428
|
#endif
|
423
|
429
|
|
|
@@ -494,7 +500,7 @@ void GcodeSuite::G29() {
|
494
|
500
|
SERIAL_PROTOCOLLNPGM("idle");
|
495
|
501
|
}
|
496
|
502
|
|
497
|
|
- if (no_action) return;
|
|
503
|
+ if (no_action) G29_RETURN(false);
|
498
|
504
|
|
499
|
505
|
if (abl_probe_index == 0) {
|
500
|
506
|
// For the initial G29 S2 save software endstop state
|
|
@@ -584,7 +590,7 @@ void GcodeSuite::G29() {
|
584
|
590
|
// If G29 is not completed, they will not be re-enabled
|
585
|
591
|
soft_endstops_enabled = false;
|
586
|
592
|
#endif
|
587
|
|
- return;
|
|
593
|
+ G29_RETURN(false);
|
588
|
594
|
}
|
589
|
595
|
else {
|
590
|
596
|
|
|
@@ -610,7 +616,7 @@ void GcodeSuite::G29() {
|
610
|
616
|
// If G29 is not completed, they will not be re-enabled
|
611
|
617
|
soft_endstops_enabled = false;
|
612
|
618
|
#endif
|
613
|
|
- return;
|
|
619
|
+ G29_RETURN(false);
|
614
|
620
|
}
|
615
|
621
|
else {
|
616
|
622
|
|
|
@@ -990,6 +996,8 @@ void GcodeSuite::G29() {
|
990
|
996
|
#endif
|
991
|
997
|
|
992
|
998
|
report_current_position();
|
|
999
|
+
|
|
1000
|
+ G29_RETURN(isnan(measured_z));
|
993
|
1001
|
}
|
994
|
1002
|
|
995
|
1003
|
#endif // OLDSCHOOL_ABL
|