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