Browse Source

Encapsulate probe as singleton class (#16751)

Scott Lahteine 5 years ago
parent
commit
90b6324563
No account linked to committer's email address
33 changed files with 338 additions and 300 deletions
  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 View File

977
   #endif
977
   #endif
978
 
978
 
979
   #if HAS_Z_SERVO_PROBE
979
   #if HAS_Z_SERVO_PROBE
980
-    servo_probe_init();
980
+    probe.servo_probe_init();
981
   #endif
981
   #endif
982
 
982
 
983
   #if HAS_PHOTOGRAPH
983
   #if HAS_PHOTOGRAPH

+ 10
- 10
Marlin/src/core/utility.cpp View File

83
     #if HAS_BED_PROBE
83
     #if HAS_BED_PROBE
84
 
84
 
85
       #if !HAS_PROBE_XY_OFFSET
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
       #else
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
           SERIAL_ECHOPGM(" (Right");
90
           SERIAL_ECHOPGM(" (Right");
91
-        else if (probe_offset.x < 0)
91
+        else if (probe.offset_xy.x < 0)
92
           SERIAL_ECHOPGM(" (Left");
92
           SERIAL_ECHOPGM(" (Left");
93
-        else if (probe_offset.y != 0)
93
+        else if (probe.offset_xy.y != 0)
94
           SERIAL_ECHOPGM(" (Middle");
94
           SERIAL_ECHOPGM(" (Middle");
95
         else
95
         else
96
           SERIAL_ECHOPGM(" (Aligned With");
96
           SERIAL_ECHOPGM(" (Aligned With");
97
 
97
 
98
-        if (probe_offset.y > 0) {
98
+        if (probe.offset_xy.y > 0) {
99
           #if IS_SCARA
99
           #if IS_SCARA
100
             SERIAL_ECHOPGM("-Distal");
100
             SERIAL_ECHOPGM("-Distal");
101
           #else
101
           #else
102
             SERIAL_ECHOPGM("-Back");
102
             SERIAL_ECHOPGM("-Back");
103
           #endif
103
           #endif
104
         }
104
         }
105
-        else if (probe_offset.y < 0) {
105
+        else if (probe.offset_xy.y < 0) {
106
           #if IS_SCARA
106
           #if IS_SCARA
107
             SERIAL_ECHOPGM("-Proximal");
107
             SERIAL_ECHOPGM("-Proximal");
108
           #else
108
           #else
109
             SERIAL_ECHOPGM("-Front");
109
             SERIAL_ECHOPGM("-Front");
110
           #endif
110
           #endif
111
         }
111
         }
112
-        else if (probe_offset.x != 0)
112
+        else if (probe.offset_xy.x != 0)
113
           SERIAL_ECHOPGM("-Center");
113
           SERIAL_ECHOPGM("-Center");
114
 
114
 
115
         SERIAL_ECHOPGM(" & ");
115
         SERIAL_ECHOPGM(" & ");
116
 
116
 
117
       #endif
117
       #endif
118
 
118
 
119
-      if (probe_offset.z < 0)
119
+      if (probe.offset.z < 0)
120
         SERIAL_ECHOPGM("Below");
120
         SERIAL_ECHOPGM("Below");
121
-      else if (probe_offset.z > 0)
121
+      else if (probe.offset.z > 0)
122
         SERIAL_ECHOPGM("Above");
122
         SERIAL_ECHOPGM("Above");
123
       else
123
       else
124
         SERIAL_ECHOPGM("Same Z as");
124
         SERIAL_ECHOPGM("Same Z as");

+ 2
- 2
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

173
       serialprintPGM(csv ? PSTR("CSV:\n") : PSTR("LCD:\n"));
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
     // moving to the XY position to be measured. This ensures better agreement between
177
     // moving to the XY position to be measured. This ensures better agreement between
178
     // the current Z position after G28 and the mesh values.
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
     if (!lcd) SERIAL_EOL();
181
     if (!lcd) SERIAL_EOL();
182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

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

450
               SERIAL_ECHO(g29_pos.y);
450
               SERIAL_ECHO(g29_pos.y);
451
               SERIAL_ECHOLNPGM(").\n");
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
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
454
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
455
 
455
 
456
             report_current_position();
456
             report_current_position();
480
                 #if IS_KINEMATIC
480
                 #if IS_KINEMATIC
481
                   X_HOME_POS, Y_HOME_POS
481
                   X_HOME_POS, Y_HOME_POS
482
                 #else
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
                 #endif
485
                 #endif
486
               );
486
               );
487
             }
487
             }
742
      * This attempts to fill in locations closest to the nozzle's start location first.
742
      * This attempts to fill in locations closest to the nozzle's start location first.
743
      */
743
      */
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) {
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
       #if HAS_LCD_MENU
747
       #if HAS_LCD_MENU
748
         ui.capture();
748
         ui.capture();
768
             ui.wait_for_release();
768
             ui.wait_for_release();
769
             ui.quick_feedback();
769
             ui.quick_feedback();
770
             ui.release();
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
             return restore_ubl_active_state_and_leave();
772
             return restore_ubl_active_state_and_leave();
773
           }
773
           }
774
         #endif
774
         #endif
778
           : find_closest_mesh_point_of_type(INVALID, near, true);
778
           : find_closest_mesh_point_of_type(INVALID, near, true);
779
 
779
 
780
         if (best.pos.x >= 0) {    // mesh point found and is reachable by probe
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
                         best.meshpos(),
782
                         best.meshpos(),
783
                         stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
783
                         stow_probe ? PROBE_PT_STOW : PROBE_PT_RAISE, g29_verbose_level
784
                       );
784
                       );
794
       #if HAS_LCD_MENU
794
       #if HAS_LCD_MENU
795
         ui.release();
795
         ui.release();
796
       #endif
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
       #if HAS_LCD_MENU
798
       #if HAS_LCD_MENU
799
         ui.capture();
799
         ui.capture();
800
       #endif
800
       #endif
801
 
801
 
802
       #ifdef Z_AFTER_PROBING
802
       #ifdef Z_AFTER_PROBING
803
-        move_z_after_probing();
803
+        probe.move_z_after_probing();
804
       #endif
