Przeglądaj źródła

Unify debugging output with debug_out.h (#13388)

Scott Lahteine 6 lat temu
rodzic
commit
f5bcc00570
No account linked to committer's email address

+ 89
- 0
Marlin/src/core/debug_out.h Wyświetl plik

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 Wyświetl plik

35
   MARLIN_DEBUG_ERRORS        = _BV(2), ///< Not implemented
35
   MARLIN_DEBUG_ERRORS        = _BV(2), ///< Not implemented
36
   MARLIN_DEBUG_DRYRUN        = _BV(3), ///< Ignore temperature setting and E movement commands
36
   MARLIN_DEBUG_DRYRUN        = _BV(3), ///< Ignore temperature setting and E movement commands
37
   MARLIN_DEBUG_COMMUNICATION = _BV(4), ///< Not implemented
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
   MARLIN_DEBUG_ALL           = 0xFF
45
   MARLIN_DEBUG_ALL           = 0xFF
41
 };
46
 };
42
 
47
 
178
 #if ENABLED(DEBUG_LEVELING_FEATURE)
183
 #if ENABLED(DEBUG_LEVELING_FEATURE)
179
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
184
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float x, const float y, const float z);
180
   void print_xyz(PGM_P const prefix, PGM_P const suffix, const float xyz[]);
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
 #endif
191
 #endif

+ 5
- 2
Marlin/src/core/utility.cpp Wyświetl plik

321
     );
321
     );
322
 
322
 
323
     #if HAS_BED_PROBE
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
       if ((X_PROBE_OFFSET_FROM_EXTRUDER) > 0)
329
       if ((X_PROBE_OFFSET_FROM_EXTRUDER) > 0)
327
         SERIAL_ECHOPGM(" (Right");
330
         SERIAL_ECHOPGM(" (Right");
328
       else if ((X_PROBE_OFFSET_FROM_EXTRUDER) < 0)
331
       else if ((X_PROBE_OFFSET_FROM_EXTRUDER) < 0)

+ 2
- 0
Marlin/src/core/utility.h Wyświetl plik

118
 
118
 
119
 #if ENABLED(DEBUG_LEVELING_FEATURE)
119
 #if ENABLED(DEBUG_LEVELING_FEATURE)
120
   void log_machine_info();
120
   void log_machine_info();
121
+#else
122
+  #define log_machine_info() NOOP
121
 #endif
123
 #endif
122
 
124
 
123
 template<typename T>
125
 template<typename T>

+ 15
- 17
Marlin/src/feature/bedlevel/abl/abl.cpp Wyświetl plik

29
 
29
 
30
 #include "../../../module/motion.h"
30
 #include "../../../module/motion.h"
31
 
31
 
32
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
33
+#include "../../../core/debug_out.h"
34
+
32
 int bilinear_grid_spacing[2], bilinear_start[2];
35
 int bilinear_grid_spacing[2], bilinear_start[2];
33
 float bilinear_grid_factor[2],
36
 float bilinear_grid_factor[2],
34
       z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
37
       z_values[GRID_MAX_POINTS_X][GRID_MAX_POINTS_Y];
37
  * Extrapolate a single point from its neighbors
40
  * Extrapolate a single point from its neighbors
38
  */
41
  */
39
 static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) {
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
   if (!isnan(z_values[x][y])) {
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
     return;  // Don't overwrite good values.
56
     return;  // Don't overwrite good values.
58
   }
57
   }
59
-  SERIAL_EOL();
60
 
58
 
61
   // Get X neighbors, Y neighbors, and XY neighbors
59
   // Get X neighbors, Y neighbors, and XY neighbors
62
   const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;
60
   const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir;

+ 4
- 3
Marlin/src/feature/bedlevel/bedlevel.cpp Wyświetl plik

39
   #include "../../lcd/ultralcd.h"
39
   #include "../../lcd/ultralcd.h"
40
 #endif
40
 #endif
41
 
41
 
42
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
43
+#include "../../core/debug_out.h"
44
+
42
 #if ENABLED(G26_MESH_VALIDATION)
45
 #if ENABLED(G26_MESH_VALIDATION)
43
   bool g26_debug_flag; // = false
46
   bool g26_debug_flag; // = false
44
 #endif
47
 #endif
122
  * Reset calibration results to zero.
125
  * Reset calibration results to zero.
123
  */
126
  */
