소스 검색

Encapsulate probe as singleton class (#16751)

Scott Lahteine 4 년 전
부모
커밋
90b6324563
No account linked to committer's email address
33개의 변경된 파일338개의 추가작업 그리고 300개의 파일을 삭제
  1. 1
    1
      Marlin/src/MarlinCore.cpp
  2. 10
    10
      Marlin/src/core/utility.cpp
  3. 2
    2
      Marlin/src/feature/bedlevel/ubl/ubl.cpp
  4. 26
    26
      Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
  5. 3
    3
      Marlin/src/gcode/bedlevel/G42.cpp
  6. 2
    2
      Marlin/src/gcode/bedlevel/M420.cpp
  7. 10
    10
      Marlin/src/gcode/bedlevel/abl/G29.cpp
  8. 2
    2
      Marlin/src/gcode/calibrate/G28.cpp
  9. 2
    2
      Marlin/src/gcode/calibrate/G33.cpp
  10. 6
    6
      Marlin/src/gcode/calibrate/G34_M422.cpp
  11. 8
    8
      Marlin/src/gcode/calibrate/G76_M871.cpp
  12. 6
    6
      Marlin/src/gcode/calibrate/M48.cpp
  13. 7
    0
      Marlin/src/gcode/config/M304.cpp
  14. 3
    3
      Marlin/src/gcode/motion/M290.cpp
  15. 4
    4
      Marlin/src/gcode/probe/G30.cpp
  16. 2
    2
      Marlin/src/gcode/probe/G31_G32.cpp
  17. 3
    3
      Marlin/src/gcode/probe/M401_M402.cpp
  18. 4
    4
      Marlin/src/gcode/probe/M851.cpp
  19. 1
    1
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp
  20. 1
    1
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp
  21. 1
    1
      Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp
  22. 3
    3
      Marlin/src/lcd/extensible_ui/ui_api.cpp
  23. 4
    4
      Marlin/src/lcd/menu/menu.cpp
  24. 5
    3
      Marlin/src/lcd/menu/menu_advanced.cpp
  25. 1
    1
      Marlin/src/lcd/menu/menu_bed_leveling.cpp
  26. 1
    4
      Marlin/src/lcd/menu/menu_configuration.cpp
  27. 20
    15
      Marlin/src/module/configuration_store.cpp
  28. 2
    2
      Marlin/src/module/delta.cpp
  29. 10
    10
      Marlin/src/module/motion.cpp
  30. 4
    4
      Marlin/src/module/motion.h
  31. 2
    2
      Marlin/src/module/planner.cpp
  32. 57
    48
      Marlin/src/module/probe.cpp
  33. 125
    107
      Marlin/src/module/probe.h

+ 1
- 1
Marlin/src/MarlinCore.cpp 파일 보기

@@ -977,7 +977,7 @@ void setup() {
977 977
   #endif
978 978
 
979 979
   #if HAS_Z_SERVO_PROBE
980
-    servo_probe_init();
980
+    probe.servo_probe_init();
981 981
   #endif
982 982
 
983 983
   #if HAS_PHOTOGRAPH

+ 10
- 10
Marlin/src/core/utility.cpp 파일 보기

@@ -83,42 +83,42 @@ void safe_delay(millis_t ms) {
83 83
     #if HAS_BED_PROBE
84 84
 
85 85
       #if !HAS_PROBE_XY_OFFSET
86
-        SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " (");
86
+        SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe.offset.z, " (");
87 87
       #else
88
-        SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
89
-        if (probe_offset.x > 0)
88
+        SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR, probe.offset.z);
89
+        if (probe.offset_xy.x > 0)
90 90
           SERIAL_ECHOPGM(" (Right");
91
-        else if (probe_offset.x < 0)
91
+        else if (probe.offset_xy.x < 0)
92 92
           SERIAL_ECHOPGM(" (Left");
93
-        else if (probe_offset.y != 0)
93
+        else if (probe.offset_xy.y != 0)
94 94
           SERIAL_ECHOPGM(" (Middle");
95 95
         else
96 96
           SERIAL_ECHOPGM(" (Aligned With");
97 97
 
98
-        if (probe_offset.y > 0) {
98
+        if (probe.offset_xy.y > 0) {
99 99
           #if IS_SCARA
100 100
             SERIAL_ECHOPGM("-Distal");
101 101
           #else
102 102
             SERIAL_ECHOPGM("-Back");
103 103
           #endif
104 104
         }
105
-        else if (probe_offset.y < 0) {
105
+        else if (probe.offset_xy.y < 0) {
106 106
           #if IS_SCARA
107 107
             SERIAL_ECHOPGM("-Proximal");
108 108
           #else
109 109
             SERIAL_ECHOPGM("-Front");
110 110
           #endif
111 111
         }
112
-        else if (probe_offset.x != 0)
112
+        else if (probe.offset_xy.x != 0)
113 113
           SERIAL_ECHOPGM("-Center");
114 114
 
115 115
         SERIAL_ECHOPGM(" & ");
116 116
 
117 117
       #endif
118 118
 
119
-      if (probe_offset.z < 0)
119
+      if (probe.offset.z < 0)
120 120
         SERIAL_ECHOPGM("Below");
121
-      else if (probe_offset.z > 0)
121
+      else if (probe.offset.z > 0)
122 122
         SERIAL_ECHOPGM("Above");
123 123
       else
124 124
         SERIAL_ECHOPGM("Same Z as");

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl.cpp 파일 보기

@@ -173,10 +173,10 @@
173 173
       serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
174 174
     }
175 175
 
176
-    // Add XY probe offset from extruder because probe_at_point() subtracts them when
176
+    // Add XY probe offset from extruder because probe.probe_at_point() subtracts them when
177 177
     // moving to the XY position to be measured. This ensures better agreement between
178 178
     // the current Z position after G28 and the mesh values.
179
-    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy);
179
+    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe.offset_xy);
180 180
 
181 181
     if (!lcd) SERIAL_EOL();
182 182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

+ 26
- 26
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp 파일 보기

@@ -450,7 +450,7 @@
450 450
               SERIAL_ECHO(g29_pos.y);
451 451
               SERIAL_ECHOLNPGM(").\n");
452 452
             }
453
-            const xy_pos_t near = g29_pos + probe_offset_xy;
453
+            const xy_pos_t near = g29_pos + probe.offset_xy;
454 454
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
455 455
 
456 456
             report_current_position();
@@ -480,8 +480,8 @@
480 480
                 #if IS_KINEMATIC
481 481
                   X_HOME_POS, Y_HOME_POS
482 482
                 #else
483
-                  probe_offset_xy.x > 0 ? X_BED_SIZE : 0,
484
-                  probe_offset_xy.y < 0 ? Y_BED_SIZE : 0
483
+                  probe.offset_xy.x > 0 ? X_BED_SIZE : 0,
484
+                  probe.offset_xy.y < 0 ? Y_BED_SIZE : 0
485 485
                 #endif
486 486
               );
487 487
             }
@@ -742,7 +742,7 @@
742 742
      * This attempts to fill in locations closest to the nozzle's start location first.
743 743
      */