804
       #endif
805
 
805
 
806
       restore_ubl_active_state_and_leave();
806
       restore_ubl_active_state_and_leave();
807
 
807
 
808
       do_blocking_move_to_xy(
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
       ui.return_to_status();
907
       ui.return_to_status();
908
 
908
 
909
       mesh_index_pair location;
909
       mesh_index_pair location;
910
-      xy_int8_t &lpos = location.pos;
910
+      const xy_int8_t &lpos = location.pos;
911
       do {
911
       do {
912
         location = find_closest_mesh_point_of_type(INVALID, pos);
912
         location = find_closest_mesh_point_of_type(INVALID, pos);
913
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
913
         // It doesn't matter if the probe can't reach the NAN location. This is a manual probe.
1006
       #endif
1006
       #endif
1007
 
1007
 
1008
       MeshFlags done_flags{0};
1008
       MeshFlags done_flags{0};
1009
-      xy_int8_t &lpos = location.pos;
1009
+      const xy_int8_t &lpos = location.pos;
1010
       do {
1010
       do {
1011
         location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags);
1011
         location = find_closest_mesh_point_of_type(SET_IN_BITMAP, pos, false, &done_flags);
1012
 
1012
 
1294
     closest.distance = -99999.9f;
1294
     closest.distance = -99999.9f;
1295
 
1295
 
1296
     // Get the reference position, either nozzle or probe
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
     float best_so_far = 99999.99f;
1299
     float best_so_far = 99999.99f;
1300
 
1300
 
1393
     #include "../../../libs/vector_3.h"
1393
     #include "../../../libs/vector_3.h"
1394
 
1394
 
1395
     void unified_bed_leveling::tilt_mesh_based_on_probed_grid(const bool do_3_pt_leveling) {
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
                   dx = (x_max - x_min) / (g29_grid_size - 1),
1398
                   dx = (x_max - x_min) / (g29_grid_size - 1),
1399
                   dy = (y_max - y_min) / (g29_grid_size - 1);
1399
                   dy = (y_max - y_min) / (g29_grid_size - 1);
1400
 
1400
 
1401
       xy_float_t points[3];
1401
       xy_float_t points[3];
1402
-      get_three_probe_points(points);
1402
+      probe.get_three_points(points);
1403
 
1403
 
1404
       float measured_z;
1404
       float measured_z;
1405
       bool abort_flag = false;
1405
       bool abort_flag = false;
1417
           ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1417
           ui.status_printf_P(0, PSTR(S_FMT " 1/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1418
         #endif
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
         if (isnan(measured_z))
1421
         if (isnan(measured_z))
1422
           abort_flag = true;
1422
           abort_flag = true;
1423
         else {
1423
         else {
1438
             ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1438
             ui.status_printf_P(0, PSTR(S_FMT " 2/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1439
           #endif
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
           #ifdef VALIDATE_MESH_TILT
1442
           #ifdef VALIDATE_MESH_TILT
1443
             z2 = measured_z;
1443
             z2 = measured_z;
1444
           #endif
1444
           #endif
1460
             ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1460
             ui.status_printf_P(0, PSTR(S_FMT " 3/3"), GET_TEXT(MSG_LCD_TILTING_MESH));
1461
           #endif
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
           #ifdef VALIDATE_MESH_TILT
1464
           #ifdef VALIDATE_MESH_TILT
1465
             z3 = measured_z;
1465
             z3 = measured_z;
1466
           #endif
1466
           #endif
1476
           }
1476
           }
1477
         }
1477
         }
1478
 
1478
 
1479
-        STOW_PROBE();
1479
+        probe.stow();
1480
         #ifdef Z_AFTER_PROBING
1480
         #ifdef Z_AFTER_PROBING
1481
-          move_z_after_probing();
1481
+          probe.move_z_after_probing();
1482
         #endif
1482
         #endif
1483
 
1483
 
1484
         if (abort_flag) {
1484
         if (abort_flag) {
1504
                 ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
1504
                 ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_LCD_TILTING_MESH), point_num, total_points);
1505
               #endif
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
               abort_flag = isnan(measured_z);
1509
               abort_flag = isnan(measured_z);
1510
 
1510
 
1523
                 }
1523
                 }
1524
               #endif
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
               if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F("   final >>>---> ", measured_z, 7);
1528
               if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F("   final >>>---> ", measured_z, 7);
1529
 
1529
 
1540
           zig_zag ^= true;
1540
           zig_zag ^= true;
1541
         }
1541
         }
1542
       }
1542
       }
1543
-      STOW_PROBE();
1543
+      probe.stow();
1544
       #ifdef Z_AFTER_PROBING
1544
       #ifdef Z_AFTER_PROBING
1545
-        move_z_after_probing();
1545
+        probe.move_z_after_probing();
1546
       #endif
1546
       #endif
1547
 
1547
 
1548
       if (abort_flag || finish_incremental_LSF(&lsf_results)) {
1548
       if (abort_flag || finish_incremental_LSF(&lsf_results)) {
1728
       adjust_mesh_to_mean(g29_c_flag, g29_constant);
1728
       adjust_mesh_to_mean(g29_c_flag, g29_constant);
1729
 
1729
 
1730
       #if HAS_BED_PROBE
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
       #endif
1732
       #endif
1733
 
1733
 
1734
       SERIAL_ECHOLNPAIR("MESH_MIN_X  " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);
1734
       SERIAL_ECHOLNPAIR("MESH_MIN_X  " STRINGIFY(MESH_MIN_X) "=", MESH_MIN_X); serial_delay(50);

+ 3
- 3
Marlin/src/gcode/bedlevel/G42.cpp View File

27
 #include "../gcode.h"
27
 #include "../gcode.h"
28
 #include "../../MarlinCore.h" // for IsRunning()
28
 #include "../../MarlinCore.h" // for IsRunning()
29
 #include "../../module/motion.h"
29
 #include "../../module/motion.h"
30
-#include "../../module/probe.h" // for probe_offset
30
+#include "../../module/probe.h" // for probe.offset
31
 #include "../../feature/bedlevel/bedlevel.h"
31
 #include "../../feature/bedlevel/bedlevel.h"
32
 
32
 
33
 /**
33
 /**
53
 
53
 
54
     #if HAS_PROBE_XY_OFFSET
54
     #if HAS_PROBE_XY_OFFSET
55
       if (parser.boolval('P')) {
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
     #endif
59
     #endif
60
 
60
 

+ 2
- 2
Marlin/src/gcode/bedlevel/M420.cpp View File

64
 
64
 
65
   #if ENABLED(MARLIN_DEV_MODE)
65
   #if ENABLED(MARLIN_DEV_MODE)
66
     if (parser.intval('S') == 2) {
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
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
69
       #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
70
         bilinear_start.set(x_min, y_min);
70
         bilinear_start.set(x_min, y_min);
71
         bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),
71
         bilinear_grid_spacing.set((x_max - x_min) / (GRID_MAX_POINTS_X - 1),

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

269
     #endif
269
     #endif
270
 
270
 
271
     vector_3 points[3];
271
     vector_3 points[3];
272
-    get_three_probe_points(points);
272
+    probe.get_three_points(points);
273
 
273
 
274
   #endif // AUTO_BED_LEVELING_3POINT
274
   #endif // AUTO_BED_LEVELING_3POINT
275
 
275
 
392
 
392
 
393
       xy_probe_feedrate_mm_s = MMM_TO_MMS(parser.linearval('S', XY_PROBE_SPEED));
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
       if (parser.seen('H')) {
398
       if (parser.seen('H')) {
399
         const int16_t size = (int16_t)parser.value_linear_units();
399
         const int16_t size = (int16_t)parser.value_linear_units();
452
 
452
 
453
     #if HAS_BED_PROBE
453
     #if HAS_BED_PROBE
454
       // Deploy the probe. Probe will raise if needed.
454
       // Deploy the probe. Probe will raise if needed.
455
-      if (DEPLOY_PROBE()) {
455
+      if (probe.deploy()) {
456
         set_bed_leveling_enabled(abl_should_enable);
456
         set_bed_leveling_enabled(abl_should_enable);
457
         G29_RETURN(false);
457
         G29_RETURN(false);
458
       }
458
       }
712
             ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
712
             ui.status_printf_P(0, PSTR(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_MESH), int(pt_index), int(GRID_MAX_POINTS));
713
           #endif
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
           if (isnan(measured_z)) {
717
           if (isnan(measured_z)) {
718
             set_bed_leveling_enabled(abl_should_enable);
718
             set_bed_leveling_enabled(abl_should_enable);
764
 
764
 
765
         // Retain the last probe position
765
         // Retain the last probe position
766
         probePos = points[i];
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
         if (isnan(measured_z)) {
768
         if (isnan(measured_z)) {
769
           set_bed_leveling_enabled(abl_should_enable);
769
           set_bed_leveling_enabled(abl_should_enable);
770
           break;
770
           break;
788
     #endif
788
     #endif
789
 
789
 
790
     // Stow the probe. No raise for FIX_MOUNTED_PROBE.
790
     // Stow the probe. No raise for FIX_MOUNTED_PROBE.
791
-    if (STOW_PROBE()) {
791
+    if (probe.stow()) {
792
       set_bed_leveling_enabled(abl_should_enable);
792
       set_bed_leveling_enabled(abl_should_enable);
793
       measured_z = NAN;
793
       measured_z = NAN;
794
     }
794
     }
923
         planner.force_unapply_leveling(converted); // use conversion machinery
923
         planner.force_unapply_leveling(converted); // use conversion machinery
924
 
924
 
925
         // Use the last measured distance to the bed, if possible
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
           const float simple_z = current_position.z - measured_z;
929
           const float simple_z = current_position.z - measured_z;
930
           if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted.z, "  Discrepancy ", simple_z - converted.z);
930
           if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted.z, "  Discrepancy ", simple_z - converted.z);
964
     sync_plan_position();
964
     sync_plan_position();
965
 
965
 
966
   #if HAS_BED_PROBE && defined(Z_AFTER_PROBING)
966
   #if HAS_BED_PROBE && defined(Z_AFTER_PROBING)
967
-    move_z_after_probing();
967
+    probe.move_z_after_probing();
968
   #endif
968
   #endif
969
 
969
 
970
   #ifdef Z_PROBE_END_SCRIPT
970
   #ifdef Z_PROBE_END_SCRIPT

+ 2
- 2
Marlin/src/gcode/calibrate/G28.cpp View File

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

+ 2
- 2
Marlin/src/gcode/calibrate/G33.cpp View File

100
     do_blocking_move_to_z(delta_clip_start_height);
100
     do_blocking_move_to_z(delta_clip_start_height);
101
   #endif
101
   #endif
102
   #if HAS_BED_PROBE
102
   #if HAS_BED_PROBE
103
-    STOW_PROBE();
103
+    probe.stow();
104
   #endif
104
   #endif
105
   restore_feedrate_and_scaling();
105
   restore_feedrate_and_scaling();
106
   #if HOTENDS > 1
106
   #if HOTENDS > 1
190
  */
190
  */
191
 static float calibration_probe(const xy_pos_t &xy, const bool stow) {
191
 static float calibration_probe(const xy_pos_t &xy, const bool stow) {
192
   #if HAS_BED_PROBE
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
   #else
194
   #else
195
     UNUSED(stow);
195
     UNUSED(stow);
196
     return lcd_probe_pt(xy);
196
     return lcd_probe_pt(xy);

+ 6
- 6
Marlin/src/gcode/calibrate/G34_M422.cpp View File

133
 
133
 
134
   do { // break out on error
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
       break;
138
       break;
139
     #endif
139
     #endif
140
 
140
 
240
         if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe);
240
         if (iteration == 0 || i > 0) do_blocking_move_to_z(z_probe);
241
 
241
 
242
         // Probe a Z height for each stepper.
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
         if (isnan(z_probed_height)) {
244
         if (isnan(z_probed_height)) {
245
           SERIAL_ECHOLNPGM("Probing failed.");
245
           SERIAL_ECHOLNPGM("Probing failed.");
246
           err_break = true;
246
           err_break = true;
314
 
314
 
315
         #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
315
         #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
316
           // Optimize one iteration's correction based on the first measurements
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
         #endif
318
         #endif
319
 
319
 
320
         // Check for less accuracy compared to last move
320
         // Check for less accuracy compared to last move
379
     // After this operation the z position needs correction
379
     // After this operation the z position needs correction
380
     set_axis_is_not_at_home(Z_AXIS);
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
     // the probe deployed if it was successful.
383
     // the probe deployed if it was successful.
384
-    STOW_PROBE();
384
+    probe.stow();
385
 
385
 
386
     // Home Z after the alignment procedure
386
     // Home Z after the alignment procedure
387
     process_subcommands_now_P(PSTR("G28 Z"));
387
     process_subcommands_now_P(PSTR("G28 Z"));

+ 8
- 8
Marlin/src/gcode/calibrate/G76_M871.cpp View File

113
     }
113
     }
114
     // Ensure probe position is reachable
114
     // Ensure probe position is reachable
115
     destination.set(
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
     if (!position_is_reachable_by_probe(destination)) {
119
     if (!position_is_reachable_by_probe(destination)) {
120
       SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
120
       SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
209
 
209
 
210
       // Do a single probe
210
       // Do a single probe
211
       remember_feedrate_scaling_off();
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
         PROBE_PT_NONE
215
         PROBE_PT_NONE
216
       );
216
       );
217
       restore_feedrate_and_scaling();
217
       restore_feedrate_and_scaling();
318
 
318
 
319
       // Do a single probe
319
       // Do a single probe
320
       remember_feedrate_scaling_off();
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
         PROBE_PT_NONE
324
         PROBE_PT_NONE
325
       );
325
       );
326
       restore_feedrate_and_scaling();
326
       restore_feedrate_and_scaling();

+ 6
- 6
Marlin/src/gcode/calibrate/M48.cpp View File

80
   xy_float_t next_pos = current_position;
80
   xy_float_t next_pos = current_position;
81
 
81
 
82
   const xy_pos_t probe_pos = {
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
   if (!position_is_reachable_by_probe(probe_pos)) {
87
   if (!position_is_reachable_by_probe(probe_pos)) {
120
   float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
120
   float mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
121
 
121
 
122
   // Move to the first point, deploy, and probe
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
   bool probing_good = !isnan(t);
124
   bool probing_good = !isnan(t);
125
 
125
 
126
   if (probing_good) {
126
   if (probing_good) {
169
           while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
169
           while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
170
                                                 // numbers outside of the range, but just to be safe we clamp them.
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
           next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
173
           next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
174
                        noz_pos.y + sin(RADIANS(angle)) * radius);
174
                        noz_pos.y + sin(RADIANS(angle)) * radius);
175
 
175
 
194
       } // n_legs
194
       } // n_legs
195
 
195
 
196
       // Probe a single point
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
       // Break the loop if the probe fails
199
       // Break the loop if the probe fails
200
       probing_good = !isnan(sample_set[n]);
200
       probing_good = !isnan(sample_set[n]);
238
     } // n_samples loop
238
     } // n_samples loop
239
   }
239
   }
240
 
240
 
241
-  STOW_PROBE();
241
+  probe.stow();
242
 
242
 
243
   if (probing_good) {
243
   if (probing_good) {
244
     SERIAL_ECHOLNPGM("Finished!");
244
     SERIAL_ECHOLNPGM("Finished!");

+ 7
- 0
Marlin/src/gcode/config/M304.cpp View File

27
 #include "../gcode.h"
27
 #include "../gcode.h"
28
 #include "../../module/temperature.h"
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
 void GcodeSuite::M304() {
37
 void GcodeSuite::M304() {
31
   if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
38
   if (parser.seen('P')) thermalManager.temp_bed.pid.Kp = parser.value_float();
32
   if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());
39
   if (parser.seen('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float());

+ 3
- 3
Marlin/src/gcode/motion/M290.cpp View File

46
         && active_extruder == 0
46
         && active_extruder == 0
47
       #endif
47
       #endif
48
     ) {
48
     ) {
49
-      probe_offset.z += offs;
49
+      probe.offset.z += offs;
50
       SERIAL_ECHO_START();
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
     else {
53
     else {
54
       #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
54
       #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
98
     SERIAL_ECHO_START();
98
     SERIAL_ECHO_START();
99
 
99
 
100
     #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
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
     #endif
102
     #endif
103
 
103
 
104
     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
104
     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)

+ 4
- 4
Marlin/src/gcode/probe/G30.cpp View File

40
  */
40
  */
41
 void GcodeSuite::G30() {
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
   if (!position_is_reachable_by_probe(pos)) return;
46
   if (!position_is_reachable_by_probe(pos)) return;
47
 
47
 
53
   remember_feedrate_scaling_off();
53
   remember_feedrate_scaling_off();
54
 
54
 
55
   const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;
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
   if (!isnan(measured_z))
57
   if (!isnan(measured_z))
58
     SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
58
     SERIAL_ECHOLNPAIR("Bed X: ", FIXFLOAT(pos.x), " Y: ", FIXFLOAT(pos.y), " Z: ", FIXFLOAT(measured_z));
59
 
59
 
60
   restore_feedrate_and_scaling();
60
   restore_feedrate_and_scaling();
61
 
61
 
62
   #ifdef Z_AFTER_PROBING
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
   #endif
64
   #endif
65
 
65
 
66
   report_current_position();
66
   report_current_position();

+ 2
- 2
Marlin/src/gcode/probe/G31_G32.cpp View File

30
 /**
30
 /**
31
  * G31: Deploy the Z probe
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
  * G32: Stow the Z probe
36
  * G32: Stow the Z probe
37
  */
37
  */
38
-void GcodeSuite::G32() { STOW_PROBE(); }
38
+void GcodeSuite::G32() { probe.stow(); }
39
 
39
 
40
 #endif // Z_PROBE_SLED
40
 #endif // Z_PROBE_SLED

+ 3
- 3
Marlin/src/gcode/probe/M401_M402.cpp View File

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

+ 4
- 4
Marlin/src/gcode/probe/M851.cpp View File

39
   if (!parser.seen("XYZ")) {
39
   if (!parser.seen("XYZ")) {
40
     SERIAL_ECHOLNPAIR_P(
40
     SERIAL_ECHOLNPAIR_P(
41
       #if HAS_PROBE_XY_OFFSET
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
       #else
43
       #else
44
         PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
44
         PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
45
       #endif
45
       #endif
46
-      , probe_offset.z
46
+      , probe.offset.z
47
     );
47
     );
48
     return;
48
     return;
49
   }
49
   }
50
 
50
 
51
   // Start with current offsets and modify
51
   // Start with current offsets and modify
52
-  xyz_pos_t offs = probe_offset;
52
+  xyz_pos_t offs = probe.offset;
53
 
53
 
54
   // Assume no errors
54
   // Assume no errors
55
   bool ok = true;
55
   bool ok = true;
93
   }
93
   }
94
 
94
 
95
   // Save the new offsets
95
   // Save the new offsets
96
-  if (ok) probe_offset = offs;
96
+  if (ok) probe.offset = offs;
97
 }
97
 }
98
 
98
 
99
 #endif // HAS_BED_PROBE
99
 #endif // HAS_BED_PROBE

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionFYSETC.cpp View File

453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
455
     #if HAS_BED_PROBE
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
       #if ENABLED(BABYSTEPPING)
457
       #if ENABLED(BABYSTEPPING)
458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
459
       #endif
459
       #endif

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionHIPRECY.cpp View File

453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
453
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
454
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
455
     #if HAS_BED_PROBE
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
       #if ENABLED(BABYSTEPPING)
457
       #if ENABLED(BABYSTEPPING)
458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
458
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
459
       #endif
459
       #endif

+ 1
- 1
Marlin/src/lcd/extensible_ui/lib/dgus/DGUSDisplayDefinitionOrigin.cpp View File

285
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
285
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_ReallyAbort, nullptr),
286
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
286
     VPHELPER(VP_SD_Print_Setting, nullptr, DGUSScreenVariableHandler::DGUSLCD_SD_PrintTune, nullptr),
287
     #if HAS_BED_PROBE
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
       #if ENABLED(BABYSTEPPING)
289
       #if ENABLED(BABYSTEPPING)
290
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
290
         VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, DGUSScreenVariableHandler::HandleLiveAdjustZ, nullptr),
291
       #endif
291
       #endif

+ 3
- 3
Marlin/src/lcd/extensible_ui/ui_api.cpp View File

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

+ 4
- 4
Marlin/src/lcd/menu/menu.cpp View File

406
       ui.encoderPosition = 0;
406
       ui.encoderPosition = 0;
407
 
407
 
408
       const float diff = planner.steps_to_mm[Z_AXIS] * babystep_increment,
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
                   new_offs =
410
                   new_offs =
411
                     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
411
                     #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
412
                       do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
412
                       do_probe ? new_probe_offset : hotend_offset[active_extruder].z - diff
418
 
418
 
419
         babystep.add_steps(Z_AXIS, babystep_increment);
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
         #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
422
         #if ENABLED(BABYSTEP_HOTEND_Z_OFFSET)
423
           else hotend_offset[active_extruder].z = new_offs;
423
           else hotend_offset[active_extruder].z = new_offs;
424
         #endif
424
         #endif
432
           MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z));