124
 void reset_bed_level() {
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
   set_bed_leveling_enabled(false);
129
   set_bed_leveling_enabled(false);
129
   #if ENABLED(MESH_BED_LEVELING)
130
   #if ENABLED(MESH_BED_LEVELING)
130
     mbl.reset();
131
     mbl.reset();

+ 29
- 32
Marlin/src/feature/bedlevel/ubl/ubl.h Wyświetl plik

29
 #include "../../../lcd/ultralcd.h"
29
 #include "../../../lcd/ultralcd.h"
30
 #include "../../../Marlin.h"
30
 #include "../../../Marlin.h"
31
 
31
 
32
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
33
+#include "../../../core/debug_out.h"
34
+
32
 #define UBL_VERSION "1.01"
35
 #define UBL_VERSION "1.01"
33
 #define UBL_OK false
36
 #define UBL_OK false
34
 #define UBL_ERR true
37
 #define UBL_ERR true
199
      */
202
      */
200
     static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
203
     static inline float z_correction_for_x_on_horizontal_mesh_line(const float &rx0, const int x1_i, const int yi) {
201
       if (!WITHIN(x1_i, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(yi, 0, GRID_MAX_POINTS_Y - 1)) {
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
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
211
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
210
         return (
212
         return (
229
     //
231
     //
230
     static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
232
     static inline float z_correction_for_y_on_vertical_mesh_line(const float &ry0, const int xi, const int y1_i) {
231
       if (!WITHIN(xi, 0, GRID_MAX_POINTS_X - 1) || !WITHIN(y1_i, 0, GRID_MAX_POINTS_Y - 1)) {
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
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
240
         // The requested location is off the mesh. Return UBL_Z_RAISE_WHEN_OFF_MESH or NAN.
240
         return (
241
         return (
285
                          mesh_index_to_ypos(cy), z1,
286
                          mesh_index_to_ypos(cy), z1,
286
                          mesh_index_to_ypos(cy + 1), z2);
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
       if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
296
       if (isnan(z0)) { // if part of the Mesh is undefined, it will show up as NAN
301
         z0 = 0.0;      // in ubl.z_values[][] and propagate through the
297
         z0 = 0.0;      // in ubl.z_values[][] and propagate through the
303
                        // because part of the Mesh is undefined and we don't have the
299
                        // because part of the Mesh is undefined and we don't have the
304
                        // information we need to complete the height correction.
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
       return z0;
310
       return z0;
317
     }
311
     }
342
 extern unified_bed_leveling ubl;
336
 extern unified_bed_leveling ubl;
343
 
337
 
344
 #define Z_VALUES(X,Y) ubl.z_values[X][Y]
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 Wyświetl plik

46
     #include "../../../module/tool_change.h"
46
     #include "../../../module/tool_change.h"
47
   #endif
47
   #endif
48
 
48
 
49
+  #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
50
+  #include "../../../core/debug_out.h"
51
+
49
   #include <math.h>
52
   #include <math.h>
50
 
53
 
51
   #define UBL_G29_P31
54
   #define UBL_G29_P31
442
               SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
445
               SERIAL_ECHOLNPGM("Mesh invalidated. Probing mesh.");
443
             }
446
             }
444
             if (g29_verbose_level > 1) {
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
               SERIAL_CHAR(',');
449
               SERIAL_CHAR(',');
447
               SERIAL_ECHO(g29_y_pos);
450
               SERIAL_ECHO(g29_y_pos);
448
               SERIAL_ECHOLNPGM(").\n");
451
               SERIAL_ECHOLNPGM(").\n");
1463
 
1466
 
1464
               abort_flag = isnan(measured_z);
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
               measured_z -= get_z_correction(rx, ry) /* + zprobe_zoffset */ ;
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
               if (g29_verbose_level > 3) {
1487
               if (g29_verbose_level > 3) {
1488
                 serial_spaces(16);
1488
                 serial_spaces(16);
1489
                 SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
1489
                 SERIAL_ECHOLNPAIR("Corrected_Z=", measured_z);
1524
                 y_tmp = mesh_index_to_ypos(j),
1524
                 y_tmp = mesh_index_to_ypos(j),
1525
                 z_tmp = z_values[i][j];
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
           apply_rotation_xyz(rotation, x_tmp, y_tmp, z_tmp);
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
           z_values[i][j] = z_tmp - lsf_results.D;
1549
           z_values[i][j] = z_tmp - lsf_results.D;
1554
           #if ENABLED(EXTENSIBLE_UI)
1550
           #if ENABLED(EXTENSIBLE_UI)
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 Wyświetl plik

42
   #include "../../feature/host_actions.h"
42
   #include "../../feature/host_actions.h"
43
 #endif
43
 #endif
44
 
44
 
45
+#define DEBUG_OUT ENABLED(MMU2_DEBUG)
46
+#include "../../core/debug_out.h"
47
+
45
 #define MMU_TODELAY 100
48
 #define MMU_TODELAY 100
46
 #define MMU_TIMEOUT 10
49
 #define MMU_TIMEOUT 10
47
 #define MMU_CMD_TIMEOUT 60000ul //5min timeout for mmu commands (except P0)
50
 #define MMU_CMD_TIMEOUT 60000ul //5min timeout for mmu commands (except P0)
128
 }
131
 }
129
 
132
 
130
 void MMU2::reset() {
133
 void MMU2::reset() {
131
-  #if ENABLED(MMU2_DEBUG)
132
-    SERIAL_ECHOLNPGM("MMU <= reset");
133
-  #endif
134
+  DEBUG_ECHOLNPGM("MMU <= reset");
134
 
135
 
135
   #if PIN_EXISTS(MMU2_RST)
136
   #if PIN_EXISTS(MMU2_RST)
136
     WRITE(MMU2_RST_PIN, LOW);
137
     WRITE(MMU2_RST_PIN, LOW);
153
 
154
 
154
     case -1:
155
     case -1:
155
       if (rx_start()) {
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
         // send "read version" request
160
         // send "read version" request
162
         tx_str_P(PSTR("S1\n"));
161
         tx_str_P(PSTR("S1\n"));
173
       if (rx_ok()) {
172
       if (rx_ok()) {
174
         sscanf(rx_buffer, "%uok\n", &version);
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
         tx_str_P(PSTR("S2\n")); // read build number
177
         tx_str_P(PSTR("S2\n")); // read build number
181
         state = -3;
178
         state = -3;
185
     case -3:
182
     case -3:
186
       if (rx_ok()) {
183
       if (rx_ok()) {
187
         sscanf(rx_buffer, "%uok\n", &buildnr);
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
         checkVersion();
188
         checkVersion();
193
 
189
 
194
         #if ENABLED(MMU2_MODE_12V)
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
           tx_str_P(PSTR("M1\n")); // switch to stealth mode
193
           tx_str_P(PSTR("M1\n")); // switch to stealth mode
200
           state = -5;
194
           state = -5;
201
 
195
 
202
         #else
196
         #else
203
-          #if ENABLED(MMU2_DEBUG)
204
-            SERIAL_ECHOLNPGM("MMU <= 'P0'");
205
-          #endif
197
+          DEBUG_ECHOLNPGM("MMU <= 'P0'");
206
 
198
 
207
           tx_str_P(PSTR("P0\n")); // read finda
199
           tx_str_P(PSTR("P0\n")); // read finda
208
           state = -4;
200
           state = -4;
213
     case -5:
205
     case -5:
214
       // response to M1
206
       // response to M1
215
       if (rx_ok()) {
207
       if (rx_ok()) {
216
-        #if ENABLED(MMU2_DEBUG)
217
-          SERIAL_ECHOLNPGM("MMU => ok");
218
-        #endif
208
+        DEBUG_ECHOLNPGM("MMU => ok");
219
 
209
 
220
         checkVersion();
210
         checkVersion();
221
 
211
 
222
-        #if ENABLED(MMU2_DEBUG)
223
-          SERIAL_ECHOLNPGM("MMU <= 'P0'");
224
-        #endif
212
+        DEBUG_ECHOLNPGM("MMU <= 'P0'");
225
 
213
 
226
         tx_str_P(PSTR("P0\n")); // read finda
214
         tx_str_P(PSTR("P0\n")); // read finda
227
         state = -4;
215
         state = -4;
232
       if (rx_ok()) {
220
       if (rx_ok()) {
233
         sscanf(rx_buffer, "%hhuok\n", &finda);
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
         enabled = true;
225
         enabled = true;
240
         state = 1;
226
         state = 1;
246
         if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) {
232
         if (WITHIN(cmd, MMU_CMD_T0, MMU_CMD_T4)) {
247
           // tool change
233
           // tool change
248
           int filament = cmd - MMU_CMD_T0;
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
           tx_printf_P(PSTR("T%d\n"), filament);
236
           tx_printf_P(PSTR("T%d\n"), filament);
255
           state = 3; // wait for response
237
           state = 3; // wait for response
256
         }
238
         }
257
         else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) {
239
         else if (WITHIN(cmd, MMU_CMD_L0, MMU_CMD_L4)) {
258
           // load
240
           // load
259
           int filament = cmd - MMU_CMD_L0;
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
           tx_printf_P(PSTR("L%d\n"), filament);
243
           tx_printf_P(PSTR("L%d\n"), filament);
266
           state = 3; // wait for response
244
           state = 3; // wait for response
267
         }
245
         }
268
         else if (cmd == MMU_CMD_C0) {
246
         else if (cmd == MMU_CMD_C0) {
269
           // continue loading
247
           // continue loading
270
-
271
-          #if ENABLED(MMU2_DEBUG)
272
-            SERIAL_ECHOLNPGM("MMU <= 'C0'");
273
-          #endif
274
-
248
+          DEBUG_ECHOLNPGM("MMU <= 'C0'");
275
           tx_str_P(PSTR("C0\n"));
249
           tx_str_P(PSTR("C0\n"));
276
           state = 3; // wait for response
250
           state = 3; // wait for response
277
         }
251
         }
278
         else if (cmd == MMU_CMD_U0) {
252
         else if (cmd == MMU_CMD_U0) {
279
           // unload current
253
           // unload current
280
-          #if ENABLED(MMU2_DEBUG)
281
-            SERIAL_ECHOLNPGM("MMU <= 'U0'");
282
-          #endif
254
+          DEBUG_ECHOLNPGM("MMU <= 'U0'");
283
 
255
 
284
           tx_str_P(PSTR("U0\n"));
256
           tx_str_P(PSTR("U0\n"));
285
           state = 3; // wait for response
257
           state = 3; // wait for response
287
         else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
259
         else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
288
           // eject filament
260
           // eject filament
289
           int filament = cmd - MMU_CMD_E0;
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
           tx_printf_P(PSTR("E%d\n"), filament);
263
           tx_printf_P(PSTR("E%d\n"), filament);
295
           state = 3; // wait for response
264
           state = 3; // wait for response
296
         }
265
         }
297
         else if (cmd == MMU_CMD_R0) {
266
         else if (cmd == MMU_CMD_R0) {
298
           // recover after eject
267
           // recover after eject
299
-          #if ENABLED(MMU2_DEBUG)
300
-            SERIAL_ECHOLNPGM("MMU <= 'R0'");
301
-          #endif
302
-
268
+          DEBUG_ECHOLNPGM("MMU <= 'R0'");
303
           tx_str_P(PSTR("R0\n"));
269
           tx_str_P(PSTR("R0\n"));
304
           state = 3; // wait for response
270
           state = 3; // wait for response
305
         }
271
         }
306
         else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
272
         else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
307
           // filament type
273
           // filament type
308
           int filament = cmd - MMU_CMD_F0;
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
           tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg);
278
           tx_printf_P(PSTR("F%d %d\n"), filament, cmd_arg);
316
           state = 3; // wait for response
279
           state = 3; // wait for response
317
         }
280
         }
330
       if (rx_ok()) {
293
       if (rx_ok()) {
331
         sscanf(rx_buffer, "%hhuok\n", &finda);
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
         state = 1;
299
         state = 1;
346
 
300
 
355
 
309
 
356
     case 3:   // response to mmu commands
310
     case 3:   // response to mmu commands
357
       if (rx_ok()) {
311
       if (rx_ok()) {
358
-        #if ENABLED(MMU2_DEBUG)
359
-          SERIAL_ECHOLNPGM("MMU => 'ok'");
360
-        #endif
361
-
312
+        DEBUG_ECHOLNPGM("MMU => 'ok'");
362
         ready = true;
313
         ready = true;
363
         state = 1;
314
         state = 1;
364
         last_cmd = MMU_CMD_NONE;
315
         last_cmd = MMU_CMD_NONE;
366
       else if (ELAPSED(millis(), last_request + MMU_CMD_TIMEOUT)) {
317
       else if (ELAPSED(millis(), last_request + MMU_CMD_TIMEOUT)) {
367
         // resend request after timeout
318
         // resend request after timeout
368
         if (last_cmd) {
319
         if (last_cmd) {
369
-          #if ENABLED(MMU2_DEBUG)
370
-            SERIAL_ECHOLNPGM("MMU retry");
371
-          #endif
372
-
320
+          DEBUG_ECHOLNPGM("MMU retry");
373
           cmd = last_cmd;
321
           cmd = last_cmd;
374
           last_cmd = MMU_CMD_NONE;
322
           last_cmd = MMU_CMD_NONE;
375
         }
323
         }
404
     rx_buffer[i] = '\0';
352
     rx_buffer[i] = '\0';
405
 
353
 
406
     if (i == sizeof(rx_buffer) - 1) {
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
       break;
356
       break;
412
     }
357
     }
413
   }
358
   }
876
       const float es = pgm_read_float(&(step->extrude)),
821
       const float es = pgm_read_float(&(step->extrude)),
877
                   fr = pgm_read_float(&(step->feedRate));
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
       current_position[E_AXIS] += es;
827
       current_position[E_AXIS] += es;
887
       planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
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 Wyświetl plik

48
   #include "../../../libs/vector_3.h"
48
   #include "../../../libs/vector_3.h"
49
 #endif
49
 #endif
50
 
50
 
51
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
52
+#include "../../../core/debug_out.h"
53
+
51
 #if ABL_GRID
54
 #if ABL_GRID
52
   #if ENABLED(PROBE_Y_FIRST)
55
   #if ENABLED(PROBE_Y_FIRST)
53
     #define PR_OUTER_VAR xCount
56
     #define PR_OUTER_VAR xCount
187
   if (axis_unhomed_error()) G29_RETURN(false);
190
   if (axis_unhomed_error()) G29_RETURN(false);
188
 
191
 
189
   if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
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
     G29_RETURN(false);
194
     G29_RETURN(false);
197
   }
195
   }
198
 
196
 
470
 
468
 
471
     #if ENABLED(AUTO_BED_LEVELING_3POINT)
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
       // Probe at 3 arbitrary points
473
       // Probe at 3 arbitrary points
478
       points[0].z = points[1].z = points[2].z = 0;
474
       points[0].z = points[1].z = points[2].z = 0;
555
           ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
551
           ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
556
         #endif
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
       #endif
556
       #endif
567
     }
557
     }
790
   // return or loop before this point.
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
   #if ENABLED(PROBE_MANUALLY)
785
   #if ENABLED(PROBE_MANUALLY)
798
     g29_in_progress = false;
786
     g29_in_progress = false;
929
         // Correct the current XYZ position based on the tilted plane.
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
         float converted[XYZ];
922
         float converted[XYZ];
937
         COPY(converted, current_position);
923
         COPY(converted, current_position);
945
           && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
931
           && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
946
         ) {
932
         ) {
947
           const float simple_z = current_position[Z_AXIS] - measured_z;
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
           converted[Z_AXIS] = simple_z;
935
           converted[Z_AXIS] = simple_z;
956
         }
936
         }
957
 
937
 
958
         // The rotated XY and corrected Z are now current_position
938
         // The rotated XY and corrected Z are now current_position
959
         COPY(current_position, converted);
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
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
944
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
967
 
945
 
968
       if (!dryrun) {
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
         // Unapply the offset because it is going to be immediately applied
949
         // Unapply the offset because it is going to be immediately applied
974
         // and cause compensation movement in Z
950
         // and cause compensation movement in Z
975
         current_position[Z_AXIS] -= bilinear_z_offset(current_position);
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
     #endif // ABL_PLANAR
956
     #endif // ABL_PLANAR
983
 
957
 
984
     #ifdef Z_PROBE_END_SCRIPT
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
       planner.synchronize();
960
       planner.synchronize();
989
       enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
961
       enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
990
     #endif
962
     #endif
996
   // Restore state after probing
968
   // Restore state after probing
997
   if (!faux) clean_up_after_endstop_or_probe_move();
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
   KEEPALIVE_STATE(IN_HANDLER);
973
   KEEPALIVE_STATE(IN_HANDLER);
1004
 
974
 

+ 14
- 33
Marlin/src/gcode/calibrate/G28.cpp Wyświetl plik

49
   #include "../../libs/L6470/L6470_Marlin.h"
49
   #include "../../libs/L6470/L6470_Marlin.h"
50
 #endif
50
 #endif
51
 
51
 
52
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
53
+#include "../../core/debug_out.h"
54
+
52
 #if ENABLED(QUICK_HOME)
55
 #if ENABLED(QUICK_HOME)
53
 
56
 
54
   static void quick_home_xy() {
57
   static void quick_home_xy() {
113
       return;
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
     sync_plan_position();
121
     sync_plan_position();
121
 
122
 
133
 
134
 
134
     if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) {
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
       // This causes the carriage on Dual X to unpark
139
       // This causes the carriage on Dual X to unpark
141
       #if ENABLED(DUAL_X_CARRIAGE)
140
       #if ENABLED(DUAL_X_CARRIAGE)
154
       SERIAL_ECHO_MSG(MSG_ZPROBE_OUT);
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
 #endif // Z_SAFE_HOMING
159
 #endif // Z_SAFE_HOMING
182
  */
179
  */
183
 void GcodeSuite::G28(const bool always_home_all) {
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
   #if ENABLED(DUAL_X_CARRIAGE)
187
   #if ENABLED(DUAL_X_CARRIAGE)
193
     bool IDEX_saved_duplication_state = extruder_duplication_enabled;
188
     bool IDEX_saved_duplication_state = extruder_duplication_enabled;
200
       sync_plan_position();
195
       sync_plan_position();
201
       SERIAL_ECHOLNPGM("Simulated Homing");
196
       SERIAL_ECHOLNPGM("Simulated Homing");
202
       report_current_position();
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
       return;
199
       return;
207
     }
200
     }
208
   #endif
201
   #endif
215
         all_axes_homed()  // homing needed only if never homed
208
         all_axes_homed()  // homing needed only if never homed
216
       #endif
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
       return;
212
       return;
225
     }
213
     }
226
   }
214
   }
297
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
285
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
298
       destination[Z_AXIS] = z_homing_height;
286
       destination[Z_AXIS] = z_homing_height;
299
       if (destination[Z_AXIS] > current_position[Z_AXIS]) {
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
         do_blocking_move_to_z(destination[Z_AXIS]);
289
         do_blocking_move_to_z(destination[Z_AXIS]);
307
       }
290
       }
308
     }
291
     }
451
       SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
434
       SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
452
   #endif
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
   #if HAS_DRIVER(L6470)
439
   #if HAS_DRIVER(L6470)
459
     // Set L6470 absolute position registers to counts
440
     // Set L6470 absolute position registers to counts

+ 15
- 36
Marlin/src/gcode/calibrate/G34_M422.cpp Wyświetl plik

42
   #include "../../feature/bedlevel/bedlevel.h"
42
   #include "../../feature/bedlevel/bedlevel.h"
43
 #endif
43
 #endif
44
 
44
 
45
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
46
+#include "../../core/debug_out.h"
47
+
45
 float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X,
48
 float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X,
46
       z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y;
49
       z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y;
47
 
50
 
59
  * Parameters: I<iterations> T<accuracy> A<amplification>
62
  * Parameters: I<iterations> T<accuracy> A<amplification>
60
  */
63
  */
61
 void GcodeSuite::G34() {
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
   do { // break out on error
70
   do { // break out on error
70
 
71
 
71
     if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) {
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
       break;
74
       break;
76
     }
75
     }
77
 
76
 
128
           z_measured[Z_STEPPER_COUNT] = { 0 };
127
           z_measured[Z_STEPPER_COUNT] = { 0 };
129
     bool err_break = false;
128
     bool err_break = false;
130
     for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
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
       // Reset minimum value
132
       // Reset minimum value
136
       float z_measured_min = 100000.0f;
133
       float z_measured_min = 100000.0f;
141
 
138
 
142
         // Stop on error
139
         // Stop on error
143
         if (isnan(z_measured[zstepper])) {
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
           err_break = true;
142
           err_break = true;
148
           break;
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
         // Remember the maximum position to calculate the correction
148
         // Remember the maximum position to calculate the correction
159
         z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
149
         z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
178
         // Check for lost accuracy compared to last move
168
         // Check for lost accuracy compared to last move
179
         if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
169
         if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
180
           // Stop here
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
           err_break = true;
172
           err_break = true;
185
           break;
173
           break;
186
         }
174
         }
190
         // Only stop early if all measured points achieve accuracy target
178
         // Only stop early if all measured points achieve accuracy target
191
         if (z_align_abs > z_auto_align_accuracy) success_break = false;
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
         switch (zstepper) {
183
         switch (zstepper) {
201
           case 0: stepper.set_z_lock(false); break;
184
           case 0: stepper.set_z_lock(false); break;
219
       stepper.set_separate_multi_axis(false);
202
       stepper.set_separate_multi_axis(false);
220
 
203
 
221
       if (success_break) {
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
         break;
206
         break;
226
       }
207
       }
227
     }
208
     }
252
 
233
 
253
   } while(0);
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 Wyświetl plik

31
   #include "../../module/delta.h"
31
   #include "../../module/delta.h"
32
   #include "../../module/motion.h"
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
    * M666: Set delta endstop adjustment
38
    * M666: Set delta endstop adjustment
36
    */
39
    */
37
   void GcodeSuite::M666() {
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
     LOOP_XYZ(i) {
42
     LOOP_XYZ(i) {
44
       if (parser.seen(axis_codes[i])) {
43
       if (parser.seen(axis_codes[i])) {
45
         const float v = parser.value_linear_units();
44
         const float v = parser.value_linear_units();
46
         if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
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
 #elif HAS_EXTRA_ENDSTOPS
52
 #elif HAS_EXTRA_ENDSTOPS

+ 2
- 2
Marlin/src/gcode/control/M111.cpp Wyświetl plik

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

+ 11
- 14
Marlin/src/gcode/control/T.cpp Wyświetl plik

31
   #include "../../feature/prusa_MMU2/mmu2.h"
31
   #include "../../feature/prusa_MMU2/mmu2.h"
32
 #endif
32
 #endif
33
 
33
 
34
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
+#include "../../core/debug_out.h"
36
+
34
 /**
37
 /**
35
  * T0-T<n>: Switch tool, usually switching extruders
38
  * T0-T<n>: Switch tool, usually switching extruders
36
  *
39
  *
45
  */
48
  */
46
 void GcodeSuite::T(const uint8_t tool_index) {
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
   #if ENABLED(PRUSA_MMU2)
56
   #if ENABLED(PRUSA_MMU2)
58
     if (parser.string_arg) {
57
     if (parser.string_arg) {
75
 
74
 
76
   #endif
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 Wyświetl plik

29
 #include "../../../module/stepper_indirection.h"
29
 #include "../../../module/stepper_indirection.h"
30
 #include "../../../module/planner.h"
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
  * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
37
  * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
93
   L6470.say_axis(axis);
96
   L6470.say_axis(axis);
94
   #if ENABLED(L6470_CHITCHAT)
97
   #if ENABLED(L6470_CHITCHAT)
95
     sprintf_P(temp_buf, PSTR("   status: %4x   "), status);
98
     sprintf_P(temp_buf, PSTR("   status: %4x   "), status);
96
-    SERIAL_ECHO(temp_buf);
99
+    DEBUG_ECHO(temp_buf);
97
     print_bin(status);
100
     print_bin(status);
98
   #endif
101
   #endif
99
   sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375);
102
   sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375);
134
 void GcodeSuite::M906() {
137
 void GcodeSuite::M906() {
135
   #define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value)
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
   bool report_current = true;
142
   bool report_current = true;
140
 
143
 

+ 70
- 66
Marlin/src/gcode/feature/L6470/M916-918.cpp Wyświetl plik

29
 #include "../../../module/planner.h"
29
 #include "../../../module/planner.h"
30
 #include "../../../libs/L6470/L6470_Marlin.h"
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
  * M916: increase KVAL_HOLD until get thermal warning
37
  * M916: increase KVAL_HOLD until get thermal warning
59
 
62
 
60
 void GcodeSuite::M916() {
63
 void GcodeSuite::M916() {
61
 
64
 
62
-  L6470_ECHOLNPGM("M916");
65
+  DEBUG_ECHOLNPGM("M916");
63
 
66
 
64
   // Variables used by L6470_get_user_input function - some may not be used
67
   // Variables used by L6470_get_user_input function - some may not be used
65
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of Axes to be monitored
68
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of Axes to be monitored
80
   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))
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
     return;  // quit if invalid user input
84
     return;  // quit if invalid user input
82
 
85
 
83
-  L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
86
+  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
84
 
87
 
85
   planner.synchronize();                             // wait for all current movement commands to complete
88
   planner.synchronize();                             // wait for all current movement commands to complete
86
 
89
 
92
   char gcode_string[80];
95
   char gcode_string[80];
93
   uint16_t status_composite = 0;
96
   uint16_t status_composite = 0;
94
 
97
 
95
-  L6470_ECHOLNPGM(".\n.");
98
+  DEBUG_ECHOLNPGM(".\n.");
96
 
99
 
97
   do {
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
     for (j = 0; j < driver_count; j++)
104
     for (j = 0; j < driver_count; j++)
102
       L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
105
       L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
119
     }
122
     }
120
 
123
 
121
     if (status_composite && (status_composite & STATUS_UVLO)) {
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
       for (j = 0; j < driver_count; j++) {
126
       for (j = 0; j < driver_count; j++) {
124
-        L6470_ECHOPGM("...");
127
+        DEBUG_ECHOPGM("...");
125
         L6470.error_status_decode(axis_status[j], axis_index[j]);
128
         L6470.error_status_decode(axis_status[j], axis_index[j]);
126
       }
129
       }
127
       return;
130
       return;
133
 
136
 
134
   } while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold);  // exit when kval_hold == 0 (rolls over)
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
   if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) {
140
   if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) {
138
-    L6470_ECHOLNPGM("has occurred");
141
+    DEBUG_ECHOLNPGM("has occurred");
139
     for (j = 0; j < driver_count; j++) {
142
     for (j = 0; j < driver_count; j++) {
140
-      L6470_ECHOPGM("...");
143
+      DEBUG_ECHOPGM("...");
141
       L6470.error_status_decode(axis_status[j], axis_index[j]);
144
       L6470.error_status_decode(axis_status[j], axis_index[j]);
142
     }
145
     }
143
   }
146
   }
144
   else
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
  */
179
  */
177
 void GcodeSuite::M917() {
180
 void GcodeSuite::M917() {
178
 
181
 
179
-  L6470_ECHOLNPGM("M917");
182
+  DEBUG_ECHOLNPGM("M917");
180
 
183
 
181
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of axes to be monitored
184
   char axis_mon[3][3] = { "  ", "  ", "  " };  // list of axes to be monitored
182
   uint8_t axis_index[3];
185
   uint8_t axis_index[3];
196
   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))
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
     return;  // quit if invalid user input
200
     return;  // quit if invalid user input
198
 
201
 
199
-  L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
202
+  DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
200
 
203
 
201
   planner.synchronize();                             // wait for all current movement commands to complete
204
   planner.synchronize();                             // wait for all current movement commands to complete
202
   for (j = 0; j < driver_count; j++)
205
   for (j = 0; j < driver_count; j++)
211
         // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
214
         // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
212
         // 3 - OCD finalized - increasing STALL - exit when STALL warning stop
215
         // 3 - OCD finalized - increasing STALL - exit when STALL warning stop
213
         // 4 - all testing completed
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
   do {
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
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f  F%4.3f"), temp_axis_string, position_min, final_feedrate);
228
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f  F%4.3f"), temp_axis_string, position_min, final_feedrate);
226
     gcode.process_subcommands_now_P(gcode_string);
229
     gcode.process_subcommands_now_P(gcode_string);
238
     }
241
     }
239
 
242
 
240
     if (status_composite && (status_composite & STATUS_UVLO)) {
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
       for (j = 0; j < driver_count; j++) {
245
       for (j = 0; j < driver_count; j++) {
243
-        L6470_ECHOPGM("...");
246
+        DEBUG_ECHOPGM("...");
244
         L6470.error_status_decode(axis_status[j], axis_index[j]);
247
         L6470.error_status_decode(axis_status[j], axis_index[j]);
245
       }
248
       }
246
       return;
249
       return;
247
     }
250
     }
248
 
251
 
249
     if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) {
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
       uint16_t status_composite_temp = 0;
254
       uint16_t status_composite_temp = 0;
252
       uint8_t k = 0;
255
       uint8_t k = 0;
253
       do {
256
       do {
255
         if (!(k % 4)) {
258
         if (!(k % 4)) {
256
           kval_hold *= 0.95;
259
           kval_hold *= 0.95;
257
           L6470_EOL();
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
           for (j = 0; j < driver_count; j++)
262
           for (j = 0; j < driver_count; j++)
260
             L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
263
             L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
261
         }
264
         }
262
-        L6470_ECHOLNPGM(".");
265
+        DEBUG_ECHOLNPGM(".");
263
         gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
266
         gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
264
         watchdog_reset();   // beat the dog
267
         watchdog_reset();   // beat the dog
265
         safe_delay(5000);
268
         safe_delay(5000);
281
             if (ocd_th_val >=15) {
284
             if (ocd_th_val >=15) {
282
               ocd_th_val = 15;           // limit to max
285
               ocd_th_val = 15;           // limit to max
283
               test_phase = 2;            // at highest value so skip phase 1
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
             else {
289
             else {
287
               ocd_th_val++;              // normal exit to next phase
290
               ocd_th_val++;              // normal exit to next phase
288
               test_phase = 1;            // setup for first pass of phase 1
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
           else {  // phase 0 without OCD warning - keep on decrementing if can
295
           else {  // phase 0 without OCD warning - keep on decrementing if can
293
             if (ocd_th_val) {
296
             if (ocd_th_val) {
294
               ocd_th_val--;              // try lower value
297
               ocd_th_val--;              // try lower value
295
-              L6470_ECHOLNPGM("LOGIC E0C - dec OCD");
298
+              DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD");
296
             }
299
             }
297
             else {
300
             else {
298
               test_phase = 2;            // at lowest value without warning so skip phase 1
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
         } break;
305
         } break;
307
             if (ocd_th_val >= 15) {
310
             if (ocd_th_val >= 15) {
308
               ocd_th_val = 15;           // limit to max
311
               ocd_th_val = 15;           // limit to max
309
               test_phase = 2;            // at highest value so go to next phase
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
             else {
315
             else {
313
               ocd_th_val++;              // try a higher value
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
           else { // phase 1 without OCD warning - normal exit to phase 2
320
           else { // phase 1 without OCD warning - normal exit to phase 2
318
             test_phase = 2;
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
         } break;
324
         } break;
322
 
325
 
325
             // phase 2 with stall warning - time to go to next phase
328
             // phase 2 with stall warning - time to go to next phase
326
             if (stall_th_val >= 127) {
329
             if (stall_th_val >= 127) {
327
               stall_th_val = 127;  // limit to max
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
               test_phase = 4;
333
               test_phase = 4;
331
             }
334
             }
332
             else {
335
             else {
333
               test_phase = 3;              // normal exit to next phase (found failing value of STALL)
336
               test_phase = 3;              // normal exit to next phase (found failing value of STALL)
334
               stall_th_val++;              // setup for first pass of phase 3
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
           else {  // phase 2 without stall warning - decrement if can
341
           else {  // phase 2 without stall warning - decrement if can
339
             if (stall_th_val) {
342
             if (stall_th_val) {
340
               stall_th_val--;              // try a lower value
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
             else {
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
               test_phase = 4;
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
         } break;
352
         } break;
353
             // phase 3 with stall warning - increment if can
356
             // phase 3 with stall warning - increment if can
354
             if (stall_th_val >= 127) {
357
             if (stall_th_val >= 127) {
355
               stall_th_val = 127; // limit to max
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
               test_phase = 4;
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
             else {
363
             else {
361
               stall_th_val++;              // still looking for passing value
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
           else {  //phase 3 without stall warning  but have OCD warning
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
             test_phase = 4;
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
         } break;
373
         } break;
371
 
374
 
377
         case 0: { // phase 0 without OCD warning - keep on decrementing if can
380
         case 0: { // phase 0 without OCD warning - keep on decrementing if can
378
           if (ocd_th_val) {
381
           if (ocd_th_val) {
379
             ocd_th_val--;             // try lower value
382
             ocd_th_val--;             // try lower value
380
-            L6470_ECHOLNPGM("LOGIC N0A - DEC OCD");
383
+            DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD");
381
           }
384
           }
382
           else {
385
           else {
383
             test_phase = 2;           // at lowest value without warning so skip phase 1
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
         } break;
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
         case 2: { // phase 2 without stall warning - keep on decrementing if can
393
         case 2: { // phase 2 without stall warning - keep on decrementing if can
391
           if (stall_th_val) {
394
           if (stall_th_val) {
392
             stall_th_val--;              // try a lower value (stay in phase 2)
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
           else {
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
             test_phase = 4;
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
         } break;
403
         } break;
401
 
404
 
402
         case 3: { test_phase = 4;
405
         case 3: { test_phase = 4;
403
-           L6470_ECHOLNPGM("LOGIC N3 - finished!");
406
+           DEBUG_ECHOLNPGM("LOGIC N3 - finished!");
404
         } break;  // phase 3 without any warnings - desired exit
407
         } break;  // phase 3 without any warnings - desired exit
405
       }  //
408
       }  //
406
     }  // end of status checks
409
     }  // end of status checks
409
       for (j = 0; j < driver_count; j++) {                       // update threshold(s)
412
       for (j = 0; j < driver_count; j++) {                       // update threshold(s)
410
         L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val);
413
         L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val);
411
         L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val);
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
   } while (test_phase != 4);
420
   } while (test_phase != 4);
418
 
421
 
419
   if (status_composite) {
422
   if (status_composite) {
420
-    L6470_ECHOLNPGM("Completed with errors");
423
+    DEBUG_ECHOLNPGM("Completed with errors");
421
     for (j = 0; j < driver_count; j++) {
424
     for (j = 0; j < driver_count; j++) {
422
-      L6470_ECHOPGM("...");
425
+      DEBUG_ECHOPGM("...");
423
       L6470.error_status_decode(axis_status[j], axis_index[j]);
426
       L6470.error_status_decode(axis_status[j], axis_index[j]);
424
     }
427
     }
425
   }
428
   }
426
   else
429
   else
427
-    L6470_ECHOLNPGM("Completed with no errors");
430
+    DEBUG_ECHOLNPGM("Completed with no errors");
428
 
431
 
429
 } // M917
432
 } // M917
430
 
433
 
448
  */
451
  */
449
 void GcodeSuite::M918() {
452
 void GcodeSuite::M918() {
450
 
453
 
451
-  L6470_ECHOLNPGM("M918");
454
+  DEBUG_ECHOLNPGM("M918");
452
 
455
 
453
   char axis_mon[3][3] = { "  ", "  ", "  " };  // List of axes to monitor
456
   char axis_mon[3][3] = { "  ", "  ", "  " };  // List of axes to monitor
454
   uint8_t axis_index[3];
457
   uint8_t axis_index[3];
469
 
472
 
470
   uint8_t m_steps = parser.byteval('M');
473
   uint8_t m_steps = parser.byteval('M');
471
   LIMIT(m_steps, 0, 128);
474
   LIMIT(m_steps, 0, 128);
472
-  L6470_ECHOLNPAIR("M = ", m_steps);
475
+  DEBUG_ECHOLNPAIR("M = ", m_steps);
473
 
476
 
474
   int8_t m_bits = -1;
477
   int8_t m_bits = -1;
475
        if (m_steps > 85) m_bits = 7;  // 128 (no synch output)
478
        if (m_steps > 85) m_bits = 7;  // 128 (no synch output)
484
 
487
 
485
   if (m_bits >= 0) {
488
   if (m_bits >= 0) {
486
     const int micros = _BV(m_bits);
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
   for (j = 0; j < driver_count; j++)
495
   for (j = 0; j < driver_count; j++)
493
     L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits);   // set microsteps
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
   float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
500
   float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
498
         current_feedrate = 0;
501
         current_feedrate = 0;
508
 
511
 
509
   char gcode_string[80];
512
   char gcode_string[80];
510
   uint16_t status_composite = 0;
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
   do {
516
   do {
514
     current_feedrate += feedrate_inc;
517
     current_feedrate += feedrate_inc;
515
-    L6470_ECHOLNPAIR("...feedrate = ", current_feedrate);
518
+    DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
516
 
519
 
517
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
520
     sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
518
     gcode.process_subcommands_now_P(gcode_string);
521
     gcode.process_subcommands_now_P(gcode_string);
529
     if (status_composite) break;       // quit if any errors flags are raised
532
     if (status_composite) break;       // quit if any errors flags are raised
530
   } while (current_feedrate < final_feedrate * 0.99);
533
   } while (current_feedrate < final_feedrate * 0.99);
531
 
534
 
535
+  DEBUG_ECHOPGM("Completed with errors");
532
   if (status_composite) {
536
   if (status_composite) {
533
-    L6470_ECHOLNPGM("Completed with errors");
537
+    DEBUG_ECHOLNPGM("errors");
534
     for (j = 0; j < driver_count; j++) {
538
     for (j = 0; j < driver_count; j++) {
535
-      L6470_ECHOPGM("...");
539
+      DEBUG_ECHOPGM("...");
536
       L6470.error_status_decode(axis_status[j], axis_index[j]);
540
       L6470.error_status_decode(axis_status[j], axis_index[j]);
537
     }
541
     }
538
   }
542
   }
539
   else
543
   else
540
-    L6470_ECHOLNPGM("Completed with no errors");
544
+    DEBUG_ECHOLNPGM("no errors");
541
 
545
 
542
 } // M918
546
 } // M918
543
 
547
 

+ 4
- 2
Marlin/src/gcode/host/M114.cpp Wyświetl plik

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

+ 24
- 21
Marlin/src/libs/L6470/L6470_Marlin.cpp Wyświetl plik

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

+ 0
- 20
Marlin/src/libs/L6470/L6470_Marlin.h Wyświetl plik

25
 
25
 
26
 #include <L6470.h>
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
 #define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P)
28
 #define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P)
49
 
29
 
50
 #define MAX_L6470  (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin
30
 #define MAX_L6470  (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin

+ 29
- 48
Marlin/src/module/configuration_store.cpp Wyświetl plik

379
 
379
 
380
 #endif // SD_FIRMWARE_UPDATE
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
 #if ENABLED(EEPROM_SETTINGS)
385
 #if ENABLED(EEPROM_SETTINGS)
405
 
386
 
427
 
408
 
428
   bool MarlinSettings::size_error(const uint16_t size) {
409
   bool MarlinSettings::size_error(const uint16_t size) {
429
     if (size != datasize()) {
410
     if (size != datasize()) {
430
-      CHITCHAT_ERROR_MSG("EEPROM datasize error.");
411
+      DEBUG_ERROR_MSG("EEPROM datasize error.");
431
       return true;
412
       return true;
432
     }
413
     }
433
     return false;
414
     return false;
1103
       EEPROM_WRITE(final_crc);
1084
       EEPROM_WRITE(final_crc);
1104
 
1085
 
1105
       // Report storage size
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
       eeprom_error |= size_error(eeprom_size);
1090
       eeprom_error |= size_error(eeprom_size);
1110
     }
1091
     }
1141
         stored_ver[0] = '?';
1122
         stored_ver[0] = '?';
1142
         stored_ver[1] = '\0';
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
       eeprom_error = true;
1127
       eeprom_error = true;
1147
     }
1128
     }
1148
     else {
1129
     else {
1807
 
1788
 
1808
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
1789
       eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
1809
       if (eeprom_error) {
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
       else if (working_crc != stored_crc) {
1794
       else if (working_crc != stored_crc) {
1814
         eeprom_error = true;
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
       else if (!validating) {
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
       if (!validating && !eeprom_error) postprocess();
1805
       if (!validating && !eeprom_error) postprocess();
1831
             SERIAL_EOL();
1812
             SERIAL_EOL();
1832
             #if ENABLED(EEPROM_CHITCHAT)
1813
             #if ENABLED(EEPROM_CHITCHAT)
1833
               ubl.echo_name();
1814
               ubl.echo_name();
1834
-              CHITCHAT_ECHOLNPGM(" initialized.\n");
1815
+              DEBUG_ECHOLNPGM(" initialized.\n");
1835
             #endif
1816
             #endif
1836
           }
1817
           }
1837
           else {
1818
           else {
1838
             eeprom_error = true;
1819
             eeprom_error = true;
1839
             #if ENABLED(EEPROM_CHITCHAT)
1820
             #if ENABLED(EEPROM_CHITCHAT)
1840
-              CHITCHAT_ECHOPGM("?Can't enable ");
1821
+              DEBUG_ECHOPGM("?Can't enable ");
1841
               ubl.echo_name();
1822
               ubl.echo_name();
1842
-              CHITCHAT_ECHOLNPGM(".");
1823
+              DEBUG_ECHOLNPGM(".");
1843
             #endif
1824
             #endif
1844
             ubl.reset();
1825
             ubl.reset();
1845
           }
1826
           }
1846
 
1827
 
1847
           if (ubl.storage_slot >= 0) {
1828
           if (ubl.storage_slot >= 0) {
1848
             load_mesh(ubl.storage_slot);
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
           else {
1832
           else {
1852
             ubl.reset();
1833
             ubl.reset();
1853
-            CHITCHAT_ECHOLNPGM("UBL System reset()");
1834
+            DEBUG_ECHOLNPGM("UBL System reset()");
1854
           }
1835
           }
1855
         }
1836
         }
1856
       #endif
1837
       #endif
1881
 
1862
 
1882
     inline void ubl_invalid_slot(const int s) {
1863
     inline void ubl_invalid_slot(const int s) {
1883
       #if ENABLED(EEPROM_CHITCHAT)
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
       #else
1868
       #else
1888
         UNUSED(s);
1869
         UNUSED(s);
1889
       #endif
1870
       #endif
1912
         const int16_t a = calc_num_meshes();
1893
         const int16_t a = calc_num_meshes();
1913
         if (!WITHIN(slot, 0, a - 1)) {
1894
         if (!WITHIN(slot, 0, a - 1)) {
1914
           ubl_invalid_slot(a);
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
           return;
1898
           return;
1918
         }
1899
         }
1919
 
1900
 
1926
         persistentStore.access_finish();
1907
         persistentStore.access_finish();
1927
 
1908
 
1928
         if (status) SERIAL_ECHOLNPGM("?Unable to save mesh data.");
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
       #else
1912
       #else
1932
 
1913
 
1955
         persistentStore.access_finish();
1936
         persistentStore.access_finish();
1956
 
1937
 
1957
         if (status) SERIAL_ECHOLNPGM("?Unable to load mesh data.");
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
         EEPROM_FINISH();
1941
         EEPROM_FINISH();
1961
 
1942
 
1974
 #else // !EEPROM_SETTINGS
1955
 #else // !EEPROM_SETTINGS
1975
 
1956
 
1976
   bool MarlinSettings::save() {
1957
   bool MarlinSettings::save() {
1977
-    CHITCHAT_ERROR_MSG("EEPROM disabled");
1958
+    DEBUG_ERROR_MSG("EEPROM disabled");
1978
     return false;
1959
     return false;
1979
   }
1960
   }
1980
 
1961
 
2281
 
2262
 
2282
   postprocess();
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
 #if DISABLED(DISABLE_M503)
2269
 #if DISABLED(DISABLE_M503)

+ 5
- 6
Marlin/src/module/delta.cpp Wyświetl plik

46
   #include "stepper_indirection.h"
46
   #include "stepper_indirection.h"
47
 #endif
47
 #endif
48
 
48
 
49
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
50
+#include "../core/debug_out.h"
51
+
49
 // Initialized by settings.load()
52
 // Initialized by settings.load()
50
 float delta_height,
53
 float delta_height,
51
       delta_endstop_adj[ABC] = { 0 },
54
       delta_endstop_adj[ABC] = { 0 },
216
  * This is like quick_home_xy() but for 3 towers.
219
  * This is like quick_home_xy() but for 3 towers.
217
  */
220
  */
218
 void home_delta() {
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
   // Init the current position of all carriages to 0,0,0
223
   // Init the current position of all carriages to 0,0,0
223
   ZERO(current_position);
224
   ZERO(current_position);
224
   ZERO(destination);
225
   ZERO(destination);
264
 
265
 
265
   sync_plan_position();
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
 #endif // DELTA
271
 #endif // DELTA

+ 48
- 145
Marlin/src/module/motion.cpp Wyświetl plik

59
   #include "../feature/fwretract.h"
59
   #include "../feature/fwretract.h"
60
 #endif
60
 #endif
61
 
61
 
62
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
63
+#include "../core/debug_out.h"
64
+
62
 #define XYZ_CONSTS(type, array, CONFIG) const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }
65
 #define XYZ_CONSTS(type, array, CONFIG) const PROGMEM type array##_P[XYZ] = { X_##CONFIG, Y_##CONFIG, Z_##CONFIG }
63
 
66
 
64
 XYZ_CONSTS(float, base_min_pos,   MIN_POS);
67
 XYZ_CONSTS(float, base_min_pos,   MIN_POS);
205
  * no kinematic translation. Used for homing axes and cartesian/core syncing.
208
  * no kinematic translation. Used for homing axes and cartesian/core syncing.
206
  */
209
  */
207
 void sync_plan_position() {
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
   planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
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
    * Calculate delta, start a line, and set current_position to destination
295
    * Calculate delta, start a line, and set current_position to destination
295
    */
296
    */
296
   void prepare_uninterpolated_move_to_destination(const float &fr_mm_s/*=0.0*/) {
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
     #if UBL_SEGMENTED
300
     #if UBL_SEGMENTED
302
       // ubl segmented line will do z-only moves in single segment
301
       // ubl segmented line will do z-only moves in single segment
320
  * Plan a move to (X, Y, Z) and set the current_position
319
  * Plan a move to (X, Y, Z) and set the current_position
321
  */
320
  */
322
 void do_blocking_move_to(const float rx, const float ry, const float rz, const float &fr_mm_s/*=0.0*/) {
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
   const float z_feedrate  = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
324
   const float z_feedrate  = fr_mm_s ? fr_mm_s : homing_feedrate(Z_AXIS),
328
               xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
325
               xy_feedrate = fr_mm_s ? fr_mm_s : XY_PROBE_FEEDRATE_MM_S;
335
 
332
 
336
     set_destination_from_current();          // sync destination at the start
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
     // when in the danger zone
337
     // when in the danger zone
343
     if (current_position[Z_AXIS] > delta_clip_start_height) {
338
     if (current_position[Z_AXIS] > delta_clip_start_height) {
346
         destination[Y_AXIS] = ry;
341
         destination[Y_AXIS] = ry;
347
         destination[Z_AXIS] = rz;
342
         destination[Z_AXIS] = rz;
348
         prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
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
         return;
345
         return;
353
       }
346
       }
354
       destination[Z_AXIS] = delta_clip_start_height;
347
       destination[Z_AXIS] = delta_clip_start_height;
355
       prepare_uninterpolated_move_to_destination(); // set_current_from_destination()
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
     if (rz > current_position[Z_AXIS]) {    // raising?
352
     if (rz > current_position[Z_AXIS]) {    // raising?
362
       destination[Z_AXIS] = rz;
353
       destination[Z_AXIS] = rz;
363
       prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
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
     destination[X_AXIS] = rx;
358
     destination[X_AXIS] = rx;
370
     destination[Y_AXIS] = ry;
359
     destination[Y_AXIS] = ry;
371
     prepare_move_to_destination();         // set_current_from_destination()
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
     if (rz < current_position[Z_AXIS]) {    // lowering?
363
     if (rz < current_position[Z_AXIS]) {    // lowering?
377
       destination[Z_AXIS] = rz;
364
       destination[Z_AXIS] = rz;
378
       prepare_uninterpolated_move_to_destination(z_feedrate);   // set_current_from_destination()
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
   #elif IS_SCARA
369
   #elif IS_SCARA
423
 
408
 
424
   #endif
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
   planner.synchronize();
413
   planner.synchronize();
431
 }
414
 }
938
                   planner.buffer_line(   CUR_X,    CUR_Y,    CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
921
                   planner.buffer_line(   CUR_X,    CUR_Y,    CUR_Z, CUR_E, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
939
           delayed_move_time = 0;
922
           delayed_move_time = 0;
940
           active_extruder_parked = false;
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
           break;
925
           break;
945
         case DXC_SCALED_DUPLICATION_MODE:
926
         case DXC_SCALED_DUPLICATION_MODE:
946
         case DXC_DUPLICATION_MODE:
927
         case DXC_DUPLICATION_MODE:
947
           if (active_extruder == 0) {
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
             // move duplicate extruder into correct duplication position.
930
             // move duplicate extruder into correct duplication position.
955
             planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
931
             planner.set_position_mm(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
956
 
932
 
964
             sync_plan_position();
940
             sync_plan_position();
965
             extruder_duplication_enabled = true;
941
             extruder_duplication_enabled = true;
966
             active_extruder_parked = false;
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
           break;
946
           break;
977
       }
947
       }
978
     }
948
     }
1189
  */
1159
  */
1190
 void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
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
   #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
1171
   #if HOMING_Z_WITH_PROBE && HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
1208
     // Wait for bed to heat back up between probing points
1172
     // Wait for bed to heat back up between probing points
1279
     #endif
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
  * Callers must sync the planner position after calling this!
1265
  * Callers must sync the planner position after calling this!
1308
  */
1266
  */
1309
 void set_axis_is_at_home(const AxisEnum axis) {
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
   SBI(axis_known_position, axis);
1270
   SBI(axis_known_position, axis);
1319
   SBI(axis_homed, axis);
1271
   SBI(axis_homed, axis);
1351
 
1303
 
1352
         current_position[Z_AXIS] -= zprobe_zoffset;
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
       #endif
1312
       #endif
1366
     }
1313
     }
1367
   #endif
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
   #if ENABLED(I2C_POSITION_ENCODERS)
1324
   #if ENABLED(I2C_POSITION_ENCODERS)
1383
     I2CPEM.homed(axis);
1325
     I2CPEM.homed(axis);
1388
  * Set an axis' to be unhomed.
1330
  * Set an axis' to be unhomed.
1389
  */
1331
  */
1390
 void set_axis_is_not_at_home(const AxisEnum axis) {
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
   CBI(axis_known_position, axis);
1335
   CBI(axis_known_position, axis);
1400
   CBI(axis_homed, axis);
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
   #if ENABLED(I2C_POSITION_ENCODERS)
1340
   #if ENABLED(I2C_POSITION_ENCODERS)
1411
     I2CPEM.unhomed(axis);
1341
     I2CPEM.unhomed(axis);
1434
     if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
1364
     if (!CAN_HOME(X) && !CAN_HOME(Y) && !CAN_HOME(Z)) return;
1435
   #endif
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
   const int axis_home_dir = (
1369
   const int axis_home_dir = (
1446
     #if ENABLED(DUAL_X_CARRIAGE)
1370
     #if ENABLED(DUAL_X_CARRIAGE)
1472
   #endif
1396
   #endif
1473
 
1397
 
1474
   // Fast move towards endstop until triggered
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
   #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1401
   #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1480
     // BLTOUCH needs to be deployed every time
1402
     // BLTOUCH needs to be deployed every time
1506
   // If a second homing move is configured...
1428
   // If a second homing move is configured...
1507
   if (bump) {
1429
   if (bump) {
1508
     // Move away from the endstop by the axis HOME_BUMP_MM
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
     do_homing_move(axis, -bump
1432
     do_homing_move(axis, -bump
1513
       #if HOMING_Z_WITH_PROBE
1433
       #if HOMING_Z_WITH_PROBE
1514
         , axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0
1434
         , axis == Z_AXIS ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0.0
1516
     );
1436
     );
1517
 
1437
 
1518
     // Slow move towards endstop until triggered
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
     #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1441
     #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
1524
       // BLTOUCH needs to be deployed every time
1442
       // BLTOUCH needs to be deployed every time
1644
 
1562
 
1645
     // retrace by the amount specified in delta_endstop_adj + additional dist in order to have minimum steps
1563
     // retrace by the amount specified in delta_endstop_adj + additional dist in order to have minimum steps
1646
     if (delta_endstop_adj[axis] * Z_HOME_DIR <= 0) {
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
       do_homing_move(axis, delta_endstop_adj[axis] - (MIN_STEPS_PER_SEGMENT + 1) * planner.steps_to_mm[axis] * Z_HOME_DIR);
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
 
1573
 
1658
     destination[axis] = current_position[axis];
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
   #endif
1578
   #endif
1665
 
1579
 
1673
     if (axis == Z_AXIS) fwretract.current_hop = 0.0;
1587
     if (axis == Z_AXIS) fwretract.current_hop = 0.0;
1674
   #endif
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
 } // homeaxis()
1592
 } // homeaxis()
1684
 
1593
 
1685
 #if HAS_WORKSPACE_OFFSET
1594
 #if HAS_WORKSPACE_OFFSET
1686
   void update_workspace_offset(const AxisEnum axis) {
1595
   void update_workspace_offset(const AxisEnum axis) {
1687
     workspace_offset[axis] = home_offset[axis] + position_shift[axis];
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
 #endif
1599
 #endif
1697
 
1600
 

+ 34
- 61
Marlin/src/module/probe.cpp Wyświetl plik

69
   #include "stepper_indirection.h"
69
   #include "stepper_indirection.h"
70
 #endif
70
 #endif
71
 
71
 
72
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
73
+#include "../core/debug_out.h"
74
+
72
 #if ENABLED(Z_PROBE_SLED)
75
 #if ENABLED(Z_PROBE_SLED)
73
 
76
 
74
   #ifndef SLED_DOCKING_OFFSET
77
   #ifndef SLED_DOCKING_OFFSET
82
    *              If true, move to MAX_X and release the solenoid
85
    *              If true, move to MAX_X and release the solenoid
83
    */
86
    */
84
   static void dock_sled(bool stow) {
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
     // Dock sled a bit closer to ensure proper capturing
90
     // Dock sled a bit closer to ensure proper capturing
90
     do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
91
     do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0));
312
 
313
 
313
     bltouch_command(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW);
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
     return false;
318
     return false;
320
   }
319
   }
325
  * Raise Z to a minimum height to make room for a probe to move
324
  * Raise Z to a minimum height to make room for a probe to move
326
  */
325
  */
327
 inline void do_probe_raise(const float z_raise) {
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
   float z_dest = z_raise;
329
   float z_dest = z_raise;
333
   if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
330
   if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
393
 // returns false for ok and true for failure
390
 // returns false for ok and true for failure
394
 bool set_probe_deployed(const bool deploy) {
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
   if (endstops.z_probe_enabled == deploy) return false;
398
   if (endstops.z_probe_enabled == deploy) return false;
404
 
399
 
521
 #endif
516
 #endif
522
 
517
 
523
 static bool do_probe_move(const float z, const float fr_mm_s) {
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
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
521
   #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER)
529
     // Wait for bed to heat back up between probing points
522
     // Wait for bed to heat back up between probing points
601
   // Tell the planner where we actually are
594
   // Tell the planner where we actually are
602
   sync_plan_position();
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
   return !probe_triggered;
599
   return !probe_triggered;
609
 }
600
 }
616
  */
607
  */
617
 static float run_z_probe() {
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
   // Stop the probe before it goes too low to prevent damage.
612
   // Stop the probe before it goes too low to prevent damage.
624
   // If Z isn't known then probe to -10mm.
613
   // If Z isn't known then probe to -10mm.
629
 
618
 
630
     // Do a first probe at the fast speed
619
     // Do a first probe at the fast speed
631
     if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) {
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
       return NAN;
625
       return NAN;
639
     }
626
     }
640
 
627
 
641
     float first_probe_z = current_position[Z_AXIS];
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
     // move up to make clearance for the probe
632
     // move up to make clearance for the probe
648
     do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
633
     do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
666
 
651
 
667
       // move down slowly to find bed
652
       // move down slowly to find bed
668
       if (do_probe_move(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) {
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
         return NAN;
658
         return NAN;
676
       }
659
       }
677
 
660
 
694
 
677
 
695
     const float z2 = current_position[Z_AXIS];
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
     // Return a weighted average of the fast and slow probes
682
     // Return a weighted average of the fast and slow probes
702
     const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
683
     const float measured_z = (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
708
 
689
 
709
   #endif
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
   return measured_z;
694
   return measured_z;
716
 }
695
 }
725
  * - Return the probed Z position
704
  * - Return the probed Z position
726
  */
705
  */
727
 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*/) {
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
   // TODO: Adapt for SCARA, where the offset rotates
717
   // TODO: Adapt for SCARA, where the offset rotates
743
   float nx = rx, ny = ry;
718
   float nx = rx, ny = ry;
788
     SERIAL_ERROR_MSG(MSG_ERR_PROBING_FAILED);
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
   return measured_z;
768
   return measured_z;
796
 }
769
 }

+ 77
- 152
Marlin/src/module/tool_change.cpp Wyświetl plik

31
 
31
 
32
 #include "../Marlin.h"
32
 #include "../Marlin.h"
33
 
33
 
34
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
+#include "../core/debug_out.h"
36
+
34
 #if EXTRUDERS > 1
37
 #if EXTRUDERS > 1
35
   toolchange_settings_t toolchange_settings;  // Initialized by settings.load()
38
   toolchange_settings_t toolchange_settings;  // Initialized by settings.load()
36
 #endif
39
 #endif
169
 
172
 
170
     current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
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
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
180
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
180
     planner.synchronize();
181
     planner.synchronize();
183
 
184
 
184
     current_position[X_AXIS] = grabpos + offsetcompensation;
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
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
192
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
194
     planner.synchronize();
193
     planner.synchronize();
199
     // STEP 3
198
     // STEP 3
200
 
199
 
201
     current_position[X_AXIS] = mpe_settings.parking_xpos[tmp_extruder] + offsetcompensation;
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
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
206
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
210
     planner.synchronize();
207
     planner.synchronize();
212
     // STEP 4
209
     // STEP 4
213
 
210
 
214
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + (active_extruder == 0 ? MPE_TRAVEL_DISTANCE : -MPE_TRAVEL_DISTANCE) + offsetcompensation;
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
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
217
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
223
     planner.synchronize();
218
     planner.synchronize();
226
 
221
 
227
     current_position[X_AXIS] = mpe_settings.parking_xpos[active_extruder] + offsetcompensation;
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
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
229
     planner.buffer_line(current_position, mpe_settings.slow_feedrate, tmp_extruder);
237
     planner.synchronize();
230
     planner.synchronize();
240
 
233
 
241
     current_position[X_AXIS] = oldx;
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
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
241
     planner.buffer_line(current_position, mpe_settings.fast_feedrate, tmp_extruder);
251
     planner.synchronize();
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
 #elif ENABLED(PARKING_EXTRUDER)
247
 #elif ENABLED(PARKING_EXTRUDER)
302
 
291
 
303
       // STEP 1
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
       current_position[Z_AXIS] += toolchange_settings.z_raise;
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
       fast_line_to_current(Z_AXIS);
300
       fast_line_to_current(Z_AXIS);
316
       planner.synchronize();
301
       planner.synchronize();
319
 
304
 
320
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
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
       fast_line_to_current(X_AXIS);
312
       fast_line_to_current(X_AXIS);
330
       planner.synchronize();
313
       planner.synchronize();
331
 
314
 
332
       // STEP 3
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
       pe_deactivate_solenoid(active_extruder);
319
       pe_deactivate_solenoid(active_extruder);
339
 
320
 
340
       // STEP 4
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
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
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
       fast_line_to_current(X_AXIS);
329
       fast_line_to_current(X_AXIS);
353
       planner.synchronize();
330
       planner.synchronize();
354
 
331
 
355
       // STEP 5
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
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
335
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
361
         pe_activate_solenoid(active_extruder); //just save power for inverted magnets
336
         pe_activate_solenoid(active_extruder); //just save power for inverted magnets
368
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
343
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
369
       fast_line_to_current(X_AXIS);
344
       fast_line_to_current(X_AXIS);
370
       current_position[X_AXIS] = grabpos;
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
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
347
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
375
       planner.synchronize();
348
       planner.synchronize();
376
 
349
 
382
         #endif
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
       fast_line_to_current(X_AXIS);
360
       fast_line_to_current(X_AXIS);
390
       planner.synchronize();
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
     else { // nomove == true
365
     else { // nomove == true
397
       // Only engage magnetic field for new extruder
366
       // Only engage magnetic field for new extruder
405
       current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
374
       current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
406
     #endif
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
 #endif // PARKING_EXTRUDER
380
 #endif // PARKING_EXTRUDER
433
 
400
 
434
     // 1. Raise Z to give enough clearance
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
     current_position[Z_AXIS] += toolchange_settings.z_raise;
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
     fast_line_to_current(Z_AXIS);
409
     fast_line_to_current(Z_AXIS);
447
     planner.synchronize();
410
     planner.synchronize();
450
 
413
 
451
     current_position[X_AXIS] = placexpos;
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
     fast_line_to_current(X_AXIS);
421
     fast_line_to_current(X_AXIS);
461
     planner.synchronize();
422
     planner.synchronize();
462
 
423
 
463
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
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
     fast_line_to_current(Y_AXIS);
428
     fast_line_to_current(Y_AXIS);
470
     planner.synchronize();
429
     planner.synchronize();
471
 
430
 
472
     // 3. Unlock tool and drop it in the dock
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
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
435
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
479
     safe_delay(500);
436
     safe_delay(500);
480
 
437
 
481
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
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
     planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
442
     planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder);
488
     planner.synchronize();
443
     planner.synchronize();
489
     safe_delay(200);
444
     safe_delay(200);
490
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
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
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
449
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
497
     planner.synchronize();
450
     planner.synchronize();
498
 
451
 
499
     // 4. Move to the new toolhead
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
     current_position[X_AXIS] = grabxpos;
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
     fast_line_to_current(X_AXIS);
460
     fast_line_to_current(X_AXIS);
512
     planner.synchronize();
461
     planner.synchronize();
513
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
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
     fast_line_to_current(Y_AXIS);
466
     fast_line_to_current(Y_AXIS);
520
     planner.synchronize();
467
     planner.synchronize();
521
 
468
 
522
     // 5. Grab and lock the new toolhead
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
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
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
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
477
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder);
535
     planner.synchronize();
478
     planner.synchronize();
540
 
483
 
541
     current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR;
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
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
488
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
548
     planner.synchronize();
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
 #endif // SWITCHING_TOOLHEAD
494
 #endif // SWITCHING_TOOLHEAD
563
 #if ENABLED(DUAL_X_CARRIAGE)
502
 #if ENABLED(DUAL_X_CARRIAGE)
564
 
503
 
565
   inline void dualx_tool_change(const uint8_t tmp_extruder, bool &no_move) {
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
     const float xhome = x_home_pos(active_extruder);
515
     const float xhome = x_home_pos(active_extruder);
579
     if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
516
     if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE
581
         && (delayed_move_time || current_position[X_AXIS] != xhome) && ! no_move
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
       // Park old head
523
       // Park old head
588
       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);
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
       planner.synchronize();
525
       planner.synchronize();
599
     // This function resets the max/min values - the current position may be overwritten below.
535
     // This function resets the max/min values - the current position may be overwritten below.
600
     set_axis_is_at_home(X_AXIS);
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
     switch (dual_x_carriage_mode) {
540
     switch (dual_x_carriage_mode) {
607
       case DXC_FULL_CONTROL_MODE:
541
       case DXC_FULL_CONTROL_MODE:
620
         break;
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
 #endif // DUAL_X_CARRIAGE
563
 #endif // DUAL_X_CARRIAGE
680
 
612
 
681
     if (!no_move && !all_axes_homed()) {
613
     if (!no_move && !all_axes_homed()) {
682
       no_move = true;
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
     #if HAS_LCD_MENU
618
     #if HAS_LCD_MENU
777
         move_nozzle_servo(tmp_extruder);
707
         move_nozzle_servo(tmp_extruder);
778
       #endif
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
       // The newly-selected extruder XY is actually at...
712
       // The newly-selected extruder XY is actually at...
786
       current_position[X_AXIS] += xdiff;
713
       current_position[X_AXIS] += xdiff;
802
 
729
 
803
       // Return to position and lower again
730
       // Return to position and lower again
804
       if (safe_to_move && !no_move && IsRunning()) {
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
         #if ENABLED(SINGLENOZZLE)
734
         #if ENABLED(SINGLENOZZLE)
810
           #if FAN_COUNT > 0
735
           #if FAN_COUNT > 0

Ładowanie…
Anuluj
Zapisz