Browse Source

Unify debugging output with debug_out.h (#13388)

Scott Lahteine 5 years ago
parent
commit
f5bcc00570
No account linked to committer's email address

+ 89
- 0
Marlin/src/core/debug_out.h View File

@@ -0,0 +1,89 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+//
25
+// Serial aliases for debugging.
26
+// Include this header after defining DEBUG_OUT
27
+//  (or not) in a given .cpp file
28
+//
29
+
30
+#undef DEBUG_ECHO_START
31
+#undef DEBUG_ERROR_START
32
+#undef DEBUG_CHAR
33
+#undef DEBUG_ECHO
34
+#undef DEBUG_ECHO_F
35
+#undef DEBUG_ECHOLN
36
+#undef DEBUG_ECHOPGM
37
+#undef DEBUG_ECHOLNPGM
38
+#undef DEBUG_ECHOPAIR
39
+#undef DEBUG_ECHOPAIR_F
40
+#undef DEBUG_ECHOLNPAIR
41
+#undef DEBUG_ECHOLNPAIR_F
42
+#undef DEBUG_ECHO_MSG
43
+#undef DEBUG_ERROR_MSG
44
+#undef DEBUG_EOL
45
+#undef DEBUG_POS
46
+#undef DEBUG_XYZ
47
+#undef DEBUG_DELAY
48
+
49
+#if DEBUG_OUT
50
+  #define DEBUG_ECHO_START        SERIAL_ECHO_START
51
+  #define DEBUG_ERROR_START       SERIAL_ERROR_START
52
+  #define DEBUG_CHAR              SERIAL_CHAR
53
+  #define DEBUG_ECHO              SERIAL_ECHO
54
+  #define DEBUG_ECHO_F            SERIAL_ECHO_F
55
+  #define DEBUG_ECHOLN            SERIAL_ECHOLN
56
+  #define DEBUG_ECHOPGM           SERIAL_ECHOPGM
57
+  #define DEBUG_ECHOLNPGM         SERIAL_ECHOLNPGM
58
+  #define DEBUG_ECHOPAIR          SERIAL_ECHOPAIR
59
+  #define DEBUG_ECHOPAIR_F        SERIAL_ECHOPAIR_F
60
+  #define DEBUG_ECHOLNPAIR        SERIAL_ECHOLNPAIR
61
+  #define DEBUG_ECHOLNPAIR_F      SERIAL_ECHOLNPAIR_F
62
+  #define DEBUG_ECHO_MSG          SERIAL_ECHO_MSG
63
+  #define DEBUG_ERROR_MSG         SERIAL_ERROR_MSG
64
+  #define DEBUG_EOL               SERIAL_EOL
65
+  #define DEBUG_POS               SERIAL_POS
66
+  #define DEBUG_XYZ               SERIAL_XYZ
67
+  #define DEBUG_DELAY(ms)         serial_delay(ms)
68
+#else
69
+  #define DEBUG_ECHO_START()      NOOP
70
+  #define DEBUG_ERROR_START()     NOOP
71
+  #define DEBUG_CHAR(...)         NOOP
72
+  #define DEBUG_ECHO(...)         NOOP
73
+  #define DEBUG_ECHO_F(...)       NOOP
74
+  #define DEBUG_ECHOLN(...)       NOOP
75
+  #define DEBUG_ECHOPGM(...)      NOOP
76
+  #define DEBUG_ECHOLNPGM(...)    NOOP
77
+  #define DEBUG_ECHOPAIR(...)     NOOP
78
+  #define DEBUG_ECHOPAIR_F(...)   NOOP
79
+  #define DEBUG_ECHOLNPAIR(...)   NOOP
80
+  #define DEBUG_ECHOLNPAIR_F(...) NOOP
81
+  #define DEBUG_ECHO_MSG(...)     NOOP
82
+  #define DEBUG_ERROR_MSG(...)    NOOP
83
+  #define DEBUG_EOL()             NOOP
84
+  #define DEBUG_POS(...)          NOOP
85
+  #define DEBUG_XYZ(...)          NOOP
86
+  #define DEBUG_DELAY(...)        NOOP
87
+#endif
88
+
89
+#undef DEBUG_OUT

+ 12
- 3
Marlin/src/core/serial.h View File

@@ -35,8 +35,13 @@ enum MarlinDebugFlags : uint8_t {
35 35
   MARLIN_DEBUG_ERRORS        = _BV(2), ///< Not implemented
36 36
   MARLIN_DEBUG_DRYRUN        = _BV(3), ///< Ignore temperature setting and E movement commands
37 37
   MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
38
-  MARLIN_DEBUG_LEVELING      = _BV(5), ///< Print detailed output for homing and leveling
39
-  MARLIN_DEBUG_MESH_ADJUST   = _BV(6), ///< UBL bed leveling
38
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
39
+    MARLIN_DEBUG_LEVELING    = _BV(5), ///< Print detailed output for homing and leveling
40
+    MARLIN_DEBUG_MESH_ADJUST = _BV(6), ///< UBL bed leveling
41
+  #else
42
+    MARLIN_DEBUG_LEVELING    = 0,
43
+    MARLIN_DEBUG_MESH_ADJUST = 0,
44
+  #endif
40 45
   MARLIN_DEBUG_ALL           = 0xFF
41 46
 };
42 47
 
@@ -178,5 +183,9 @@ void print_bin(const uint16_t val);
178 183
 #if ENABLED(DEBUG_LEVELING_FEATURE)
179 184
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
180 185
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
181
-  #define DEBUG_POS(SUFFIX,VAR) do { print_xyz(PSTR("  " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
186
+  #define SERIAL_POS(SUFFIX,VAR) do { print_xyz(PSTR("  " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
187
+  #define SERIAL_XYZ(PREFIX,...) do { print_xyz(PSTR(PREFIX), NULL, __VA_ARGS__); } while(0)
188
+#else
189
+  #define SERIAL_POS(...) NOOP
190
+  #define SERIAL_XYZ(...) NOOP
182 191
 #endif

+ 5
- 2
Marlin/src/core/utility.cpp View File

@@ -321,8 +321,11 @@ void safe_delay(millis_t ms) {
321 321
     );
322 322
 
323 323
     #if HAS_BED_PROBE
324
-      SERIAL_ECHOPGM("Probe Offset X:" STRINGIFY(X_PROBE_OFFSET_FROM_EXTRUDER) " Y:" STRINGIFY(Y_PROBE_OFFSET_FROM_EXTRUDER));
325
-      SERIAL_ECHOPAIR(" Z:", zprobe_zoffset);
324
+      SERIAL_ECHOPAIR(
325
+        "Probe Offset X:" STRINGIFY(X_PROBE_OFFSET_FROM_EXTRUDER)
326
+                    " Y:" STRINGIFY(Y_PROBE_OFFSET_FROM_EXTRUDER)
327
+                    " Z:", zprobe_zoffset
328
+      );
326 329
       if ((X_PROBE_OFFSET_FROM_EXTRUDER) > 0)
327 330
         SERIAL_ECHOPGM(" (Right");
328 331
       else if ((X_PROBE_OFFSET_FROM_EXTRUDER) < 0)

+ 2
- 0
Marlin/src/core/utility.h View File

@@ -118,6 +118,8 @@ inline void serial_delay(const millis_t ms) {
118 118
 
119 119
 #if ENABLED(DEBUG_LEVELING_FEATURE)
120 120
   void log_machine_info();
121
+#else
122
+  #define log_machine_info() NOOP
121 123
 #endif
122 124
 
123 125
 template<typename T>

+ 15
- 17
Marlin/src/feature/bedlevel/abl/abl.cpp View File

@@ -29,6 +29,9 @@
29 29
 
30 30
 #include "../../../module/motion.h"
31 31
 
32
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
33
+#include "../../../core/debug_out.h"
34
+
32 35
 int bilinear_grid_spacing[2], bilinear_start[2];
33 36
 float bilinear_grid_factor[2],
34 37
       z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
@@ -37,26 +40,21 @@ float bilinear_grid_factor[2],
37 40
  * Extrapolate a single point from its neighbors
38 41
  */
39 42
 static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
40
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
41
-    if (DEBUGGING(LEVELING)) {
42
-      SERIAL_ECHOPGM("Extrapolate [");
43
-      if (x < 10) SERIAL_CHAR(' ');
44
-      SERIAL_ECHO((int)x);
45
-      SERIAL_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' ');
46
-      SERIAL_CHAR(' ');
47
-      if (y < 10) SERIAL_CHAR(' ');
48
-      SERIAL_ECHO((int)y);
49
-      SERIAL_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' ');
50
-      SERIAL_CHAR(']');
51
-    }
52
-  #endif
43
+  if (DEBUGGING(LEVELING)) {
44
+    DEBUG_ECHOPGM("Extrapolate [");
45
+    if (x < 10) DEBUG_CHAR(' ');
46
+    DEBUG_ECHO((int)x);
47
+    DEBUG_CHAR(xdir ? (xdir > 0 ? '+' : '-') : ' ');
48
+    DEBUG_CHAR(' ');
49
+    if (y < 10) DEBUG_CHAR(' ');
50
+    DEBUG_ECHO((int)y);
51
+    DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' ');
52
+    DEBUG_ECHOLNPGM("]");
53
+  }
53 54
   if (!isnan(z_values[x][y])) {
54
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
55
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" (done)");
56
-    #endif
55
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" (done)");
57 56
     return;  // Don't overwrite good values.
58 57
   }
59
-  SERIAL_EOL();
60 58
 
61 59
   // Get X neighbors, Y neighbors, and XY neighbors
62 60
   const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;

+ 4
- 3
Marlin/src/feature/bedlevel/bedlevel.cpp View File

@@ -39,6 +39,9 @@
39 39
   #include "../../lcd/ultralcd.h"
40 40
 #endif
41 41
 
42
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
43
+#include "../../core/debug_out.h"
44
+
42 45
 #if ENABLED(G26_MESH_VALIDATION)
43 46
   bool g26_debug_flag; // = false
44 47
 #endif
@@ -122,9 +125,7 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
122 125
  * Reset calibration results to zero.
123 126
  */
