|
@@ -38,12 +38,44 @@
|
38
|
38
|
#if ENABLED(MKS_TEST)
|
39
|
39
|
|
40
|
40
|
#include "mks_hardware.h"
|
|
41
|
+ #include "../../../module/endstops.h"
|
41
|
42
|
|
42
|
43
|
bool pw_det_sta, pw_off_sta, mt_det_sta;
|
43
|
44
|
#if PIN_EXISTS(MT_DET_2)
|
44
|
45
|
bool mt_det2_sta;
|
45
|
46
|
#endif
|
46
|
|
- bool endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
|
|
47
|
+ #if HAS_X_MIN || HAS_X_MAX
|
|
48
|
+ bool endstopx1_sta;
|
|
49
|
+ #else
|
|
50
|
+ constexpr static bool endstopx1_sta = true;
|
|
51
|
+ #endif
|
|
52
|
+ #if HAS_X2_MIN || HAS_X2_MAX
|
|
53
|
+ bool endstopx2_sta;
|
|
54
|
+ #else
|
|
55
|
+ constexpr static bool endstopx2_sta = true;
|
|
56
|
+ #endif
|
|
57
|
+ #if HAS_Y_MIN || HAS_Y_MAX
|
|
58
|
+ bool endstopy1_sta;
|
|
59
|
+ #else
|
|
60
|
+ constexpr static bool endstopy1_sta = true;
|
|
61
|
+ #endif
|
|
62
|
+ #if HAS_Y2_MIN || HAS_Y2_MAX
|
|
63
|
+ bool endstopy2_sta;
|
|
64
|
+ #else
|
|
65
|
+ constexpr static bool endstopy2_sta = true;
|
|
66
|
+ #endif
|
|
67
|
+ #if HAS_Z_MIN || HAS_Z_MAX
|
|
68
|
+ bool endstopz1_sta;
|
|
69
|
+ #else
|
|
70
|
+ constexpr static bool endstopz1_sta = true;
|
|
71
|
+ #endif
|
|
72
|
+ #if HAS_Z2_MIN || HAS_Z2_MAX
|
|
73
|
+ bool endstopz2_sta;
|
|
74
|
+ #else
|
|
75
|
+ constexpr static bool endstopz2_sta = true;
|
|
76
|
+ #endif
|
|
77
|
+
|
|
78
|
+ #define ESTATE(S) (READ(S##_PIN) != S##_ENDSTOP_INVERTING)
|
47
|
79
|
|
48
|
80
|
void test_gpio_readlevel_L() {
|
49
|
81
|
WRITE(WIFI_IO0_PIN, HIGH);
|
|
@@ -54,10 +86,36 @@
|
54
|
86
|
#if PIN_EXISTS(MT_DET_2)
|
55
|
87
|
mt_det2_sta = (READ(MT_DET_2_PIN) == LOW);
|
56
|
88
|
#endif
|
57
|
|
- endstopx1_sta = (READ(X_MIN_PIN) == LOW);
|
58
|
|
- endstopy1_sta = (READ(Y_MIN_PIN) == LOW);
|
59
|
|
- endstopz1_sta = (READ(Z_MIN_PIN) == LOW);
|
60
|
|
- endstopz2_sta = (READ(Z_MAX_PIN) == LOW);
|
|
89
|
+ #if HAS_X_MIN
|
|
90
|
+ endstopx1_sta = ESTATE(X_MIN);
|
|
91
|
+ #elif HAS_X_MAX
|
|
92
|
+ endstopx1_sta = ESTATE(X_MAX);
|
|
93
|
+ #endif
|
|
94
|
+ #if HAS_X2_MIN
|
|
95
|
+ endstopx2_sta = ESTATE(X2_MIN);
|
|
96
|
+ #elif HAS_X2_MAX
|
|
97
|
+ endstopx2_sta = ESTATE(X2_MAX);
|
|
98
|
+ #endif
|
|
99
|
+ #if HAS_Y_MIN
|
|
100
|
+ endstopy1_sta = ESTATE(Y_MIN);
|
|
101
|
+ #elif HAS_Y_MAX
|
|
102
|
+ endstopy1_sta = ESTATE(Y_MAX);
|
|
103
|
+ #endif
|
|
104
|
+ #if HAS_Y2_MIN
|
|
105
|
+ endstopy2_sta = ESTATE(Y2_MIN);
|
|
106
|
+ #elif HAS_Y2_MAX
|
|
107
|
+ endstopy2_sta = ESTATE(Y2_MAX);
|
|
108
|
+ #endif
|
|
109
|
+ #if HAS_Z_MIN
|
|
110
|
+ endstopz1_sta = ESTATE(Z_MIN);
|
|
111
|
+ #elif HAS_Z_MAX
|
|
112
|
+ endstopz1_sta = ESTATE(Z_MAX);
|
|
113
|
+ #endif
|
|
114
|
+ #if HAS_Z2_MIN
|
|
115
|
+ endstopz2_sta = ESTATE(Z2_MIN);
|
|
116
|
+ #elif HAS_Z2_MAX
|
|
117
|
+ endstopz2_sta = ESTATE(Z2_MAX);
|
|
118
|
+ #endif
|
61
|
119
|
}
|
62
|
120
|
|
63
|
121
|
void test_gpio_readlevel_H() {
|
|
@@ -69,44 +127,66 @@
|
69
|
127
|
#if PIN_EXISTS(MT_DET_2)
|
70
|
128
|
mt_det2_sta = (READ(MT_DET_2_PIN) == HIGH);
|
71
|
129
|
#endif
|
72
|
|
- endstopx1_sta = (READ(X_MIN_PIN) == HIGH);
|
73
|
|
- endstopy1_sta = (READ(Y_MIN_PIN) == HIGH);
|
74
|
|
- endstopz1_sta = (READ(Z_MIN_PIN) == HIGH);
|
75
|
|
- endstopz2_sta = (READ(Z_MAX_PIN) == HIGH);
|
|
130
|
+ #if HAS_X_MIN
|
|
131
|
+ endstopx1_sta = !ESTATE(X_MIN);
|
|
132
|
+ #elif HAS_X_MAX
|
|
133
|
+ endstopx1_sta = !ESTATE(X_MAX);
|
|
134
|
+ #endif
|
|
135
|
+ #if HAS_X2_MIN
|
|
136
|
+ endstopx2_sta = !ESTATE(X2_MIN);
|
|
137
|
+ #elif HAS_X2_MAX
|
|
138
|
+ endstopx2_sta = !ESTATE(X2_MAX);
|
|
139
|
+ #endif
|
|
140
|
+ #if HAS_Y_MIN
|
|
141
|
+ endstopy1_sta = !ESTATE(Y_MIN);
|
|
142
|
+ #elif HAS_Y_MAX
|
|
143
|
+ endstopy1_sta = !ESTATE(Y_MAX);
|
|
144
|
+ #endif
|
|
145
|
+ #if HAS_Y2_MIN
|
|
146
|
+ endstopy2_sta = !ESTATE(Y2_MIN);
|
|
147
|
+ #elif HAS_Y2_MAX
|
|
148
|
+ endstopy2_sta = !ESTATE(Y2_MAX);
|
|
149
|
+ #endif
|
|
150
|
+ #if HAS_Z_MIN
|
|
151
|
+ endstopz1_sta = !ESTATE(Z_MIN);
|
|
152
|
+ #elif HAS_Z_MAX
|
|
153
|
+ endstopz1_sta = !ESTATE(Z_MAX);
|
|
154
|
+ #endif
|
|
155
|
+ #if HAS_Z2_MIN
|
|
156
|
+ endstopz2_sta = !ESTATE(Z2_MIN);
|
|
157
|
+ #elif HAS_Z2_MAX
|
|
158
|
+ endstopz2_sta = !ESTATE(Z2_MAX);
|
|
159
|
+ #endif
|
76
|
160
|
}
|
77
|
161
|
|
78
|
162
|
void init_test_gpio() {
|
79
|
|
- SET_INPUT_PULLUP(X_MIN_PIN);
|
80
|
|
- SET_INPUT_PULLUP(Y_MIN_PIN);
|
81
|
|
- SET_INPUT_PULLUP(Z_MIN_PIN);
|
82
|
|
- SET_INPUT_PULLUP(Z_MAX_PIN);
|
|
163
|
+ endstops.init();
|
83
|
164
|
|
84
|
165
|
SET_OUTPUT(WIFI_IO0_PIN);
|
85
|
166
|
|
86
|
|
- SET_INPUT_PULLUP(MT_DET_1_PIN);
|
|
167
|
+ #if PIN_EXISTS(MT_DET_1)
|
|
168
|
+ SET_INPUT_PULLUP(MT_DET_1_PIN);
|
|
169
|
+ #endif
|
87
|
170
|
#if PIN_EXISTS(MT_DET_2)
|
88
|
171
|
SET_INPUT_PULLUP(MT_DET_2_PIN);
|
89
|
172
|
#endif
|
90
|
173
|
|
91
|
174
|
SET_INPUT_PULLUP(MKS_TEST_POWER_LOSS_PIN);
|
92
|
175
|
SET_INPUT_PULLUP(MKS_TEST_PS_ON_PIN);
|
93
|
|
-
|
94
|
176
|
SET_INPUT_PULLUP(SERVO0_PIN);
|
95
|
177
|
|
96
|
|
- SET_OUTPUT(X_ENABLE_PIN);
|
97
|
|
- SET_OUTPUT(Y_ENABLE_PIN);
|
98
|
|
- SET_OUTPUT(Z_ENABLE_PIN);
|
99
|
|
- SET_OUTPUT(E0_ENABLE_PIN);
|
100
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
101
|
|
- SET_OUTPUT(E1_ENABLE_PIN);
|
|
178
|
+ OUT_WRITE(X_ENABLE_PIN, LOW);
|
|
179
|
+ #if HAS_Y_AXIS
|
|
180
|
+ OUT_WRITE(Y_ENABLE_PIN, LOW);
|
102
|
181
|
#endif
|
103
|
|
-
|
104
|
|
- WRITE(X_ENABLE_PIN, LOW);
|
105
|
|
- WRITE(Y_ENABLE_PIN, LOW);
|
106
|
|
- WRITE(Z_ENABLE_PIN, LOW);
|
107
|
|
- WRITE(E0_ENABLE_PIN, LOW);
|
108
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
109
|
|
- WRITE(E1_ENABLE_PIN, LOW);
|
|
182
|
+ #if HAS_Z_AXIS
|
|
183
|
+ OUT_WRITE(Z_ENABLE_PIN, LOW);
|
|
184
|
+ #endif
|
|
185
|
+ #if HAS_EXTRUDERS
|
|
186
|
+ OUT_WRITE(E0_ENABLE_PIN, LOW);
|
|
187
|
+ #endif
|
|
188
|
+ #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
189
|
+ OUT_WRITE(E1_ENABLE_PIN, LOW);
|
110
|
190
|
#endif
|
111
|
191
|
|
112
|
192
|
#if ENABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
@@ -161,34 +241,54 @@
|
161
|
241
|
|
162
|
242
|
void mks_hardware_test() {
|
163
|
243
|
if (millis() % 2000 < 1000) {
|
|
244
|
+ thermalManager.fan_speed[0] = 255;
|
164
|
245
|
WRITE(X_DIR_PIN, LOW);
|
165
|
|
- WRITE(Y_DIR_PIN, LOW);
|
166
|
|
- WRITE(Z_DIR_PIN, LOW);
|
167
|
|
- WRITE(E0_DIR_PIN, LOW);
|
168
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
246
|
+ #if HAS_Y_AXIS
|
|
247
|
+ WRITE(Y_DIR_PIN, LOW);
|
|
248
|
+ #endif
|
|
249
|
+ #if HAS_Z_AXIS
|
|
250
|
+ WRITE(Z_DIR_PIN, LOW);
|
|
251
|
+ #endif
|
|
252
|
+ #if HAS_EXTRUDERS
|
|
253
|
+ WRITE(E0_DIR_PIN, LOW);
|
|
254
|
+ #endif
|
|
255
|
+ #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
169
|
256
|
WRITE(E1_DIR_PIN, LOW);
|
170
|
257
|
#endif
|
171
|
|
- thermalManager.fan_speed[0] = 255;
|
172
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
258
|
+ #if HAS_MULTI_HOTEND && DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
173
|
259
|
WRITE(HEATER_1_PIN, HIGH); // HE1
|
174
|
260
|
#endif
|
175
|
|
- WRITE(HEATER_0_PIN, HIGH); // HE0
|
176
|
|
- WRITE(HEATER_BED_PIN, HIGH); // HOT-BED
|
|
261
|
+ #if HAS_HOTEND
|
|
262
|
+ WRITE(HEATER_0_PIN, HIGH); // HE0
|
|
263
|
+ #endif
|
|
264
|
+ #if HAS_HEATED_BED
|
|
265
|
+ WRITE(HEATER_BED_PIN, HIGH); // HOT-BED
|
|
266
|
+ #endif
|
177
|
267
|
}
|
178
|
268
|
else {
|
|
269
|
+ thermalManager.fan_speed[0] = 0;
|
179
|
270
|
WRITE(X_DIR_PIN, HIGH);
|
180
|
|
- WRITE(Y_DIR_PIN, HIGH);
|
181
|
|
- WRITE(Z_DIR_PIN, HIGH);
|
182
|
|
- WRITE(E0_DIR_PIN, HIGH);
|
183
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
271
|
+ #if HAS_Y_AXIS
|
|
272
|
+ WRITE(Y_DIR_PIN, HIGH);
|
|
273
|
+ #endif
|
|
274
|
+ #if HAS_Y_AXIS
|
|
275
|
+ WRITE(Z_DIR_PIN, HIGH);
|
|
276
|
+ #endif
|
|
277
|
+ #if HAS_EXTRUDERS
|
|
278
|
+ WRITE(E0_DIR_PIN, HIGH);
|
|
279
|
+ #endif
|
|
280
|
+ #if HAS_MULTI_EXTRUDER && DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
184
|
281
|
WRITE(E1_DIR_PIN, HIGH);
|
185
|
282
|
#endif
|
186
|
|
- thermalManager.fan_speed[0] = 0;
|
187
|
|
- #if DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
|
283
|
+ #if HAS_MULTI_HOTEND && DISABLED(MKS_HARDWARE_TEST_ONLY_E0)
|
188
|
284
|
WRITE(HEATER_1_PIN, LOW); // HE1
|
189
|
285
|
#endif
|
190
|
|
- WRITE(HEATER_0_PIN, LOW); // HE0
|
191
|
|
- WRITE(HEATER_BED_PIN, LOW); // HOT-BED
|
|
286
|
+ #if HAS_HOTEND
|
|
287
|
+ WRITE(HEATER_0_PIN, LOW); // HE0
|
|
288
|
+ #endif
|
|
289
|
+ #if HAS_HEATED_BED
|
|
290
|
+ WRITE(HEATER_BED_PIN, LOW); // HOT-BED
|
|
291
|
+ #endif
|
192
|
292
|
}
|
193
|
293
|
|
194
|
294
|
if (endstopx1_sta && endstopx2_sta && endstopy1_sta && endstopy2_sta && endstopz1_sta && endstopz2_sta) {
|