Explorar el Código

🚸 M666: Fix value filter, add report (#22337)

In reference to #22325
Scott Lahteine hace 3 años
padre
commit
01ae1ced38
No account linked to committer's email address

+ 51
- 23
Marlin/src/gcode/calibrate/M666.cpp Ver fichero

@@ -27,30 +27,72 @@
27 27
 #include "../gcode.h"
28 28
 
29 29
 #if ENABLED(DELTA)
30
-
31 30
   #include "../../module/delta.h"
32 31
   #include "../../module/motion.h"
32
+#else
33
+  #include "../../module/endstops.h"
34
+#endif
33 35
 
34
-  #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
35
-  #include "../../core/debug_out.h"
36
+#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
37
+#include "../../core/debug_out.h"
38
+
39
+void M666_report(const bool forReplay=true) {
40
+  if (!forReplay) { SERIAL_ECHOLNPGM("; Endstop adjustment:"); SERIAL_ECHO_START(); }
41
+  #if ENABLED(DELTA)
42
+    SERIAL_ECHOLNPAIR_P(
43
+        PSTR("  M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
44
+      , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
45
+      , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
46
+    );
47
+  #else
48
+    SERIAL_ECHOPGM("  M666");
49
+    #if ENABLED(X_DUAL_ENDSTOPS)
50
+      SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
51
+    #endif
52
+    #if ENABLED(Y_DUAL_ENDSTOPS)
53
+      SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
54
+    #endif
55
+    #if ENABLED(Z_MULTI_ENDSTOPS)
56
+      #if NUM_Z_STEPPER_DRIVERS >= 3
57
+        SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
58
+        if (!forReplay) SERIAL_ECHO_START();
59
+        SERIAL_ECHOPAIR("  M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
60
+        #if NUM_Z_STEPPER_DRIVERS >= 4
61
+          if (!forReplay) SERIAL_ECHO_START();
62
+          SERIAL_ECHOPAIR("  M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
63
+        #endif
64
+      #else
65
+        SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
66
+      #endif
67
+    #endif
68
+  #endif
69
+}
70
+
71
+#if ENABLED(DELTA)
36 72
 
37 73
   /**
38 74
    * M666: Set delta endstop adjustment
39 75
    */
40 76
   void GcodeSuite::M666() {
41 77
     DEBUG_SECTION(log_M666, "M666", DEBUGGING(LEVELING));
78
+    bool is_err = false, is_set = false;
42 79
     LOOP_LINEAR_AXES(i) {
43 80
       if (parser.seen(AXIS_CHAR(i))) {
81
+        is_set = true;
44 82
         const float v = parser.value_linear_units();
45
-        if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
46
-        if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", delta_endstop_adj[i]);
83
+        if (v > 0)
84
+          is_err = true;
85
+        else {
86
+          delta_endstop_adj[i] = v;
87
+          if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", AS_CHAR(AXIS_CHAR(i)), "] = ", v);
88
+        }
47 89
       }
48 90
     }
91
+    if (is_err) SERIAL_ECHOLNPAIR("?M666 offsets must be <= 0");
92
+    if (!is_set) M666_report();
49 93
   }
50 94
 
51
-#elif HAS_EXTRA_ENDSTOPS
52
-
53
-  #include "../../module/endstops.h"
95
+#else
54 96
 
55 97
   /**
56 98
    * M666: Set Dual Endstops offsets for X, Y, and/or Z.
@@ -81,21 +123,7 @@
81 123
         #endif
82 124
       }
83 125
     #endif
84
-    if (!parser.seen("XYZ")) {
85
-      auto echo_adj = [](PGM_P const label, const_float_t value) { SERIAL_ECHOPAIR_P(label, value); };
86
-      SERIAL_ECHOPGM("Dual Endstop Adjustment (mm): ");
87
-      #if ENABLED(X_DUAL_ENDSTOPS)
88
-        echo_adj(PSTR(" X2:"), endstops.x2_endstop_adj);
89
-      #endif
90
-      #if ENABLED(Y_DUAL_ENDSTOPS)
91
-        echo_adj(PSTR(" Y2:"), endstops.y2_endstop_adj);
92
-      #endif
93
-      #if ENABLED(Z_MULTI_ENDSTOPS)
94
-        #define _ECHO_ZADJ(N) echo_adj(PSTR(" Z" STRINGIFY(N) ":"), endstops.z##N##_endstop_adj);
95
-        REPEAT_S(2, INCREMENT(NUM_Z_STEPPER_DRIVERS), _ECHO_ZADJ)
96
-      #endif
97
-      SERIAL_EOL();
98
-    }
126
+    if (!parser.seen("XYZ")) M666_report();
99 127
   }
100 128
 
101 129
 #endif // HAS_EXTRA_ENDSTOPS

+ 2
- 2
Marlin/src/gcode/feature/controllerfan/M710.cpp Ver fichero

@@ -27,7 +27,7 @@
27 27
 #include "../../gcode.h"
28 28
 #include "../../../feature/controllerfan.h"
29 29
 
30
-void M710_report(const bool forReplay) {
30
+void M710_report(const bool forReplay=true) {
31 31
   if (!forReplay) { SERIAL_ECHOLNPGM("; Controller Fan"); SERIAL_ECHO_START(); }
32 32
   SERIAL_ECHOLNPAIR("  M710"
33 33
     " S", int(controllerFan.settings.active_speed),
@@ -75,7 +75,7 @@ void GcodeSuite::M710() {
75 75
   if (seenD) controllerFan.settings.duration = parser.value_ushort();
76 76
 
77 77
   if (!(seenR || seenS || seenI || seenA || seenD))
78
-    M710_report(false);
78
+    M710_report();
79 79
 }
80 80
 
81 81
 #endif // CONTROLLER_FAN_EDITABLE

+ 9
- 34
Marlin/src/module/settings.cpp Ver fichero

@@ -130,7 +130,7 @@
130 130
 
131 131
 #include "../feature/controllerfan.h"
132 132
 #if ENABLED(CONTROLLER_FAN_EDITABLE)
133
-  void M710_report(const bool forReplay);
133
+  void M710_report(const bool forReplay=true);
134 134
 #endif
135 135
 
136 136
 #if ENABLED(CASE_LIGHT_ENABLE)
@@ -168,6 +168,10 @@
168 168
   void M554_report();
169 169
 #endif
170 170
 
171
+#if EITHER(DELTA, HAS_EXTRA_ENDSTOPS)
172
+  void M666_report(const bool forReplay=true);
173
+#endif
174
+
171 175
 #define _EN_ITEM(N) , E##N
172 176
 
173 177
 typedef struct { uint16_t LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM); } tmc_stepper_current_t;
@@ -3302,14 +3306,6 @@ void MarlinSettings::reset() {
3302 3306
 
3303 3307
     #elif ENABLED(DELTA)
3304 3308
 
3305
-      CONFIG_ECHO_HEADING("Endstop adjustment:");
3306
-      CONFIG_ECHO_START();
3307
-      SERIAL_ECHOLNPAIR_P(
3308
-          PSTR("  M666 X"), LINEAR_UNIT(delta_endstop_adj.a)
3309
-        , SP_Y_STR, LINEAR_UNIT(delta_endstop_adj.b)
3310
-        , SP_Z_STR, LINEAR_UNIT(delta_endstop_adj.c)
3311
-      );
3312
-
3313 3309
       CONFIG_ECHO_HEADING("Delta settings: L<diagonal rod> R<radius> H<height> S<segments per sec> XYZ<tower angle trim> ABC<rod trim>");
3314 3310
       CONFIG_ECHO_START();
3315 3311
       SERIAL_ECHOLNPAIR_P(
@@ -3325,32 +3321,11 @@ void MarlinSettings::reset() {
3325 3321
         , PSTR(" C"), LINEAR_UNIT(delta_diagonal_rod_trim.c)
3326 3322
       );
3327 3323
 
3328
-    #elif HAS_EXTRA_ENDSTOPS
3329
-
3330
-      CONFIG_ECHO_HEADING("Endstop adjustment:");
3331
-      CONFIG_ECHO_START();
3332
-      SERIAL_ECHOPGM("  M666");
3333
-      #if ENABLED(X_DUAL_ENDSTOPS)
3334
-        SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
3335
-      #endif
3336
-      #if ENABLED(Y_DUAL_ENDSTOPS)
3337
-        SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
3338
-      #endif
3339
-      #if ENABLED(Z_MULTI_ENDSTOPS)
3340
-        #if NUM_Z_STEPPER_DRIVERS >= 3
3341
-          SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
3342
-          CONFIG_ECHO_START();
3343
-          SERIAL_ECHOPAIR("  M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
3344
-          #if NUM_Z_STEPPER_DRIVERS >= 4
3345
-            CONFIG_ECHO_START();
3346
-            SERIAL_ECHOPAIR("  M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
3347
-          #endif
3348
-        #else
3349
-          SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
3350
-        #endif
3351
-      #endif
3324
+    #endif
3352 3325
 
3353
-    #endif // [XYZ]_DUAL_ENDSTOPS
3326
+    #if EITHER(DELTA, HAS_EXTRA_ENDSTOPS)
3327
+      M666_report(forReplay);
3328
+    #endif
3354 3329
 
3355 3330
     #if PREHEAT_COUNT
3356 3331
 

Loading…
Cancelar
Guardar