124 127
 void reset_bed_level() {
125
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
126
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
127
-  #endif
128
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("reset_bed_level");
128 129
   set_bed_leveling_enabled(false);
129 130
   #if ENABLED(MESH_BED_LEVELING)
130 131
     mbl.reset();

+ 29
- 32
Marlin/src/feature/bedlevel/ubl/ubl.h View File

@@ -29,6 +29,9 @@
29 29
 #include "../../../lcd/ultralcd.h"
30 30
 #include "../../../Marlin.h"
31 31
 
32
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
33
+#include "../../../core/debug_out.h"
34
+
32 35
 #define UBL_VERSION "1.01"
33 36
 #define UBL_OK false
34 37
 #define UBL_ERR true
@@ -199,12 +202,11 @@ class unified_bed_leveling {
199 202
      */
200 203
     static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
201 204
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
202
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
203
-          if (DEBUGGING(LEVELING)) {
204
-            serialprintPGM( !WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) ? PSTR("x1_i") : PSTR("yi") );
205
-            SERIAL_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")");
206
-          }
207
-        #endif
205
+
206
+        if (DEBUGGING(LEVELING)) {
207
+          if (WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("yi"); else DEBUG_ECHOPGM("x1_i");
208
+          DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_x_on_horizontal_mesh_line(rx0=", rx0, ",x1_i=", x1_i, ",yi=", yi, ")");
209
+        }
208 210
 
209 211
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
210 212
         return (
@@ -229,12 +231,11 @@ class unified_bed_leveling {
229 231
     //
230 232
     static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
231 233
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
232
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
233
-          if (DEBUGGING(LEVELING)) {
234
-            serialprintPGM(!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) ? PSTR("xi") : PSTR("y1_i"));
235
-            SERIAL_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")");
236
-          }
237
-        #endif
234
+
235
+        if (DEBUGGING(LEVELING)) {
236
+          if (WITHIN(xi, 0, GRID_MAX_POINTS_X - 1)) DEBUG_ECHOPGM("y1_i"); else DEBUG_ECHOPGM("xi");
237
+          DEBUG_ECHOLNPAIR(" out of bounds in z_correction_for_y_on_vertical_mesh_line(ry0=", ry0, ", xi=", xi, ", y1_i=", y1_i, ")");
238
+        }
238 239
 
239 240
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
240 241
         return (
@@ -285,17 +286,12 @@ class unified_bed_leveling {
285 286
                          mesh_index_to_ypos(cy), z1,
286 287
                          mesh_index_to_ypos(cy + 1), z2);
287 288
 
288
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
289
-        if (DEBUGGING(MESH_ADJUST)) {
290
-          SERIAL_ECHOPAIR(" raw get_z_correction(", rx0);
291
-          SERIAL_CHAR(','); SERIAL_ECHO(ry0);
292
-          SERIAL_ECHOPAIR_F(") = ", z0, 6);
293
-        }
294
-      #endif
295
-
296
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
297
-        if (DEBUGGING(MESH_ADJUST)) SERIAL_ECHOLNPAIR_F(" >>>---> ", z0, 6);
298
-      #endif
289
+      if (DEBUGGING(MESH_ADJUST)) {
290
+        DEBUG_ECHOPAIR(" raw get_z_correction(", rx0);
291
+        DEBUG_CHAR(','); DEBUG_ECHO(ry0);
292
+        DEBUG_ECHOPAIR_F(") = ", z0, 6);
293
+        DEBUG_ECHOLNPAIR_F(" >>>---> ", z0, 6);
294
+      }
299 295
 
300 296
       if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
301 297
         z0 = 0.0;      // in ubl.z_values[][] and propagate through the
@@ -303,15 +299,13 @@ class unified_bed_leveling {
303 299
                        // because part of the Mesh is undefined and we don't have the
304 300
                        // information we need to complete the height correction.
305 301
 
306
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
307
-          if (DEBUGGING(MESH_ADJUST)) {
308
-            SERIAL_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
309
-            SERIAL_CHAR(',');
310
-            SERIAL_ECHO(ry0);
311
-            SERIAL_CHAR(')');
312
-            SERIAL_EOL();
313
-          }
314
-        #endif
302
+        if (DEBUGGING(MESH_ADJUST)) {
303
+          DEBUG_ECHOPAIR("??? Yikes!  NAN in get_z_correction(", rx0);
304
+          DEBUG_CHAR(',');
305
+          DEBUG_ECHO(ry0);
306
+          DEBUG_CHAR(')');
307
+          DEBUG_EOL();
308
+        }
315 309
       }
316 310
       return z0;
317 311
     }
@@ -342,3 +336,6 @@ class unified_bed_leveling {
342 336
 extern unified_bed_leveling ubl;
343 337
 
344 338
 #define Z_VALUES(X,Y) ubl.z_values[X][Y]
339
+
340
+// Prevent debugging propagating to other files
341
+#include "../../../core/debug_out.h"

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

@@ -46,6 +46,9 @@
46 46
     #include "../../../module/tool_change.h"
47 47
   #endif
48 48
 
49
+  #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
50
+  #include "../../../core/debug_out.h"
51
+
49 52
   #include <math.h>
50 53
 
51 54
   #define UBL_G29_P31
@@ -442,7 +445,7 @@
442 445
               SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
443 446
             }
444 447
             if (g29_verbose_level > 1) {
445
-              SERIAL_ECHOPAIR("Probing Mesh Points Closest to (", g29_x_pos);
448
+              SERIAL_ECHOPAIR("Probing around (", g29_x_pos);
446 449
               SERIAL_CHAR(',');
447 450
               SERIAL_ECHO(g29_y_pos);
448 451
               SERIAL_ECHOLNPGM(").\n");
@@ -1463,27 +1466,24 @@
1463 1466
 
1464 1467
               abort_flag = isnan(measured_z);
1465 1468
 
1466
-              #if ENABLED(DEBUG_LEVELING_FEATURE)
1467
-                if (DEBUGGING(LEVELING)) {
1468
-                  SERIAL_CHAR('(');
1469
-                  SERIAL_ECHO_F(rx, 7);
1470
-                  SERIAL_CHAR(',');
1471
-                  SERIAL_ECHO_F(ry, 7);
1472
-                  SERIAL_ECHOPGM(")   logical: ");
1473
-                  SERIAL_CHAR('(');
1474
-                  SERIAL_ECHO_F(LOGICAL_X_POSITION(rx), 7);
1475
-                  SERIAL_CHAR(',');
1476
-                  SERIAL_ECHO_F(LOGICAL_Y_POSITION(ry), 7);
1477
-                  SERIAL_ECHOPAIR_F(")   measured: ", measured_z, 7);
1478
-                  SERIAL_ECHOPAIR_F("   correction: ", get_z_correction(rx, ry), 7);
1479
-                }
1480
-              #endif
1469
+              if (DEBUGGING(LEVELING)) {
1470
+                DEBUG_CHAR('(');
1471
+                DEBUG_ECHO_F(rx, 7);
1472
+                DEBUG_CHAR(',');
1473
+                DEBUG_ECHO_F(ry, 7);
1474
+                DEBUG_ECHOPGM(")   logical: ");
1475
+                DEBUG_CHAR('(');
1476
+                DEBUG_ECHO_F(LOGICAL_X_POSITION(rx), 7);
1477
+                DEBUG_CHAR(',');
1478
+                DEBUG_ECHO_F(LOGICAL_Y_POSITION(ry), 7);
1479
+                DEBUG_ECHOPAIR_F(")   measured: ", measured_z, 7);
1480
+                DEBUG_ECHOPAIR_F("   correction: ", get_z_correction(rx, ry), 7);
1481
+              }
1481 1482
 
1482 1483
               measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
1483 1484
 
1484
-              #if ENABLED(DEBUG_LEVELING_FEATURE)
1485
-                if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR_F("   final >>>---> ", measured_z, 7);
1486
-              #endif
1485
+              if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR_F("   final >>>---> ", measured_z, 7);
1486
+
1487 1487
               if (g29_verbose_level > 3) {
1488 1488
                 serial_spaces(16);
1489 1489
                 SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
@@ -1524,31 +1524,27 @@
1524 1524
                 y_tmp = mesh_index_to_ypos(j),
1525 1525
                 z_tmp = z_values[i][j];
1526 1526
 
1527
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
1528
-            if (DEBUGGING(LEVELING)) {
1529
-              SERIAL_ECHOPAIR_F("before rotation = [", x_tmp, 7);
1530
-              SERIAL_CHAR(',');
1531
-              SERIAL_ECHO_F(y_tmp, 7);
1532
-              SERIAL_CHAR(',');
1533
-              SERIAL_ECHO_F(z_tmp, 7);
1534
-              SERIAL_ECHOPGM("]   ---> ");
1535
-              serial_delay(20);
1536
-            }
1537
-          #endif
1527
+          if (DEBUGGING(LEVELING)) {
1528
+            DEBUG_ECHOPAIR_F("before rotation = [", x_tmp, 7);
1529
+            DEBUG_CHAR(',');
1530
+            DEBUG_ECHO_F(y_tmp, 7);
1531
+            DEBUG_CHAR(',');
1532
+            DEBUG_ECHO_F(z_tmp, 7);
1533
+            DEBUG_ECHOPGM("]   ---> ");
1534
+            DEBUG_DELAY(20);
1535
+          }
1538 1536
 
1539 1537
           apply_rotation_xyz(rotation, x_tmp, y_tmp, z_tmp);
1540 1538
 
1541
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
1542
-            if (DEBUGGING(LEVELING)) {
1543
-              SERIAL_ECHOPAIR_F("after rotation = [", x_tmp, 7);
1544
-              SERIAL_CHAR(',');
1545
-              SERIAL_ECHO_F(y_tmp, 7);
1546
-              SERIAL_CHAR(',');
1547
-              SERIAL_ECHO_F(z_tmp, 7);
1548
-              SERIAL_ECHOLNPGM("]");
1549
-              serial_delay(55);
1550
-            }
1551
-          #endif
1539
+          if (DEBUGGING(LEVELING)) {
1540
+            DEBUG_ECHOPAIR_F("after rotation = [", x_tmp, 7);
1541
+            DEBUG_CHAR(',');
1542
+            DEBUG_ECHO_F(y_tmp, 7);
1543
+            DEBUG_CHAR(',');
1544
+            DEBUG_ECHO_F(z_tmp, 7);
1545
+            DEBUG_ECHOLNPGM("]");
1546
+            DEBUG_DELAY(55);
1547
+          }
1552 1548
 
1553 1549
           z_values[i][j] = z_tmp - lsf_results.D;
1554 1550
           #if ENABLED(EXTENSIBLE_UI)
@@ -1557,62 +1553,59 @@
1557 1553
         }
1558 1554
       }
1559 1555
 
1560
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1561
-        if (DEBUGGING(LEVELING)) {
1562
-          rotation.debug(PSTR("rotation matrix:\n"));
1563
-          SERIAL_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7);
1564
-          SERIAL_ECHOPAIR_F("  B=", lsf_results.B, 7);
1565
-          SERIAL_ECHOLNPAIR_F("  D=", lsf_results.D, 7);
1566
-          serial_delay(55);
1567
-
1568
-          SERIAL_ECHOPAIR_F("bed plane normal = [", normal.x, 7);
1569
-          SERIAL_CHAR(',');
1570
-          SERIAL_ECHO_F(normal.y, 7);
1571
-          SERIAL_CHAR(',');
1572
-          SERIAL_ECHO_F(normal.z, 7);
1573
-          SERIAL_ECHOLNPGM("]");
1574
-          SERIAL_EOL();
1575
-
1576
-          /**
1577
-           * The following code can be used to check the validity of the mesh tilting algorithm.
1578
-           * When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
1579
-           * The only difference is just 3 points are used in the calculations.   That fact guarantees
1580
-           * each probed point should have an exact match when a get_z_correction() for that location
1581
-           * is calculated.  The Z error between the probed point locations and the get_z_correction()
1582
-           * numbers for those locations should be 0.
1583
-           */
1584
-          #if 0
1585
-          float t, t1, d;
1586
-          t = normal.x * (PROBE_PT_1_X) + normal.y * (PROBE_PT_1_Y);
1587
-          d = t + normal.z * z1;
1588
-          SERIAL_ECHOPAIR_F("D from 1st point: ", d, 6);
1589
-          SERIAL_ECHOLNPAIR_F("   Z error: ", normal.z*z1-get_z_correction(PROBE_PT_1_X, PROBE_PT_1_Y), 6);
1590
-
1591
-          t = normal.x * (PROBE_PT_2_X) + normal.y * (PROBE_PT_2_Y);
1592
-          d = t + normal.z * z2;
1593
-          SERIAL_EOL();
1594
-          SERIAL_ECHOPAIR_F("D from 2nd point: ", d, 6);
1595
-          SERIAL_ECHOLNPAIR_F("   Z error: ", normal.z*z2-get_z_correction(PROBE_PT_2_X, PROBE_PT_2_Y), 6);
1596
-
1597
-          t = normal.x * (PROBE_PT_3_X) + normal.y * (PROBE_PT_3_Y);
1598
-          d = t + normal.z * z3;
1599
-          SERIAL_ECHOPAIR_F("D from 3rd point: ", d, 6);
1600
-          SERIAL_ECHOLNPAIR_F("   Z error: ", normal.z*z3-get_z_correction(PROBE_PT_3_X, PROBE_PT_3_Y), 6);
1601
-
1602
-          t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1603
-          d = t + normal.z * 0;
1604
-          SERIAL_ECHOLNPAIR_F("D from home location with Z=0 : ", d, 6);
1605
-
1606
-          t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1607
-          d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
1608
-          SERIAL_ECHOPAIR_F("D from home location using mesh value for Z: ", d, 6);
1609
-
1610
-          SERIAL_ECHOPAIR("   Z error: (", Z_SAFE_HOMING_X_POINT);
1611
-          SERIAL_ECHOPAIR(",", Z_SAFE_HOMING_Y_POINT);
1612
-          SERIAL_ECHOLNPAIR_F(") = ", get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6);
1613
-          #endif
1614
-        } // DEBUGGING(LEVELING)
1615
-      #endif
1556
+      if (DEBUGGING(LEVELING)) {
1557
+        rotation.debug(PSTR("rotation matrix:\n"));
1558
+        DEBUG_ECHOPAIR_F("LSF Results A=", lsf_results.A, 7);
1559
+        DEBUG_ECHOPAIR_F("  B=", lsf_results.B, 7);
1560
+        DEBUG_ECHOLNPAIR_F("  D=", lsf_results.D, 7);
1561
+        DEBUG_DELAY(55);
1562
+
1563
+        DEBUG_ECHOPAIR_F("bed plane normal = [", normal.x, 7);
1564
+        DEBUG_CHAR(',');
1565
+        DEBUG_ECHO_F(normal.y, 7);
1566
+        DEBUG_CHAR(',');
1567
+        DEBUG_ECHO_F(normal.z, 7);
1568
+        DEBUG_ECHOLNPGM("]");
1569
+        DEBUG_EOL();
1570
+
1571
+        /**
1572
+         * The following code can be used to check the validity of the mesh tilting algorithm.
1573
+         * When a 3-Point Mesh Tilt is done, the same algorithm is used as the grid based tilting.
1574
+         * The only difference is just 3 points are used in the calculations.   That fact guarantees
1575
+         * each probed point should have an exact match when a get_z_correction() for that location
1576
+         * is calculated.  The Z error between the probed point locations and the get_z_correction()
1577
+         * numbers for those locations should be 0.
1578
+         */
1579
+        #if 0
1580
+        float t, t1, d;
1581
+        t = normal.x * (PROBE_PT_1_X) + normal.y * (PROBE_PT_1_Y);
1582
+        d = t + normal.z * z1;
1583
+        DEBUG_ECHOPAIR_F("D from 1st point: ", d, 6);
1584
+        DEBUG_ECHOLNPAIR_F("   Z error: ", normal.z*z1-get_z_correction(PROBE_PT_1_X, PROBE_PT_1_Y), 6);
1585
+
1586
+        t = normal.x * (PROBE_PT_2_X) + normal.y * (PROBE_PT_2_Y);
1587
+        d = t + normal.z * z2;
1588
+        DEBUG_EOL();
1589
+        DEBUG_ECHOPAIR_F("D from 2nd point: ", d, 6);
1590
+        DEBUG_ECHOLNPAIR_F("   Z error: ", normal.z*z2-get_z_correction(PROBE_PT_2_X, PROBE_PT_2_Y), 6);
1591
+
1592
+        t = normal.x * (PROBE_PT_3_X) + normal.y * (PROBE_PT_3_Y);
1593
+        d = t + normal.z * z3;
1594
+        DEBUG_ECHOPAIR_F("D from 3rd point: ", d, 6);
1595
+        DEBUG_ECHOLNPAIR_F("   Z error: ", normal.z*z3-get_z_correction(PROBE_PT_3_X, PROBE_PT_3_Y), 6);
1596
+
1597
+        t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1598
+        d = t + normal.z * 0;
1599
+        DEBUG_ECHOLNPAIR_F("D from home location with Z=0 : ", d, 6);
1600
+
1601
+        t = normal.x * (Z_SAFE_HOMING_X_POINT) + normal.y * (Z_SAFE_HOMING_Y_POINT);
1602
+        d = t + get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT); // normal.z * 0;
1603
+        DEBUG_ECHOPAIR_F("D from home location using mesh value for Z: ", d, 6);
1604
+
1605
+        DEBUG_ECHOPAIR("   Z error: (", Z_SAFE_HOMING_X_POINT, ",", Z_SAFE_HOMING_Y_POINT);
1606
+        DEBUG_ECHOLNPAIR_F(") = ", get_z_correction(Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT), 6);
1607
+        #endif
1608
+      } // DEBUGGING(LEVELING)
1616 1609
 
1617 1610
     }
1618 1611
 

+ 30
- 89
Marlin/src/feature/prusa_MMU2/mmu2.cpp View File

@@ -42,6 +42,9 @@ MMU2 mmu2;
42 42
   #include "../../feature/host_actions.h"
43 43
 #endif
44 44
 
45
+#define DEBUG_OUT ENABLED(MMU2_DEBUG)
46
+#include "../../core/debug_out.h"
47
+
45 48
 #define MMU_TODELAY 100
46 49
 #define MMU_TIMEOUT 10
47 50
 #define MMU_CMD_TIMEOUT 60000ul //5min timeout for mmu commands (except P0)
@@ -128,9 +131,7 @@ void MMU2::init() {
128 131
 }
129 132
 