432
           MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_HOTEND_OFFSET_Z), LCD_Z_OFFSET_FUNC(hotend_offset[active_extruder].z));
433
         else
433
         else
434
       #endif
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
       #if ENABLED(BABYSTEP_ZPROBE_GFX_OVERLAY)
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
       #endif
439
       #endif
440
     }
440
     }
441
   }
441
   }

+ 5
- 3
Marlin/src/lcd/menu/menu_advanced.cpp View File

497
     void menu_probe_offsets() {
497
     void menu_probe_offsets() {
498
       START_MENU();
498
       START_MENU();
499
       BACK_ITEM(MSG_ADVANCED_SETTINGS);
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
       END_MENU();
505
       END_MENU();
504
     }
506
     }
505
   #endif
507
   #endif

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_leveling.cpp View File

279
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
279
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
280
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
280
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
281
   #elif HAS_BED_PROBE
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
   #endif
283
   #endif
284
 
284
 
285
   #if ENABLED(LEVEL_BED_CORNERS)
285
   #if ENABLED(LEVEL_BED_CORNERS)

+ 1
- 4
Marlin/src/lcd/menu/menu_configuration.cpp View File

317
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
317
   #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
318
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
318
     SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
319
   #elif HAS_BED_PROBE
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
   #endif
321
   #endif
