Browse Source

🚸 More ExtUI events for ABL / UBL

Scott Lahteine 2 years ago
parent
commit
fe745fdef0
2 changed files with 30 additions and 25 deletions
  1. 7
    0
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  2. 23
    25
      Marlin/src/gcode/bedlevel/abl/G29.cpp

+ 7
- 0
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

@@ -762,6 +762,7 @@ void unified_bed_leveling::shift_mesh_height() {
762 762
     probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
763 763
 
764 764
     TERN_(HAS_MARLINUI_MENU, ui.capture());
765
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
765 766
 
766 767
     save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
767 768
     uint8_t count = GRID_MAX_POINTS;
@@ -783,6 +784,7 @@ void unified_bed_leveling::shift_mesh_height() {
783 784
           ui.quick_feedback();
784 785
           ui.release();
785 786
           probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW
787
+          TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
786 788
           return restore_ubl_active_state_and_leave();
787 789
         }
788 790
       #endif
@@ -822,6 +824,8 @@ void unified_bed_leveling::shift_mesh_height() {
822 824
       constrain(nearby.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X),
823 825
       constrain(nearby.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
824 826
     );
827
+
828
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
825 829
   }
826 830
 
827 831
 #endif // HAS_BED_PROBE
@@ -921,6 +925,7 @@ void set_message_with_feedback(FSTR_P const fstr) {
921 925
    */
922 926
   void unified_bed_leveling::manually_probe_remaining_mesh(const xy_pos_t &pos, const_float_t z_clearance, const_float_t thick, const bool do_ubl_mesh_map) {
923 927
     ui.capture();
928
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
924 929
 
925 930
     save_ubl_active_state_and_disable();  // No bed level correction so only raw data is obtained
926 931
     do_blocking_move_to_xy_z(current_position, z_clearance);
@@ -984,6 +989,8 @@ void set_message_with_feedback(FSTR_P const fstr) {
984 989
 
985 990
     restore_ubl_active_state_and_leave();
986 991
     do_blocking_move_to_xy_z(pos, Z_CLEARANCE_DEPLOY_PROBE);
992
+
993
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
987 994
   }
988 995
 
989 996
   /**

+ 23
- 25
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -74,10 +74,14 @@
74 74
   #endif
75 75
 #endif
76 76
 
77
-#define G29_RETURN(retry) do{ \
77
+#define G29_RETURN(retry, did) do{ \
78 78
   if (TERN(G29_RETRY_AND_RECOVER, !retry, true)) { \
79 79
     TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE, false)); \
80 80
   } \
81
+  if (did) { \
82
+    TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone()); \
83
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone()); \
84
+  } \
81 85
   return TERN_(G29_RETRY_AND_RECOVER, retry); \
82 86
 }while(0)
83 87
 
@@ -233,7 +237,7 @@ G29_TYPE GcodeSuite::G29() {
233 237
   // G29 Q is also available if debugging
234 238
   #if ENABLED(DEBUG_LEVELING_FEATURE)
235 239
     if (seenQ || DEBUGGING(LEVELING)) log_machine_info();
236
-    if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false);
240
+    if (DISABLED(PROBE_MANUALLY) && seenQ) G29_RETURN(false, false);
237 241
   #endif
238 242
 
239 243
   // A = Abort manual probing
@@ -245,7 +249,7 @@ G29_TYPE GcodeSuite::G29() {
245 249
   // O = Don't level if leveling is already active
246 250
   if (!no_action && planner.leveling_active && parser.boolval('O')) {
247 251
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");
248
-    G29_RETURN(false);
252
+    G29_RETURN(false, false);
249 253
   }
250 254
 
251 255
   // Send 'N' to force homing before G29 (internal only)
@@ -253,7 +257,7 @@ G29_TYPE GcodeSuite::G29() {
253 257
     process_subcommands_now(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
254 258
 
255 259
   // Don't allow auto-leveling without homing first
256
-  if (homing_needed_error()) G29_RETURN(false);
260
+  if (homing_needed_error()) G29_RETURN(false, false);
257 261
 
258 262
   // 3-point leveling gets points from the probe class
259 263
   #if ENABLED(AUTO_BED_LEVELING_3POINT)
@@ -291,13 +295,13 @@ G29_TYPE GcodeSuite::G29() {
291 295
       if (seen_w) {
292 296
         if (!leveling_is_valid()) {
293 297
           SERIAL_ERROR_MSG("No bilinear grid");
294
-          G29_RETURN(false);
298
+          G29_RETURN(false, false);
295 299
         }
296 300
 
297 301
         const float rz = parser.seenval('Z') ? RAW_Z_POSITION(parser.value_linear_units()) : current_position.z;
298 302
         if (!WITHIN(rz, -10, 10)) {
299 303
           SERIAL_ERROR_MSG("Bad Z value");
300
-          G29_RETURN(false);
304
+          G29_RETURN(false, false);
301 305
         }
302 306
 
303 307
         const float rx = RAW_X_POSITION(parser.linearval('X', NAN)),
@@ -325,7 +329,7 @@ G29_TYPE GcodeSuite::G29() {
325 329
           set_bed_leveling_enabled(abl.reenable);
326 330
           if (abl.reenable) report_current_position();
327 331
         }
328
-        G29_RETURN(false);
332
+        G29_RETURN(false, false);
329 333
       } // parser.seen_test('W')
330 334
 
331 335
     #else
@@ -337,13 +341,13 @@ G29_TYPE GcodeSuite::G29() {
337 341
     // Jettison bed leveling data
338 342
     if (!seen_w && parser.seen_test('J')) {
339 343
       reset_bed_level();
340
-      G29_RETURN(false);
344
+      G29_RETURN(false, false);
341 345
     }
342 346
 
343 347
     abl.verbose_level = parser.intval('V');
344 348
     if (!WITHIN(abl.verbose_level, 0, 4)) {
345 349
       SERIAL_ECHOLNPGM("?(V)erbose level implausible (0-4).");
346
-      G29_RETURN(false);
350
+      G29_RETURN(false, false);
347 351
     }
348 352
 
349 353
     abl.dryrun = parser.boolval('D') || TERN0(PROBE_MANUALLY, no_action);
@@ -364,11 +368,11 @@ G29_TYPE GcodeSuite::G29() {
364 368
 
365 369
       if (!WITHIN(abl.grid_points.x, 2, GRID_MAX_POINTS_X)) {
366 370
         SERIAL_ECHOLNPGM("?Probe points (X) implausible (2-" STRINGIFY(GRID_MAX_POINTS_X) ").");
367
-        G29_RETURN(false);
371
+        G29_RETURN(false, false);
368 372
       }
369 373
       if (!WITHIN(abl.grid_points.y, 2, GRID_MAX_POINTS_Y)) {
370 374
         SERIAL_ECHOLNPGM("?Probe points (Y) implausible (2-" STRINGIFY(GRID_MAX_POINTS_Y) ").");
371
-        G29_RETURN(false);
375
+        G29_RETURN(false, false);
372 376
       }
373 377
 
374 378
       abl.abl_points = abl.grid_points.x * abl.grid_points.y;
@@ -403,7 +407,7 @@ G29_TYPE GcodeSuite::G29() {
403 407
                               " F", abl.probe_position_lf.y, " B", abl.probe_position_rb.y);
404 408
         }
405 409
         SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds.");
406
-        G29_RETURN(false);
410
+        G29_RETURN(false, false);
407 411
       }
408 412
 
409 413
       // Probe at the points of a lattice grid
@@ -420,8 +424,6 @@ G29_TYPE GcodeSuite::G29() {
420 424
 
421 425
     planner.synchronize();
422 426
 
423
-    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
424
-
425 427
     #if ENABLED(AUTO_BED_LEVELING_3POINT)
426 428
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
427 429
       points[0].z = points[1].z = points[2].z = 0;  // Probe at 3 arbitrary points
@@ -429,6 +431,8 @@ G29_TYPE GcodeSuite::G29() {
429 431
       TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LevelingStart());
430 432
     #endif
431 433
 
434
+    TERN_(EXTENSIBLE_UI, ExtUI::onLevelingStart());
435
+
432 436
     if (!faux) {
433 437
       remember_feedrate_scaling_off();
434 438
 
@@ -483,7 +487,7 @@ G29_TYPE GcodeSuite::G29() {
483 487
     #elif HAS_BED_PROBE
484 488
       if (probe.deploy()) { // (returns true on deploy failure)
485 489
         set_bed_leveling_enabled(abl.reenable);
486
-        G29_RETURN(false);
490
+        G29_RETURN(false, true);
487 491
       }
488 492
     #endif
489 493
 
@@ -529,7 +533,7 @@ G29_TYPE GcodeSuite::G29() {
529 533
     }
530 534
 
531 535
     // For 'A' or 'Q' exit with success state
532
-    if (no_action) G29_RETURN(false);
536
+    if (no_action) G29_RETURN(false, true);
533 537
 
534 538
     if (abl.abl_probe_index == 0) {
535 539
       // For the initial G29 S2 save software endstop state
@@ -604,14 +608,13 @@ G29_TYPE GcodeSuite::G29() {
604 608
         // Disable software endstops to allow manual adjustment
605 609
         // If G29 is not completed, they will not be re-enabled
606 610
         SET_SOFT_ENDSTOP_LOOSE(true);
607
-        G29_RETURN(false);
611
+        G29_RETURN(false, true);
608 612
       }
609 613
       else {
610 614
         // Leveling done! Fall through to G29 finishing code below
611 615
         SERIAL_ECHOLNPGM("Grid probing done.");
612 616
         // Re-enable software endstops, if needed
613 617
         SET_SOFT_ENDSTOP_LOOSE(false);
614
-        TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
615 618
       }
616 619
 
617 620
     #elif ENABLED(AUTO_BED_LEVELING_3POINT)
@@ -623,7 +626,7 @@ G29_TYPE GcodeSuite::G29() {
623 626
         // Disable software endstops to allow manual adjustment
624 627
         // If G29 is not completed, they will not be re-enabled
625 628
         SET_SOFT_ENDSTOP_LOOSE(true);
626
-        G29_RETURN(false);
629
+        G29_RETURN(false, true);
627 630
       }
628 631
       else {
629 632
 
@@ -641,8 +644,6 @@ G29_TYPE GcodeSuite::G29() {
641 644
           abl.reenable = false;
642 645
         }
643 646
 
644
-        TERN_(EXTENSIBLE_UI, ExtUI::onLevelingDone());
645
-
646 647
       }
647 648
 
648 649
     #endif // AUTO_BED_LEVELING_3POINT
@@ -938,14 +939,11 @@ G29_TYPE GcodeSuite::G29() {
938 939
     process_subcommands_now(F(Z_PROBE_END_SCRIPT));
939 940
   #endif
940 941
 
941
-  TERN_(HAS_DWIN_E3V2_BASIC, DWIN_LevelingDone());
942
-
943 942
   TERN_(HAS_MULTI_HOTEND, if (abl.tool_index != 0) tool_change(abl.tool_index));
944 943
 
945 944
   report_current_position();
946 945
 
947
-  G29_RETURN(isnan(abl.measured_z));
948
-
946
+  G29_RETURN(isnan(abl.measured_z), true);
949 947
 }
950 948
 
951 949
 #endif // HAS_ABL_NOT_UBL

Loading…
Cancel
Save