130 133
 void MMU2::reset() {
131
-  #if ENABLED(MMU2_DEBUG)
132
-    SERIAL_ECHOLNPGM("MMU <= reset");
133
-  #endif
134
+  DEBUG_ECHOLNPGM("MMU <= reset");
134 135
 
135 136
   #if PIN_EXISTS(MMU2_RST)
136 137
     WRITE(MMU2_RST_PIN, LOW);
@@ -153,10 +154,8 @@ void MMU2::mmuLoop() {
153 154
 
154 155
     case -1:
155 156
       if (rx_start()) {
156
-        #if ENABLED(MMU2_DEBUG)
157
-          SERIAL_ECHOLNPGM("MMU => 'start'");
158
-          SERIAL_ECHOLNPGM("MMU <= 'S1'");
159
-        #endif
157
+        DEBUG_ECHOLNPGM("MMU => 'start'");
158
+        DEBUG_ECHOLNPGM("MMU <= 'S1'");
160 159
 
161 160
         // send "read version" request
162 161
         tx_str_P(PSTR("S1\n"));
@@ -173,9 +172,7 @@ void MMU2::mmuLoop() {
173 172
       if (rx_ok()) {
174 173
         sscanf(rx_buffer, "%uok\n", &version);
175 174
 
176
-        #if ENABLED(MMU2_DEBUG)
177
-          SERIAL_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'");
178
-        #endif
175
+        DEBUG_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'");
179 176
 
180 177
         tx_str_P(PSTR("S2\n")); // read build number
181 178
         state = -3;
@@ -185,24 +182,19 @@ void MMU2::mmuLoop() {
185 182
     case -3:
186 183
       if (rx_ok()) {
187 184
         sscanf(rx_buffer, "%uok\n", &buildnr);
188
-        #if ENABLED(MMU2_DEBUG)
189
-          SERIAL_ECHOLNPAIR("MMU => ", buildnr);
190
-        #endif
185
+
186
+        DEBUG_ECHOLNPAIR("MMU => ", buildnr);
191 187
 
192 188
         checkVersion();
193 189
 
194 190
         #if ENABLED(MMU2_MODE_12V)
195
-          #if ENABLED(MMU2_DEBUG)
196
-            SERIAL_ECHOLNPGM("MMU <= 'M1'");
197
-          #endif
191
+          DEBUG_ECHOLNPGM("MMU <= 'M1'");
198 192
 
199 193
           tx_str_P(PSTR("M1\n")); // switch to stealth mode
200 194
           state = -5;
201 195
 
202 196
         #else
203
-          #if ENABLED(MMU2_DEBUG)
204
-            SERIAL_ECHOLNPGM("MMU <= 'P0'");
205
-          #endif
197
+          DEBUG_ECHOLNPGM("MMU <= 'P0'");
206 198
 
207 199
           tx_str_P(PSTR("P0\n")); // read finda
208 200
           state = -4;
@@ -213,15 +205,11 @@ void MMU2::mmuLoop() {
213 205
     case -5:
214 206
       // response to M1
215 207
       if (rx_ok()) {
216
-        #if ENABLED(MMU2_DEBUG)
217
-          SERIAL_ECHOLNPGM("MMU => ok");
218
-        #endif
208
+        DEBUG_ECHOLNPGM("MMU => ok");
219 209
 
220 210
         checkVersion();
221 211
 
222
-        #if ENABLED(MMU2_DEBUG)
223
-          SERIAL_ECHOLNPGM("MMU <= 'P0'");
224
-        #endif
212
+        DEBUG_ECHOLNPGM("MMU <= 'P0'");
225 213
 
226 214
         tx_str_P(PSTR("P0\n")); // read finda
227 215
         state = -4;
@@ -232,9 +220,7 @@ void MMU2::mmuLoop() {
232 220
       if (rx_ok()) {
233 221
         sscanf(rx_buffer, "%hhuok\n", &finda);
234 222
 
235
-        #if ENABLED(MMU2_DEBUG)
236
-          SERIAL_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED");
237
-        #endif
223
+        DEBUG_ECHOLNPAIR("MMU => ", finda, "\nMMU - ENABLED");
238 224
 
239 225
         enabled = true;
240 226
         state = 1;
@@ -246,40 +232,26 @@ void MMU2::mmuLoop() {
246 232
         if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) {
247 233
           // tool change
248 234
           int filament = cmd - MMU_CMD_T0;
249
-
250
-          #if ENABLED(MMU2_DEBUG)
251
-            SERIAL_ECHOLNPAIR("MMU <= T", filament);
252
-          #endif
253
-
235
+          DEBUG_ECHOLNPAIR("MMU <= T", filament);
254 236
           tx_printf_P(PSTR("T%d\n"), filament);
255 237
           state = 3; // wait for response
256 238
         }
257 239
         else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) {
258 240
           // load
259 241
           int filament = cmd - MMU_CMD_L0;
260
-
261
-          #if ENABLED(MMU2_DEBUG)
262
-            SERIAL_ECHOLNPAIR("MMU <= L", filament);
263
-          #endif
264
-
242
+          DEBUG_ECHOLNPAIR("MMU <= L", filament);
265 243
           tx_printf_P(PSTR("L%d\n"), filament);
266 244
           state = 3; // wait for response
267 245
         }
268 246
         else if (cmd == MMU_CMD_C0) {
269 247
           // continue loading
270
-
271
-          #if ENABLED(MMU2_DEBUG)
272
-            SERIAL_ECHOLNPGM("MMU <= 'C0'");
273
-          #endif
274
-
248
+          DEBUG_ECHOLNPGM("MMU <= 'C0'");
275 249
           tx_str_P(PSTR("C0\n"));
276 250
           state = 3; // wait for response
277 251
         }
278 252
         else if (cmd == MMU_CMD_U0) {
279 253
           // unload current
280
-          #if ENABLED(MMU2_DEBUG)
281
-            SERIAL_ECHOLNPGM("MMU <= 'U0'");
282
-          #endif
254
+          DEBUG_ECHOLNPGM("MMU <= 'U0'");
283 255
 
284 256
           tx_str_P(PSTR("U0\n"));
285 257
           state = 3; // wait for response
@@ -287,31 +259,22 @@ void MMU2::mmuLoop() {
287 259
         else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
288 260
           // eject filament
289 261
           int filament = cmd - MMU_CMD_E0;
290
-
291
-          #if ENABLED(MMU2_DEBUG)
292
-            SERIAL_ECHOLNPAIR("MMU <= E", filament);
293
-          #endif
262
+          DEBUG_ECHOLNPAIR("MMU <= E", filament);
294 263
           tx_printf_P(PSTR("E%d\n"), filament);
295 264
           state = 3; // wait for response
296 265
         }
297 266
         else if (cmd == MMU_CMD_R0) {
298 267
           // recover after eject
299
-          #if ENABLED(MMU2_DEBUG)
300
-            SERIAL_ECHOLNPGM("MMU <= 'R0'");
301
-          #endif
302
-
268
+          DEBUG_ECHOLNPGM("MMU <= 'R0'");
303 269
           tx_str_P(PSTR("R0\n"));
304 270
           state = 3; // wait for response
305 271
         }
306 272
         else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
307 273
           // filament type
308 274
           int filament = cmd - MMU_CMD_F0;
309
-          #if ENABLED(MMU2_DEBUG)
310
-            SERIAL_ECHOPAIR("MMU <= F", filament, " ");
311
-            SERIAL_ECHO_F(cmd_arg, DEC);
312
-            SERIAL_ECHOPGM("\n");
313
-          #endif
314
-
275
+          DEBUG_ECHOPAIR("MMU <= F", filament, " ");
276
+          DEBUG_ECHO_F(cmd_arg, DEC);
277
+          DEBUG_EOL();
315 278
           tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg);
316 279
           state = 3; // wait for response
317 280
         }
@@ -330,17 +293,8 @@ void MMU2::mmuLoop() {
330 293
       if (rx_ok()) {
331 294
         sscanf(rx_buffer, "%hhuok\n", &finda);
332 295
 
333
-        #if ENABLED(MMU2_DEBUG)
334
-          // This is super annoying. Only activate if necessary
335
-          /*
336
-            if (findaRunoutValid) {
337
-              SERIAL_ECHOLNPGM("MMU <= 'P0'");
338
-              SERIAL_ECHOPGM("MMU => ");
339
-              SERIAL_ECHO_F(finda, DEC);
340
-              SERIAL_ECHOPGM("\n");
341
-            }
342
-          */
343
-        #endif
296
+        // This is super annoying. Only activate if necessary
297
+        // if (findaRunoutValid) DEBUG_ECHOLNPAIR_F("MMU <= 'P0'\nMMU => ", finda, 6);
344 298
 
345 299
         state = 1;
346 300
 
@@ -355,10 +309,7 @@ void MMU2::mmuLoop() {
355 309
 
356 310
     case 3:   // response to mmu commands
357 311
       if (rx_ok()) {
358
-        #if ENABLED(MMU2_DEBUG)
359
-          SERIAL_ECHOLNPGM("MMU => 'ok'");
360
-        #endif
361
-
312
+        DEBUG_ECHOLNPGM("MMU => 'ok'");
362 313
         ready = true;
363 314
         state = 1;
364 315
         last_cmd = MMU_CMD_NONE;
@@ -366,10 +317,7 @@ void MMU2::mmuLoop() {
366 317
       else if (ELAPSED(millis(), last_request + MMU_CMD_TIMEOUT)) {
367 318
         // resend request after timeout
368 319
         if (last_cmd) {
369
-          #if ENABLED(MMU2_DEBUG)
370
-            SERIAL_ECHOLNPGM("MMU retry");
371
-          #endif
372
-
320
+          DEBUG_ECHOLNPGM("MMU retry");
373 321
           cmd = last_cmd;
374 322
           last_cmd = MMU_CMD_NONE;
375 323
         }
@@ -404,10 +352,7 @@ bool MMU2::rx_str_P(const char* str) {
404 352
     rx_buffer[i] = '\0';
405 353
 
406 354
     if (i == sizeof(rx_buffer) - 1) {
407
-      #if ENABLED(MMU2_DEBUG)
408
-        SERIAL_ECHOLNPGM("rx buffer overrun");
409
-      #endif
410
-
355
+      DEBUG_ECHOLNPGM("rx buffer overrun");
411 356
       break;
412 357
     }
413 358
   }
@@ -876,12 +821,8 @@ void MMU2::filamentRunout() {
876 821
       const float es = pgm_read_float(&(step->extrude)),
877 822
                   fr = pgm_read_float(&(step->feedRate));
878 823
 
879
-      #if ENABLED(MMU2_DEBUG)
880
-        SERIAL_ECHO_START();
881
-        SERIAL_ECHOPAIR("E step ", es);
882
-        SERIAL_CHAR('/');
883
-        SERIAL_ECHOLN(fr);
884
-      #endif
824
+      DEBUG_ECHO_START();
825
+      DEBUG_ECHOLNPAIR("E step ", es, "/", fr);
885 826
 
886 827
       current_position[E_AXIS] += es;
887 828
       planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],

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

@@ -48,6 +48,9 @@
48 48
   #include "../../../libs/vector_3.h"
49 49
 #endif
50 50
 
51
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
52
+#include "../../../core/debug_out.h"
53
+
51 54
 #if ABL_GRID
52 55
   #if ENABLED(PROBE_Y_FIRST)
53 56
     #define PR_OUTER_VAR xCount
@@ -187,12 +190,7 @@ G29_TYPE GcodeSuite::G29() {
187 190
   if (axis_unhomed_error()) G29_RETURN(false);
188 191
 
189 192
   if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
190
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
191
-      if (DEBUGGING(LEVELING)) {
192
-        SERIAL_ECHOLNPGM("> Auto-level not needed, skip");
193
-        SERIAL_ECHOLNPGM("<<< G29");
194
-      }
195
-    #endif
193
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip\n<<< G29");
196 194
     G29_RETURN(false);
197 195
   }
198 196
 
@@ -470,9 +468,7 @@ G29_TYPE GcodeSuite::G29() {
470 468
 
471 469
     #if ENABLED(AUTO_BED_LEVELING_3POINT)
472 470
 
473
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
474
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
475
-      #endif
471
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
476 472
 
477 473
       // Probe at 3 arbitrary points
478 474
       points[0].z = points[1].z = points[2].z = 0;
@@ -555,13 +551,7 @@ G29_TYPE GcodeSuite::G29() {
555 551
           ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
556 552
         #endif
557 553
 
558
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
559
-          if (DEBUGGING(LEVELING)) {
560
-            SERIAL_ECHOPAIR("Save X", xCount);
561
-            SERIAL_ECHOPAIR(" Y", yCount);
562
-            SERIAL_ECHOLNPAIR(" Z", measured_z + zoffset);
563
-          }
564
-        #endif
554
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Save X", xCount, " Y", yCount, " Z", measured_z + zoffset);
565 555
 
566 556
       #endif
567 557
     }
@@ -790,9 +780,7 @@ G29_TYPE GcodeSuite::G29() {
790 780
   // return or loop before this point.
791 781
   //
792 782
 
793
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
794
-    if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
795
-  #endif
783
+  if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
796 784
 
797 785
   #if ENABLED(PROBE_MANUALLY)
798 786
     g29_in_progress = false;
@@ -929,9 +917,7 @@ G29_TYPE GcodeSuite::G29() {
929 917
         // Correct the current XYZ position based on the tilted plane.
930 918
         //
931 919
 
932
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
933
-          if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
934
-        #endif
920
+        if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
935 921
 
936 922
         float converted[XYZ];
937 923
         COPY(converted, current_position);
@@ -945,46 +931,32 @@ G29_TYPE GcodeSuite::G29() {
945 931
           && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
946 932
         ) {
947 933
           const float simple_z = current_position[Z_AXIS] - measured_z;
948
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
949
-            if (DEBUGGING(LEVELING)) {
950
-              SERIAL_ECHOPAIR("Z from Probe:", simple_z);
951
-              SERIAL_ECHOPAIR("  Matrix:", converted[Z_AXIS]);
952
-              SERIAL_ECHOLNPAIR("  Discrepancy:", simple_z - converted[Z_AXIS]);
953
-            }
954
-          #endif
934
+          if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted[Z_AXIS], "  Discrepancy ", simple_z - converted[Z_AXIS]);
955 935
           converted[Z_AXIS] = simple_z;
956 936
         }
957 937
 
958 938
         // The rotated XY and corrected Z are now current_position
959 939
         COPY(current_position, converted);
960 940
 
961
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
962
-          if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
963
-        #endif
941
+        if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
964 942
       }
965 943
 
966 944
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
967 945
 
968 946
       if (!dryrun) {
969
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
970
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
971
-        #endif
947
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
972 948
 
973 949
         // Unapply the offset because it is going to be immediately applied
974 950
         // and cause compensation movement in Z
975 951
         current_position[Z_AXIS] -= bilinear_z_offset(current_position);
976 952
 
977
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
978
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
979
-        #endif
953
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
980 954
       }
981 955
 
982 956
     #endif // ABL_PLANAR
983 957
 
984 958
     #ifdef Z_PROBE_END_SCRIPT
985
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
986
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
987
-      #endif
959
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
988 960
       planner.synchronize();
989 961
       enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
990 962
     #endif
@@ -996,9 +968,7 @@ G29_TYPE GcodeSuite::G29() {
996 968
   // Restore state after probing
997 969
   if (!faux) clean_up_after_endstop_or_probe_move();
998 970
 
999
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1000
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29");
1001
-  #endif
971
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29");
1002 972
 
1003 973
   KEEPALIVE_STATE(IN_HANDLER);
1004 974
 

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

@@ -49,6 +49,9 @@
49 49
   #include "../../libs/L6470/L6470_Marlin.h"
50 50
 #endif
51 51
 
52
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
53
+#include "../../core/debug_out.h"
54
+
52 55
 #if ENABLED(QUICK_HOME)
53 56
 
54 57
   static void quick_home_xy() {
@@ -113,9 +116,7 @@
113 116
       return;
114 117
     }
115 118
 
116
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
117
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Z_SAFE_HOMING >>>");
118
-    #endif
119
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z_SAFE_HOMING >>>");
119 120
 
120 121
     sync_plan_position();
121 122
 
@@ -133,9 +134,7 @@
133 134
 
134 135
     if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) {
135 136
 
136
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
137
-        if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
138
-      #endif
137
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
139 138
 
140 139
       // This causes the carriage on Dual X to unpark
141 140
       #if ENABLED(DUAL_X_CARRIAGE)
@@ -154,9 +153,7 @@
154 153
       SERIAL_ECHO_MSG(MSG_ZPROBE_OUT);
155 154
     }
156 155
 
157
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
158
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< Z_SAFE_HOMING");
159
-    #endif
156
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Z_SAFE_HOMING");
160 157
   }
161 158
 
162 159
 #endif // Z_SAFE_HOMING
@@ -182,12 +179,10 @@
182 179
  */
183 180
 void GcodeSuite::G28(const bool always_home_all) {
184 181
 
185
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
186
-    if (DEBUGGING(LEVELING)) {
187
-      SERIAL_ECHOLNPGM(">>> G28");
188
-      log_machine_info();
189
-    }
190
-  #endif
182
+  if (DEBUGGING(LEVELING)) {
183
+    DEBUG_ECHOLNPGM(">>> G28");
184
+    log_machine_info();
185
+  }
191 186
 
192 187
   #if ENABLED(DUAL_X_CARRIAGE)
193 188
     bool IDEX_saved_duplication_state = extruder_duplication_enabled;
@@ -200,9 +195,7 @@ void GcodeSuite::G28(const bool always_home_all) {
200 195
       sync_plan_position();
201 196
       SERIAL_ECHOLNPGM("Simulated Homing");
202 197
       report_current_position();
203
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
204
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
205
-      #endif
198
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
206 199
       return;
207 200
     }
208 201
   #endif
@@ -215,12 +208,7 @@ void GcodeSuite::G28(const bool always_home_all) {
215 208
         all_axes_homed()  // homing needed only if never homed
216 209
       #endif
217 210
     ) {
218
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
219
-        if (DEBUGGING(LEVELING)) {
220
-          SERIAL_ECHOLNPGM("> homing not needed, skip");
221
-          SERIAL_ECHOLNPGM("<<< G28");
222
-        }
223
-      #endif
211
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip\n<<< G28");
224 212
       return;
225 213
     }
226 214
   }
@@ -297,12 +285,7 @@ void GcodeSuite::G28(const bool always_home_all) {
297 285
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
298 286
       destination[Z_AXIS] = z_homing_height;
299 287
       if (destination[Z_AXIS] > current_position[Z_AXIS]) {
300
-
301
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
302
-          if (DEBUGGING(LEVELING))
303
-            SERIAL_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
304
-        #endif
305
-
288
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
306 289
         do_blocking_move_to_z(destination[Z_AXIS]);
307 290
       }
308 291
     }
@@ -451,9 +434,7 @@ void GcodeSuite::G28(const bool always_home_all) {
451 434
       SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
452 435
   #endif
453 436
 
454
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
455
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
456
-  #endif
437
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
457 438
 
458 439
   #if HAS_DRIVER(L6470)
459 440
     // Set L6470 absolute position registers to counts

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

@@ -42,6 +42,9 @@
42 42
   #include "../../feature/bedlevel/bedlevel.h"
43 43
 #endif
44 44
 
45
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
46
+#include "../../core/debug_out.h"
47
+
45 48
 float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X,
46 49
       z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y;
47 50
 
@@ -59,19 +62,15 @@ inline void set_all_z_lock(const bool lock) {
59 62
  * Parameters: I<iterations> T<accuracy> A<amplification>
60 63
  */
61 64
 void GcodeSuite::G34() {
62
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
63
-    if (DEBUGGING(LEVELING)) {
64
-      SERIAL_ECHOLNPGM(">>> G34");
65
-      log_machine_info();
66
-    }
67
-  #endif
65
+  if (DEBUGGING(LEVELING)) {
66
+    DEBUG_ECHOLNPGM(">>> G34");
67
+    log_machine_info();
68
+  }
68 69
 
69 70
   do { // break out on error
70 71
 
71 72
     if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) {
72
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
73
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> XY homing required.");
74
-      #endif
73
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> XY homing required.");
75 74
       break;
76 75
     }
77 76
 
@@ -128,9 +127,7 @@ void GcodeSuite::G34() {
128 127
           z_measured[Z_STEPPER_COUNT] = { 0 };
129 128
     bool err_break = false;
130 129
     for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
131
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
132
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> probing all positions.");
133
-      #endif
130
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
134 131
 
135 132
       // Reset minimum value
136 133
       float z_measured_min = 100000.0f;
@@ -141,19 +138,12 @@ void GcodeSuite::G34() {
141 138
 
142 139
         // Stop on error
143 140
         if (isnan(z_measured[zstepper])) {
144
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
145
-            if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> PROBING FAILED!");
146
-          #endif
141
+          if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> PROBING FAILED!");
147 142
           err_break = true;
148 143
           break;
149 144
         }
150 145
 
151
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
152
-          if (DEBUGGING(LEVELING)) {
153
-            SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
154
-            SERIAL_ECHOLNPAIR(" measured position is ", z_measured[zstepper]);
155
-          }
156
-        #endif
146
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " measured position is ", z_measured[zstepper]);
157 147
 
158 148
         // Remember the maximum position to calculate the correction
159 149
         z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
@@ -178,9 +168,7 @@ void GcodeSuite::G34() {
178 168
         // Check for lost accuracy compared to last move
179 169
         if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
180 170
           // Stop here
181
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
182
-            if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> detected decreasing accuracy.");
183
-          #endif
171
+          if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> detected decreasing accuracy.");
184 172
           err_break = true;
185 173
           break;
186 174
         }
@@ -190,12 +178,7 @@ void GcodeSuite::G34() {
190 178
         // Only stop early if all measured points achieve accuracy target
191 179
         if (z_align_abs > z_auto_align_accuracy) success_break = false;
192 180
 
193
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
194
-          if (DEBUGGING(LEVELING)) {
195
-            SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
196
-            SERIAL_ECHOLNPAIR(" corrected by ", z_align_move);
197
-          }
198
-        #endif
181
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
199 182
 
200 183
         switch (zstepper) {
201 184
           case 0: stepper.set_z_lock(false); break;
@@ -219,9 +202,7 @@ void GcodeSuite::G34() {
219 202
       stepper.set_separate_multi_axis(false);
220 203
 
221 204
       if (success_break) {
222
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
223
-          if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> achieved target accuracy.");
224
-        #endif
205
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> achieved target accuracy.");
225 206
         break;
226 207
       }
227 208
     }
@@ -252,9 +233,7 @@ void GcodeSuite::G34() {
252 233
 
253 234
   } while(0);
254 235
 
255
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
256
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G34");
257
-  #endif
236
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G34");
258 237
 }
259 238
 
260 239
 /**

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

@@ -31,32 +31,22 @@
31 31
   #include "../../module/delta.h"
32 32
   #include "../../module/motion.h"
33 33
 
34
+  #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
+  #include "../../core/debug_out.h"
36
+
34 37
   /**
35 38
    * M666: Set delta endstop adjustment
36 39
    */
37 40
   void GcodeSuite::M666() {
38
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
39
-      if (DEBUGGING(LEVELING)) {
40
-        SERIAL_ECHOLNPGM(">>> M666");
41
-      }
42
-    #endif
41
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(">>> M666");
43 42
     LOOP_XYZ(i) {
44 43
       if (parser.seen(axis_codes[i])) {
45 44
         const float v = parser.value_linear_units();
46 45
         if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
47
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
48
-          if (DEBUGGING(LEVELING)) {
49
-            SERIAL_ECHOPAIR("delta_endstop_adj[", axis_codes[i]);
50
-            SERIAL_ECHOLNPAIR("] = ", delta_endstop_adj[i]);
51
-          }
52
-        #endif
46
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", axis_codes[i], "] = ", delta_endstop_adj[i]);
53 47
       }
54 48
     }
55
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
56
-      if (DEBUGGING(LEVELING)) {
57
-        SERIAL_ECHOLNPGM("<<< M666");
58
-      }
59
-    #endif
49
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< M666");
60 50
   }
61 51
 
62 52
 #elif HAS_EXTRA_ENDSTOPS

+ 2
- 2
Marlin/src/gcode/control/M111.cpp View File

@@ -34,14 +34,14 @@ void GcodeSuite::M111() {
34 34
                     str_debug_8[] PROGMEM = MSG_DEBUG_DRYRUN,
35 35
                     str_debug_16[] PROGMEM = MSG_DEBUG_COMMUNICATION
36 36
                     #if ENABLED(DEBUG_LEVELING_FEATURE)
37
-                      , str_debug_32[] PROGMEM = MSG_DEBUG_LEVELING
37
+                      , str_debug_lvl[] PROGMEM = MSG_DEBUG_LEVELING
38 38
                     #endif
39 39
                     ;
40 40
 
41 41
   static PGM_P const debug_strings[] PROGMEM = {
42 42
     str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16
43 43
     #if ENABLED(DEBUG_LEVELING_FEATURE)
44
-      , str_debug_32
44
+      , str_debug_lvl
45 45
     #endif
46 46
   };
47 47
 

+ 11
- 14
Marlin/src/gcode/control/T.cpp View File

@@ -31,6 +31,9 @@
31 31
   #include "../../feature/prusa_MMU2/mmu2.h"
32 32
 #endif
33 33
 
34
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
+#include "../../core/debug_out.h"
36
+
34 37
 /**
35 38
  * T0-T<n>: Switch tool, usually switching extruders
36 39
  *
@@ -45,14 +48,10 @@
45 48
  */
46 49
 void GcodeSuite::T(const uint8_t tool_index) {
47 50
 
48
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
49
-    if (DEBUGGING(LEVELING)) {
50
-      SERIAL_ECHOPAIR(">>> T(", tool_index);
51
-      SERIAL_CHAR(')');
52
-      SERIAL_EOL();
53
-      DEBUG_POS("BEFORE", current_position);
54
-    }
55
-  #endif
51
+  if (DEBUGGING(LEVELING)) {
52
+    DEBUG_ECHOLNPAIR(">>> T(", tool_index, ")");
53
+    DEBUG_POS("BEFORE", current_position);
54
+  }
56 55
 
57 56
   #if ENABLED(PRUSA_MMU2)
58 57
     if (parser.string_arg) {
@@ -75,10 +74,8 @@ void GcodeSuite::T(const uint8_t tool_index) {
75 74
 
76 75
   #endif
77 76
 
78
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
79
-    if (DEBUGGING(LEVELING)) {
80
-      DEBUG_POS("AFTER", current_position);
81
-      SERIAL_ECHOLNPGM("<<< T()");
82
-    }
83
-  #endif
77
+  if (DEBUGGING(LEVELING)) {
78
+    DEBUG_POS("AFTER", current_position);
79
+    DEBUG_ECHOLNPGM("<<< T()");
80
+  }
84 81
 }

+ 5
- 2
Marlin/src/gcode/feature/L6470/M906.cpp View File

@@ -29,6 +29,9 @@
29 29
 #include "../../../module/stepper_indirection.h"
30 30
 #include "../../../module/planner.h"
31 31
 
32
+#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
33
+#include "../../../core/debug_out.h"
34
+
32 35
 /**
33 36
  *
34 37
  * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
@@ -93,7 +96,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
93 96
   L6470.say_axis(axis);
94 97
   #if ENABLED(L6470_CHITCHAT)
95 98
     sprintf_P(temp_buf, PSTR("   status: %4x   "), status);
96
-    SERIAL_ECHO(temp_buf);
99
+    DEBUG_ECHO(temp_buf);
97 100
     print_bin(status);
98 101
   #endif
99 102
   sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375);
@@ -134,7 +137,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
134 137
 void GcodeSuite::M906() {
135 138
   #define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value)
136 139
 
137
-  L6470_ECHOLNPGM("M906");
140
+  DEBUG_ECHOLNPGM("M906");
138 141
 
139 142
   bool report_current = true;
140 143
 

+ 70
- 66
Marlin/src/gcode/feature/L6470/M916-918.cpp View File

@@ -29,6 +29,9 @@
29 29
 #include "../../../module/planner.h"
30 30
 #include "../../../libs/L6470/L6470_Marlin.h"
31 31
 
32
+#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
33
+#include "../../../core/debug_out.h"
34
+
32 35
 /**
33 36
  *
34 37
  * M916: increase KVAL_HOLD until get thermal warning
@@ -59,7 +62,7 @@
59 62
 
60 63
 void GcodeSuite::M916() {
61 64
 
62
-  L6470_ECHOLNPGM("M916");
65
+  DEBUG_ECHOLNPGM("M916");
63 66
 
64 67
   // Variables used by L6470_get_user_input function - some may not be used
65 68
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of Axes to be monitored
@@ -80,7 +83,7 @@ void GcodeSuite::M916() {
80 83
   if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
81 84
     return;  // quit if invalid user input
82 85
 
83
-  L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
86
+  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
84 87
 
85 88
   planner.synchronize();                             // wait for all current movement commands to complete
86 89
 
@@ -92,11 +95,11 @@ void GcodeSuite::M916() {
92 95
   char gcode_string[80];
93 96
   uint16_t status_composite = 0;
94 97
 
95
-  L6470_ECHOLNPGM(".\n.");
98
+  DEBUG_ECHOLNPGM(".\n.");
96 99
 
97 100
   do {
98 101
 
99
-    L6470_ECHOLNPAIR("kval_hold = ", kval_hold);   // set & report KVAL_HOLD for this run
102
+    DEBUG_ECHOLNPAIR("kval_hold = ", kval_hold);   // set & report KVAL_HOLD for this run
100 103
 
101 104
     for (j = 0; j < driver_count; j++)
102 105
       L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
@@ -119,9 +122,9 @@ void GcodeSuite::M916() {
119 122
     }
120 123
 
121 124
     if (status_composite && (status_composite & STATUS_UVLO)) {
122
-      L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
125
+      DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
123 126
       for (j = 0; j < driver_count; j++) {
124
-        L6470_ECHOPGM("...");
127
+        DEBUG_ECHOPGM("...");
125 128
         L6470.error_status_decode(axis_status[j], axis_index[j]);
126 129
       }
127 130
       return;
@@ -133,18 +136,18 @@ void GcodeSuite::M916() {
133 136
 
134 137
   } while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold);  // exit when kval_hold == 0 (rolls over)
135 138
 
136
-  L6470_ECHOPGM(".\n.\nThermal warning/shutdown ");
139
+  DEBUG_ECHOPGM(".\n.\nThermal warning/shutdown ");
137 140
   if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) {
138
-    L6470_ECHOLNPGM("has occurred");
141
+    DEBUG_ECHOLNPGM("has occurred");
139 142
     for (j = 0; j < driver_count; j++) {
140
-      L6470_ECHOPGM("...");
143
+      DEBUG_ECHOPGM("...");
141 144
       L6470.error_status_decode(axis_status[j], axis_index[j]);
142 145
     }
143 146
   }
144 147
   else
145
-    L6470_ECHOLNPGM("(Unable to get)");
148
+    DEBUG_ECHOLNPGM("(Unable to get)");
146 149
 
147
-  L6470_ECHOLNPGM(".");
150
+  DEBUG_ECHOLNPGM(".");
148 151
 }
149 152
 
150 153
 /**
@@ -176,7 +179,7 @@ void GcodeSuite::M916() {
176 179
  */
177 180
 void GcodeSuite::M917() {
178 181
 
179
-  L6470_ECHOLNPGM("M917");
182
+  DEBUG_ECHOLNPGM("M917");
180 183
 
181 184
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of axes to be monitored
182 185
   uint8_t axis_index[3];
@@ -196,7 +199,7 @@ void GcodeSuite::M917() {
196 199
   if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
197 200
     return;  // quit if invalid user input
198 201
 
199
-  L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
202
+  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
200 203
 
201 204
   planner.synchronize();                             // wait for all current movement commands to complete
202 205
   for (j = 0; j < driver_count; j++)
@@ -211,16 +214,16 @@ void GcodeSuite::M917() {
211 214
         // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
212 215
         // 3 - OCD finalized - increasing STALL - exit when STALL warning stop
213 216
         // 4 - all testing completed
214
-  L6470_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375);   // first status display
215
-  L6470_ECHOPAIR("  (OCD_TH:  : ", ocd_th_val);
216
-  L6470_ECHOPAIR(")   Stall threshold: ", (stall_th_val + 1) * 31.25);
217
-  L6470_ECHOPAIR("  (STALL_TH: ", stall_th_val);
218
-  L6470_ECHOLNPGM(")");
217
+  DEBUG_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375);   // first status display
218
+  DEBUG_ECHOPAIR("  (OCD_TH:  : ", ocd_th_val);
219
+  DEBUG_ECHOPAIR(")   Stall threshold: ", (stall_th_val + 1) * 31.25);
220
+  DEBUG_ECHOPAIR("  (STALL_TH: ", stall_th_val);
221
+  DEBUG_ECHOLNPGM(")");
219 222
 
220 223
   do {
221 224
 
222
-    L6470_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
223
-    L6470_ECHOLNPAIR("   OCD threshold : ", (ocd_th_val + 1) * 375);
225
+    DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
226
+    DEBUG_ECHOLNPAIR("   OCD threshold : ", (ocd_th_val + 1) * 375);
224 227
 
225 228
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f  F%4.3f"), temp_axis_string, position_min, final_feedrate);
226 229
     gcode.process_subcommands_now_P(gcode_string);
@@ -238,16 +241,16 @@ void GcodeSuite::M917() {
238 241
     }
239 242
 
240 243
     if (status_composite && (status_composite & STATUS_UVLO)) {
241
-      L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
244
+      DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
242 245
       for (j = 0; j < driver_count; j++) {
243
-        L6470_ECHOPGM("...");
246
+        DEBUG_ECHOPGM("...");
244 247
         L6470.error_status_decode(axis_status[j], axis_index[j]);
245 248
       }
246 249
       return;
247 250
     }
248 251
 
249 252
     if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) {
250
-      L6470_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down ");
253
+      DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down ");
251 254
       uint16_t status_composite_temp = 0;
252 255
       uint8_t k = 0;
253 256
       do {
@@ -255,11 +258,11 @@ void GcodeSuite::M917() {
255 258
         if (!(k % 4)) {
256 259
           kval_hold *= 0.95;
257 260
           L6470_EOL();
258
-          L6470_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold);
261
+          DEBUG_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold);
259 262
           for (j = 0; j < driver_count; j++)
260 263
             L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
261 264
         }
262
-        L6470_ECHOLNPGM(".");
265
+        DEBUG_ECHOLNPGM(".");
263 266
         gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
264 267
         watchdog_reset();   // beat the dog
265 268
         safe_delay(5000);
@@ -281,22 +284,22 @@ void GcodeSuite::M917() {
281 284
             if (ocd_th_val >=15) {
282 285
               ocd_th_val = 15;           // limit to max
283 286
               test_phase = 2;            // at highest value so skip phase 1
284
-              L6470_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
287
+              DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
285 288
             }
286 289
             else {
287 290
               ocd_th_val++;              // normal exit to next phase
288 291
               test_phase = 1;            // setup for first pass of phase 1
289
-              L6470_ECHOLNPGM("LOGIC E0B - inc OCD  & go to 1");
292
+              DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD  & go to 1");
290 293
             }
291 294
           }
292 295
           else {  // phase 0 without OCD warning - keep on decrementing if can
293 296
             if (ocd_th_val) {
294 297
               ocd_th_val--;              // try lower value
295
-              L6470_ECHOLNPGM("LOGIC E0C - dec OCD");
298
+              DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD");
296 299
             }
297 300
             else {
298 301
               test_phase = 2;            // at lowest value without warning so skip phase 1
299
-              L6470_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
302
+              DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
300 303
             }
301 304
           }
302 305
         } break;
@@ -307,16 +310,16 @@ void GcodeSuite::M917() {
307 310
             if (ocd_th_val >= 15) {
308 311
               ocd_th_val = 15;           // limit to max
309 312
               test_phase = 2;            // at highest value so go to next phase
310
-              L6470_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
313
+              DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
311 314
             }
312 315
             else {
313 316
               ocd_th_val++;              // try a higher value
314
-              L6470_ECHOLNPGM("LOGIC E1B - inc OCD");
317
+              DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD");
315 318
             }
316 319
           }
317 320
           else { // phase 1 without OCD warning - normal exit to phase 2
318 321
             test_phase = 2;
319
-            L6470_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
322
+            DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
320 323
           }
321 324
         } break;
322 325
 
@@ -325,25 +328,25 @@ void GcodeSuite::M917() {
325 328
             // phase 2 with stall warning - time to go to next phase
326 329
             if (stall_th_val >= 127) {
327 330
               stall_th_val = 127;  // limit to max
328
-              L6470_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
329
-              L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
331
+              DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
332
+              DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
330 333
               test_phase = 4;
331 334
             }
332 335
             else {
333 336
               test_phase = 3;              // normal exit to next phase (found failing value of STALL)
334 337
               stall_th_val++;              // setup for first pass of phase 3
335
-              L6470_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
338
+              DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
336 339
             }
337 340
           }
338 341
           else {  // phase 2 without stall warning - decrement if can
339 342
             if (stall_th_val) {
340 343
               stall_th_val--;              // try a lower value
341
-              L6470_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
344
+              DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
342 345
             }
343 346
             else {
344
-              L6470_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning");
347
+              DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning");
345 348
               test_phase = 4;
346
-              L6470_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
349
+              DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
347 350
             }
348 351
           }
349 352
         } break;
@@ -353,19 +356,19 @@ void GcodeSuite::M917() {
353 356
             // phase 3 with stall warning - increment if can
354 357
             if (stall_th_val >= 127) {
355 358
               stall_th_val = 127; // limit to max
356
-              L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
359
+              DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
357 360
               test_phase = 4;
358
-              L6470_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
361
+              DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
359 362
             }
360 363
             else {
361 364
               stall_th_val++;              // still looking for passing value
362
-              L6470_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
365
+              DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
363 366
             }
364 367
           }
365 368
           else {  //phase 3 without stall warning  but have OCD warning
366
-            L6470_ECHOLNPGM("Hardware problem - OCD warning without STALL warning");
369
+            DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning");
367 370
             test_phase = 4;
368
-            L6470_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
371
+            DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
369 372
           }
370 373
         } break;
371 374
 
@@ -377,30 +380,30 @@ void GcodeSuite::M917() {
377 380
         case 0: { // phase 0 without OCD warning - keep on decrementing if can
378 381
           if (ocd_th_val) {
379 382
             ocd_th_val--;             // try lower value
380
-            L6470_ECHOLNPGM("LOGIC N0A - DEC OCD");
383
+            DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD");
381 384
           }
382 385
           else {
383 386
             test_phase = 2;           // at lowest value without warning so skip phase 1
384
-            L6470_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
387
+            DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
385 388
           }
386 389
         } break;
387 390
 
388
-        case 1: L6470_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
391
+        case 1: DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
389 392
 
390 393
         case 2: { // phase 2 without stall warning - keep on decrementing if can
391 394
           if (stall_th_val) {
392 395
             stall_th_val--;              // try a lower value (stay in phase 2)
393
-            L6470_ECHOLNPGM("LOGIC N2B - dec STALL");
396
+            DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL");
394 397
           }
395 398
           else {
396
-            L6470_ECHOLNPGM("finished - STALL at lowest value but still no stall warning");
399
+            DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning");
397 400
             test_phase = 4;
398
-            L6470_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
401
+            DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
399 402
           }
400 403
         } break;
401 404
 
402 405
         case 3: { test_phase = 4;
403
-           L6470_ECHOLNPGM("LOGIC N3 - finished!");
406
+           DEBUG_ECHOLNPGM("LOGIC N3 - finished!");
404 407
         } break;  // phase 3 without any warnings - desired exit
405 408
       }  //
406 409
     }  // end of status checks
@@ -409,22 +412,22 @@ void GcodeSuite::M917() {
409 412
       for (j = 0; j < driver_count; j++) {                       // update threshold(s)
410 413
         L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val);
411 414
         L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val);
412
-        if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) L6470_ECHOLNPGM("OCD mismatch");
413
-        if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) L6470_ECHOLNPGM("STALL mismatch");
415
+        if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) DEBUG_ECHOLNPGM("OCD mismatch");
416
+        if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) DEBUG_ECHOLNPGM("STALL mismatch");
414 417
       }
415 418
     }
416 419
 
417 420
   } while (test_phase != 4);
418 421
 
419 422
   if (status_composite) {
420
-    L6470_ECHOLNPGM("Completed with errors");
423
+    DEBUG_ECHOLNPGM("Completed with errors");
421 424
     for (j = 0; j < driver_count; j++) {
422
-      L6470_ECHOPGM("...");
425
+      DEBUG_ECHOPGM("...");
423 426
       L6470.error_status_decode(axis_status[j], axis_index[j]);
424 427
     }
425 428
   }
426 429
   else
427
-    L6470_ECHOLNPGM("Completed with no errors");
430
+    DEBUG_ECHOLNPGM("Completed with no errors");
428 431
 
429 432
 } // M917
430 433
 
@@ -448,7 +451,7 @@ void GcodeSuite::M917() {
448 451
  */
449 452
 void GcodeSuite::M918() {
450 453
 
451
-  L6470_ECHOLNPGM("M918");
454
+  DEBUG_ECHOLNPGM("M918");
452 455
 
453 456
   char axis_mon[3][3] = { "  ", "  ", "  " };  // List of axes to monitor
454 457
   uint8_t axis_index[3];
@@ -469,7 +472,7 @@ void GcodeSuite::M918() {
469 472
 
470 473
   uint8_t m_steps = parser.byteval('M');
471 474
   LIMIT(m_steps, 0, 128);
472
-  L6470_ECHOLNPAIR("M = ", m_steps);
475
+  DEBUG_ECHOLNPAIR("M = ", m_steps);
473 476
 
474 477
   int8_t m_bits = -1;
475 478
        if (m_steps > 85) m_bits = 7;  // 128 (no synch output)
@@ -484,15 +487,15 @@ void GcodeSuite::M918() {
484 487
 
485 488
   if (m_bits >= 0) {
486 489
     const int micros = _BV(m_bits);
487
-    if (micros < 100) { L6470_CHAR(' '); if (micros < 10) L6470_CHAR(' '); }
488
-    L6470_ECHO(micros);
489
-    L6470_ECHOPGM(" uSTEPS");
490
+    if (micros < 100) { DEBUG_CHAR(' '); if (micros < 10) DEBUG_CHAR(' '); }
491
+    DEBUG_ECHO(micros);
492
+    DEBUG_ECHOPGM(" uSTEPS");
490 493
   }
491 494
 
492 495
   for (j = 0; j < driver_count; j++)
493 496
     L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits);   // set microsteps
494 497
 
495
-  L6470_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
498
+  DEBUG_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
496 499
 
497 500
   float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
498 501
         current_feedrate = 0;
@@ -508,11 +511,11 @@ void GcodeSuite::M918() {
508 511
 
509 512
   char gcode_string[80];
510 513
   uint16_t status_composite = 0;
511
-  L6470_ECHOLNPGM(".\n.\n.");            // make the feedrate prints easier to see
514
+  DEBUG_ECHOLNPGM(".\n.\n.");            // make the feedrate prints easier to see
512 515
 
513 516
   do {
514 517
     current_feedrate += feedrate_inc;
515
-    L6470_ECHOLNPAIR("...feedrate = ", current_feedrate);
518
+    DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
516 519
 
517 520
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
518 521
     gcode.process_subcommands_now_P(gcode_string);
@@ -529,15 +532,16 @@ void GcodeSuite::M918() {
529 532
     if (status_composite) break;       // quit if any errors flags are raised
530 533
   } while (current_feedrate < final_feedrate * 0.99);
531 534
 
535
+  DEBUG_ECHOPGM("Completed with errors");
532 536
   if (status_composite) {
533
-    L6470_ECHOLNPGM("Completed with errors");
537
+    DEBUG_ECHOLNPGM("errors");
534 538
     for (j = 0; j < driver_count; j++) {
535
-      L6470_ECHOPGM("...");
539
+      DEBUG_ECHOPGM("...");
536 540
       L6470.error_status_decode(axis_status[j], axis_index[j]);
537 541
     }
538 542
   }
539 543
   else
540
-    L6470_ECHOLNPGM("Completed with no errors");
544
+    DEBUG_ECHOLNPGM("no errors");
541 545
 
542 546
 } // M918
543 547
 

+ 4
- 2
Marlin/src/gcode/host/M114.cpp View File

@@ -32,6 +32,8 @@
32 32
     //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
33 33
     //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
34 34
     #include "../../module/L6470/L6470_Marlin.h"
35
+    #define DEBUG_OUT ENABLED(L6470_CHITCHAT)
36
+    #include "../../core/debug_out.h"
35 37
   #endif
36 38
 
37 39
   void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
@@ -95,10 +97,10 @@
95 97
           temp = L6470_GETPARAM(L6470_ABS_POS,Q);                   \
96 98
           if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK;  \
97 99
           sprintf_P(temp_buf, PSTR(":%8ld   "), temp);              \
98
-          L6470_ECHO(temp_buf);                                     \
100
+          DEBUG_ECHO(temp_buf);                                     \
99 101
         }while(0)
100 102
 
101
-      L6470_ECHOPGM("\nL6470:");
103
+      DEBUG_ECHOPGM("\nL6470:");
102 104
       #if AXIS_DRIVER_TYPE_X(L6470)
103 105
         REPORT_ABSOLUTE_POS(X);
104 106
       #endif

+ 24
- 21
Marlin/src/libs/L6470/L6470_Marlin.cpp View File

@@ -36,6 +36,9 @@ L6470_Marlin L6470;
36 36
 #include "../../gcode/gcode.h"
37 37
 #include "../planner.h"
38 38
 
39
+#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
40
+#include "../../core/debug_out.h"
41
+
39 42
 uint8_t L6470_Marlin::dir_commands[MAX_L6470];  // array to hold direction command for each driver
40 43
 
41 44
 char L6470_Marlin::index_to_axis[MAX_L6470][3] = { "X ", "Y ", "Z ", "X2", "Y2", "Z2", "Z3", "E0", "E1", "E2", "E3", "E4", "E5" };
@@ -286,16 +289,16 @@ void L6470_Marlin::set_param(uint8_t axis, uint8_t param, uint32_t value) {
286 289
 }
287 290
 
288 291
 inline void echo_min_max(const char a, const float &min, const float &max) {
289
-  L6470_CHAR(' '); L6470_CHAR(a);
290
-  L6470_ECHOPAIR(" min = ", min);
291
-  L6470_ECHOLNPAIR("  max = ", max);
292
+  DEBUG_CHAR(' '); DEBUG_CHAR(a);
293
+  DEBUG_ECHOPAIR(" min = ", min);
294
+  DEBUG_ECHOLNPAIR("  max = ", max);
292 295
 }
293 296
 inline void echo_oct_used(const float &oct, const bool stall) {
294
-  L6470_ECHOPAIR("over_current_threshold used     : ", oct);
297
+  DEBUG_ECHOPAIR("over_current_threshold used     : ", oct);
295 298
   serialprintPGM(stall ? PSTR("  (Stall") : PSTR("  (OCD"));
296
-  L6470_ECHOLNPGM(" threshold)");
299
+  DEBUG_ECHOLNPGM(" threshold)");
297 300
 }
298
-inline void err_out_of_bounds() { L6470_ECHOLNPGM("ERROR - motion out of bounds"); }
301
+inline void err_out_of_bounds() { DEBUG_ECHOLNPGM("ERROR - motion out of bounds"); }
299 302
 
300 303
 bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3], char axis_mon[3][3],
301 304
                           float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold,
@@ -307,7 +310,7 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
307 310
   uint8_t j;   // general purpose counter
308 311
 
309 312
   if (!all_axes_homed()) {
310
-    L6470_ECHOLNPGM("ERROR - home all before running this command");
313
+    DEBUG_ECHOLNPGM("ERROR - home all before running this command");
311 314
     //return true;
312 315
   }
313 316
 
@@ -424,12 +427,12 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
424 427
   }
425 428
 
426 429
   if (driver_count == 0) {
427
-    L6470_ECHOLNPGM("ERROR - not a L6470 axis");
430
+    DEBUG_ECHOLNPGM("ERROR - not a L6470 axis");
428 431
     return true;
429 432
   }
430 433
 
431
-  L6470_ECHOPGM("Monitoring:");
432
-  for (j = 0; j < driver_count; j++) L6470_ECHOPAIR("  ", axis_mon[j]);
434
+  DEBUG_ECHOPGM("Monitoring:");
435
+  for (j = 0; j < driver_count; j++) DEBUG_ECHOPAIR("  ", axis_mon[j]);
433 436
   L6470_EOL();
434 437
 
435 438
   // now have a list of driver(s) to monitor
@@ -440,14 +443,14 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
440 443
 
441 444
   kval_hold = parser.byteval('K');
442 445
   if (kval_hold) {
443
-    L6470_ECHOLNPAIR("kval_hold = ", kval_hold);
446
+    DEBUG_ECHOLNPAIR("kval_hold = ", kval_hold);
444 447
     for (j = 0; j < driver_count; j++)
445 448
       set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
446 449
   }
447 450
   else {
448 451
     // only print the KVAL_HOLD from one of the drivers
449 452
     kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD);
450
-    L6470_ECHOLNPAIR("KVAL_HOLD = ", kval_hold);
453
+    DEBUG_ECHOLNPAIR("KVAL_HOLD = ", kval_hold);
451 454
   }
452 455
 
453 456
   //
@@ -474,7 +477,7 @@ bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3],
474 477
         OCD_TH_actual = (OCD_TH_val_local + 1) * 375;
475 478
       }
476 479
 
477
-      L6470_ECHOLNPAIR("over_current_threshold specified: ", over_current_threshold);
480
+      DEBUG_ECHOLNPAIR("over_current_threshold specified: ", over_current_threshold);
478 481
       echo_oct_used(STALL_TH_actual, true);
479 482
       echo_oct_used(OCD_TH_actual, false);
480 483
 
@@ -547,13 +550,13 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
547 550
     char temp_buf[10];
548 551
     say_axis(axis);
549 552
     sprintf_P(temp_buf, PSTR("  %4x   "), status);
550
-    L6470_ECHO(temp_buf);
553
+    DEBUG_ECHO(temp_buf);
551 554
     print_bin(status);
552
-    L6470_ECHOPGM("  THERMAL: ");
555
+    DEBUG_ECHOPGM("  THERMAL: ");
553 556
     serialprintPGM((status & STATUS_TH_SD) ? PSTR("SHUTDOWN") : (status & STATUS_TH_WRN) ? PSTR("WARNING ") : PSTR("OK      "));
554
-    L6470_ECHOPGM("   OVERCURRENT: ");
557
+    DEBUG_ECHOPGM("   OVERCURRENT: ");
555 558
     echo_yes_no(status & STATUS_OCD);
556
-    L6470_ECHOPGM("   STALL: ");
559
+    DEBUG_ECHOPGM("   STALL: ");
557 560
     echo_yes_no(status & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B));
558 561
     L6470_EOL();
559 562
   #else
@@ -642,14 +645,14 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
642 645
       if (driver_L6470_data[j].com_counter == 0) {      // warn user when it first happens
643 646
         driver_L6470_data[j].com_counter++;
644 647
         append_stepper_err(p, stepper_index, PSTR(" - communications lost\n"));
645
-        L6470_ECHO(temp_buf);
648
+        DEBUG_ECHO(temp_buf);
646 649
       }
647 650
       else {
648 651
         driver_L6470_data[j].com_counter++;
649 652
         if (driver_L6470_data[j].com_counter > 240) {  // remind of com problem about every 2 minutes
650 653
           driver_L6470_data[j].com_counter = 1;
651 654
           append_stepper_err(p, stepper_index, PSTR(" - still no communications\n"));
652
-          L6470_ECHO(temp_buf);
655
+          DEBUG_ECHO(temp_buf);
653 656
         }
654 657
       }
655 658
     }
@@ -657,7 +660,7 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
657 660
       if (driver_L6470_data[j].com_counter) {   // comms re-established
658 661
         driver_L6470_data[j].com_counter = 0;
659 662
         append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n"));
660
-        L6470_ECHO(temp_buf);
663
+        DEBUG_ECHO(temp_buf);
661 664
         init_to_defaults();
662 665
       }
663 666
       else {
@@ -718,7 +721,7 @@ void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis
718 721
             p += sprintf_P(p, PSTR("%c\n"), ' ');
719 722
           #endif
720 723
 
721
-          L6470_ECHOLN(temp_buf);  // print the error message
724
+          DEBUG_ECHOLN(temp_buf);  // print the error message
722 725
         }
723 726
         else {
724 727
           driver_L6470_data[j].is_ot = false;

+ 0
- 20
Marlin/src/libs/L6470/L6470_Marlin.h View File

@@ -25,26 +25,6 @@
25 25
 
26 26
 #include <L6470.h>
27 27
 
28
-#if ENABLED(L6470_CHITCHAT)
29
-  #define L6470_EOL()           SERIAL_EOL()
30
-  #define L6470_CHAR(C)         SERIAL_CHAR(C)
31
-  #define L6470_ECHO(V)         SERIAL_ECHO(V)
32
-  #define L6470_ECHOLN(V)       SERIAL_ECHOLN(V)
33
-  #define L6470_ECHOPGM(S)      SERIAL_ECHOPGM(S)
34
-  #define L6470_ECHOLNPGM(S)    SERIAL_ECHOLNPGM(S)
35
-  #define L6470_ECHOPAIR(S,V)   SERIAL_ECHOPAIR(S,V)
36
-  #define L6470_ECHOLNPAIR(S,V) SERIAL_ECHOLNPAIR(S,V)
37
-#else
38
-  #define L6470_EOL()           NOOP
39
-  #define L6470_CHAR(C)         NOOP
40
-  #define L6470_ECHO(V)         NOOP
41
-  #define L6470_ECHOLN(V)       NOOP
42
-  #define L6470_ECHOPGM(S)      NOOP
43
-  #define L6470_ECHOLNPGM(S)    NOOP
44
-  #define L6470_ECHOPAIR(S,V)   NOOP
45
-  #define L6470_ECHOLNPAIR(S,V) NOOP
46
-#endif
47
-
48 28
 #define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P)
49 29
 
50 30
 #define MAX_L6470  (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin

+ 29
- 48
Marlin/src/module/configuration_store.cpp View File

@@ -379,27 +379,8 @@ void MarlinSettings::postprocess() {
379 379
 
380 380
 #endif // SD_FIRMWARE_UPDATE
381 381
 
382
-#if ENABLED(EEPROM_CHITCHAT)
383
-  #define CHITCHAT_ECHO(V)              SERIAL_ECHO(V)
384
-  #define CHITCHAT_ECHOLNPGM(STR)       SERIAL_ECHOLNPGM(STR)
385
-  #define CHITCHAT_ECHOPAIR(...)        SERIAL_ECHOPAIR(__VA_ARGS__)
386
-  #define CHITCHAT_ECHOLNPAIR(...)      SERIAL_ECHOLNPAIR(__VA_ARGS__)
387
-  #define CHITCHAT_ECHO_START()         SERIAL_ECHO_START()
388
-  #define CHITCHAT_ERROR_START()        SERIAL_ERROR_START()
389
-  #define CHITCHAT_ERROR_MSG(STR)       SERIAL_ERROR_MSG(STR)
390
-  #define CHITCHAT_ECHOPGM(STR)         SERIAL_ECHOPGM(STR)
391
-  #define CHITCHAT_EOL()                SERIAL_EOL()
392
-#else
393
-  #define CHITCHAT_ECHO(V)              NOOP
394
-  #define CHITCHAT_ECHOLNPGM(STR)       NOOP
395
-  #define CHITCHAT_ECHOPAIR(...)        NOOP
396
-  #define CHITCHAT_ECHOLNPAIR(...)      NOOP
397
-  #define CHITCHAT_ECHO_START()         NOOP
398
-  #define CHITCHAT_ERROR_START()        NOOP
399
-  #define CHITCHAT_ERROR_MSG(STR)       NOOP
400
-  #define CHITCHAT_ECHOPGM(STR)         NOOP
401
-  #define CHITCHAT_EOL()                NOOP
402
-#endif
382
+#define DEBUG_OUT ENABLED(EEPROM_CHITCHAT)
383
+#include "../core/debug_out.h"
403 384
 
404 385
 #if ENABLED(EEPROM_SETTINGS)
405 386
 
@@ -427,7 +408,7 @@ void MarlinSettings::postprocess() {
427 408
 
428 409
   bool MarlinSettings::size_error(const uint16_t size) {
429 410
     if (size != datasize()) {
430
-      CHITCHAT_ERROR_MSG("EEPROM datasize error.");
411
+      DEBUG_ERROR_MSG("EEPROM datasize error.");
431 412
       return true;
432 413
     }
433 414
     return false;
@@ -1103,8 +1084,8 @@ void MarlinSettings::postprocess() {
1103 1084
       EEPROM_WRITE(final_crc);
1104 1085
 
1105 1086
       // Report storage size
1106
-      CHITCHAT_ECHO_START();
1107
-      CHITCHAT_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")");
1087
+      DEBUG_ECHO_START();
1088
+      DEBUG_ECHOLNPAIR("Settings Stored (", eeprom_size, " bytes; crc ", (uint32_t)final_crc, ")");
1108 1089
 
1109 1090
       eeprom_error |= size_error(eeprom_size);
1110 1091
     }
@@ -1141,8 +1122,8 @@ void MarlinSettings::postprocess() {
1141 1122
         stored_ver[0] = '?';
1142 1123
         stored_ver[1] = '\0';
1143 1124
       }
1144
-      CHITCHAT_ECHO_START();
1145
-      CHITCHAT_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1125
+      DEBUG_ECHO_START();
1126
+      DEBUG_ECHOLNPAIR("EEPROM version mismatch (EEPROM=", stored_ver, " Marlin=" EEPROM_VERSION ")");
1146 1127
       eeprom_error = true;
1147 1128
     }
1148 1129
     else {
@@ -1807,18 +1788,18 @@ void MarlinSettings::postprocess() {
1807 1788
 
1808 1789
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
1809 1790
       if (eeprom_error) {
1810
-        CHITCHAT_ECHO_START();
1811
-        CHITCHAT_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
1791
+        DEBUG_ECHO_START();
1792
+        DEBUG_ECHOLNPAIR("Index: ", int(eeprom_index - (EEPROM_OFFSET)), " Size: ", datasize());
1812 1793
       }
1813 1794
       else if (working_crc != stored_crc) {
1814 1795
         eeprom_error = true;
1815
-        CHITCHAT_ERROR_START();
1816
-        CHITCHAT_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
1796
+        DEBUG_ERROR_START();
1797
+        DEBUG_ECHOLNPAIR("EEPROM CRC mismatch - (stored) ", stored_crc, " != ", working_crc, " (calculated)!");
1817 1798
       }
1818 1799
       else if (!validating) {
1819
-        CHITCHAT_ECHO_START();
1820
-        CHITCHAT_ECHO(version);
1821
-        CHITCHAT_ECHOLNPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")");
1800
+        DEBUG_ECHO_START();
1801
+        DEBUG_ECHO(version);
1802
+        DEBUG_ECHOLNPAIR(" stored settings retrieved (", eeprom_index - (EEPROM_OFFSET), " bytes; crc ", (uint32_t)working_crc, ")");
1822 1803
       }
1823 1804
 
1824 1805
       if (!validating && !eeprom_error) postprocess();
@@ -1831,26 +1812,26 @@ void MarlinSettings::postprocess() {
1831 1812
             SERIAL_EOL();
1832 1813
             #if ENABLED(EEPROM_CHITCHAT)
1833 1814
               ubl.echo_name();
1834
-              CHITCHAT_ECHOLNPGM(" initialized.\n");
1815
+              DEBUG_ECHOLNPGM(" initialized.\n");
1835 1816
             #endif
1836 1817
           }
1837 1818
           else {
1838 1819
             eeprom_error = true;
1839 1820
             #if ENABLED(EEPROM_CHITCHAT)
1840
-              CHITCHAT_ECHOPGM("?Can't enable ");
1821
+              DEBUG_ECHOPGM("?Can't enable ");
1841 1822
               ubl.echo_name();
1842
-              CHITCHAT_ECHOLNPGM(".");
1823
+              DEBUG_ECHOLNPGM(".");
1843 1824
             #endif
1844 1825
             ubl.reset();
1845 1826
           }
1846 1827
 
1847 1828
           if (ubl.storage_slot >= 0) {
1848 1829
             load_mesh(ubl.storage_slot);
1849
-            CHITCHAT_ECHOLNPAIR("Mesh ", ubl.storage_slot, " loaded from storage.");
1830
+            DEBUG_ECHOLNPAIR("Mesh ", ubl.storage_slot, " loaded from storage.");
1850 1831
           }
1851 1832
           else {
1852 1833
             ubl.reset();
1853
-            CHITCHAT_ECHOLNPGM("UBL System reset()");
1834
+            DEBUG_ECHOLNPGM("UBL System reset()");
1854 1835
           }
1855 1836
         }
1856 1837
       #endif
@@ -1881,9 +1862,9 @@ void MarlinSettings::postprocess() {
1881 1862
 
1882 1863
     inline void ubl_invalid_slot(const int s) {
1883 1864
       #if ENABLED(EEPROM_CHITCHAT)
1884
-        CHITCHAT_ECHOLNPGM("?Invalid slot.");
1885
-        CHITCHAT_ECHO(s);
1886
-        CHITCHAT_ECHOLNPGM(" mesh slots available.");
1865
+        DEBUG_ECHOLNPGM("?Invalid slot.");
1866
+        DEBUG_ECHO(s);
1867
+        DEBUG_ECHOLNPGM(" mesh slots available.");
1887 1868
       #else
1888 1869
         UNUSED(s);
1889 1870
       #endif
@@ -1912,8 +1893,8 @@ void MarlinSettings::postprocess() {
1912 1893
         const int16_t a = calc_num_meshes();
1913 1894
         if (!WITHIN(slot, 0, a - 1)) {
1914 1895
           ubl_invalid_slot(a);
1915
-          CHITCHAT_ECHOLNPAIR("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot);
1916
-          CHITCHAT_EOL();
1896
+          DEBUG_ECHOLNPAIR("E2END=", persistentStore.capacity() - 1, " meshes_end=", meshes_end, " slot=", slot);
1897
+          DEBUG_EOL();
1917 1898
           return;
1918 1899
         }
1919 1900
 
@@ -1926,7 +1907,7 @@ void MarlinSettings::postprocess() {
1926 1907
         persistentStore.access_finish();
1927 1908
 
1928 1909
         if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data.");
1929
-        else        CHITCHAT_ECHOLNPAIR("Mesh saved in slot ", slot);
1910
+        else        DEBUG_ECHOLNPAIR("Mesh saved in slot ", slot);
1930 1911
 
1931 1912
       #else
1932 1913
 
@@ -1955,7 +1936,7 @@ void MarlinSettings::postprocess() {
1955 1936
         persistentStore.access_finish();
1956 1937
 
1957 1938
         if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data.");
1958
-        else        CHITCHAT_ECHOLNPAIR("Mesh loaded from slot ", slot);
1939
+        else        DEBUG_ECHOLNPAIR("Mesh loaded from slot ", slot);
1959 1940
 
1960 1941
         EEPROM_FINISH();
1961 1942
 
@@ -1974,7 +1955,7 @@ void MarlinSettings::postprocess() {
1974 1955
 #else // !EEPROM_SETTINGS
1975 1956
 
1976 1957
   bool MarlinSettings::save() {
1977
-    CHITCHAT_ERROR_MSG("EEPROM disabled");
1958
+    DEBUG_ERROR_MSG("EEPROM disabled");
1978 1959
     return false;
1979 1960
   }
1980 1961
 
@@ -2281,8 +2262,8 @@ void MarlinSettings::reset() {
2281 2262
 
2282 2263
   postprocess();
2283 2264
 
2284
-  CHITCHAT_ECHO_START();
2285
-  CHITCHAT_ECHOLNPGM("Hardcoded Default Settings Loaded");
2265
+  DEBUG_ECHO_START();
2266
+  DEBUG_ECHOLNPGM("Hardcoded Default Settings Loaded");
2286 2267
 }
2287 2268
 
2288 2269
 #if DISABLED(DISABLE_M503)

+ 5
- 6
Marlin/src/module/delta.cpp View File

@@ -46,6 +46,9 @@
46 46
   #include "stepper_indirection.h"
47 47
 #endif
48 48
 
49
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
50
+#include "../core/debug_out.h"
51
+
49 52
 // Initialized by settings.load()
50 53
 float delta_height,
51 54
       delta_endstop_adj[ABC] = { 0 },
@@ -216,9 +219,7 @@ void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
216 219
  * This is like quick_home_xy() but for 3 towers.
217 220
  */
218 221
 void home_delta() {
219
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
220
-    if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
221
-  #endif
222
+  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
222 223
   // Init the current position of all carriages to 0,0,0
223 224
   ZERO(current_position);
224 225
   ZERO(destination);
@@ -264,9 +265,7 @@ void home_delta() {
264 265
 
265 266
   sync_plan_position();
266 267
 
267
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
268
-    if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
269
-  #endif
268
+  if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
270 269
 }
271 270
 
272 271
 #endif // DELTA

+ 48
- 145
Marlin/src/module/motion.cpp View File

@@ -59,6 +59,9 @@
59 59
   #include "../feature/fwretract.h"
60 60
 #endif
61 61
 
62
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
63
+#include "../core/debug_out.h"
64
+
62 65
 #define XYZ_CONSTS(type, array, CONFIG) const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }
63 66
 
64 67
 XYZ_CONSTS(float, base_min_pos,   MIN_POS);
@@ -205,9 +208,7 @@ void report_current_position() {
205 208
  * no kinematic translation. Used for homing axes and cartesian/core syncing.
206 209
  */
207 210
 void sync_plan_position() {
208
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
209
-    if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
210
-  #endif
211
+  if (DEBUGGING(LEVELING)) DEBUG_POS("sync_plan_position", current_position);
211 212
   planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
212 213
 }
213 214
 
@@ -294,9 +295,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
294 295
    * Calculate delta, start a line, and set current_position to destination
295 296
    */
296 297
   void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
297
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
298
-      if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
299
-    #endif
298
+    if (DEBUGGING(LEVELING)) DEBUG_POS("prepare_uninterpolated_move_to_destination", destination);
300 299
 
301 300
     #if UBL_SEGMENTED
302 301
       // ubl segmented line will do z-only moves in single segment
@@ -320,9 +319,7 @@ void buffer_line_to_destination(const float fr_mm_s) {
320 319
  * Plan a move to (X, Y, Z) and set the current_position
321 320
  */
322 321
 void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
323
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
324
-    if (DEBUGGING(LEVELING)) print_xyz(PSTR(">>> do_blocking_move_to"), NULL, rx, ry, rz);
325
-  #endif
322
+  if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
326 323
 
327 324
   const float z_feedrate  = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
328 325
               xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
@@ -335,9 +332,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
335 332
 
336 333
     set_destination_from_current();          // sync destination at the start
337 334
 
338
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
339
-      if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
340
-    #endif
335
+    if (DEBUGGING(LEVELING)) DEBUG_POS("set_destination_from_current", destination);
341 336
 
342 337
     // when in the danger zone
343 338
     if (current_position[Z_AXIS] > delta_clip_start_height) {
@@ -346,39 +341,29 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
346 341
         destination[Y_AXIS] = ry;
347 342
         destination[Z_AXIS] = rz;
348 343
         prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
349
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
350
-          if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
351
-        #endif
344
+        if (DEBUGGING(LEVELING)) DEBUG_POS("danger zone move", current_position);
352 345
         return;
353 346
       }
354 347
       destination[Z_AXIS] = delta_clip_start_height;
355 348
       prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
356
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
357
-        if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
358
-      #endif
349
+      if (DEBUGGING(LEVELING)) DEBUG_POS("zone border move", current_position);
359 350
     }
360 351
 
361 352
     if (rz > current_position[Z_AXIS]) {    // raising?
362 353
       destination[Z_AXIS] = rz;
363 354
       prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
364
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
365
-        if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
366
-      #endif
355
+      if (DEBUGGING(LEVELING)) DEBUG_POS("z raise move", current_position);
367 356
     }
368 357
 
369 358
     destination[X_AXIS] = rx;
370 359
     destination[Y_AXIS] = ry;
371 360
     prepare_move_to_destination();         // set_current_from_destination()
372
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
373
-      if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
374
-    #endif
361
+    if (DEBUGGING(LEVELING)) DEBUG_POS("xy move", current_position);
375 362
 
376 363
     if (rz < current_position[Z_AXIS]) {    // lowering?
377 364
       destination[Z_AXIS] = rz;
378 365
       prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
379
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
380
-        if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
381
-      #endif
366
+      if (DEBUGGING(LEVELING)) DEBUG_POS("z lower move", current_position);
382 367
     }
383 368
 
384 369
   #elif IS_SCARA
@@ -423,9 +408,7 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
423 408
 
424 409
   #endif
425 410
 
426
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
427
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< do_blocking_move_to");
428
-  #endif
411
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< do_blocking_move_to");
429 412
 
430 413
   planner.synchronize();
431 414
 }
@@ -938,19 +921,12 @@ void clean_up_after_endstop_or_probe_move() {
938 921
                   planner.buffer_line(   CUR_X,    CUR_Y,    CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
939 922
           delayed_move_time = 0;
940 923
           active_extruder_parked = false;
941
-          #if ENABLED(DEBUG_LEVELING_FEATURE)
942
-            if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Clear active_extruder_parked");
943
-          #endif
924
+          if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Clear active_extruder_parked");
944 925
           break;
945 926
         case DXC_SCALED_DUPLICATION_MODE:
946 927
         case DXC_DUPLICATION_MODE:
947 928
           if (active_extruder == 0) {
948
-            #if ENABLED(DEBUG_LEVELING_FEATURE)
949
-              if (DEBUGGING(LEVELING)) {
950
-                SERIAL_ECHOPAIR("Set planner X", inactive_extruder_x_pos);
951
-                SERIAL_ECHOLNPAIR(" ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
952
-              }
953
-            #endif
929
+            if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Set planner X", inactive_extruder_x_pos, " ... Line to X", current_position[X_AXIS] + duplicate_extruder_x_offset);
954 930
             // move duplicate extruder into correct duplication position.
955 931
             planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
956 932
 
@@ -964,15 +940,9 @@ void clean_up_after_endstop_or_probe_move() {
964 940
             sync_plan_position();
965 941
             extruder_duplication_enabled = true;
966 942
             active_extruder_parked = false;
967
-            #if ENABLED(DEBUG_LEVELING_FEATURE)
968
-              if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked");
969
-            #endif
970
-          }
971
-          else {
972
-            #if ENABLED(DEBUG_LEVELING_FEATURE)
973
-              if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Active extruder not 0");
974
-            #endif
943
+            if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Set extruder_duplication_enabled\nClear active_extruder_parked");
975 944
           }
945
+          else if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Active extruder not 0");
976 946
           break;
977 947
       }
978 948
     }
@@ -1189,20 +1159,14 @@ float get_homing_bump_feedrate(const AxisEnum axis) {
1189 1159
  */
1190 1160
 void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
1191 1161
 
1192
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1193
-    if (DEBUGGING(LEVELING)) {
1194
-      SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]);
1195
-      SERIAL_ECHOPAIR(", ", distance);
1196
-      SERIAL_ECHOPGM(", ");
1197
-      if (fr_mm_s)
1198
-        SERIAL_ECHO(fr_mm_s);
1199
-      else {
1200
-        SERIAL_ECHOPAIR("[", homing_feedrate(axis));
1201
-        SERIAL_CHAR(']');
1202
-      }
1203
-      SERIAL_ECHOLNPGM(")");
1204
-    }
1205
-  #endif
1162
+  if (DEBUGGING(LEVELING)) {
1163
+    DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
1164
+    if (fr_mm_s)
1165
+      DEBUG_ECHO(fr_mm_s);
1166
+    else
1167
+      DEBUG_ECHOPAIR("[", homing_feedrate(axis), "]");
1168
+    DEBUG_ECHOLNPGM(")");
1169
+  }
1206 1170
 
1207 1171
   #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
1208 1172
     // Wait for bed to heat back up between probing points
@@ -1279,13 +1243,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
1279 1243
     #endif
1280 1244
   }
1281 1245
 
1282
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1283
-    if (DEBUGGING(LEVELING)) {
1284
-      SERIAL_ECHOPAIR("<<< do_homing_move(", axis_codes[axis]);
1285
-      SERIAL_CHAR(')');
1286
-      SERIAL_EOL();
1287
-    }
1288
-  #endif
1246
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< do_homing_move(", axis_codes[axis], ")");
1289 1247
 }
1290 1248
 
1291 1249
 /**
@@ -1307,13 +1265,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm
1307 1265
  * Callers must sync the planner position after calling this!
1308 1266
  */
1309 1267
 void set_axis_is_at_home(const AxisEnum axis) {
1310
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1311
-    if (DEBUGGING(LEVELING)) {
1312
-      SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
1313
-      SERIAL_CHAR(')');
1314
-      SERIAL_EOL();
1315
-    }
1316
-  #endif
1268
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_at_home(", axis_codes[axis], ")");
1317 1269
 
1318 1270
   SBI(axis_known_position, axis);
1319 1271
   SBI(axis_homed, axis);
@@ -1351,33 +1303,23 @@ void set_axis_is_at_home(const AxisEnum axis) {
1351 1303
 
1352 1304
         current_position[Z_AXIS] -= zprobe_zoffset;
1353 1305
 
1354
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
1355
-          if (DEBUGGING(LEVELING)) {
1356
-            SERIAL_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***");
1357
-            SERIAL_ECHOLNPAIR("> zprobe_zoffset = ", zprobe_zoffset);
1358
-          }
1359
-        #endif
1306
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> zprobe_zoffset = ", zprobe_zoffset);
1360 1307
 
1361
-      #elif ENABLED(DEBUG_LEVELING_FEATURE)
1308
+      #else
1362 1309
 
1363
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***");
1310
+        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***");
1364 1311
 
1365 1312
       #endif
1366 1313
     }
1367 1314
   #endif
1368 1315
 
1369
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1370
-    if (DEBUGGING(LEVELING)) {
1371
-      #if HAS_HOME_OFFSET
1372
-        SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]);
1373
-        SERIAL_ECHOLNPAIR("] = ", home_offset[axis]);
1374
-      #endif
1375
-      DEBUG_POS("", current_position);
1376
-      SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]);
1377
-      SERIAL_CHAR(')');
1378
-      SERIAL_EOL();
1379
-    }
1380
-  #endif
1316
+  if (DEBUGGING(LEVELING)) {
1317
+    #if HAS_HOME_OFFSET
1318
+      DEBUG_ECHOLNPAIR("> home_offset[", axis_codes[axis], "] = ", home_offset[axis]);
1319
+    #endif
1320
+    DEBUG_POS("", current_position);
1321
+    DEBUG_ECHOLNPAIR("<<< set_axis_is_at_home(", axis_codes[axis], ")");
1322
+  }
1381 1323
 
1382 1324
   #if ENABLED(I2C_POSITION_ENCODERS)
1383 1325
     I2CPEM.homed(axis);
@@ -1388,24 +1330,12 @@ void set_axis_is_at_home(const AxisEnum axis) {
1388 1330
  * Set an axis' to be unhomed.
1389 1331
  */
1390 1332
 void set_axis_is_not_at_home(const AxisEnum axis) {
1391
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1392
-    if (DEBUGGING(LEVELING)) {
1393
-      SERIAL_ECHOPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis]);
1394
-      SERIAL_CHAR(')');
1395
-      SERIAL_EOL();
1396
-    }
1397
-  #endif
1333
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> set_axis_is_not_at_home(", axis_codes[axis], ")");
1398 1334
 
1399 1335
   CBI(axis_known_position, axis);
1400 1336
   CBI(axis_homed, axis);
1401 1337
 
1402
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1403
-    if (DEBUGGING(LEVELING)) {
1404
-      SERIAL_ECHOPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis]);
1405
-      SERIAL_CHAR(')');
1406
-      SERIAL_EOL();
1407
-    }
1408
-  #endif
1338
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< set_axis_is_not_at_home(", axis_codes[axis], ")");
1409 1339
 
1410 1340
   #if ENABLED(I2C_POSITION_ENCODERS)
1411 1341
     I2CPEM.unhomed(axis);
@@ -1434,13 +1364,7 @@ void homeaxis(const AxisEnum axis) {
1434 1364
     if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
1435 1365
   #endif
1436 1366
 
1437
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1438
-    if (DEBUGGING(LEVELING)) {
1439
-      SERIAL_ECHOPAIR(">>> homeaxis(", axis_codes[axis]);
1440
-      SERIAL_CHAR(')');
1441
-      SERIAL_EOL();
1442
-    }
1443
-  #endif
1367
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(">>> homeaxis(", axis_codes[axis], ")");
1444 1368
 
1445 1369
   const int axis_home_dir = (
1446 1370
     #if ENABLED(DUAL_X_CARRIAGE)
@@ -1472,9 +1396,7 @@ void homeaxis(const AxisEnum axis) {
1472 1396
   #endif
1473 1397
 
1474 1398
   // Fast move towards endstop until triggered
1475
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1476
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 1 Fast:");
1477
-  #endif
1399
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 1 Fast:");
1478 1400
 
1479 1401
   #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1480 1402
     // BLTOUCH needs to be deployed every time
@@ -1506,9 +1428,7 @@ void homeaxis(const AxisEnum axis) {
1506 1428
   // If a second homing move is configured...
1507 1429
   if (bump) {
1508 1430
     // Move away from the endstop by the axis HOME_BUMP_MM
1509
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1510
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Move Away:");
1511
-    #endif
1431
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
1512 1432
     do_homing_move(axis, -bump
1513 1433
       #if HOMING_Z_WITH_PROBE
1514 1434
         , axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0
@@ -1516,9 +1436,7 @@ void homeaxis(const AxisEnum axis) {
1516 1436
     );
1517 1437
 
1518 1438
     // Slow move towards endstop until triggered
1519
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1520
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 2 Slow:");
1521
-    #endif
1439
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home 2 Slow:");
1522 1440
 
1523 1441
     #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1524 1442
       // BLTOUCH needs to be deployed every time
@@ -1644,9 +1562,7 @@ void homeaxis(const AxisEnum axis) {
1644 1562
 
1645 1563
     // retrace by the amount specified in delta_endstop_adj + additional dist in order to have minimum steps
1646 1564
     if (delta_endstop_adj[axis] * Z_HOME_DIR <= 0) {
1647
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
1648
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("delta_endstop_adj:");
1649
-      #endif
1565
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("delta_endstop_adj:");
1650 1566
       do_homing_move(axis, delta_endstop_adj[axis] - (MIN_STEPS_PER_SEGMENT + 1) * planner.steps_to_mm[axis] * Z_HOME_DIR);
1651 1567
     }
1652 1568
 
@@ -1657,9 +1573,7 @@ void homeaxis(const AxisEnum axis) {
1657 1573
 
1658 1574
     destination[axis] = current_position[axis];
1659 1575
 
1660
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1661
-      if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
1662
-    #endif
1576
+    if (DEBUGGING(LEVELING)) DEBUG_POS("> AFTER set_axis_is_at_home", current_position);
1663 1577
 
1664 1578
   #endif
1665 1579
 
@@ -1673,25 +1587,14 @@ void homeaxis(const AxisEnum axis) {
1673 1587
     if (axis == Z_AXIS) fwretract.current_hop = 0.0;
1674 1588
   #endif
1675 1589
 
1676
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
1677
-    if (DEBUGGING(LEVELING)) {
1678
-      SERIAL_ECHOPAIR("<<< homeaxis(", axis_codes[axis]);
1679
-      SERIAL_CHAR(')');
1680
-      SERIAL_EOL();
1681
-    }
1682
-  #endif
1590
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< homeaxis(", axis_codes[axis], ")");
1591
+
1683 1592
 } // homeaxis()
1684 1593
 
1685 1594
 #if HAS_WORKSPACE_OFFSET
1686 1595
   void update_workspace_offset(const AxisEnum axis) {
1687 1596
     workspace_offset[axis] = home_offset[axis] + position_shift[axis];
1688
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
1689
-      if (DEBUGGING(LEVELING)) {
1690
-        SERIAL_ECHOPAIR("For ", axis_codes[axis]);
1691
-        SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
1692
-        SERIAL_ECHOLNPAIR("\n position_shift = ", position_shift[axis]);
1693
-      }
1694
-    #endif
1597
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Axis ", axis_codes[axis], " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]);
1695 1598
   }
1696 1599
 #endif
1697 1600
 

+ 34
- 61
Marlin/src/module/probe.cpp View File

@@ -69,6 +69,9 @@ float zprobe_zoffset; // Initialized by settings.load()
69 69
   #include "stepper_indirection.h"
70 70
 #endif
71 71
 
72
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
73
+#include "../core/debug_out.h"
74
+
72 75
 #if ENABLED(Z_PROBE_SLED)
73 76
 
74 77
   #ifndef SLED_DOCKING_OFFSET
@@ -82,9 +85,7 @@ float zprobe_zoffset; // Initialized by settings.load()
82 85
    *              If true, move to MAX_X and release the solenoid
83 86
    */
84 87
   static void dock_sled(bool stow) {
85
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
86
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("dock_sled(", stow, ")");
87
-    #endif
88
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("dock_sled(", stow, ")");
88 89
 
89 90
     // Dock sled a bit closer to ensure proper capturing
90 91
     do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
@@ -312,9 +313,7 @@ float zprobe_zoffset; // Initialized by settings.load()
312 313
 
313 314
     bltouch_command(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW);
314 315
 
315
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
316
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("set_bltouch_deployed(", deploy, ")");
317
-    #endif
316
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("set_bltouch_deployed(", deploy, ")");
318 317
 
319 318
     return false;
320 319
   }
@@ -325,9 +324,7 @@ float zprobe_zoffset; // Initialized by settings.load()
325 324
  * Raise Z to a minimum height to make room for a probe to move
326 325
  */
327 326
 inline void do_probe_raise(const float z_raise) {
328
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
329
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
330
-  #endif
327
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("do_probe_raise(", z_raise, ")");
331 328
 
332 329
   float z_dest = z_raise;
333 330
   if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
@@ -393,12 +390,10 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
393 390
 // returns false for ok and true for failure
394 391
 bool set_probe_deployed(const bool deploy) {
395 392
 
396
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
397
-    if (DEBUGGING(LEVELING)) {
398
-      DEBUG_POS("set_probe_deployed", current_position);
399
-      SERIAL_ECHOLNPAIR("deploy: ", deploy);
400
-    }
401
-  #endif
393
+  if (DEBUGGING(LEVELING)) {
394
+    DEBUG_POS("set_probe_deployed", current_position);
395
+    DEBUG_ECHOLNPAIR("deploy: ", deploy);
396
+  }
402 397
 
403 398
   if (endstops.z_probe_enabled == deploy) return false;
404 399
 
@@ -521,9 +516,7 @@ bool set_probe_deployed(const bool deploy) {
521 516
 #endif
522 517
 
523 518
 static bool do_probe_move(const float z, const float fr_mm_s) {
524
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
525
-    if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
526
-  #endif
519
+  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
527 520
 
528 521
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
529 522
     // Wait for bed to heat back up between probing points
@@ -601,9 +594,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
601 594
   // Tell the planner where we actually are
602 595
   sync_plan_position();
603 596
 
604
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
605
-    if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
606
-  #endif
597
+  if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
607 598
 
608 599
   return !probe_triggered;
609 600
 }
@@ -616,9 +607,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
616 607
  */
617 608
 static float run_z_probe() {
618 609
 
619
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
620
-    if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
621
-  #endif
610
+  if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
622 611
 
623 612
   // Stop the probe before it goes too low to prevent damage.
624 613
   // If Z isn't known then probe to -10mm.
@@ -629,20 +618,16 @@ static float run_z_probe() {
629 618
 
630 619
     // Do a first probe at the fast speed
631 620
     if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
632
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
633
-        if (DEBUGGING(LEVELING)) {
634
-          SERIAL_ECHOLNPGM("FAST Probe fail!");
635
-          DEBUG_POS("<<< run_z_probe", current_position);
636
-        }
637
-      #endif
621
+      if (DEBUGGING(LEVELING)) {
622
+        DEBUG_ECHOLNPGM("FAST Probe fail!");
623
+        DEBUG_POS("<<< run_z_probe", current_position);
624
+      }
638 625
       return NAN;
639 626
     }
640 627
 
641 628
     float first_probe_z = current_position[Z_AXIS];
642 629
 
643
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
644
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z);
645
-    #endif
630
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("1st Probe Z:", first_probe_z);
646 631
 
647 632
     // move up to make clearance for the probe
648 633
     do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
@@ -666,12 +651,10 @@ static float run_z_probe() {
666 651
 
667 652
       // move down slowly to find bed
668 653
       if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
669
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
670
-          if (DEBUGGING(LEVELING)) {
671
-            SERIAL_ECHOLNPGM("SLOW Probe fail!");
672
-            DEBUG_POS("<<< run_z_probe", current_position);
673
-          }
674
-        #endif
654
+        if (DEBUGGING(LEVELING)) {
655
+          DEBUG_ECHOLNPGM("SLOW Probe fail!");
656
+          DEBUG_POS("<<< run_z_probe", current_position);
657
+        }
675 658
         return NAN;
676 659
       }
677 660
 
@@ -694,9 +677,7 @@ static float run_z_probe() {
694 677
 
695 678
     const float z2 = current_position[Z_AXIS];
696 679
 
697
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
698
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
699
-    #endif
680
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2);
700 681
 
701 682
     // Return a weighted average of the fast and slow probes
702 683
     const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
@@ -708,9 +689,7 @@ static float run_z_probe() {
708 689
 
709 690
   #endif
710 691
 
711
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
712
-    if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
713
-  #endif
692
+  if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
714 693
 
715 694
   return measured_z;
716 695
 }
@@ -725,19 +704,15 @@ static float run_z_probe() {
725 704
  * - Return the probed Z position
726 705
  */
727 706
 float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/) {
728
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
729
-    if (DEBUGGING(LEVELING)) {
730
-      SERIAL_ECHOLNPAIR(
731
-        ">>> probe_pt(", LOGICAL_X_POSITION(rx),
732
-        ", ", LOGICAL_Y_POSITION(ry),
733
-        ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
734
-        ", ", int(verbose_level),
735
-        ", ", probe_relative ? "probe" : "nozzle",
736
-        "_relative)"
737
-      );
738
-      DEBUG_POS("", current_position);
739
-    }
740
-  #endif
707
+  if (DEBUGGING(LEVELING)) {
708
+    DEBUG_ECHOLNPAIR(
709
+      ">>> probe_pt(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
710
+      ", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
711
+      ", ", int(verbose_level),
712
+      ", ", probe_relative ? "probe" : "nozzle", "_relative)"
713
+    );
714
+    DEBUG_POS("", current_position);
715
+  }
741 716
 
742 717
   // TODO: Adapt for SCARA, where the offset rotates
743 718
   float nx = rx, ny = ry;
@@ -788,9 +763,7 @@ float probe_pt(const float &rx, const float &ry, const ProbePtRaise raise_after/
788 763
     SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
789 764
   }
790 765
 
791
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
792
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< probe_pt");
793
-  #endif
766
+  if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< probe_pt");
794 767
 
795 768
   return measured_z;
796 769
 }

+ 77
- 152
Marlin/src/module/tool_change.cpp View File

@@ -31,6 +31,9 @@
31 31
 
32 32
 #include "../Marlin.h"
33 33
 
34
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
+#include "../core/debug_out.h"
36
+
34 37
 #if EXTRUDERS > 1
35 38
   toolchange_settings_t toolchange_settings;  // Initialized by settings.load()
36 39
 #endif
@@ -169,12 +172,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
169 172
 
170 173
     current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
171 174
 
172
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
173
-      if (DEBUGGING(LEVELING)) {
174
-        SERIAL_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
175
-        DEBUG_POS(" to new extruder ParkPos", current_position);
176
-      }
177
-    #endif
175
+    if (DEBUGGING(LEVELING)) {
176
+      DEBUG_ECHOPAIR("(1) Move extruder ", int(tmp_extruder));
177
+      DEBUG_POS(" to new extruder ParkPos", current_position);
178
+    }
178 179
 
179 180
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
180 181
     planner.synchronize();
@@ -183,12 +184,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
183 184
 
184 185
     current_position[X_AXIS] = grabpos + offsetcompensation;
185 186
 
186
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
187
-      if (DEBUGGING(LEVELING)) {
188
-        SERIAL_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
189
-        DEBUG_POS(" to new extruder GrabPos", current_position);
190
-      }
191
-    #endif
187
+    if (DEBUGGING(LEVELING)) {
188
+      DEBUG_ECHOPAIR("(2) Couple extruder ", int(tmp_extruder));
189
+      DEBUG_POS(" to new extruder GrabPos", current_position);
190
+    }
192 191
 
193 192
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
194 193
     planner.synchronize();
@@ -199,12 +198,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
199 198
     // STEP 3
200 199
 
201 200
     current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
202
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
203
-      if (DEBUGGING(LEVELING)) {
204
-        SERIAL_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
205
-        DEBUG_POS(" back to new extruder ParkPos", current_position);
206
-      }
207
-    #endif
201
+    if (DEBUGGING(LEVELING)) {
202
+      DEBUG_ECHOPAIR("(3) Move extruder ", int(tmp_extruder));
203
+      DEBUG_POS(" back to new extruder ParkPos", current_position);
204
+    }
208 205
 
209 206
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
210 207
     planner.synchronize();
@@ -212,12 +209,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
212 209
     // STEP 4
213 210
 
214 211
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
215
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
216
-      if (DEBUGGING(LEVELING)) {
217
-        SERIAL_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
218
-        DEBUG_POS(" close to old extruder ParkPos", current_position);
219
-      }
220
-    #endif
212
+    if (DEBUGGING(LEVELING)) {
213
+      DEBUG_ECHOPAIR("(4) Move extruder ", int(tmp_extruder));
214
+      DEBUG_POS(" close to old extruder ParkPos", current_position);
215
+    }
221 216
 
222 217
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
223 218
     planner.synchronize();
@@ -226,12 +221,10 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
226 221
 
227 222
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
228 223
 
229
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
230
-      if (DEBUGGING(LEVELING)) {
231
-        SERIAL_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
232
-        DEBUG_POS(" at old extruder ParkPos", current_position);
233
-      }
234
-    #endif
224
+    if (DEBUGGING(LEVELING)) {
225
+      DEBUG_ECHOPAIR("(5) Park extruder ", int(tmp_extruder));
226
+      DEBUG_POS(" at old extruder ParkPos", current_position);
227
+    }
235 228
 
236 229
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
237 230
     planner.synchronize();
@@ -240,19 +233,15 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
240 233
 
241 234
     current_position[X_AXIS] = oldx;
242 235
 
243
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
244
-      if (DEBUGGING(LEVELING)) {
245
-        SERIAL_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
246
-        DEBUG_POS(" to starting position", current_position);
247
-      }
248
-    #endif
236
+    if (DEBUGGING(LEVELING)) {
237
+      DEBUG_ECHOPAIR("(6) Move extruder ", int(tmp_extruder));
238
+      DEBUG_POS(" to starting position", current_position);
239
+    }
249 240
 
250 241
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
251 242
     planner.synchronize();
252 243
 
253
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
254
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Autopark done.");
255
-    #endif
244
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Autopark done.");
256 245
   }
257 246
 
258 247
 #elif ENABLED(PARKING_EXTRUDER)
@@ -302,15 +291,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
302 291
 
303 292
       // STEP 1
304 293
 
305
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
306
-        if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
307
-      #endif
294
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
308 295
 
309 296
       current_position[Z_AXIS] += toolchange_settings.z_raise;
310 297
 
311
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
312
-        if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
313
-      #endif
298
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
314 299
 
315 300
       fast_line_to_current(Z_AXIS);
316 301
       planner.synchronize();
@@ -319,43 +304,33 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
319 304
 
320 305
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
321 306
 
322
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
323
-        if (DEBUGGING(LEVELING)) {
324
-          SERIAL_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
325
-          DEBUG_POS("Moving ParkPos", current_position);
326
-        }
327
-      #endif
307
+      if (DEBUGGING(LEVELING)) {
308
+        DEBUG_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
309
+        DEBUG_POS("Moving ParkPos", current_position);
310
+      }
328 311
 
329 312
       fast_line_to_current(X_AXIS);
330 313
       planner.synchronize();
331 314
 
332 315
       // STEP 3
333 316
 
334
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
335
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Disengage magnet ");
336
-      #endif
317
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Disengage magnet ");
337 318
 
338 319
       pe_deactivate_solenoid(active_extruder);
339 320
 
340 321
       // STEP 4
341 322
 
342
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
343
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to position near new extruder");
344
-      #endif
323
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to position near new extruder");
345 324
 
346 325
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
347 326
 
348
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
349
-        if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
350
-      #endif
327
+      if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
351 328
 
352 329
       fast_line_to_current(X_AXIS);
353 330
       planner.synchronize();
354 331
 
355 332
       // STEP 5
356
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
357
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Engage magnetic field");
358
-      #endif
333
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Engage magnetic field");
359 334
 
360 335
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
361 336
         pe_activate_solenoid(active_extruder); //just save power for inverted magnets
@@ -368,9 +343,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
368 343
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
369 344
       fast_line_to_current(X_AXIS);
370 345
       current_position[X_AXIS] = grabpos;
371
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
372
-        if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
373
-      #endif
346
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
374 347
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
375 348
       planner.synchronize();
376 349
 
@@ -382,16 +355,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
382 355
         #endif
383 356
       ;
384 357
 
385
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
386
-        if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
387
-      #endif
358
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
388 359
 
389 360
       fast_line_to_current(X_AXIS);
390 361
       planner.synchronize();
391 362
 
392
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
393
-        SERIAL_ECHOLNPGM("Autopark done.");
394
-      #endif
363
+      DEBUG_ECHOLNPGM("Autopark done.");
395 364
     }
396 365
     else { // nomove == true
397 366
       // Only engage magnetic field for new extruder
@@ -405,9 +374,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
405 374
       current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
406 375
     #endif
407 376
 
408
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
409
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
410
-    #endif
377
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Applying Z-offset", current_position);
411 378
   }
412 379
 
413 380
 #endif // PARKING_EXTRUDER
@@ -433,15 +400,11 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
433 400
 
434 401
     // 1. Raise Z to give enough clearance
435 402
 
436
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
437
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
438
-    #endif
403
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
439 404
 
440 405
     current_position[Z_AXIS] += toolchange_settings.z_raise;
441 406
 
442
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
443
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
444
-    #endif
407
+    if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
445 408
 
446 409
     fast_line_to_current(Z_AXIS);
447 410
     planner.synchronize();
@@ -450,86 +413,66 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
450 413
 
451 414
     current_position[X_AXIS] = placexpos;
452 415
 
453
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
454
-      if (DEBUGGING(LEVELING)) {
455
-        SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
456
-        DEBUG_POS("Move X SwitchPos", current_position);
457
-      }
458
-    #endif
416
+    if (DEBUGGING(LEVELING)) {
417
+      DEBUG_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
418
+      DEBUG_POS("Move X SwitchPos", current_position);
419
+    }
459 420
 
460 421
     fast_line_to_current(X_AXIS);
461 422
     planner.synchronize();
462 423
 
463 424
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
464 425
 
465
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
466
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
467
-    #endif
426
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
468 427
 
469 428
     fast_line_to_current(Y_AXIS);
470 429
     planner.synchronize();
471 430
 
472 431
     // 3. Unlock tool and drop it in the dock
473 432
 
474
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
475
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
476
-    #endif
433
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Unlock and Place Toolhead");
477 434
 
478 435
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
479 436
     safe_delay(500);
480 437
 
481 438
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
482 439
 
483
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
484
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
485
-    #endif
440
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
486 441
 
487 442
     planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
488 443
     planner.synchronize();
489 444
     safe_delay(200);
490 445
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
491 446
 
492
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
493
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
494
-    #endif
447
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
495 448
 
496 449
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
497 450
     planner.synchronize();
498 451
 
499 452
     // 4. Move to the new toolhead
500 453
 
501
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
502
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
503
-    #endif
454
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to new toolhead position");
504 455
 
505 456
     current_position[X_AXIS] = grabxpos;
506 457
 
507
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
508
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
509
-    #endif
458
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
510 459
 
511 460
     fast_line_to_current(X_AXIS);
512 461
     planner.synchronize();
513 462
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
514 463
 
515
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
516
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
517
-    #endif
464
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
518 465
 
519 466
     fast_line_to_current(Y_AXIS);
520 467
     planner.synchronize();
521 468
 
522 469
     // 5. Grab and lock the new toolhead
523 470
 
524
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
525
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
526
-    #endif
471
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Grab and lock new toolhead ");
527 472
 
528 473
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
529 474
 
530
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
531
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
532
-    #endif
475
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
533 476
 
534 477
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
535 478
     planner.synchronize();
@@ -540,16 +483,12 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
540 483
 
541 484
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
542 485
 
543
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
544
-      if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
545
-    #endif
486
+    if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
546 487
 
547 488
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
548 489
     planner.synchronize();
549 490
 
550
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
551
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Toolhead change done.");
552
-    #endif
491
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Toolhead change done.");
553 492
   }
554 493
 
555 494
 #endif // SWITCHING_TOOLHEAD
@@ -563,17 +502,15 @@ inline void invalid_extruder_error(const uint8_t e) {
563 502
 #if ENABLED(DUAL_X_CARRIAGE)
564 503
 
565 504
   inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
566
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
567
-      if (DEBUGGING(LEVELING)) {
568
-        SERIAL_ECHOPGM("Dual X Carriage Mode ");
569
-        switch (dual_x_carriage_mode) {
570
-          case DXC_FULL_CONTROL_MODE: SERIAL_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
571
-          case DXC_AUTO_PARK_MODE: SERIAL_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
572
-          case DXC_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
573
-          case DXC_SCALED_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
574
-        }
505
+    if (DEBUGGING(LEVELING)) {
506
+      DEBUG_ECHOPGM("Dual X Carriage Mode ");
507
+      switch (dual_x_carriage_mode) {
508
+        case DXC_FULL_CONTROL_MODE: DEBUG_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
509
+        case DXC_AUTO_PARK_MODE: DEBUG_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
510
+        case DXC_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
511
+        case DXC_SCALED_DUPLICATION_MODE: DEBUG_ECHOLNPGM("DXC_SCALED_DUPLICATION_MODE"); break;
575 512
       }
576
-    #endif
513
+    }
577 514
 
578 515
     const float xhome = x_home_pos(active_extruder);
579 516
     if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
@@ -581,9 +518,8 @@ inline void invalid_extruder_error(const uint8_t e) {
581 518
         && (delayed_move_time || current_position[X_AXIS] != xhome) && ! no_move
582 519
     ) {
583 520
 
584
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
585
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("MoveX to ", xhome);
586
-      #endif
521
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("MoveX to ", xhome);
522
+
587 523
       // Park old head
588 524
       planner.buffer_line(xhome, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
589 525
       planner.synchronize();
@@ -599,9 +535,7 @@ inline void invalid_extruder_error(const uint8_t e) {
599 535
     // This function resets the max/min values - the current position may be overwritten below.
600 536
     set_axis_is_at_home(X_AXIS);
601 537
 
602
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
603
-      if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
604
-    #endif
538
+    if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
605 539
 
606 540
     switch (dual_x_carriage_mode) {
607 541
       case DXC_FULL_CONTROL_MODE:
@@ -620,12 +554,10 @@ inline void invalid_extruder_error(const uint8_t e) {
620 554
         break;
621 555
     }
622 556
 
623
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
624
-      if (DEBUGGING(LEVELING)) {
625
-        SERIAL_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
626
-        DEBUG_POS("New extruder (parked)", current_position);
627
-      }
628
-    #endif
557
+    if (DEBUGGING(LEVELING)) {
558
+      DEBUG_ECHOLNPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
559
+      DEBUG_POS("New extruder (parked)", current_position);
560
+    }
629 561
   }
630 562
 
631 563
 #endif // DUAL_X_CARRIAGE
@@ -680,9 +612,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
680 612
 
681 613
     if (!no_move && !all_axes_homed()) {
682 614
       no_move = true;
683
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
684
-        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("No move on toolchange");
685
-      #endif
615
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("No move on toolchange");
686 616
     }
687 617
 
688 618
     #if HAS_LCD_MENU
@@ -777,10 +707,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
777 707
         move_nozzle_servo(tmp_extruder);
778 708
       #endif
779 709
 
780
-      #if ENABLED(DEBUG_LEVELING_FEATURE)
781
-        if (DEBUGGING(LEVELING))
782
-          SERIAL_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
783
-      #endif
710
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Offset Tool XY by { ", xdiff, ", ", ydiff, ", ", zdiff, " }");
784 711
 
785 712
       // The newly-selected extruder XY is actually at...
786 713
       current_position[X_AXIS] += xdiff;
@@ -802,9 +729,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
802 729
 
803 730
       // Return to position and lower again
804 731
       if (safe_to_move && !no_move && IsRunning()) {
805
-        #if ENABLED(DEBUG_LEVELING_FEATURE)
806
-          if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
807
-        #endif
732
+        if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
808 733
 
809 734
         #if ENABLED(SINGLENOZZLE)
810 735
           #if FAN_COUNT > 0

Loading…
Cancel
Save