Ver código fonte

Extend M122 for all steppers

Scott Lahteine 8 anos atrás
pai
commit
127e21ae00
1 arquivos alterados com 52 adições e 39 exclusões
  1. 52
    39
      Marlin/Marlin_main.cpp

+ 52
- 39
Marlin/Marlin_main.cpp Ver arquivo

@@ -5884,45 +5884,6 @@ inline void gcode_M117() {
5884 5884
  */
5885 5885
 inline void gcode_M119() { endstops.M119(); }
5886 5886
 
5887
-#if ENABLED(HAVE_TMC2130DRIVER)
5888
-  /**
5889
-   * M122: Output Trinamic TMC2130 status to serial output. Very bad formatting.
5890
-   */
5891
-  inline void gcode_M122() {
5892
-    SERIAL_PROTOCOLLNPGM("REPORTING TMC2130 STATUS");
5893
-    #if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(X_IS_TMC2130)
5894
-      stepperX.read_STAT();
5895
-      SERIAL_PROTOCOLLN("X-AXIS: ");
5896
-      SERIAL_PROTOCOLLN((stepperX.isReset() ? "RESET " : "----- "));
5897
-      SERIAL_PROTOCOLLN((stepperX.isError() ? "ERROR " : "----- "));
5898
-      SERIAL_PROTOCOLLN((stepperX.isStallguard() ? "SLGRD " : "----- "));
5899
-      SERIAL_PROTOCOLLN((stepperX.isStandstill() ? "STILL " : "----- "));
5900
-      SERIAL_PROTOCOLLN((stepperX.debug()));
5901
-      SERIAL_PROTOCOLLN("-----");
5902
-    #endif
5903
-    #if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Y_IS_TMC2130)
5904
-      stepperY.read_STAT();
5905
-      SERIAL_PROTOCOLLN("Y-AXIS: ");
5906
-      SERIAL_PROTOCOLLN((stepperY.isReset() ? "RESET " : "----- "));
5907
-      SERIAL_PROTOCOLLN((stepperY.isError() ? "ERROR " : "----- "));
5908
-      SERIAL_PROTOCOLLN((stepperY.isStallguard() ? "SLGRD " : "----- "));
5909
-      SERIAL_PROTOCOLLN((stepperY.isStandstill() ? "STILL " : "----- "));
5910
-      SERIAL_PROTOCOLLN((stepperY.debug()));
5911
-      SERIAL_PROTOCOLLN("-----");
5912
-    #endif
5913
-    #if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Z_IS_TMC2130)
5914
-      stepperZ.read_STAT();
5915
-      SERIAL_PROTOCOLLN("Z-AXIS: ");
5916
-      SERIAL_PROTOCOLLN((stepperZ.isReset() ? "RESET " : "----- "));
5917
-      SERIAL_PROTOCOLLN((stepperZ.isError() ? "ERROR " : "----- "));
5918
-      SERIAL_PROTOCOLLN((stepperZ.isStallguard() ? "SLGRD " : "----- "));
5919
-      SERIAL_PROTOCOLLN((stepperZ.isStandstill() ? "STILL " : "----- "));
5920
-      SERIAL_PROTOCOLLN((stepperZ.debug()));
5921
-      SERIAL_PROTOCOLLN("-----");
5922
-    #endif
5923
-  }
5924
-#endif // HAVE_TMC2130DRIVER
5925
-
5926 5887
 /**
5927 5888
  * M120: Enable endstops and set non-homing endstop state to "enabled"
5928 5889
  */
@@ -5933,6 +5894,58 @@ inline void gcode_M120() { endstops.enable_globally(true); }
5933 5894
  */
5934 5895
 inline void gcode_M121() { endstops.enable_globally(false); }
5935 5896
 
5897
+#if ENABLED(HAVE_TMC2130DRIVER)
5898
+
5899
+  /**
5900
+   * M122: Output Trinamic TMC2130 status to serial output. Very bad formatting.
5901
+   */
5902
+
5903
+  static void tmc2130_report(Trinamic_TMC2130 &stepr, const char *name) {
5904
+    stepr.read_STAT();
5905
+    SERIAL_PROTOCOL(name);
5906
+    SERIAL_PROTOCOL(": ");
5907
+    stepr.isReset() ? SERIAL_PROTOCOLPGM("RESET ") : SERIAL_PROTOCOLPGM("----- ");
5908
+    stepr.isError() ? SERIAL_PROTOCOLPGM("ERROR ") : SERIAL_PROTOCOLPGM("----- ");
5909
+    stepr.isStallguard() ? SERIAL_PROTOCOLPGM("SLGRD ") : SERIAL_PROTOCOLPGM("----- ");
5910
+    stepr.isStandstill() ? SERIAL_PROTOCOLPGM("STILL ") : SERIAL_PROTOCOLPGM("----- ");
5911
+    SERIAL_PROTOCOLLN(stepr.debug());
5912
+  }
5913
+
5914
+  inline void gcode_M122() {
5915
+    SERIAL_PROTOCOLLNPGM("Reporting TMC2130 status");
5916
+    #if ENABLED(X_IS_TMC2130)
5917
+      tmc2130_report(stepperX, "X");
5918
+    #endif
5919
+    #if ENABLED(X2_IS_TMC2130)
5920
+      tmc2130_report(stepperX2, "X2");
5921
+    #endif
5922
+    #if ENABLED(Y_IS_TMC2130)
5923
+      tmc2130_report(stepperY, "Y");
5924
+    #endif
5925
+    #if ENABLED(Y2_IS_TMC2130)
5926
+      tmc2130_report(stepperY2, "Y2");
5927
+    #endif
5928
+    #if ENABLED(Z_IS_TMC2130)
5929
+      tmc2130_report(stepperZ, "Z");
5930
+    #endif
5931
+    #if ENABLED(Z2_IS_TMC2130)
5932
+      tmc2130_report(stepperZ2, "Z2");
5933
+    #endif
5934
+    #if ENABLED(E0_IS_TMC2130)
5935
+      tmc2130_report(stepperE0, "E0");
5936
+    #endif
5937
+    #if ENABLED(E1_IS_TMC2130)
5938
+      tmc2130_report(stepperE1, "E1");
5939
+    #endif
5940
+    #if ENABLED(E2_IS_TMC2130)
5941
+      tmc2130_report(stepperE2, "E2");
5942
+    #endif
5943
+    #if ENABLED(E3_IS_TMC2130)
5944
+      tmc2130_report(stepperE3, "E3");
5945
+    #endif
5946
+  }
5947
+#endif // HAVE_TMC2130DRIVER
5948
+
5936 5949
 #if ENABLED(BLINKM)
5937 5950
 
5938 5951
   /**

Carregando…
Cancelar
Salvar