322
 
322
 
323
   const bool busy = printer_busy();
323
   const bool busy = printer_busy();
324
   if (!busy) {
324
   if (!busy) {
325
-    //
326
-    // Delta Calibration
327
-    //
328
     #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
325
     #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION)
329
       SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
326
       SUBMENU(MSG_DELTA_CALIBRATE, menu_delta_calibrate);
330
     #endif
327
     #endif

+ 20
- 15
Marlin/src/module/configuration_store.cpp View File

587
       #if HAS_FILAMENT_SENSOR
587
       #if HAS_FILAMENT_SENSOR
588
         const bool &runout_sensor_enabled = runout.enabled;
588
         const bool &runout_sensor_enabled = runout.enabled;
589
       #else
589
       #else
590
-        const bool runout_sensor_enabled = true;
590
+        constexpr bool runout_sensor_enabled = true;
591
       #endif
591
       #endif
592
       #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
592
       #if HAS_FILAMENT_SENSOR && defined(FILAMENT_RUNOUT_DISTANCE_MM)
593
         const float &runout_distance_mm = runout.runout_distance();
593
         const float &runout_distance_mm = runout.runout_distance();
594
       #else
594
       #else
595
-        const float runout_distance_mm = 0;
595
+        constexpr float runout_distance_mm = 0;
596
       #endif
596
       #endif
597
       _FIELD_TEST(runout_sensor_enabled);
597
       _FIELD_TEST(runout_sensor_enabled);
598
       EEPROM_WRITE(runout_sensor_enabled);
598
       EEPROM_WRITE(runout_sensor_enabled);
643
     //
643
     //
644
     {
644
     {
645
       _FIELD_TEST(probe_offset);
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
       //
1463
       //
1459
       {
1464
       {
1460
         #if HAS_FILAMENT_SENSOR
1465
         #if HAS_FILAMENT_SENSOR
1461
-          bool &runout_sensor_enabled = runout.enabled;
1466
+          const bool &runout_sensor_enabled = runout.enabled;
1462
         #else
1467
         #else
1463
           bool runout_sensor_enabled;
1468
           bool runout_sensor_enabled;
1464
         #endif
1469
         #endif
1515
       {
1520
       {
1516
         _FIELD_TEST(probe_offset);
1521
         _FIELD_TEST(probe_offset);
1517
         #if HAS_BED_PROBE
1522
         #if HAS_BED_PROBE
1518
-          xyz_pos_t &zpo = probe_offset;
1523
+          const xyz_pos_t &zpo = probe.offset;
1519
         #else
1524
         #else
1520
           xyz_pos_t zpo;
1525
           xyz_pos_t zpo;
1521
         #endif
1526
         #endif
1609
       {
1614
       {
1610
         _FIELD_TEST(bltouch_last_written_mode);
1615
         _FIELD_TEST(bltouch_last_written_mode);
1611
         #if ENABLED(BLTOUCH)
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
         #else
1618
         #else
1614
           bool bltouch_last_written_mode;
1619
           bool bltouch_last_written_mode;
1615
         #endif
1620
         #endif
2120
       //
2125
       //
2121
       {
2126
       {
2122
         #if ENABLED(BACKLASH_GCODE)
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
         #else
2130
         #else
2126
           float backlash_distance_mm[XYZ];
2131
           float backlash_distance_mm[XYZ];
2127
           uint8_t backlash_correction;
2132
           uint8_t backlash_correction;
2128
         #endif
2133
         #endif
2129
         #if ENABLED(BACKLASH_GCODE) && defined(BACKLASH_SMOOTHING_MM)
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
         #else
2136
         #else
2132
           float backlash_smoothing_mm;
2137
           float backlash_smoothing_mm;
2133
         #endif
2138
         #endif
2461
     constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
2466
     constexpr float dpo[] = NOZZLE_TO_PROBE_OFFSET;
2462
     static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2467
     static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2463
     #if HAS_PROBE_XY_OFFSET
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
     #else
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
     #endif
2473
     #endif
2469
   #endif
2474
   #endif
2470
 
2475
 
3216
       CONFIG_ECHO_START();
3221
       CONFIG_ECHO_START();
3217
       SERIAL_ECHOLNPAIR_P(
3222
       SERIAL_ECHOLNPAIR_P(
3218
         #if HAS_PROBE_XY_OFFSET
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
                   SP_Z_STR
3226
                   SP_Z_STR
3222
         #else
3227
         #else
3223
           PSTR("  M851 X0 Y0 Z")
3228
           PSTR("  M851 X0 Y0 Z")
3224
         #endif
3229
         #endif
3225
-        , LINEAR_UNIT(probe_offset.z)
3230
+        , LINEAR_UNIT(probe.offset.z)
3226
       );
3231
       );
3227
     #endif
3232
     #endif
3228
 
3233
 

+ 2
- 2
Marlin/src/module/delta.cpp View File

95
   float delta_calibration_radius() {
95
   float delta_calibration_radius() {
96
     return calibration_radius_factor * (
96
     return calibration_radius_factor * (
97
       #if HAS_BED_PROBE
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
       #else
99
       #else
100
         DELTA_PRINTABLE_RADIUS
100
         DELTA_PRINTABLE_RADIUS
101
       #endif
101
       #endif
251
   // Move all carriages together linearly until an endstop is hit.
251
   // Move all carriages together linearly until an endstop is hit.
252
   current_position.z = (delta_height + 10
252
   current_position.z = (delta_height + 10
253
     #if HAS_BED_PROBE
253
     #if HAS_BED_PROBE
254
-      - probe_offset.z
254
+      - probe.offset.z
255
     #endif
255
     #endif
256
   );
256
   );
257
   line_to_current_position(homing_feedrate(Z_AXIS));
257
   line_to_current_position(homing_feedrate(Z_AXIS));

+ 10
- 10
Marlin/src/module/motion.cpp View File

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

+ 4
- 4
Marlin/src/module/motion.h View File

329
       // Return true if the both nozzle and the probe can reach the given point.
329
       // Return true if the both nozzle and the probe can reach the given point.
330
       // Note: This won't work on SCARA since the probe offset rotates with the arm.
330
       // Note: This won't work on SCARA since the probe offset rotates with the arm.
331
       inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
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
                && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
333
                && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
334
       }
334
       }
335
 
335
 
369
      *          nozzle must be be able to reach +10,-10.
369
      *          nozzle must be be able to reach +10,-10.
370
      */
370
      */
371
     inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
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
   #endif // HAS_BED_PROBE
377
   #endif // HAS_BED_PROBE

+ 2
- 2
Marlin/src/module/planner.cpp View File

2779
       const xyze_float_t &max_acc_edit_scaled = max_accel_edit;
2779
       const xyze_float_t &max_acc_edit_scaled = max_accel_edit;
2780
     #else
2780
     #else
2781
       constexpr xyze_float_t max_accel_edit = DEFAULT_MAX_ACCELERATION;
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
     #endif
2783
     #endif
2784
     limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled);
2784
     limit_and_warn(targetValue, axis, PSTR("Acceleration"), max_acc_edit_scaled);
2785
   #endif
2785
   #endif
2796
       const xyze_float_t &max_fr_edit_scaled = max_fr_edit;
2796
       const xyze_float_t &max_fr_edit_scaled = max_fr_edit;
2797
     #else
2797
     #else
2798
       constexpr xyze_float_t max_fr_edit = DEFAULT_MAX_FEEDRATE;
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
     #endif
2800
     #endif
2801
     limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled);
2801
     limit_and_warn(targetValue, axis, PSTR("Feedrate"), max_fr_edit_scaled);
2802
   #endif
2802
   #endif

+ 57
- 48
Marlin/src/module/probe.cpp View File

21
  */
21
  */
22
 
22
 
23
 /**
23
 /**
24
- * probe.cpp
24
+ * module/probe.cpp
25
  */
25
  */
26
 
26
 
27
 #include "../inc/MarlinConfig.h"
27
 #include "../inc/MarlinConfig.h"
84
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
84
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
85
 #include "../core/debug_out.h"
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
 #if HAS_PROBE_XY_OFFSET
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
 #endif
93
 #endif
93
 
94
 
94
-
95
 #if ENABLED(Z_PROBE_SLED)
95
 #if ENABLED(Z_PROBE_SLED)
96
 
96
 
97
   #ifndef SLED_DOCKING_OFFSET
97
   #ifndef SLED_DOCKING_OFFSET
104
    * stow[in]     If false, move to MAX_X and engage the solenoid
104
    * stow[in]     If false, move to MAX_X and engage the solenoid
105
    *              If true, move to MAX_X and release the solenoid
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
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
108
     if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
109
 
109
 
110
     // Dock sled a bit closer to ensure proper capturing
110
     // Dock sled a bit closer to ensure proper capturing
118
 #elif ENABLED(TOUCH_MI_PROBE)
118
 #elif ENABLED(TOUCH_MI_PROBE)
119
 
119
 
120
   // Move to the magnet to unlock the probe
120
   // Move to the magnet to unlock the probe
121
-  void run_deploy_moves_script() {
121
+  inline void run_deploy_moves_script() {
122
     #ifndef TOUCH_MI_DEPLOY_XPOS
122
     #ifndef TOUCH_MI_DEPLOY_XPOS
123
       #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS
123
       #define TOUCH_MI_DEPLOY_XPOS X_MIN_POS
124
     #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED
124
     #elif TOUCH_MI_DEPLOY_XPOS > X_MAX_BED
153
   }
153
   }
154
 
154
 
155
   // Move down to the bed to stow the probe
155
   // Move down to the bed to stow the probe
156
-  void run_stow_moves_script() {
156
+  inline void run_stow_moves_script() {
157
     const xyz_pos_t oldpos = current_position;
157
     const xyz_pos_t oldpos = current_position;
158
     endstops.enable_z_probe(false);
158
     endstops.enable_z_probe(false);
159
     do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
159
     do_blocking_move_to_z(TOUCH_MI_RETRACT_Z, MMM_TO_MMS(HOMING_FEEDRATE_Z));
162
 
162
 
163
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
163
 #elif ENABLED(Z_PROBE_ALLEN_KEY)
164
 
164
 
165
-  void run_deploy_moves_script() {
165
+  inline void run_deploy_moves_script() {
166
     #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1
166
     #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_1
167
       #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE
167
       #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE
168
         #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0
168
         #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0
200
     #endif
200
     #endif
201
   }
201
   }
202
 
202
 
203
-  void run_stow_moves_script() {
203
+  inline void run_stow_moves_script() {
204
     #ifdef Z_PROBE_ALLEN_KEY_STOW_1
204
     #ifdef Z_PROBE_ALLEN_KEY_STOW_1
205
       #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE
205
       #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE
206
         #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0
206
         #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0
241
 #endif // Z_PROBE_ALLEN_KEY
241
 #endif // Z_PROBE_ALLEN_KEY
242
 
242
 
243
 #if QUIET_PROBING
243
 #if QUIET_PROBING
244
-  void probing_pause(const bool p) {
244
+
245
+  void Probe::set_probing_paused(const bool p) {
245
     #if ENABLED(PROBING_HEATERS_OFF)
246
     #if ENABLED(PROBING_HEATERS_OFF)
246
       thermalManager.pause(p);
247
       thermalManager.pause(p);
247
     #endif
248
     #endif
262
       #endif
263
       #endif
263
     );
264
     );
264
   }
265
   }
266
+
265
 #endif // QUIET_PROBING
267
 #endif // QUIET_PROBING
266
 
268
 
267
 /**
269
 /**
268
  * Raise Z to a minimum height to make room for a probe to move
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
   float z_dest = z_raise;
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
   NOMORE(z_dest, Z_MAX_POS);
278
   NOMORE(z_dest, Z_MAX_POS);
277
 
279
 
351
   #endif
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
   if (DEBUGGING(LEVELING)) {
363
   if (DEBUGGING(LEVELING)) {
358
-    DEBUG_POS("set_probe_deployed", current_position);
364
+    DEBUG_POS("Probe::set_deployed", current_position);
359
     DEBUG_ECHOLNPAIR("deploy: ", deploy);
365
     DEBUG_ECHOLNPAIR("deploy: ", deploy);
360
   }
366
   }
361
 
367
 
378
   #endif
384
   #endif
379
 
385
 
380
   if (deploy_stow_condition && unknown_condition)
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
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
389
   #if EITHER(Z_PROBE_SLED, Z_PROBE_ALLEN_KEY)
384
     if (axis_unhomed_error(
390
     if (axis_unhomed_error(
433
 
439
 
434
 #ifdef Z_AFTER_PROBING
440
 #ifdef Z_AFTER_PROBING
435
   // After probing move to a preferred Z position
441
   // After probing move to a preferred Z position
436
-  void move_z_after_probing() {
442
+  void Probe::move_z_after_probing() {
437
     if (current_position.z != Z_AFTER_PROBING) {
443
     if (current_position.z != Z_AFTER_PROBING) {
438
       do_blocking_move_to_z(Z_AFTER_PROBING);
444
       do_blocking_move_to_z(Z_AFTER_PROBING);
439
       current_position.z = Z_AFTER_PROBING;
445
       current_position.z = Z_AFTER_PROBING;
450
  */
456
  */
451
 
457
 
452
 #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
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
 #endif
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
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
465
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
460
     // Wait for bed to heat back up between probing points
466
     // Wait for bed to heat back up between probing points
482
   #endif
488
   #endif
483
 
489
 
484
   #if QUIET_PROBING
490
   #if QUIET_PROBING
485
-    probing_pause(true);
491
+    set_probing_paused(true);
486
   #endif
492
   #endif
487
 
493
 
488
   // Move down until the probe is triggered
494
   // Move down until the probe is triggered
504
   ;
510
   ;
505
 
511
 
506
   #if QUIET_PROBING
512
   #if QUIET_PROBING
507
-    probing_pause(false);
513
+    set_probing_paused(false);
508
   #endif
514
   #endif
509
 
515
 
510
   // Re-enable stealthChop if used. Disable diag1 pin on driver.
516
   // Re-enable stealthChop if used. Disable diag1 pin on driver.
530
   // Tell the planner where we actually are
536
   // Tell the planner where we actually are
531
   sync_plan_position();
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
   return !probe_triggered;
541
   return !probe_triggered;
536
 }
542
 }
543
  *
549
  *
544
  * @return The Z position of the bed at the current XY or NAN on error.
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
   // Stop the probe before it goes too low to prevent damage.
556
   // Stop the probe before it goes too low to prevent damage.
551
   // If Z isn't known then probe to -10mm.
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
   // Double-probing does a fast probe followed by a slow probe
560
   // Double-probing does a fast probe followed by a slow probe
555
   #if TOTAL_PROBING == 2
561
   #if TOTAL_PROBING == 2
556
 
562
 
557
     // Do a first probe at the fast speed
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
       if (DEBUGGING(LEVELING)) {
565
       if (DEBUGGING(LEVELING)) {
560
         DEBUG_ECHOLNPGM("FAST Probe fail!");
566
         DEBUG_ECHOLNPGM("FAST Probe fail!");
561
         DEBUG_POS("<<< run_z_probe", current_position);
567
         DEBUG_POS("<<< run_z_probe", current_position);
574
 
580
 
575
     // If the nozzle is well over the travel height then
581
     // If the nozzle is well over the travel height then
576
     // move down quickly before doing the slow probe
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
     if (current_position.z > z) {
584
     if (current_position.z > z) {
579
       // Probe down fast. If the probe never triggered, raise for probe clearance
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
         do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
587
         do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
582
     }
588
     }
583
   #endif
589
   #endif
587
   #endif
593
   #endif
588
 
594
 
589
   #if TOTAL_PROBING > 2
595
   #if TOTAL_PROBING > 2
590
-    float probes_total = 0;
596
+    float probes_z_sum = 0;
591
     for (
597
     for (
592
       #if EXTRA_PROBING
598
       #if EXTRA_PROBING
593
         uint8_t p = 0; p < TOTAL_PROBING; p++
599
         uint8_t p = 0; p < TOTAL_PROBING; p++
598
   #endif
604
   #endif
599
     {
605
     {
600
       // Probe downward slowly to find the bed
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
         if (DEBUGGING(LEVELING)) {
608
         if (DEBUGGING(LEVELING)) {
603
           DEBUG_ECHOLNPGM("SLOW Probe fail!");
609
           DEBUG_ECHOLNPGM("SLOW Probe fail!");
604
           DEBUG_POS("<<< run_z_probe", current_position);
610
           DEBUG_POS("<<< run_z_probe", current_position);
622
           }
628
           }
623
         }
629
         }
624
       #elif TOTAL_PROBING > 2
630
       #elif TOTAL_PROBING > 2
625
-        probes_total += z;
631
+        probes_z_sum += z;
626
       #else
632
       #else
627
         UNUSED(z);
633
         UNUSED(z);
628
       #endif
634
       #endif
653
 
659
 
654
       // Return the average value of all remaining probes.
660
       // Return the average value of all remaining probes.
655
       for (uint8_t i = min_avg_idx; i <= max_avg_idx; i++)
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
     #endif
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
   #elif TOTAL_PROBING == 2
668
   #elif TOTAL_PROBING == 2
663
 
669
 
689
  *   - Raise to the BETWEEN height
695
  *   - Raise to the BETWEEN height
690
  * - Return the probed Z position
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
   if (DEBUGGING(LEVELING)) {
699
   if (DEBUGGING(LEVELING)) {
694
     DEBUG_ECHOLNPAIR(
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
       ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
702
       ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
697
       ", ", int(verbose_level),
703
       ", ", int(verbose_level),
698
       ", ", probe_relative ? "probe" : "nozzle", "_relative)"
704
       ", ", probe_relative ? "probe" : "nozzle", "_relative)"
702
 
708
 
703
   // TODO: Adapt for SCARA, where the offset rotates
709
   // TODO: Adapt for SCARA, where the offset rotates
704
   xyz_pos_t npos = { rx, ry };
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
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
718
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
710
 
719
 
724
   do_blocking_move_to(npos);
733
   do_blocking_move_to(npos);
725
 
734
 
726
   float measured_z = NAN;
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
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
739
     const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
731
     if (big_raise || raise_after == PROBE_PT_RAISE)
740
     if (big_raise || raise_after == PROBE_PT_RAISE)
732
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
741
       do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
733
     else if (raise_after == PROBE_PT_STOW)
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
   if (verbose_level > 2) {
746
   if (verbose_level > 2) {
738
     SERIAL_ECHOPAIR_F("Bed X: ", LOGICAL_X_POSITION(rx), 3);
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
   feedrate_mm_s = old_feedrate_mm_s;
752
   feedrate_mm_s = old_feedrate_mm_s;
744
 
753
 
745
   if (isnan(measured_z)) {
754
   if (isnan(measured_z)) {
746
-    STOW_PROBE();
755
+    stow();
747
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
756
     LCD_MESSAGEPGM(MSG_LCD_PROBING_FAILED);
748
     SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
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
   return measured_z;
762
   return measured_z;
754
 }
763
 }
755
 
764
 
756
 #if HAS_Z_SERVO_PROBE
765
 #if HAS_Z_SERVO_PROBE
757
 
766
 
758
-  void servo_probe_init() {
767
+  void Probe::servo_probe_init() {
759
     /**
768
     /**
760
      * Set position of Z Servo Endstop
769
      * Set position of Z Servo Endstop
761
      *
770
      *

+ 125
- 107
Marlin/src/module/probe.h View File

22
 #pragma once
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
 #include "../inc/MarlinConfig.h"
28
 #include "../inc/MarlinConfig.h"
29
 
29
 
30
 #if HAS_BED_PROBE
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
     PROBE_PT_BIG_RAISE  // Raise to big clearance after run_z_probe
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
   #endif
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
         #if IS_KINEMATIC
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
         #else
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
         #endif
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
   #endif
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…
Cancel
Save