Pārlūkot izejas kodu

Report on M92 with no arguments (#12833)

Scott Lahteine 6 gadus atpakaļ
vecāks
revīzija
4200bd2fc1
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam

+ 68
- 1
Marlin/src/gcode/config/M92.cpp Parādīt failu

@@ -23,19 +23,63 @@
23 23
 #include "../gcode.h"
24 24
 #include "../../module/planner.h"
25 25
 
26
+void report_M92(
27
+  #if NUM_SERIAL > 1
28
+    const int8_t port,
29
+  #endif
30
+  const bool echo=true, const int8_t e=-1
31
+) {
32
+  if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
33
+  SERIAL_ECHOPAIR_P(port, " M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
34
+  SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
35
+  SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
36
+  #if DISABLED(DISTINCT_E_FACTORS)
37
+    SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
38
+  #endif
39
+  SERIAL_EOL_P(port);
40
+
41
+  #if ENABLED(DISTINCT_E_FACTORS)
42
+    for (uint8_t i = 0; i < E_STEPPERS; i++) {
43
+      if (e >= 0 && i != e) continue;
44
+      if (echo) SERIAL_ECHO_START_P(port); else SERIAL_CHAR(' ');
45
+      SERIAL_ECHOPAIR_P(port, " M92 T", (int)i);
46
+      SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS_N(i)]));
47
+    }
48
+  #endif
49
+}
50
+
26 51
 /**
27 52
  * M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
28 53
  *      (Follows the same syntax as G92)
29 54
  *
30 55
  *      With multiple extruders use T to specify which one.
56
+ *
57
+ *      If no argument is given print the current values.
58
+ *
59
+ *    With MAGIC_NUMBERS_GCODE:
60
+ *      Use 'H' and/or 'L' to get ideal layer-height information.
61
+ *      'H' specifies micro-steps to use. We guess if it's not supplied.
62
+ *      'L' specifies a desired layer height. Nearest good heights are shown.
31 63
  */
32 64
 void GcodeSuite::M92() {
33 65
 
34 66
   const int8_t target_extruder = get_target_extruder_from_command();
35 67
   if (target_extruder < 0) return;
36 68
 
69
+  // No arguments? Show M92 report.
70
+  if (!parser.seen("XYZE"
71
+    #if ENABLED(MAGIC_NUMBERS_GCODE)
72
+      "HL"
73
+    #endif
74
+  )) return report_M92(
75
+    #if NUM_SERIAL > 1
76
+      command_queue_port[cmd_queue_index_r],
77
+    #endif
78
+    true, target_extruder
79
+  );
80
+
37 81
   LOOP_XYZE(i) {
38
-    if (parser.seen(axis_codes[i])) {
82
+    if (parser.seenval(axis_codes[i])) {
39 83
       if (i == E_AXIS) {
40 84
         const float value = parser.value_per_axis_units((AxisEnum)(E_AXIS_N(target_extruder)));
41 85
         if (value < 20) {
@@ -54,4 +98,27 @@ void GcodeSuite::M92() {
54 98
     }
55 99
   }
56 100
   planner.refresh_positioning();
101
+
102
+  #if ENABLED(MAGIC_NUMBERS_GCODE)
103
+    #ifndef Z_MICROSTEPS
104
+      #define Z_MICROSTEPS 16
105
+    #endif
106
+    const float wanted = parser.floatval('L');
107
+    if (parser.seen('H') || wanted) {
108
+      const uint16_t argH = parser.ushortval('H'),
109
+                     micro_steps = argH ? argH : Z_MICROSTEPS;
110
+      const float z_full_step_mm = micro_steps * planner.steps_to_mm[Z_AXIS];
111
+      SERIAL_ECHO_START();
112
+      SERIAL_ECHOPAIR("{ micro_steps:", micro_steps);
113
+      SERIAL_ECHOPAIR(", z_full_step_mm:", z_full_step_mm);
114
+      if (wanted) {
115
+        const float best = uint16_t(wanted / z_full_step_mm) * z_full_step_mm;
116
+        SERIAL_ECHOPGM(", best:[");
117
+        SERIAL_ECHO(best);
118
+        if (best != wanted) { SERIAL_CHAR(','); SERIAL_ECHO(best + z_full_step_mm); }
119
+        SERIAL_CHAR(']');
120
+      }
121
+      SERIAL_ECHOLNPGM(" }");
122
+    }
123
+  #endif
57 124
 }

+ 13
- 15
Marlin/src/module/configuration_store.cpp Parādīt failu

@@ -2366,6 +2366,13 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2366 2366
     #define SAY_UNITS_P(PORT, COLON) say_units(COLON)
2367 2367
   #endif
2368 2368
 
2369
+  void report_M92(
2370
+    #if NUM_SERIAL > 1
2371
+      const int8_t port,
2372
+    #endif
2373
+    const bool echo=true, const int8_t e=-1
2374
+  );
2375
+
2369 2376
   /**
2370 2377
    * M503 - Report current settings in RAM
2371 2378
    *
@@ -2458,21 +2465,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
2458 2465
     #endif // !NO_VOLUMETRICS
2459 2466
 
2460 2467
     CONFIG_ECHO_HEADING("Steps per unit:");
2461
-    CONFIG_ECHO_START();
2462
-    SERIAL_ECHOPAIR_P(port, "  M92 X", LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]));
2463
-    SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]));
2464
-    SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.settings.axis_steps_per_mm[Z_AXIS]));
2465
-    #if DISABLED(DISTINCT_E_FACTORS)
2466
-      SERIAL_ECHOPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS]));
2467
-    #endif
2468
-    SERIAL_EOL_P(port);
2469
-    #if ENABLED(DISTINCT_E_FACTORS)
2470
-      CONFIG_ECHO_START();
2471
-      for (uint8_t i = 0; i < E_STEPPERS; i++) {
2472
-        SERIAL_ECHOPAIR_P(port, "  M92 T", (int)i);
2473
-        SERIAL_ECHOLNPAIR_P(port, " E", VOLUMETRIC_UNIT(planner.settings.axis_steps_per_mm[E_AXIS + i]));
2474
-      }
2475
-    #endif
2468
+    report_M92(
2469
+      #if NUM_SERIAL > 1
2470
+        port,
2471
+      #endif
2472
+      !forReplay
2473
+    );
2476 2474
 
2477 2475
     CONFIG_ECHO_HEADING("Maximum feedrates (units/s):");
2478 2476
     CONFIG_ECHO_START();

Notiek ielāde…
Atcelt
Saglabāt