|
@@ -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
|
}
|