744 744
     void unified_bed_leveling::probe_entire_mesh(const xy_pos_t &near, const bool do_ubl_mesh_map, const bool stow_probe, const bool do_furthest) {
745
-      DEPLOY_PROBE(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
745
+      probe.deploy(); // Deploy before ui.capture() to allow for PAUSE_BEFORE_DEPLOY_STOW
746 746
 
747 747
       #if HAS_LCD_MENU
748 748
         ui.capture();
@@ -768,7 +768,7 @@
768 768
             ui.wait_for_release();
769 769
             ui.quick_feedback();
770 770
             ui.release();
771
-            STOW_PROBE(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW
771
+            probe.stow(); // Release UI before stow to allow for PAUSE_BEFORE_DEPLOY_STOW
772 772
             return restore_ubl_active_state_and_leave();
773 773
           }
774 774
         #endif
@@ -778,7 +778,7 @@
778 778
           : find_closest_mesh_point_of_type(INVALID, near, true);
779 779
 
780 780
         if (best.pos.x >= 0) {    // mesh point found and is reachable by probe
781
-          const float measured_z = probe_at_point(
781
+          const float measured_z = probe.probe_at_point(
782 782
                         best.meshpos(),
783 783
                         stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
784 784
                       );
@@ -794,20 +794,20 @@
794 794
       #if HAS_LCD_MENU
795 795
         ui.release();
796 796
       #endif
797
-      STOW_PROBE(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
797
+      probe.stow(); // Release UI during stow to allow for PAUSE_BEFORE_DEPLOY_STOW
798 798
       #if HAS_LCD_MENU
799 799
         ui.capture();
800 800
       #endif
801 801
 
802 802
       #ifdef Z_AFTER_PROBING
803
-        move_z_after_probing();
803
+        probe.move_z_after_probing();
804 804
       #endif
805 805
 
806 806
       restore_ubl_active_state_and_leave();
807 807
 
808 808
       do_blocking_move_to_xy(
809
-        constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X),
810
-        constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
809
+        constrain(near.x - probe.offset_xy.x, MESH_MIN_X, MESH_MAX_X),
810
+        constrain(near.y - probe.offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
811 811
       );
812 812
     }
813 813
 
@@ -907,7 +907,7 @@
907 907
       ui.return_to_status();
908 908
 
909 909
       mesh_index_pair location;
910
-      xy_int8_t &lpos = location.pos;
910
+      const xy_int8_t &lpos = location.pos;
911 911
       do {
912 912
         location = find_closest_mesh_point_of_type(INVALID, pos);
913 913
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
@@ -1006,7 +1006,7 @@
1006 1006
       #endif
1007 1007
 
1008 1008
       MeshFlags done_flags{0};
1009
-      xy_int8_t &lpos = location.pos;
1009
+      const xy_int8_t &lpos = location.pos;
1010 1010
       do {
1011 1011
         location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags);
1012 1012
 
@@ -1294,7 +1294,7 @@
1294 1294
     closest.distance = -99999.9f;
1295 1295
 
1296 1296
     // Get the reference position, either nozzle or probe
1297
-    const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos;
1297
+    const xy_pos_t ref = probe_relative ? pos + probe.offset_xy : pos;
1298 1298
 
1299 1299
     float best_so_far = 99999.99f;
1300 1300
 
@@ -1393,13 +1393,13 @@
1393 1393
     #include "../../../libs/vector_3.h"
1394 1394
 
1395 1395
     void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
1396
-      const float x_min = probe_min_x(), x_max = probe_max_x(),
1397
-                  y_min = probe_min_y(), y_max = probe_max_y(),
1396
+      const float x_min = probe.min_x(), x_max = probe.max_x(),
1397
+                  y_min = probe.min_y(), y_max = probe.max_y(),
1398 1398
                   dx = (x_max - x_min) / (g29_grid_size - 1),
1399 1399
                   dy = (y_max - y_min) / (g29_grid_size - 1);
1400 1400
 
1401 1401
       xy_float_t points[3];
1402
-      get_three_probe_points(points);
1402
+      probe.get_three_points(points);
1403 1403
 
1404 1404
       float measured_z;
1405 1405
       bool abort_flag = false;
@@ -1417,7 +1417,7 @@
1417 1417
           ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1418 1418
         #endif
1419 1419
 
1420
-        measured_z = probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
1420
+        measured_z = probe.probe_at_point(points[0], PROBE_PT_RAISE, g29_verbose_level);
1421 1421
         if (isnan(measured_z))
1422 1422
           abort_flag = true;
1423 1423
         else {
@@ -1438,7 +1438,7 @@
1438 1438
             ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1439 1439
           #endif
1440 1440
 
1441
-          measured_z = probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
1441
+          measured_z = probe.probe_at_point(points[1], PROBE_PT_RAISE, g29_verbose_level);
1442 1442
           #ifdef VALIDATE_MESH_TILT
1443 1443
             z2 = measured_z;
1444 1444
           #endif
@@ -1460,7 +1460,7 @@
1460 1460
             ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1461 1461
           #endif
1462 1462
 
1463
-          measured_z = probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
1463
+          measured_z = probe.probe_at_point(points[2], PROBE_PT_STOW, g29_verbose_level);
1464 1464
           #ifdef VALIDATE_MESH_TILT
1465 1465
             z3 = measured_z;
1466 1466
           #endif
@@ -1476,9 +1476,9 @@
1476 1476
           }
1477 1477
         }
1478 1478
 
1479
-        STOW_PROBE();
1479
+        probe.stow();
1480 1480
         #ifdef Z_AFTER_PROBING
1481
-          move_z_after_probing();
1481
+          probe.move_z_after_probing();
1482 1482
         #endif
1483 1483
 
1484 1484
         if (abort_flag) {
@@ -1504,7 +1504,7 @@
1504 1504
                 ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
1505 1505
               #endif
1506 1506
 
1507
-              measured_z = probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1507
+              measured_z = probe.probe_at_point(rpos, parser.seen('E') ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level); // TODO: Needs error handling
1508 1508
 
1509 1509
               abort_flag = isnan(measured_z);
1510 1510
 
@@ -1523,7 +1523,7 @@
1523 1523
                 }
1524 1524
               #endif
1525 1525
 
1526
-              measured_z -= get_z_correction(rpos) /* + probe_offset.z */ ;
1526
+              measured_z -= get_z_correction(rpos) /* + probe.offset.z */ ;
1527 1527
 
1528 1528
               if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F("   final >>>---> ", measured_z, 7);
1529 1529
 
@@ -1540,9 +1540,9 @@
1540 1540
           zig_zag ^= true;
1541 1541
         }
1542 1542
       }
1543
-      STOW_PROBE();
1543
+      probe.stow();
1544 1544
       #ifdef Z_AFTER_PROBING
1545
-        move_z_after_probing();
1545
+        probe.move_z_after_probing();
1546 1546
       #endif
1547 1547
 
1548 1548
       if (abort_flag || finish_incremental_LSF(&lsf_results)) {
@@ -1728,7 +1728,7 @@
1728 1728
       adjust_mesh_to_mean(g29_c_flag, g29_constant);
1729 1729
 
1730 1730
       #if HAS_BED_PROBE
1731
-        SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe_offset.z, 7);
1731
+        SERIAL_ECHOLNPAIR_F("Probe Offset M851 Z", probe.offset.z, 7);
1732 1732
       #endif
1733 1733
 
1734 1734
       SERIAL_ECHOLNPAIR("MESH_MIN_X  " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);

+ 3
- 3
Marlin/src/gcode/bedlevel/G42.cpp 파일 보기

@@ -27,7 +27,7 @@
27 27
 #include "../gcode.h"
28 28
 #include "../../MarlinCore.h" // for IsRunning()
29 29
 #include "../../module/motion.h"
30
-#include "../../module/probe.h" // for probe_offset
30
+#include "../../module/probe.h" // for probe.offset
31 31
 #include "../../feature/bedlevel/bedlevel.h"
32 32
 
33 33
 /**
@@ -53,8 +53,8 @@ void GcodeSuite::G42() {
53 53
 
54 54
     #if HAS_PROBE_XY_OFFSET
55 55
       if (parser.boolval('P')) {
56
-        if (hasI) destination.x -= probe_offset_xy.x;
57
-        if (hasJ) destination.y -= probe_offset_xy.y;
56
+        if (hasI) destination.x -= probe.offset_xy.x;
57
+        if (hasJ) destination.y -= probe.offset_xy.y;
58 58
       }
59 59
     #endif
60 60
 

+ 2
- 2
Marlin/src/gcode/bedlevel/M420.cpp 파일 보기

@@ -64,8 +64,8 @@ void GcodeSuite::M420() {
64 64
 
65 65
   #if ENABLED(MARLIN_DEV_MODE)
66 66
     if (parser.intval('S') == 2) {
67
-      const float x_min = probe_min_x(), x_max = probe_max_x(),
68
-                  y_min = probe_min_y(), y_max = probe_max_y();
67
+      const float x_min = probe.min_x(), x_max = probe.max_x(),
68
+                  y_min = probe.min_y(), y_max = probe.max_y();
69 69
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
70 70
         bilinear_start.set(x_min, y_min);
71 71
         bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),

+ 10
- 10
Marlin/src/gcode/bedlevel/abl/G29.cpp 파일 보기

@@ -269,7 +269,7 @@ G29_TYPE GcodeSuite::G29() {
269 269
     #endif
270 270
 
271 271
     vector_3 points[3];
272
-    get_three_probe_points(points);
272
+    probe.get_three_points(points);
273 273
 
274 274
   #endif // AUTO_BED_LEVELING_3POINT
275 275
 
@@ -392,8 +392,8 @@ G29_TYPE GcodeSuite::G29() {
392 392
 
393 393
       xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
394 394
 
395
-      const float x_min = probe_min_x(), x_max = probe_max_x(),
396
-                  y_min = probe_min_y(), y_max = probe_max_y();
395
+      const float x_min = probe.min_x(), x_max = probe.max_x(),
396
+                  y_min = probe.min_y(), y_max = probe.max_y();
397 397
 
398 398
       if (parser.seen('H')) {
399 399
         const int16_t size = (int16_t)parser.value_linear_units();
@@ -452,7 +452,7 @@ G29_TYPE GcodeSuite::G29() {
452 452
 
453 453
     #if HAS_BED_PROBE
454 454
       // Deploy the probe. Probe will raise if needed.
455
-      if (DEPLOY_PROBE()) {
455
+      if (probe.deploy()) {
456 456
         set_bed_leveling_enabled(abl_should_enable);
457 457
         G29_RETURN(false);
458 458
       }
@@ -712,7 +712,7 @@ G29_TYPE GcodeSuite::G29() {
712 712
             ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
713 713
           #endif
714 714
 
715
-          measured_z = faux ? 0.001f * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level);
715
+          measured_z = faux ? 0.001f * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
716 716
 
717 717
           if (isnan(measured_z)) {
718 718
             set_bed_leveling_enabled(abl_should_enable);
@@ -764,7 +764,7 @@ G29_TYPE GcodeSuite::G29() {
764 764
 
765 765
         // Retain the last probe position
766 766
         probePos = points[i];
767
-        measured_z = faux ? 0.001 * random(-100, 101) : probe_at_point(probePos, raise_after, verbose_level);
767
+        measured_z = faux ? 0.001 * random(-100, 101) : probe.probe_at_point(probePos, raise_after, verbose_level);
768 768
         if (isnan(measured_z)) {
769 769
           set_bed_leveling_enabled(abl_should_enable);
770 770
           break;
@@ -788,7 +788,7 @@ G29_TYPE GcodeSuite::G29() {
788 788
     #endif
789 789
 
790 790
     // Stow the probe. No raise for FIX_MOUNTED_PROBE.
791
-    if (STOW_PROBE()) {
791
+    if (probe.stow()) {
792 792
       set_bed_leveling_enabled(abl_should_enable);
793 793
       measured_z = NAN;
794 794
     }
@@ -923,8 +923,8 @@ G29_TYPE GcodeSuite::G29() {
923 923
         planner.force_unapply_leveling(converted); // use conversion machinery
924 924
 
925 925
         // Use the last measured distance to the bed, if possible
926
-        if ( NEAR(current_position.x, probePos.x - probe_offset_xy.x)
927
-          && NEAR(current_position.y, probePos.y - probe_offset_xy.y)
926
+        if ( NEAR(current_position.x, probePos.x - probe.offset_xy.x)
927
+          && NEAR(current_position.y, probePos.y - probe.offset_xy.y)
928 928
         ) {
929 929
           const float simple_z = current_position.z - measured_z;
930 930
           if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted.z, "  Discrepancy ", simple_z - converted.z);
@@ -964,7 +964,7 @@ G29_TYPE GcodeSuite::G29() {
964 964
     sync_plan_position();
965 965
 
966 966
   #if HAS_BED_PROBE && defined(Z_AFTER_PROBING)
967
-    move_z_after_probing();
967
+    probe.move_z_after_probing();
968 968
   #endif
969 969
 
970 970
   #ifdef Z_PROBE_END_SCRIPT

+ 2
- 2
Marlin/src/gcode/calibrate/G28.cpp 파일 보기

@@ -133,7 +133,7 @@
133 133
     destination.set(safe_homing_xy, current_position.z);
134 134
 
135 135
     #if HOMING_Z_WITH_PROBE
136
-      destination -= probe_offset_xy;
136
+      destination -= probe.offset_xy;
137 137
     #endif
138 138
 
139 139
     if (position_is_reachable(destination)) {
@@ -416,7 +416,7 @@ void GcodeSuite::G28(const bool always_home_all) {
416 416
         #endif
417 417
 
418 418
         #if HOMING_Z_WITH_PROBE && defined(Z_AFTER_PROBING)
419
-          move_z_after_probing();
419
+          probe.move_z_after_probing();
420 420
         #endif
421 421
 
422 422
       } // doZ

+ 2
- 2
Marlin/src/gcode/calibrate/G33.cpp 파일 보기

@@ -100,7 +100,7 @@ void ac_cleanup(
100 100
     do_blocking_move_to_z(delta_clip_start_height);
101 101
   #endif
102 102
   #if HAS_BED_PROBE
103
-    STOW_PROBE();
103
+    probe.stow();
104 104
   #endif
105 105
   restore_feedrate_and_scaling();
106 106
   #if HOTENDS > 1
@@ -190,7 +190,7 @@ static float std_dev_points(float z_pt[NPP + 1], const bool _0p_cal, const bool
190 190
  */
191 191
 static float calibration_probe(const xy_pos_t &xy, const bool stow) {
192 192
   #if HAS_BED_PROBE
193
-    return probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
193
+    return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
194 194
   #else
195 195
     UNUSED(stow);
196 196
     return lcd_probe_pt(xy);

+ 6
- 6
Marlin/src/gcode/calibrate/G34_M422.cpp 파일 보기

@@ -133,8 +133,8 @@ void GcodeSuite::G34() {
133 133
 
134 134
   do { // break out on error
135 135
 
136
-    #if NUM_Z_STEPPER_DRIVERS == 4
137
-      SERIAL_ECHOLNPGM("Quad Z Stepper Leveling not Yet Supported");
136
+    #if NUM_Z_STEPPER_DRIVERS >= 4
137
+      SERIAL_ECHOLNPGM("Alignment not supported for over 3 steppers");
138 138
       break;
139 139
     #endif
140 140
 
@@ -240,7 +240,7 @@ void GcodeSuite::G34() {
240 240
         if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe);
241 241
 
242 242
         // Probe a Z height for each stepper.
243
-        const float z_probed_height = probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true);
243
+        const float z_probed_height = probe.probe_at_point(z_stepper_align_pos[iprobe], raise_after, 0, true);
244 244
         if (isnan(z_probed_height)) {
245 245
           SERIAL_ECHOLNPGM("Probing failed.");
246 246
           err_break = true;
@@ -314,7 +314,7 @@ void GcodeSuite::G34() {
314 314
 
315 315
         #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
316 316
           // Optimize one iteration's correction based on the first measurements
317
-          if (z_align_abs > 0.0f) amplification = iteration == 1 ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
317
+          if (z_align_abs) amplification = (iteration == 1) ? _MIN(last_z_align_move[zstepper] / z_align_abs, 2.0f) : z_auto_align_amplification;
318 318
         #endif
319 319
 
320 320
         // Check for less accuracy compared to last move
@@ -379,9 +379,9 @@ void GcodeSuite::G34() {
379 379
     // After this operation the z position needs correction
380 380
     set_axis_is_not_at_home(Z_AXIS);
381 381
 
382
-    // Stow the probe, as the last call to probe_at_point(...) left
382
+    // Stow the probe, as the last call to probe.probe_at_point(...) left
383 383
     // the probe deployed if it was successful.
384
-    STOW_PROBE();
384
+    probe.stow();
385 385
 
386 386
     // Home Z after the alignment procedure
387 387
     process_subcommands_now_P(PSTR("G28 Z"));

+ 8
- 8
Marlin/src/gcode/calibrate/G76_M871.cpp 파일 보기

@@ -113,8 +113,8 @@ void GcodeSuite::G76() {
113 113
     }
114 114
     // Ensure probe position is reachable
115 115
     destination.set(
116
-      temp_comp.measure_point_x - probe_offset.x,
117
-      temp_comp.measure_point_y - probe_offset.y
116
+      temp_comp.measure_point_x - probe.offset_xy.x,
117
+      temp_comp.measure_point_y - probe.offset_xy.y
118 118
     );
119 119
     if (!position_is_reachable_by_probe(destination)) {
120 120
       SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
@@ -209,9 +209,9 @@ void GcodeSuite::G76() {
209 209
 
210 210
       // Do a single probe
211 211
       remember_feedrate_scaling_off();
212
-      const float measured_z = probe_at_point(
213
-        destination.x + probe_offset.x,
214
-        destination.y + probe_offset.y,
212
+      const float measured_z = probe.probe_at_point(
213
+        destination.x + probe.offset_xy.x,
214
+        destination.y + probe.offset_xy.y,
215 215
         PROBE_PT_NONE
216 216
       );
217 217
       restore_feedrate_and_scaling();
@@ -318,9 +318,9 @@ void GcodeSuite::G76() {
318 318
 
319 319
       // Do a single probe
320 320
       remember_feedrate_scaling_off();
321
-      const float measured_z = probe_at_point(
322
-        destination.x + probe_offset.x,
323
-        destination.y + probe_offset.y,
321
+      const float measured_z = probe.probe_at_point(
322
+        destination.x + probe.offset_xy.x,
323
+        destination.y + probe.offset_xy.y,
324 324
         PROBE_PT_NONE
325 325
       );
326 326
       restore_feedrate_and_scaling();

+ 6
- 6
Marlin/src/gcode/calibrate/M48.cpp 파일 보기

@@ -80,8 +80,8 @@ void GcodeSuite::M48() {
80 80
   xy_float_t next_pos = current_position;
81 81
 
82 82
   const xy_pos_t probe_pos = {
83
-    parser.linearval('X', next_pos.x + probe_offset_xy.x),
84
-    parser.linearval('Y', next_pos.y + probe_offset_xy.y)
83
+    parser.linearval('X', next_pos.x + probe.offset_xy.x),
84
+    parser.linearval('Y', next_pos.y + probe.offset_xy.y)
85 85
   };
86 86
 
87 87
   if (!position_is_reachable_by_probe(probe_pos)) {
@@ -120,7 +120,7 @@ void GcodeSuite::M48() {
120 120
   float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
121 121
 
122 122
   // Move to the first point, deploy, and probe
123
-  const float t = probe_at_point(probe_pos, raise_after, verbose_level);
123
+  const float t = probe.probe_at_point(probe_pos, raise_after, verbose_level);
124 124
   bool probing_good = !isnan(t);
125 125
 
126 126
   if (probing_good) {
@@ -169,7 +169,7 @@ void GcodeSuite::M48() {
169 169
           while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
170 170
                                                 // numbers outside of the range, but just to be safe we clamp them.
171 171
 
172
-          const xy_pos_t noz_pos = probe_pos - probe_offset_xy;
172
+          const xy_pos_t noz_pos = probe_pos - probe.offset_xy;
173 173
           next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
174 174
                        noz_pos.y + sin(RADIANS(angle)) * radius);
175 175
 
@@ -194,7 +194,7 @@ void GcodeSuite::M48() {
194 194
       } // n_legs
195 195
 
196 196
       // Probe a single point
197
-      sample_set[n] = probe_at_point(probe_pos, raise_after, 0);
197
+      sample_set[n] = probe.probe_at_point(probe_pos, raise_after, 0);
198 198
 
199 199
       // Break the loop if the probe fails
200 200
       probing_good = !isnan(sample_set[n]);
@@ -238,7 +238,7 @@ void GcodeSuite::M48() {
238 238
     } // n_samples loop
239 239
   }
240 240
 
241
-  STOW_PROBE();
241
+  probe.stow();
242 242
 
243 243
   if (probing_good) {
244 244
     SERIAL_ECHOLNPGM("Finished!");

+ 7
- 0
Marlin/src/gcode/config/M304.cpp 파일 보기

@@ -27,6 +27,13 @@
27 27
 #include "../gcode.h"
28 28
 #include "../../module/temperature.h"
29 29
 
30
+/**
31
+ * M304 - Set and/or Report the current Bed PID values
32
+ *
33
+ *  P<pval> - Set the P value
34
+ *  I<ival> - Set the I value
35
+ *  D<dval> - Set the D value
36
+ */
30 37
 void GcodeSuite::M304() {
31 38
   if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
32 39
   if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());

+ 3
- 3
Marlin/src/gcode/motion/M290.cpp 파일 보기

@@ -46,9 +46,9 @@
46 46
         && active_extruder == 0
47 47
       #endif
48 48
     ) {
49
-      probe_offset.z += offs;
49
+      probe.offset.z += offs;
50 50
       SERIAL_ECHO_START();
51
-      SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe_offset.z);
51
+      SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET MSG_Z ": ", probe.offset.z);
52 52
     }
53 53
     else {
54 54
       #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
@@ -98,7 +98,7 @@ void GcodeSuite::M290() {
98 98
     SERIAL_ECHO_START();
99 99
 
100 100
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
101
-      SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe_offset.z);
101
+      SERIAL_ECHOLNPAIR(MSG_PROBE_OFFSET " " MSG_Z, probe.offset.z);
102 102
     #endif
103 103
 
104 104
     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)

+ 4
- 4
Marlin/src/gcode/probe/G30.cpp 파일 보기

@@ -40,8 +40,8 @@
40 40
  */
41 41
 void GcodeSuite::G30() {
42 42
 
43
-  const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x),
44
-                         parser.linearval('Y', current_position.y + probe_offset_xy.y) };
43
+  const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
44
+                         parser.linearval('Y', current_position.y + probe.offset_xy.y) };
45 45
 
46 46
   if (!position_is_reachable_by_probe(pos)) return;
47 47
 
@@ -53,14 +53,14 @@ void GcodeSuite::G30() {
53 53
   remember_feedrate_scaling_off();
54 54
 
55 55
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
56
-  const float measured_z = probe_at_point(pos, raise_after, 1);
56
+  const float measured_z = probe.probe_at_point(pos, raise_after, 1);
57 57
   if (!isnan(measured_z))
58 58
     SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
59 59
 
60 60
   restore_feedrate_and_scaling();
61 61
 
62 62
   #ifdef Z_AFTER_PROBING
63
-    if (raise_after == PROBE_PT_STOW) move_z_after_probing();
63
+    if (raise_after == PROBE_PT_STOW) probe.move_z_after_probing();
64 64
   #endif
65 65
 
66 66
   report_current_position();

+ 2
- 2
Marlin/src/gcode/probe/G31_G32.cpp 파일 보기

@@ -30,11 +30,11 @@
30 30
 /**
31 31
  * G31: Deploy the Z probe
32 32
  */
33
-void GcodeSuite::G31() { DEPLOY_PROBE(); }
33
+void GcodeSuite::G31() { probe.deploy(); }
34 34
 
35 35
 /**
36 36
  * G32: Stow the Z probe
37 37
  */
38
-void GcodeSuite::G32() { STOW_PROBE(); }
38
+void GcodeSuite::G32() { probe.stow(); }
39 39
 
40 40
 #endif // Z_PROBE_SLED

+ 3
- 3
Marlin/src/gcode/probe/M401_M402.cpp 파일 보기

@@ -32,7 +32,7 @@
32 32
  * M401: Deploy and activate the Z probe
33 33
  */
34 34
 void GcodeSuite::M401() {
35
-  DEPLOY_PROBE();
35
+  probe.deploy();
36 36
   report_current_position();
37 37
 }
38 38
 
@@ -40,9 +40,9 @@ void GcodeSuite::M401() {
40 40
  * M402: Deactivate and stow the Z probe
41 41
  */
42 42
 void GcodeSuite::M402() {
43
-  STOW_PROBE();
43
+  probe.stow();
44 44
   #ifdef Z_AFTER_PROBING
45
-    move_z_after_probing();
45
+    probe.move_z_after_probing();
46 46
   #endif
47 47
   report_current_position();
48 48
 }

+ 4
- 4
Marlin/src/gcode/probe/M851.cpp 파일 보기

@@ -39,17 +39,17 @@ void GcodeSuite::M851() {
39 39
   if (!parser.seen("XYZ")) {
40 40
     SERIAL_ECHOLNPAIR_P(
41 41
       #if HAS_PROBE_XY_OFFSET
42
-        PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR
42
+        PSTR(MSG_PROBE_OFFSET " X"), probe.offset_xy.x, SP_Y_STR, probe.offset_xy.y, SP_Z_STR
43 43
       #else
44 44
         PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
45 45
       #endif
46
-      , probe_offset.z
46
+      , probe.offset.z
47 47
     );
48 48
     return;
49 49
   }
50 50
 
51 51
   // Start with current offsets and modify
52
-  xyz_pos_t offs = probe_offset;
52
+  xyz_pos_t offs = probe.offset;
53 53
 
54 54
   // Assume no errors
55 55
   bool ok = true;
@@ -93,7 +93,7 @@ void GcodeSuite::M851() {
93 93
   }
94 94
 
95 95
   // Save the new offsets
96
-  if (ok) probe_offset = offs;
96
+  if (ok) probe.offset = offs;
97 97
 }
98 98
 
99 99
 #endif // HAS_BED_PROBE

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp 파일 보기

@@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
453 453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
454 454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
455 455
     #if HAS_BED_PROBE
456
-      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
456
+      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
457 457
       #if ENABLED(BABYSTEPPING)
458 458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
459 459
       #endif

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp 파일 보기

@@ -453,7 +453,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
453 453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
454 454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
455 455
     #if HAS_BED_PROBE
456
-      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
456
+      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
457 457
       #if ENABLED(BABYSTEPPING)
458 458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
459 459
       #endif

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp 파일 보기

@@ -285,7 +285,7 @@ const struct DGUS_VP_Variable ListOfVP[] PROGMEM = {
285 285
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
286 286
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
287 287
     #if HAS_BED_PROBE
288
-      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe_offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
288
+      VPHELPER(VP_SD_Print_ProbeOffsetZ, &probe.offset.z, DGUSScreenVariableHandler::HandleProbeOffsetZChanged, &DGUSScreenVariableHandler::DGUSLCD_SendFloatAsIntValueToDisplay<2>),
289 289
       #if ENABLED(BABYSTEPPING)
290 290
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
291 291
       #endif

+ 3
- 3
Marlin/src/lcd/extensible_ui/ui_api.cpp 파일 보기

@@ -733,7 +733,7 @@ namespace ExtUI {
733 733
           #if EXTRUDERS > 1
734 734
             && (linked_nozzles || active_extruder == 0)
735 735
           #endif
736
-        ) probe_offset.z += mm;
736
+        ) probe.offset.z += mm;
737 737
       #else
738 738
         UNUSED(mm);
739 739
       #endif
@@ -771,7 +771,7 @@ namespace ExtUI {
771 771
 
772 772
   float getZOffset_mm() {
773 773
     #if HAS_BED_PROBE
774
-      return probe_offset.z;
774
+      return probe.offset.z;
775 775
     #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
776 776
       return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]);
777 777
     #else
@@ -782,7 +782,7 @@ namespace ExtUI {
782 782
   void setZOffset_mm(const float value) {
783 783
     #if HAS_BED_PROBE
784 784
       if (WITHIN(value, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
785
-        probe_offset.z = value;
785
+        probe.offset.z = value;
786 786
     #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
787 787
       babystep.add_mm(Z_AXIS, (value - getZOffset_mm()));
788 788
     #else

+ 4
- 4
Marlin/src/lcd/menu/menu.cpp 파일 보기

@@ -406,7 +406,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
406 406
       ui.encoderPosition = 0;
407 407
 
408 408
       const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
409
-                  new_probe_offset = probe_offset.z + diff,
409
+                  new_probe_offset = probe.offset.z + diff,
410 410
                   new_offs =
411 411
                     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
412 412
                       do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
@@ -418,7 +418,7 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
418 418
 
419 419
         babystep.add_steps(Z_AXIS, babystep_increment);
420 420
 
421
-        if (do_probe) probe_offset.z = new_offs;
421
+        if (do_probe) probe.offset.z = new_offs;
422 422
         #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
423 423
           else hotend_offset[active_extruder].z = new_offs;
424 424
         #endif
@@ -432,10 +432,10 @@ void scroll_screen(const uint8_t limit, const bool is_menu) {
432 432
           MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z));
433 433
         else
434 434
       #endif
435
-          MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe_offset.z));
435
+          MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_ZPROBE_ZOFFSET), LCD_Z_OFFSET_FUNC(probe.offset.z));
436 436
 
437 437
       #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
438
-        if (do_probe) _lcd_zoffset_overlay_gfx(probe_offset.z);
438
+        if (do_probe) _lcd_zoffset_overlay_gfx(probe.offset.z);
439 439
       #endif
440 440
     }
441 441
   }

+ 5
- 3
Marlin/src/lcd/menu/menu_advanced.cpp 파일 보기

@@ -497,9 +497,11 @@ void menu_cancelobject();
497 497
     void menu_probe_offsets() {
498 498
       START_MENU();
499 499
       BACK_ITEM(MSG_ADVANCED_SETTINGS);
500
-      EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe_offset.x, -(X_BED_SIZE), X_BED_SIZE);
501
-      EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe_offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
502
-      EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
500
+      #if HAS_PROBE_XY_OFFSET
501
+        EDIT_ITEM(float51sign, MSG_ZPROBE_XOFFSET, &probe.offset.x, -(X_BED_SIZE), X_BED_SIZE);
502
+        EDIT_ITEM(float51sign, MSG_ZPROBE_YOFFSET, &probe.offset.y, -(Y_BED_SIZE), Y_BED_SIZE);
503
+      #endif
504
+      EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
503 505
       END_MENU();
504 506
     }
505 507
   #endif

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp 파일 보기

@@ -279,7 +279,7 @@ void menu_bed_leveling() {
279 279
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
280 280
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
281 281
   #elif HAS_BED_PROBE
282
-    EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
282
+    EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
283 283
   #endif
284 284
 
285 285
   #if ENABLED(LEVEL_BED_CORNERS)

+ 1
- 4
Marlin/src/lcd/menu/menu_configuration.cpp 파일 보기

@@ -317,14 +317,11 @@ void menu_configuration() {
317 317
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
318 318
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
319 319
   #elif HAS_BED_PROBE
320
-    EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
320
+    EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
321 321
   #endif
322 322
 
323 323
   const bool busy = printer_busy();
324 324
   if (!busy) {
325
-    //
326
-    // Delta Calibration
327
-    //
328 325
     #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
329 326
       SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
330 327
     #endif

+ 20
- 15
Marlin/src/module/configuration_store.cpp 파일 보기

@@ -587,12 +587,12 @@ void MarlinSettings::postprocess() {
587 587
       #if HAS_FILAMENT_SENSOR
588 588
         const bool &runout_sensor_enabled = runout.enabled;
589 589
       #else
590
-        const bool runout_sensor_enabled = true;
590
+        constexpr bool runout_sensor_enabled = true;
591 591
       #endif
592 592
       #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
593 593
         const float &runout_distance_mm = runout.runout_distance();
594 594
       #else
595
-        const float runout_distance_mm = 0;
595
+        constexpr float runout_distance_mm = 0;
596 596
       #endif
597 597
       _FIELD_TEST(runout_sensor_enabled);
598 598
       EEPROM_WRITE(runout_sensor_enabled);
@@ -643,7 +643,12 @@ void MarlinSettings::postprocess() {
643 643
     //
644 644
     {
645 645
       _FIELD_TEST(probe_offset);
646
-      EEPROM_WRITE(probe_offset);
646
+      #if HAS_BED_PROBE
647
+        const xyz_pos_t &zpo = probe.offset;
648
+      #else
649
+        constexpr xyz_pos_t zpo{0};
650
+      #endif
651
+      EEPROM_WRITE(zpo);
647 652
     }
648 653
 
649 654
     //
@@ -1458,7 +1463,7 @@ void MarlinSettings::postprocess() {
1458 1463
       //
1459 1464
       {
1460 1465
         #if HAS_FILAMENT_SENSOR
1461
-          bool &runout_sensor_enabled = runout.enabled;
1466
+          const bool &runout_sensor_enabled = runout.enabled;
1462 1467
         #else
1463 1468
           bool runout_sensor_enabled;
1464 1469
         #endif
@@ -1515,7 +1520,7 @@ void MarlinSettings::postprocess() {
1515 1520
       {
1516 1521
         _FIELD_TEST(probe_offset);
1517 1522
         #if HAS_BED_PROBE
1518
-          xyz_pos_t &zpo = probe_offset;
1523
+          const xyz_pos_t &zpo = probe.offset;
1519 1524
         #else
1520 1525
           xyz_pos_t zpo;
1521 1526
         #endif
@@ -1609,7 +1614,7 @@ void MarlinSettings::postprocess() {
1609 1614
       {
1610 1615
         _FIELD_TEST(bltouch_last_written_mode);
1611 1616
         #if ENABLED(BLTOUCH)
1612
-          bool &bltouch_last_written_mode = bltouch.last_written_mode;
1617
+          const bool &bltouch_last_written_mode = bltouch.last_written_mode;
1613 1618
         #else
1614 1619
           bool bltouch_last_written_mode;
1615 1620
         #endif
@@ -2120,14 +2125,14 @@ void MarlinSettings::postprocess() {
2120 2125
       //
2121 2126
       {
2122 2127
         #if ENABLED(BACKLASH_GCODE)
2123
-          xyz_float_t &backlash_distance_mm = backlash.distance_mm;
2124
-          uint8_t &backlash_correction = backlash.correction;
2128
+          const xyz_float_t &backlash_distance_mm = backlash.distance_mm;
2129
+          const uint8_t &backlash_correction = backlash.correction;
2125 2130
         #else
2126 2131
           float backlash_distance_mm[XYZ];
2127 2132
           uint8_t backlash_correction;
2128 2133
         #endif
2129 2134
         #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
2130
-          float &backlash_smoothing_mm = backlash.smoothing_mm;
2135
+          const float &backlash_smoothing_mm = backlash.smoothing_mm;
2131 2136
         #else
2132 2137
           float backlash_smoothing_mm;
2133 2138
         #endif
@@ -2461,10 +2466,10 @@ void MarlinSettings::reset() {
2461 2466
     constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
2462 2467
     static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2463 2468
     #if HAS_PROBE_XY_OFFSET
2464
-      LOOP_XYZ(a) probe_offset[a] = dpo[a];
2469
+      LOOP_XYZ(a) probe.offset[a] = dpo[a];
2465 2470
     #else
2466
-      probe_offset.x = probe_offset.y = 0;
2467
-      probe_offset.z = dpo[Z_AXIS];
2471
+      probe.offset.x = probe.offset.y = 0;
2472
+      probe.offset.z = dpo[Z_AXIS];
2468 2473
     #endif
2469 2474
   #endif
2470 2475
 
@@ -3216,13 +3221,13 @@ void MarlinSettings::reset() {
3216 3221
       CONFIG_ECHO_START();
3217 3222
       SERIAL_ECHOLNPAIR_P(
3218 3223
         #if HAS_PROBE_XY_OFFSET
3219
-          PSTR("  M851 X"), LINEAR_UNIT(probe_offset_xy.x),
3220
-                  SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y),
3224
+          PSTR("  M851 X"), LINEAR_UNIT(probe.offset_xy.x),
3225
+                  SP_Y_STR, LINEAR_UNIT(probe.offset_xy.y),
3221 3226
                   SP_Z_STR
3222 3227
         #else
3223 3228
           PSTR("  M851 X0 Y0 Z")
3224 3229
         #endif
3225
-        , LINEAR_UNIT(probe_offset.z)
3230
+        , LINEAR_UNIT(probe.offset.z)
3226 3231
       );
3227 3232
     #endif
3228 3233
 

+ 2
- 2
Marlin/src/module/delta.cpp 파일 보기

@@ -95,7 +95,7 @@ void recalc_delta_settings() {
95 95
   float delta_calibration_radius() {
96 96
     return calibration_radius_factor * (
97 97
       #if HAS_BED_PROBE
98
-        FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe_offset_xy.x, probe_offset_xy.y), MIN_PROBE_EDGE))
98
+        FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe.offset_xy.x, probe.offset_xy.y), MIN_PROBE_EDGE))
99 99
       #else
100 100
         DELTA_PRINTABLE_RADIUS
101 101
       #endif
@@ -251,7 +251,7 @@ void home_delta() {
251 251
   // Move all carriages together linearly until an endstop is hit.
252 252
   current_position.z = (delta_height + 10
253 253
     #if HAS_BED_PROBE
254
-      - probe_offset.z
254
+      - probe.offset.z
255 255
     #endif
256 256
   );
257 257
   line_to_current_position(homing_feedrate(Z_AXIS));

+ 10
- 10
Marlin/src/module/motion.cpp 파일 보기

@@ -280,7 +280,7 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
280 280
         , true
281 281
       #endif
282 282
     );
283
-    xyze_pos_t &cartes = pos;
283
+    const xyze_pos_t &cartes = pos;
284 284
   #endif
285 285
   if (axis == ALL_AXES)
286 286
     current_position = cartes;
@@ -547,7 +547,7 @@ void restore_feedrate_and_scaling() {
547 547
       soft_endstop.min[axis] = base_min_pos(axis);
548 548
       soft_endstop.max[axis] = (axis == Z_AXIS ? delta_height
549 549
       #if HAS_BED_PROBE
550
-        - probe_offset.z
550
+        - probe.offset.z
551 551
       #endif
552 552
       : base_max_pos(axis));
553 553
 
@@ -1281,7 +1281,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1281 1281
   #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
1282 1282
     // Wait for bed to heat back up between probing points
1283 1283
     if (axis == Z_AXIS && distance < 0 && thermalManager.isHeatingBed()) {
1284
-      serialprintPGM(msg_wait_for_bed_heating);
1284
+      serialprintPGM(probe.msg_wait_for_bed_heating);
1285 1285
       #if HAS_DISPLAY
1286 1286
         LCD_MESSAGEPGM(MSG_BED_HEATING);
1287 1287
       #endif
@@ -1307,7 +1307,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1307 1307
   if (is_home_dir) {
1308 1308
 
1309 1309
     #if HOMING_Z_WITH_PROBE && QUIET_PROBING
1310
-      if (axis == Z_AXIS) probing_pause(true);
1310
+      if (axis == Z_AXIS) probe.set_probing_paused(true);
1311 1311
     #endif
1312 1312
 
1313 1313
     // Disable stealthChop if used. Enable diag1 pin on driver.
@@ -1347,7 +1347,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
1347 1347
   if (is_home_dir) {
1348 1348
 
1349 1349
     #if HOMING_Z_WITH_PROBE && QUIET_PROBING
1350
-      if (axis == Z_AXIS) probing_pause(false);
1350
+      if (axis == Z_AXIS) probe.set_probing_paused(false);
1351 1351
     #endif
1352 1352
 
1353 1353
     endstops.validate_homing_move();
@@ -1397,7 +1397,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
1397 1397
   #elif ENABLED(DELTA)
1398 1398
     current_position[axis] = (axis == Z_AXIS ? delta_height
1399 1399
     #if HAS_BED_PROBE
1400
-      - probe_offset.z
1400
+      - probe.offset.z
1401 1401
     #endif
1402 1402
     : base_home_pos(axis));
1403 1403
   #else
@@ -1411,9 +1411,9 @@ void set_axis_is_at_home(const AxisEnum axis) {
1411 1411
     if (axis == Z_AXIS) {
1412 1412
       #if HOMING_Z_WITH_PROBE
1413 1413
 
1414
-        current_position.z -= probe_offset.z;
1414
+        current_position.z -= probe.offset.z;
1415 1415
 
1416
-        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe_offset.z = ", probe_offset.z);
1416
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z);
1417 1417
 
1418 1418
       #else
1419 1419
 
@@ -1509,7 +1509,7 @@ void homeaxis(const AxisEnum axis) {
1509 1509
 
1510 1510
   // Homing Z towards the bed? Deploy the Z probe or endstop.
1511 1511
   #if HOMING_Z_WITH_PROBE
1512
-    if (axis == Z_AXIS && DEPLOY_PROBE()) return;
1512
+    if (axis == Z_AXIS && probe.deploy()) return;
1513 1513
   #endif
1514 1514
 
1515 1515
   // Set flags for X, Y, Z motor locking
@@ -1751,7 +1751,7 @@ void homeaxis(const AxisEnum axis) {
1751 1751
 
1752 1752
   // Put away the Z probe
1753 1753
   #if HOMING_Z_WITH_PROBE
1754
-    if (axis == Z_AXIS && STOW_PROBE()) return;
1754
+    if (axis == Z_AXIS && probe.stow()) return;
1755 1755
   #endif
1756 1756
 
1757 1757
   #if DISABLED(DELTA) && defined(HOMING_BACKOFF_MM)

+ 4
- 4
Marlin/src/module/motion.h 파일 보기

@@ -329,7 +329,7 @@ void homeaxis(const AxisEnum axis);
329 329
       // Return true if the both nozzle and the probe can reach the given point.
330 330
       // Note: This won't work on SCARA since the probe offset rotates with the arm.
331 331
       inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
332
-        return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
332
+        return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
333 333
                && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
334 334
       }
335 335
 
@@ -369,9 +369,9 @@ void homeaxis(const AxisEnum axis);
369 369
      *          nozzle must be be able to reach +10,-10.
370 370
      */
371 371
     inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
372
-      return position_is_reachable(rx - probe_offset_xy.x, ry - probe_offset_xy.y)
373
-          && WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop)
374
-          && WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop);
372
+      return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
373
+          && WITHIN(rx, probe.min_x() - slop, probe.max_x() + slop)
374
+          && WITHIN(ry, probe.min_y() - slop, probe.max_y() + slop);
375 375
     }
376 376
 
377 377
   #endif // HAS_BED_PROBE

+ 2
- 2
Marlin/src/module/planner.cpp 파일 보기

@@ -2779,7 +2779,7 @@ void Planner::set_max_acceleration(const uint8_t axis, float targetValue) {
2779 2779
       const xyze_float_t &max_acc_edit_scaled = max_accel_edit;
2780 2780
     #else
2781 2781
       constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION;
2782
-      const xyze_float_t max_acc_edit_scaled = max_accel_edit * 2;
2782
+      constexpr xyze_float_t max_acc_edit_scaled = max_accel_edit * 2;
2783 2783
     #endif
2784 2784
     limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled);
2785 2785
   #endif
@@ -2796,7 +2796,7 @@ void Planner::set_max_feedrate(const uint8_t axis, float targetValue) {
2796 2796
       const xyze_float_t &max_fr_edit_scaled = max_fr_edit;
2797 2797
     #else
2798 2798
       constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE;
2799
-      const xyze_float_t max_fr_edit_scaled = max_fr_edit * 2;
2799
+      constexpr xyze_float_t max_fr_edit_scaled = max_fr_edit * 2;
2800 2800
     #endif
2801 2801
     limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled);
2802 2802
   #endif

+ 57
- 48
Marlin/src/module/probe.cpp 파일 보기

@@ -21,7 +21,7 @@
21 21
  */
22 22
 
23 23
 /**
24
- * probe.cpp
24
+ * module/probe.cpp
25 25
  */
26 26
 
27 27
 #include "../inc/MarlinConfig.h"
@@ -84,14 +84,14 @@
84 84
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
85 85
 #include "../core/debug_out.h"
86 86
 
87
+Probe probe;
87 88
 
88
-xyz_pos_t probe_offset; // Initialized by settings.load()
89
+xyz_pos_t Probe::offset; // Initialized by settings.load()
89 90
 
90 91
 #if HAS_PROBE_XY_OFFSET
91
-  xyz_pos_t &probe_offset_xy = probe_offset;
92
+  const xyz_pos_t &Probe::offset_xy = probe.offset;
92 93
 #endif
93 94
 
94
-
95 95
 #if ENABLED(Z_PROBE_SLED)
96 96
 
97 97
   #ifndef SLED_DOCKING_OFFSET
@@ -104,7 +104,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
104 104
    * stow[in]     If false, move to MAX_X and engage the solenoid
105 105
    *              If true, move to MAX_X and release the solenoid
106 106
    */
107
-  static void dock_sled(bool stow) {
107
+  static void dock_sled(const bool stow) {
108 108
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
109 109
 
110 110
     // Dock sled a bit closer to ensure proper capturing
@@ -118,7 +118,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
118 118
 #elif ENABLED(TOUCH_MI_PROBE)
119 119
 
120 120
   // Move to the magnet to unlock the probe
121
-  void run_deploy_moves_script() {
121
+  inline void run_deploy_moves_script() {
122 122
     #ifndef TOUCH_MI_DEPLOY_XPOS
123 123
       #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS
124 124
     #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED
@@ -153,7 +153,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
153 153
   }
154 154
 
155 155
   // Move down to the bed to stow the probe
156
-  void run_stow_moves_script() {
156
+  inline void run_stow_moves_script() {
157 157
     const xyz_pos_t oldpos = current_position;
158 158
     endstops.enable_z_probe(false);
159 159
     do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
@@ -162,7 +162,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
162 162
 
163 163
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
164 164
 
165
-  void run_deploy_moves_script() {
165
+  inline void run_deploy_moves_script() {
166 166
     #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1
167 167
       #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE
168 168
         #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0
@@ -200,7 +200,7 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
200 200
     #endif
201 201
   }
202 202
 
203
-  void run_stow_moves_script() {
203
+  inline void run_stow_moves_script() {
204 204
     #ifdef Z_PROBE_ALLEN_KEY_STOW_1
205 205
       #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE
206 206
         #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0
@@ -241,7 +241,8 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
241 241
 #endif // Z_PROBE_ALLEN_KEY
242 242
 
243 243
 #if QUIET_PROBING
244
-  void probing_pause(const bool p) {
244
+
245
+  void Probe::set_probing_paused(const bool p) {
245 246
     #if ENABLED(PROBING_HEATERS_OFF)
246 247
       thermalManager.pause(p);
247 248
     #endif
@@ -262,16 +263,17 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
262 263
       #endif
263 264
     );
264 265
   }
266
+
265 267
 #endif // QUIET_PROBING
266 268
 
267 269
 /**
268 270
  * Raise Z to a minimum height to make room for a probe to move
269 271
  */
270
-inline void do_probe_raise(const float z_raise) {
271
-  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
272
+void Probe::do_z_raise(const float z_raise) {
273
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probe::move_z(", z_raise, ")");
272 274
 
273 275
   float z_dest = z_raise;
274
-  if (probe_offset.z < 0) z_dest -= probe_offset.z;
276
+  if (offset.z < 0) z_dest -= offset.z;
275 277
 
276 278
   NOMORE(z_dest, Z_MAX_POS);
277 279
 
@@ -351,11 +353,15 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
351 353
   #endif
352 354
 }
353 355
 
354
-// returns false for ok and true for failure
355
-bool set_probe_deployed(const bool deploy) {
356
+/**
357
+ * Attempt to deploy or stow the probe
358
+ *
359
+ * Return TRUE if the probe could not be deployed/stowed
360
+ */
361
+bool Probe::set_deployed(const bool deploy) {
356 362
 
357 363
   if (DEBUGGING(LEVELING)) {
358
-    DEBUG_POS("set_probe_deployed", current_position);
364
+    DEBUG_POS("Probe::set_deployed", current_position);
359 365
     DEBUG_ECHOLNPAIR("deploy: ", deploy);
360 366
   }
361 367
 
@@ -378,7 +384,7 @@ bool set_probe_deployed(const bool deploy) {
378 384
   #endif
379 385
 
380 386
   if (deploy_stow_condition && unknown_condition)
381
-    do_probe_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
387
+    do_z_raise(_MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_CLEARANCE_DEPLOY_PROBE));
382 388
 
383 389
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
384 390
     if (axis_unhomed_error(
@@ -433,7 +439,7 @@ bool set_probe_deployed(const bool deploy) {
433 439
 
434 440
 #ifdef Z_AFTER_PROBING
435 441
   // After probing move to a preferred Z position
436
-  void move_z_after_probing() {
442
+  void Probe::move_z_after_probing() {
437 443
     if (current_position.z != Z_AFTER_PROBING) {
438 444
       do_blocking_move_to_z(Z_AFTER_PROBING);
439 445
       current_position.z = Z_AFTER_PROBING;
@@ -450,11 +456,11 @@ bool set_probe_deployed(const bool deploy) {
450 456
  */
451 457
 
452 458
 #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
453
-  const char msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
459
+  PGM_P Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n";
454 460
 #endif
455 461
 
456
-static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
457
-  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
462
+bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) {
463
+  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::move_to_z", current_position);
458 464
 
459 465
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
460 466
     // Wait for bed to heat back up between probing points
@@ -482,7 +488,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
482 488
   #endif
483 489
 
484 490
   #if QUIET_PROBING
485
-    probing_pause(true);
491
+    set_probing_paused(true);
486 492
   #endif
487 493
 
488 494
   // Move down until the probe is triggered
@@ -504,7 +510,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
504 510
   ;
505 511
 
506 512
   #if QUIET_PROBING
507
-    probing_pause(false);
513
+    set_probing_paused(false);
508 514
   #endif
509 515
 
510 516
   // Re-enable stealthChop if used. Disable diag1 pin on driver.
@@ -530,7 +536,7 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
530 536
   // Tell the planner where we actually are
531 537
   sync_plan_position();
532 538
 
533
-  if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
539
+  if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::move_to_z", current_position);
534 540
 
535 541
   return !probe_triggered;
536 542
 }
@@ -543,19 +549,19 @@ static bool do_probe_move(const float z, const feedRate_t fr_mm_s) {
543 549
  *
544 550
  * @return The Z position of the bed at the current XY or NAN on error.
545 551
  */
546
-static float run_z_probe() {
552
+float Probe::run_z_probe() {
547 553
 
548
-  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
554
+  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::run_z_probe", current_position);
549 555
 
550 556
   // Stop the probe before it goes too low to prevent damage.
551 557
   // If Z isn't known then probe to -10mm.
552
-  const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -probe_offset.z + Z_PROBE_LOW_POINT : -10.0;
558
+  const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
553 559
 
554 560
   // Double-probing does a fast probe followed by a slow probe
555 561
   #if TOTAL_PROBING == 2
556 562
 
557 563
     // Do a first probe at the fast speed
558
-    if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
564
+    if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
559 565
       if (DEBUGGING(LEVELING)) {
560 566
         DEBUG_ECHOLNPGM("FAST Probe fail!");
561 567
         DEBUG_POS("<<< run_z_probe", current_position);
@@ -574,10 +580,10 @@ static float run_z_probe() {
574 580
 
575 581
     // If the nozzle is well over the travel height then
576 582
     // move down quickly before doing the slow probe
577
-    const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (probe_offset.z < 0 ? -probe_offset.z : 0);
583
+    const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0);
578 584
     if (current_position.z > z) {
579 585
       // Probe down fast. If the probe never triggered, raise for probe clearance
580
-      if (!do_probe_move(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
586
+      if (!move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST)))
581 587
         do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
582 588
     }
583 589
   #endif
@@ -587,7 +593,7 @@ static float run_z_probe() {
587 593
   #endif
588 594
 
589 595
   #if TOTAL_PROBING > 2
590
-    float probes_total = 0;
596
+    float probes_z_sum = 0;
591 597
     for (
592 598
       #if EXTRA_PROBING
593 599
         uint8_t p = 0; p < TOTAL_PROBING; p++
@@ -598,7 +604,7 @@ static float run_z_probe() {
598 604
   #endif
599 605
     {
600 606
       // Probe downward slowly to find the bed
601
-      if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
607
+      if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
602 608
         if (DEBUGGING(LEVELING)) {
603 609
           DEBUG_ECHOLNPGM("SLOW Probe fail!");
604 610
           DEBUG_POS("<<< run_z_probe", current_position);
@@ -622,7 +628,7 @@ static float run_z_probe() {
622 628
           }
623 629
         }
624 630
       #elif TOTAL_PROBING > 2
625
-        probes_total += z;
631
+        probes_z_sum += z;
626 632
       #else
627 633
         UNUSED(z);
628 634
       #endif
@@ -653,11 +659,11 @@ static float run_z_probe() {
653 659
 
654 660
       // Return the average value of all remaining probes.
655 661
       for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++)
656
-        probes_total += probes[i];
662
+        probes_z_sum += probes[i];
657 663
 
658 664
     #endif
659 665
 
660
-    const float measured_z = probes_total * RECIPROCAL(MULTIPLE_PROBING);
666
+    const float measured_z = probes_z_sum * RECIPROCAL(MULTIPLE_PROBING);
661 667
 
662 668
   #elif TOTAL_PROBING == 2
663 669
 
@@ -689,10 +695,10 @@ static float run_z_probe() {
689 695
  *   - Raise to the BETWEEN height
690 696
  * - Return the probed Z position
691 697
  */
692
-float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
698
+float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
693 699
   if (DEBUGGING(LEVELING)) {
694 700
     DEBUG_ECHOLNPAIR(
695
-      ">>> probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
701
+      ">>> Probe::probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
696 702
       ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
697 703
       ", ", int(verbose_level),
698 704
       ", ", probe_relative ? "probe" : "nozzle", "_relative)"
@@ -702,9 +708,12 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
702 708
 
703 709
   // TODO: Adapt for SCARA, where the offset rotates
704 710
   xyz_pos_t npos = { rx, ry };
705
-  if (probe_relative) {
706
-    if (!position_is_reachable_by_probe(npos)) return NAN;  // The given position is in terms of the probe
707
-    npos -= probe_offset_xy;                                // Get the nozzle position
711
+  if (probe_relative) {                                     // The given position is in terms of the probe
712
+    if (!position_is_reachable_by_probe(npos)) {
713
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Position Not Reachable");
714
+      return NAN;
715
+    }
716
+    npos -= offset_xy;                                      // Get the nozzle position
708 717
   }
709 718
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
710 719
 
@@ -724,38 +733,38 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
724 733
   do_blocking_move_to(npos);
725 734
 
726 735
   float measured_z = NAN;
727
-  if (!DEPLOY_PROBE()) {
728
-    measured_z = run_z_probe() + probe_offset.z;
736
+  if (!deploy()) {
737
+    measured_z = run_z_probe() + offset.z;
729 738
 
730 739
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
731 740
     if (big_raise || raise_after == PROBE_PT_RAISE)
732 741
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
733 742
     else if (raise_after == PROBE_PT_STOW)
734
-      if (STOW_PROBE()) measured_z = NAN;
743
+      if (stow()) measured_z = NAN;
735 744
   }
736 745
 
737 746
   if (verbose_level > 2) {
738 747
     SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3);
739
-    SERIAL_ECHOPAIR_F(" Y: ", LOGICAL_Y_POSITION(ry), 3);
740
-    SERIAL_ECHOLNPAIR_F(" Z: ", measured_z, 3);
748
+    SERIAL_ECHOPAIR_F(   " Y: ", LOGICAL_Y_POSITION(ry), 3);
749
+    SERIAL_ECHOLNPAIR_F( " Z: ", measured_z, 3);
741 750
   }
742 751
 
743 752
   feedrate_mm_s = old_feedrate_mm_s;
744 753
 
745 754
   if (isnan(measured_z)) {
746
-    STOW_PROBE();
755
+    stow();
747 756
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
748 757
     SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
749 758
   }
750 759
 
751
-  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_at_point");
760
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Probe::probe_at_point");
752 761
 
753 762
   return measured_z;
754 763
 }
755 764
 
756 765
 #if HAS_Z_SERVO_PROBE
757 766
 
758
-  void servo_probe_init() {
767
+  void Probe::servo_probe_init() {
759 768
     /**
760 769
      * Set position of Z Servo Endstop
761 770
      *

+ 125
- 107
Marlin/src/module/probe.h 파일 보기

@@ -22,132 +22,150 @@
22 22
 #pragma once
23 23
 
24 24
 /**
25
- * probe.h - Move, deploy, enable, etc.
25
+ * module/probe.h - Move, deploy, enable, etc.
26 26
  */
27 27
 
28 28
 #include "../inc/MarlinConfig.h"
29 29
 
30 30
 #if HAS_BED_PROBE
31
-
32
-  extern xyz_pos_t probe_offset;
33
-
34
-  #if HAS_PROBE_XY_OFFSET
35
-    extern xyz_pos_t &probe_offset_xy;
36
-  #else
37
-    constexpr xy_pos_t probe_offset_xy{0};
38
-  #endif
39
-
40
-  bool set_probe_deployed(const bool deploy);
41
-  #ifdef Z_AFTER_PROBING
42
-    void move_z_after_probing();
43
-  #endif
44
-  enum ProbePtRaise : unsigned char {
45
-    PROBE_PT_NONE,  // No raise or stow after run_z_probe
46
-    PROBE_PT_STOW,  // Do a complete stow after run_z_probe
47
-    PROBE_PT_RAISE, // Raise to "between" clearance after run_z_probe
31
+  enum ProbePtRaise : uint8_t {
32
+    PROBE_PT_NONE,      // No raise or stow after run_z_probe
33
+    PROBE_PT_STOW,      // Do a complete stow after run_z_probe
34
+    PROBE_PT_RAISE,     // Raise to "between" clearance after run_z_probe
48 35
     PROBE_PT_BIG_RAISE  // Raise to big clearance after run_z_probe
49 36
   };
50
-  float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
51
-  inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
52
-    return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
53
-  }
54
-  #define DEPLOY_PROBE() set_probe_deployed(true)
55
-  #define STOW_PROBE() set_probe_deployed(false)
56
-  #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
57
-    extern const char msg_wait_for_bed_heating[25];
58
-  #endif
37
+#endif
59 38
 
60
-#else
39
+class Probe {
40
+public:
61 41
 
62
-  constexpr xyz_pos_t probe_offset{0};
63
-  constexpr xy_pos_t probe_offset_xy{0};
42
+  #if HAS_BED_PROBE
64 43
 
65
-  #define DEPLOY_PROBE()
66
-  #define STOW_PROBE()
44
+    static xyz_pos_t offset;
67 45
 
68
-#endif
46
+    // Use offset_xy for read only access
47
+    // More optimal the XY offset is known to always be zero.
48
+    #if HAS_PROBE_XY_OFFSET
49
+      static const xyz_pos_t &offset_xy;
50
+    #else
51
+      static constexpr xy_pos_t offset_xy{0};
52
+    #endif
69 53
 
70
-#if HAS_BED_PROBE || HAS_LEVELING
71
-  #if IS_KINEMATIC
72
-    constexpr float printable_radius = (
73
-      #if ENABLED(DELTA)
74
-        DELTA_PRINTABLE_RADIUS
75
-      #elif IS_SCARA
76
-        SCARA_PRINTABLE_RADIUS
77
-      #endif
78
-    );
79
-
80
-    inline float probe_radius() {
81
-      return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
54
+    static bool set_deployed(const bool deploy);
55
+
56
+    #ifdef Z_AFTER_PROBING
57
+      static void move_z_after_probing();
58
+    #endif
59
+    static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true);
60
+    static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true) {
61
+      return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative);
82 62
     }
63
+    #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
64
+      static PGM_P msg_wait_for_bed_heating[25];
65
+    #endif
66
+
67
+  #else
68
+
69
+    static constexpr xyz_pos_t offset{0};
70
+    static constexpr xy_pos_t offset_xy{0};
71
+
72
+    static bool set_deployed(const bool) { return false; }
73
+
83 74
   #endif
84 75
 
85
-  inline float probe_min_x() {
86
-    return (
87
-      #if IS_KINEMATIC
88
-        (X_CENTER) - probe_radius()
89
-      #else
90
-        _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x)
91
-      #endif
92
-    );
93
-  }
94
-  inline float probe_max_x() {
95
-    return (
96
-      #if IS_KINEMATIC
97
-        (X_CENTER) + probe_radius()
98
-      #else
99
-        _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
100
-      #endif
101
-    );
102
-  }
103
-  inline float probe_min_y() {
104
-    return (
105
-      #if IS_KINEMATIC
106
-        (Y_CENTER) - probe_radius()
107
-      #else
108
-        _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
109
-      #endif
110
-    );
111
-  }
112
-  inline float probe_max_y() {
113
-    return (
114
-      #if IS_KINEMATIC
115
-        (Y_CENTER) + probe_radius()
116
-      #else
117
-        _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
118
-      #endif
119
-    );
120
-  }
121
-
122
-  #if NEEDS_THREE_PROBE_POINTS
123
-    // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
124
-    template <typename T>
125
-    inline void get_three_probe_points(T points[3]) {
126
-      #if ENABLED(HAS_FIXED_3POINT)
127
-        points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
128
-        points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
129
-        points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
130
-      #else
76
+  static inline bool deploy() { return set_deployed(true); }
77
+  static inline bool stow() { return set_deployed(false); }
78
+
79
+  #if HAS_BED_PROBE || HAS_LEVELING
80
+    #if IS_KINEMATIC
81
+      static constexpr float printable_radius = (
82
+        #if ENABLED(DELTA)
83
+          DELTA_PRINTABLE_RADIUS
84
+        #elif IS_SCARA
85
+          SCARA_PRINTABLE_RADIUS
86
+        #endif
87
+      );
88
+
89
+      static inline float probe_radius() {
90
+        return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(offset_xy.x, offset_xy.y));
91
+      }
92
+    #endif
93
+
94
+    static inline float min_x() {
95
+      return (
131 96
         #if IS_KINEMATIC
132
-          constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
133
-                          COS0 = 1.0, COS120 = -0.5    , COS240 = -0.5;
134
-          points[0].set((X_CENTER) + probe_radius() * COS0,   (Y_CENTER) + probe_radius() * SIN0);
135
-          points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
136
-          points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
97
+          (X_CENTER) - probe_radius()
137 98
         #else
138
-          points[0].set(probe_min_x(), probe_min_y());
139
-          points[1].set(probe_max_x(), probe_min_y());
140
-          points[2].set((probe_max_x() - probe_min_x()) / 2, probe_max_y());
99
+          _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + offset_xy.x)
141 100
         #endif
142
-      #endif
101
+      );
143 102
     }
103
+    static inline float max_x() {
104
+      return (
105
+        #if IS_KINEMATIC
106
+          (X_CENTER) + probe_radius()
107
+        #else
108
+          _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + offset_xy.x)
109
+        #endif
110
+      );
111
+    }
112
+    static inline float min_y() {
113
+      return (
114
+        #if IS_KINEMATIC
115
+          (Y_CENTER) - probe_radius()
116
+        #else
117
+          _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + offset_xy.y)
118
+        #endif
119
+      );
120
+    }
121
+    static inline float max_y() {
122
+      return (
123
+        #if IS_KINEMATIC
124
+          (Y_CENTER) + probe_radius()
125
+        #else
126
+          _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + offset_xy.y)
127
+        #endif
128
+      );
129
+    }
130
+
131
+    #if NEEDS_THREE_PROBE_POINTS
132
+      // Retrieve three points to probe the bed. Any type exposing set(X,Y) may be used.
133
+      template <typename T>
134
+      static inline void get_three_points(T points[3]) {
135
+        #if ENABLED(HAS_FIXED_3POINT)
136
+          points[0].set(PROBE_PT_1_X, PROBE_PT_1_Y);
137
+          points[1].set(PROBE_PT_2_X, PROBE_PT_2_Y);
138
+          points[2].set(PROBE_PT_3_X, PROBE_PT_3_Y);
139
+        #else
140
+          #if IS_KINEMATIC
141
+            constexpr float SIN0 = 0.0, SIN120 = 0.866025, SIN240 = -0.866025,
142
+                            COS0 = 1.0, COS120 = -0.5    , COS240 = -0.5;
143
+            points[0].set((X_CENTER) + probe_radius() * COS0,   (Y_CENTER) + probe_radius() * SIN0);
144
+            points[1].set((X_CENTER) + probe_radius() * COS120, (Y_CENTER) + probe_radius() * SIN120);
145
+            points[2].set((X_CENTER) + probe_radius() * COS240, (Y_CENTER) + probe_radius() * SIN240);
146
+          #else
147
+            points[0].set(min_x(), min_y());
148
+            points[1].set(max_x(), min_y());
149
+            points[2].set((max_x() - min_x()) / 2, max_y());
150
+          #endif
151
+        #endif
152
+      }
153
+    #endif
154
+
155
+  #endif // HAS_BED_PROBE
156
+
157
+  #if HAS_Z_SERVO_PROBE
158
+    static void servo_probe_init();
144 159
   #endif
145
-#endif
146 160
 
147
-#if HAS_Z_SERVO_PROBE
148
-  void servo_probe_init();
149
-#endif
161
+  #if QUIET_PROBING
162
+    static void set_probing_paused(const bool p);
163
+  #endif
150 164
 
151
-#if QUIET_PROBING
152
-  void probing_pause(const bool p);
153
-#endif
165
+private:
166
+  static bool move_to_z(const float z, const feedRate_t fr_mm_s);
167
+  static void do_z_raise(const float z_raise);
168
+  static float run_z_probe();
169
+};
170
+
171
+extern Probe probe;

Loading…
취소
저장