Переглянути джерело

🎨 MKS Hardware Test followup (#22414)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
ellensp 3 роки тому
джерело
коміт
d819de46d3
Аккаунт користувача з таким Email не знайдено

+ 2
- 2
Marlin/src/lcd/extui/mks_ui/draw_media_select.cpp Переглянути файл

@@ -39,7 +39,7 @@ enum {
39 39
 };
40 40
 
41 41
 #if ENABLED(MKS_TEST)
42
-  extern uint8_t curent_disp_ui;
42
+  extern uint8_t current_disp_ui;
43 43
 #endif
44 44
 
45 45
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
@@ -49,7 +49,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
49 49
     case ID_T_USB_DISK: card.changeMedia(&card.media_driver_usbFlash); break;
50 50
     case ID_T_SD_DISK:  card.changeMedia(&card.media_driver_sdcard); break;
51 51
     case ID_T_RETURN:
52
-      TERN_(MKS_TEST, curent_disp_ui = 1);
52
+      TERN_(MKS_TEST, current_disp_ui = 1);
53 53
       lv_draw_ready_print();
54 54
       return;
55 55
   }

+ 7
- 5
Marlin/src/lcd/extui/mks_ui/draw_ready_print.cpp Переглянути файл

@@ -61,7 +61,7 @@ static lv_obj_t *buttonExt1, *labelExt1, *buttonFanstate, *labelFan;
61 61
 #endif
62 62
 
63 63
 #if ENABLED(MKS_TEST)
64
-  uint8_t curent_disp_ui = 0;
64
+  uint8_t current_disp_ui = 0;
65 65
 #endif
66 66
 
67 67
 enum { ID_TOOL = 1, ID_SET, ID_PRINT, ID_INFO_EXT, ID_INFO_BED, ID_INFO_FAN };
@@ -106,8 +106,10 @@ void disp_det_error() {
106 106
 lv_obj_t *e1, *e2, *e3, *bed;
107 107
 void mks_disp_test() {
108 108
   char buf[30] = {0};
109
-  sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0));
110
-  lv_label_set_text(e1, buf);
109
+  #if HAS_HOTEND
110
+    sprintf_P(buf, PSTR("e1:%d"), thermalManager.wholeDegHotend(0));
111
+    lv_label_set_text(e1, buf);
112
+  #endif
111 113
   #if HAS_MULTI_HOTEND
112 114
     sprintf_P(buf, PSTR("e2:%d"), thermalManager.wholeDegHotend(1));
113 115
     lv_label_set_text(e2, buf);
@@ -126,7 +128,7 @@ void lv_draw_ready_print() {
126 128
   ZERO(disp_state_stack._disp_state);
127 129
   scr = lv_screen_create(PRINT_READY_UI, "");
128 130
 
129
-  if (TERN0(SDSUPPORT, mks_test_flag == 0x1E)) {
131
+  if (mks_test_flag == 0x1E) {
130 132
     // Create image buttons
131 133
     buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL);
132 134
 
@@ -147,7 +149,7 @@ void lv_draw_ready_print() {
147 149
     #if HAS_MULTI_HOTEND
148 150
       e2 = lv_label_create_empty(scr);
149 151
       lv_obj_set_pos(e2, 20, 45);
150
-      sprintf_P(buf, PSTR("e1:  %d"), thermalManager.wholeDegHotend(1));
152
+      sprintf_P(buf, PSTR("e2:  %d"), thermalManager.wholeDegHotend(1));
151 153
       lv_label_set_text(e2, buf);
152 154
     #endif
153 155
     #if HAS_HEATED_BED

+ 2
- 2
Marlin/src/lcd/extui/mks_ui/draw_tool.cpp Переглянути файл

@@ -45,7 +45,7 @@ enum {
45 45
 };
46 46
 
47 47
 #if ENABLED(MKS_TEST)
48
-  extern uint8_t curent_disp_ui;
48
+  extern uint8_t current_disp_ui;
49 49
 #endif
50 50
 
51 51
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
@@ -75,7 +75,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
75 75
       lv_draw_more();
76 76
       break;
77 77
     case ID_T_RETURN:
78
-      TERN_(MKS_TEST, curent_disp_ui = 1);
78
+      TERN_(MKS_TEST, current_disp_ui = 1);
79 79
       lv_draw_ready_print();
80 80
       break;
81 81
   }

+ 5
- 1
Marlin/src/lcd/extui/mks_ui/draw_touch_calibration.cpp Переглянути файл

@@ -34,6 +34,10 @@
34 34
 static lv_obj_t *scr;
35 35
 static lv_obj_t *status_label;
36 36
 
37
+#if ENABLED(MKS_TEST)
38
+  extern uint8_t current_disp_ui;
39
+#endif
40
+
37 41
 static void event_handler(lv_obj_t *obj, lv_event_t event);
38 42
 
39 43
 enum {
@@ -93,7 +97,7 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
93 97
   if (event != LV_EVENT_RELEASED) return;
94 98
   switch (obj->mks_obj_id) {
95 99
     case ID_TC_RETURN:
96
-      TERN_(MKS_TEST, curent_disp_ui = 1);
100
+      TERN_(MKS_TEST, current_disp_ui = 1);
97 101
       lv_clear_touch_calibration_screen();
98 102
       draw_return_ui();
99 103
       break;

+ 144
- 44
Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp Переглянути файл

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

+ 2
- 0
Marlin/src/lcd/extui/mks_ui/mks_hardware.h Переглянути файл

@@ -31,6 +31,8 @@
31 31
   void mks_test_get();
32 32
   void mks_gpio_test();
33 33
   extern uint8_t mks_test_flag;
34
+#else
35
+  #define mks_test_flag 0
34 36
 #endif
35 37
 
36 38
 // String display and assets

+ 6
- 0
Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3.h Переглянути файл

@@ -220,6 +220,12 @@
220 220
   #define WIFI_RESET_PIN                    PE9   // MKS ESP WIFI RESET PIN
221 221
 #endif
222 222
 
223
+// MKS TEST
224
+#if ENABLED(MKS_TEST)
225
+  #define MKS_TEST_POWER_LOSS_PIN           PA13   // PW_DET
226
+  #define MKS_TEST_PS_ON_PIN                PB2    // PW_OFF
227
+#endif
228
+
223 229
 //
224 230
 // Onboard SD card
225 231
 //

+ 1
- 0
buildroot/tests/mks_robin_nano35 Переглянути файл

@@ -22,6 +22,7 @@ use_example_configs Mks/Robin
22 22
 opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
23 23
 opt_disable TFT_INTERFACE_FSMC
24 24
 opt_enable TFT_INTERFACE_SPI MKS_WIFI_MODULE
25
+opt_add MKS_TEST
25 26
 exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI, MKS_WIFI_MODULE" "$3"
26 27
 
27 28
 #

+ 1
- 0
buildroot/tests/mks_robin_nano35_maple Переглянути файл

@@ -32,6 +32,7 @@ use_example_configs Mks/Robin
32 32
 opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
33 33
 opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240 SERIAL_PORT_2
34 34
 opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320 MKS_WIFI_MODULE
35
+opt_add MKS_TEST
35 36
 exec_test $1 $2 "MKS Robin v2 nano LVGL SPI w/ WiFi" "$3"
36 37
 
37 38
 #

Завантаження…
Відмінити
Зберегти