Sfoglia il codice sorgente

MKS WiFi for TFT_LVGL_UI (#20191)

MKS-Sean 3 anni fa
parent
commit
35c1b330ec
Nessun account collegato all'indirizzo email del committer
36 ha cambiato i file con 1852 aggiunte e 1108 eliminazioni
  1. 4
    0
      Marlin/Configuration.h
  2. 205
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp
  3. 37
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h
  4. 24
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  5. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
  6. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp
  7. 209
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp
  8. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_more.h
  9. 46
    56
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  10. 98
    251
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  11. 15
    3
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  12. 29
    25
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp
  13. 4
    14
      Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp
  14. 34
    26
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
  15. 1
    1
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
  16. 5
    4
      Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp
  17. 9
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h
  18. 8
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h
  19. 8
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h
  20. 143
    34
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h
  21. 9
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h
  22. 10
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h
  23. 9
    0
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h
  24. 36
    26
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  25. 5
    1
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
  26. 286
    12
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp
  27. 19
    11
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h
  28. 20
    1
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp
  29. 2
    1
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h
  30. 316
    293
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
  31. 3
    8
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h
  32. 158
    278
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp
  33. 4
    3
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h
  34. 56
    54
      Marlin/src/libs/W25Qxx.cpp
  35. 2
    2
      Marlin/src/sd/SdBaseFile.cpp
  36. 1
    0
      platformio.ini

+ 4
- 0
Marlin/Configuration.h Vedi File

@@ -2395,6 +2395,10 @@
2395 2395
 //#define TFT_COLOR_UI
2396 2396
 //#define TFT_LVGL_UI
2397 2397
 
2398
+#if ENABLED(TFT_LVGL_UI)
2399
+  //#define MKS_WIFI_MODULE  // MKS WiFi module
2400
+#endif
2401
+
2398 2402
 /**
2399 2403
  * TFT Rotation. Set to one of the following values:
2400 2404
  *

+ 205
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.cpp Vedi File

@@ -0,0 +1,205 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/temperature.h"
31
+
32
+#include "QR_Encode.h"
33
+
34
+extern lv_group_t * g;
35
+static lv_obj_t * scr;
36
+static lv_obj_t *button_bind_or_not = NULL, *label_bind_or_not = NULL;
37
+static lv_obj_t *buttonReleaseBind = NULL, *label_ReleaseBind = NULL;
38
+static lv_obj_t * text_id;
39
+
40
+static uint8_t unbinding_flag = 0;
41
+static uint8_t id_mark        = 0;
42
+
43
+#define ID_CLOUD_BIND_RETURN  1
44
+#define ID_CLOUD_BIND_OR_NOT  2
45
+#define ID_CLOUD_RELEASE_BIND 3
46
+
47
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
48
+  if (event != LV_EVENT_RELEASED) return;
49
+  switch (obj->mks_obj_id) {
50
+    case ID_CLOUD_BIND_RETURN:
51
+      clear_cur_ui();
52
+      draw_return_ui();
53
+      break;
54
+    case ID_CLOUD_RELEASE_BIND:
55
+      if (cloud_para.state == 0x12) {
56
+        clear_cur_ui();
57
+        lv_draw_dialog(DIALOG_TYPE_UNBIND);
58
+      }
59
+      break;
60
+  }
61
+}
62
+
63
+void lv_draw_cloud_bind(void) {
64
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
65
+  scr = lv_screen_create(BIND_UI);
66
+
67
+  button_bind_or_not = lv_btn_create(scr, NULL);
68
+  lv_obj_set_pos(button_bind_or_not, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 3);
69
+  lv_obj_set_size(button_bind_or_not, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
70
+  lv_obj_set_event_cb_mks(button_bind_or_not, event_handler, ID_CLOUD_BIND_OR_NOT, NULL, 0);
71
+  lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_REL, &style_para_value);
72
+  lv_btn_set_style(button_bind_or_not, LV_BTN_STYLE_PR, &style_para_value);
73
+  label_bind_or_not = lv_label_create_empty(button_bind_or_not);
74
+
75
+  buttonReleaseBind = lv_btn_create(scr, NULL);
76
+  lv_obj_set_pos(buttonReleaseBind, TFT_WIDTH - 130, TFT_HEIGHT - 80 * 2);
77
+  lv_obj_set_size(buttonReleaseBind, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
78
+  lv_obj_set_event_cb_mks(buttonReleaseBind, event_handler, ID_CLOUD_RELEASE_BIND, NULL, 0);
79
+  label_ReleaseBind = lv_label_create_empty(buttonReleaseBind);
80
+  lv_label_set_text(label_ReleaseBind, cloud_menu.unbind);
81
+  lv_obj_align(label_ReleaseBind, buttonReleaseBind, LV_ALIGN_CENTER, 0, 0);
82
+
83
+  buttonBack = lv_btn_create(scr, NULL);
84
+  lv_obj_set_pos(buttonBack, TFT_WIDTH - 130, TFT_HEIGHT - 80);
85
+  lv_obj_set_size(buttonBack, PARA_UI_VALUE_BTN_X_SIZE + 15, PARA_UI_VALUE_BTN_Y_SIZE + 15);
86
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_CLOUD_BIND_RETURN, NULL, 0);
87
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
88
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
89
+  label_Back = lv_label_create_empty(buttonBack);
90
+  lv_label_set_text(label_Back, common_menu.text_back);
91
+  lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
92
+
93
+  #if BUTTONS_EXIST(EN1, EN2, ENC)
94
+    if (gCfgItems.encoder_enable) {
95
+      lv_group_add_obj(g, buttonReleaseBind);
96
+      lv_group_add_obj(g, buttonBack);
97
+    }
98
+  #endif
99
+
100
+  text_id = lv_label_create_empty(scr);
101
+  lv_obj_set_pos(text_id, 50, 60 + 200 + 20);
102
+  lv_obj_set_style(text_id, &tft_style_label_rel);
103
+  lv_label_set_text(text_id, (char *)cloud_para.id);
104
+
105
+  id_mark = 0;
106
+
107
+  disp_bind_state();
108
+}
109
+
110
+void disp_bind_state() {
111
+  if (cloud_para.state != 0x12)
112
+    unbinding_flag = 0;
113
+
114
+  if (unbinding_flag) {
115
+    lv_label_set_text(label_bind_or_not, cloud_menu.unbinding);
116
+    lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
117
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
118
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
119
+  }
120
+  else {
121
+    if (cloud_para.state == 0x10) {
122
+      lv_label_set_text(label_bind_or_not, cloud_menu.disconnected);
123
+      lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
124
+    }
125
+    else if (cloud_para.state == 0x11) {
126
+      lv_label_set_text(label_bind_or_not, cloud_menu.unbinded);
127
+      lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
128
+    }
129
+    else if (cloud_para.state == 0x12) {
130
+      lv_label_set_text(label_bind_or_not, cloud_menu.binded);
131
+      lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
132
+    }
133
+    else {
134
+      lv_label_set_text(label_bind_or_not, cloud_menu.disable);
135
+      lv_obj_align(label_bind_or_not, button_bind_or_not, LV_ALIGN_CENTER, 0, 0);
136
+    }
137
+  }
138
+
139
+  if (cloud_para.state == 0x12 && !unbinding_flag) {
140
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_back);
141
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_back);
142
+  }
143
+  else {
144
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_REL, &style_para_value);
145
+    lv_btn_set_style(buttonReleaseBind, LV_BTN_STYLE_PR, &style_para_value);
146
+  }
147
+}
148
+
149
+static char last_cloud_state = 0;
150
+void refresh_bind_ui() {
151
+  if ((last_cloud_state != cloud_para.state) || unbinding_flag) {
152
+    disp_bind_state();
153
+    last_cloud_state = cloud_para.state;
154
+  }
155
+  if (cloud_para.id[0]) {
156
+    if (!id_mark) {
157
+      display_qrcode((uint8_t *)cloud_para.id);
158
+      lv_label_set_text(text_id, (char *)cloud_para.id);
159
+    }
160
+  }
161
+  else
162
+    id_mark = 0;
163
+}
164
+
165
+void display_qrcode(uint8_t *qrcode_data) {
166
+  uint8_t i, j;
167
+  uint16_t x, y, p;
168
+
169
+  if (!id_mark) {
170
+    EncodeData((char *)qrcode_data);
171
+    id_mark = 1;
172
+  }
173
+
174
+  lv_fill_rect(10, QRCODE_Y, 300, QRCODE_Y + 300, LV_COLOR_WHITE);
175
+
176
+  if (m_nSymbleSize * 2 > QRCODE_WIDTH) return;
177
+
178
+  for (i = 0; i < 40; i++)
179
+    if ((m_nSymbleSize * i * 2) > QRCODE_WIDTH) break;
180
+
181
+  p = (i - 1) * 2;
182
+
183
+  x = QRCODE_X + 70;
184
+  y = QRCODE_Y + 70;
185
+
186
+  for (i = 0; i < m_nSymbleSize; i++)
187
+    for (j = 0; j < m_nSymbleSize; j++)
188
+      if (m_byModuleData[i][j] == 1)
189
+        lv_fill_rect(x + p * i, y + p * j, x + p * (i + 1) - 1, y + p * (j + 1) - 1, LV_COLOR_BACKGROUND);
190
+}
191
+
192
+void cloud_unbind() {
193
+  package_to_wifi(WIFI_CLOUD_UNBIND, (uint8_t *)0, 0);
194
+  unbinding_flag = 1;
195
+}
196
+
197
+void lv_clear_cloud_bind() {
198
+  #if BUTTONS_EXIST(EN1, EN2, ENC)
199
+    if (gCfgItems.encoder_enable)
200
+      lv_group_remove_all_objs(g);
201
+  #endif
202
+  lv_obj_del(scr);
203
+}
204
+
205
+#endif // HAS_TFT_LVGL_UI

+ 37
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_cloud_bind.h Vedi File

@@ -0,0 +1,37 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+extern void lv_draw_cloud_bind(void);
29
+extern void lv_clear_cloud_bind();
30
+extern void disp_bind_state();
31
+extern void refresh_bind_ui();
32
+extern void display_qrcode(uint8_t *qrcode_data);
33
+extern void cloud_unbind();
34
+
35
+#ifdef __cplusplus
36
+} /* C-declarations for C++ */
37
+#endif

+ 24
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp Vedi File

@@ -172,6 +172,17 @@ static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
172 172
     clear_cur_ui();
173 173
     draw_return_ui();
174 174
   }
175
+  #if ENABLED(MKS_WIFI_MODULE)
176
+    else if (DIALOG_IS(TYPE_UNBIND)) {
177
+      cloud_unbind();
178
+      clear_cur_ui();
179
+      draw_return_ui();
180
+    }
181
+  #endif
182
+  else {
183
+    clear_cur_ui();
184
+    draw_return_ui();
185
+  }
175 186
 }
176 187
 
177 188
 static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
@@ -246,6 +257,9 @@ void lv_draw_dialog(uint8_t type) {
246 257
         lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
247 258
       }
248 259
     }
260
+    else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMARE)) {
261
+      // nothing to do
262
+    }
249 263
   #endif
250 264
   else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
251 265
     btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
@@ -412,6 +426,10 @@ void lv_draw_dialog(uint8_t type) {
412 426
         lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
413 427
       }
414 428
     }
429
+    else if (DIALOG_IS(TYPE_UPDATE_ESP_FIRMARE)) {
430
+      lv_label_set_text(labelDialog, DIALOG_UPDATE_WIFI_FIRMWARE_EN);
431
+      lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
432
+    }
415 433
   #endif // MKS_WIFI_MODULE
416 434
   else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) {
417 435
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
@@ -445,6 +463,12 @@ void lv_draw_dialog(uint8_t type) {
445 463
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
446 464
     lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
447 465
   }
466
+  #if ENABLED(MKS_WIFI_MODULE)
467
+    else if (DIALOG_IS(TYPE_UNBIND)) {
468
+      lv_label_set_text(labelDialog, common_menu.unbind_printer_tips);
469
+      lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
470
+    }
471
+  #endif
448 472
   #if HAS_ROTARY_ENCODER
449 473
     if (gCfgItems.encoder_enable) {
450 474
       if (btnOk) lv_group_add_obj(g, btnOk);

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp Vedi File

@@ -66,8 +66,8 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
66 66
       queue.inject_P(PSTR("M84 X Y"));
67 67
       break;
68 68
     case ID_H_RETURN:
69
-      lv_clear_home();
70
-      lv_draw_tool();
69
+      clear_cur_ui();
70
+      draw_return_ui();
71 71
       break;
72 72
   }
73 73
 }

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp Vedi File

@@ -55,13 +55,13 @@ static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
55 55
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
56 56
     LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
57 57
 
58
-static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
58
+static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", ".", LV_SYMBOL_BACKSPACE, "\n",
59 59
                                      "abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
60 60
                                      "\\",  "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
61 61
                                      LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
62 62
 
63 63
 static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
64
-    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
64
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
65 65
     LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
66 66
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
67 67
     LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};

+ 209
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_more.cpp Vedi File

@@ -0,0 +1,209 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "../../../../MarlinCore.h"
27
+#include "draw_ready_print.h"
28
+#include "draw_set.h"
29
+#include "lv_conf.h"
30
+#include "draw_ui.h"
31
+#include "../../../../gcode/queue.h"
32
+
33
+extern lv_group_t * g;
34
+static lv_obj_t * scr;
35
+
36
+#define ID_CUSTOM_1   1
37
+#define ID_CUSTOM_2   2
38
+#define ID_CUSTOM_3   3
39
+#define ID_CUSTOM_4   4
40
+#define ID_CUSTOM_5   5
41
+#define ID_CUSTOM_6   6
42
+#define ID_CUSTOM_7   7
43
+#define ID_M_RETURN   8
44
+
45
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
46
+  if (event != LV_EVENT_RELEASED) return;
47
+  switch (obj->mks_obj_id) {
48
+    #if ENABLED(USER_CMD_1_ENABLE)
49
+      case ID_CUSTOM_1:
50
+        queue.inject_P(PSTR(USER_GCODE_1));
51
+        break;
52
+    #endif
53
+    #if ENABLED(USER_CMD_2_ENABLE)
54
+      case ID_CUSTOM_2:
55
+        queue.inject_P(PSTR(USER_GCODE_2));
56
+        break;
57
+    #endif
58
+    #if ENABLED(USER_CMD_3_ENABLE)
59
+      case ID_CUSTOM_3:
60
+        queue.inject_P(PSTR(USER_GCODE_3));
61
+        break;
62
+    #endif
63
+    #if ENABLED(USER_CMD_4_ENABLE)
64
+      case ID_CUSTOM_4:
65
+        queue.inject_P(PSTR(USER_GCODE_4));
66
+        break;
67
+    #endif
68
+    #if ENABLED(USER_CMD_5_ENABLE)
69
+      case ID_CUSTOM_5:
70
+        queue.inject_P(PSTR(USER_GCODE_5));
71
+        break;
72
+    #endif
73
+    #if ENABLED(USER_CMD_6_ENABLE)
74
+      case ID_CUSTOM_6:
75
+        queue.inject_P(PSTR(USER_GCODE_6));
76
+        break;
77
+    #endif
78
+    #if ENABLED(USER_CMD_7_ENABLE)
79
+      case ID_CUSTOM_7:
80
+        queue.inject_P(PSTR(USER_GCODE_7));
81
+        break;
82
+    #endif
83
+    case ID_M_RETURN:
84
+      lv_clear_more();
85
+      lv_draw_tool();
86
+      break;
87
+  }
88
+}
89
+
90
+void lv_draw_more(void) {
91
+  scr = lv_screen_create(MORE_UI);
92
+
93
+  const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
94
+
95
+  #if ENABLED(USER_CMD_1_ENABLE)
96
+    lv_obj_t *buttonCustom1 = lv_imgbtn_create(scr, "F:/bmp_custom1.bin", INTERVAL_V, titleHeight, event_handler, ID_CUSTOM_1);
97
+    if (enc_ena) lv_group_add_obj(g, buttonCustom1);
98
+    lv_obj_t *labelCustom1 = lv_label_create_empty(buttonCustom1);
99
+  #endif
100
+
101
+  #if ENABLED(USER_CMD_2_ENABLE)
102
+    lv_obj_t *buttonCustom2 = lv_imgbtn_create(scr, "F:/bmp_custom2.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_CUSTOM_2);
103
+    if (enc_ena) lv_group_add_obj(g, buttonCustom2);
104
+    lv_obj_t *labelCustom2 = lv_label_create_empty(buttonCustom2);
105
+  #endif
106
+
107
+  #if ENABLED(USER_CMD_3_ENABLE)
108
+    lv_obj_t *buttonCustom3 = lv_imgbtn_create(scr, "F:/bmp_custom3.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_CUSTOM_3);
109
+    if (enc_ena) lv_group_add_obj(g, buttonCustom3);
110
+    lv_obj_t *labelCustom3 = lv_label_create_empty(buttonCustom3);
111
+  #endif
112
+
113
+  #if ENABLED(USER_CMD_4_ENABLE)
114
+    lv_obj_t *buttonCustom4 = lv_imgbtn_create(scr, "F:/bmp_custom4.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_CUSTOM_4);
115
+    if (enc_ena) lv_group_add_obj(g, buttonCustom4);
116
+    lv_obj_t *labelCustom4 = lv_label_create_empty(buttonCustom4);
117
+  #endif
118
+
119
+  #if ENABLED(USER_CMD_5_ENABLE)
120
+    lv_obj_t *buttonCustom5 = lv_imgbtn_create(scr, "F:/bmp_custom5.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_5);
121
+    if (enc_ena) lv_group_add_obj(g, buttonCustom5);
122
+    lv_obj_t *labelCustom5 = lv_label_create_empty(buttonCustom5);
123
+  #endif
124
+
125
+  #if ENABLED(USER_CMD_6_ENABLE)
126
+    lv_obj_t *buttonCustom6 = lv_imgbtn_create(scr, "F:/bmp_custom6.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_6);
127
+    if (enc_ena) lv_group_add_obj(g, buttonCustom6);
128
+    lv_obj_t *labelCustom6 = lv_label_create_empty(buttonCustom6);
129
+  #endif
130
+
131
+  #if ENABLED(USER_CMD_7_ENABLE)
132
+    blv_obj_t *uttonCustom7 = lv_imgbtn_create(scr, "F:/bmp_custom7.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_CUSTOM_7);
133
+    if (enc_ena) lv_group_add_obj(g, buttonCustom7);
134
+    lv_obj_t *labelCustom7 = lv_label_create_empty(buttonCustom7);
135
+  #endif
136
+
137
+  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
138
+  if (enc_ena) lv_group_add_obj(g, buttonBack);
139
+  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
140
+
141
+  if (gCfgItems.multiple_language != 0) {
142
+    #if ENABLED(USER_CMD_1_ENABLE)
143
+      lv_label_set_text(labelCustom1, more_menu.custom1);
144
+      lv_obj_align(labelCustom1, buttonCustom1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
145
+    #endif
146
+    #if ENABLED(USER_CMD_2_ENABLE)
147
+      lv_label_set_text(labelCustom2, more_menu.custom2);
148
+      lv_obj_align(labelCustom2, buttonCustom2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
149
+    #endif
150
+    #if ENABLED(USER_CMD_3_ENABLE)
151
+      lv_label_set_text(labelCustom3, more_menu.custom3);
152
+      lv_obj_align(labelCustom3, buttonCustom3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
153
+    #endif
154
+    #if ENABLED(USER_CMD_4_ENABLE)
155
+      lv_label_set_text(labelCustom4, more_menu.custom4);
156
+      lv_obj_align(labelCustom4, buttonCustom4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
157
+    #endif
158
+    #if ENABLED(USER_CMD_5_ENABLE)
159
+      lv_label_set_text(labelCustom5, more_menu.custom5);
160
+      lv_obj_align(labelCustom5, buttonCustom5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
161
+    #endif
162
+    #if ENABLED(USER_CMD_6_ENABLE)
163
+      lv_label_set_text(labelCustom6, more_menu.custom6);
164
+      lv_obj_align(labelCustom6, buttonCustom6, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
165
+    #endif
166
+    #if ENABLED(USER_CMD_7_ENABLE)
167
+      lv_label_set_text(labelCustom7, more_menu.custom7);
168
+      lv_obj_align(labelCustom7, buttonCustom7, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
169
+    #endif
170
+    lv_label_set_text(label_Back, common_menu.text_back);
171
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
172
+  }
173
+
174
+  #if BUTTONS_EXIST(EN1, EN2, ENC)
175
+    if (enc_ena) {
176
+      #if ENABLED(USER_CMD_1_ENABLE)
177
+        lv_group_add_obj(g, buttonCustom1);
178
+      #endif
179
+      #if ENABLED(USER_CMD_2_ENABLE)
180
+        lv_group_add_obj(g, buttonCustom2);
181
+      #endif
182
+      #if ENABLED(USER_CMD_3_ENABLE)
183
+        lv_group_add_obj(g, buttonCustom3);
184
+      #endif
185
+      #if ENABLED(USER_CMD_4_ENABLE)
186
+        lv_group_add_obj(g, buttonCustom4);
187
+      #endif
188
+      #if ENABLED(USER_CMD_5_ENABLE)
189
+        lv_group_add_obj(g, buttonCustom5);
190
+      #endif
191
+      #if ENABLED(USER_CMD_6_ENABLE)
192
+        lv_group_add_obj(g, buttonCustom6);
193
+      #endif
194
+      #if ENABLED(USER_CMD_7_ENABLE)
195
+        lv_group_add_obj(g, buttonCustom7);
196
+      #endif
197
+      lv_group_add_obj(g, buttonBack);
198
+    }
199
+  #endif
200
+}
201
+
202
+void lv_clear_more() {
203
+  #if BUTTONS_EXIST(EN1, EN2, ENC)
204
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
205
+  #endif
206
+  lv_obj_del(scr);
207
+}
208
+
209
+#endif // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_more.h Vedi File

@@ -0,0 +1,33 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+extern void lv_draw_more(void);
29
+extern void lv_clear_more();
30
+
31
+#ifdef __cplusplus
32
+} /* C-declarations for C++ */
33
+#endif

+ 46
- 56
Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp Vedi File

@@ -27,12 +27,18 @@
27 27
 #include <lv_conf.h>
28 28
 
29 29
 #include "../../../../gcode/queue.h"
30
+#include "../../../../module/motion.h"
30 31
 #include "../../../../inc/MarlinConfig.h"
31 32
 
32 33
 extern lv_group_t *g;
33 34
 static lv_obj_t *scr;
34 35
 
35
-static lv_obj_t *labelV, *buttonV;
36
+static lv_obj_t *labelV, *buttonV, *labelP;
37
+static lv_task_t *updatePosTask;
38
+static char cur_label = 'Z'; 
39
+static float cur_pos = 0;
40
+
41
+void disp_cur_pos();
36 42
 
37 43
 enum {
38 44
   ID_M_X_P = 1,
@@ -47,67 +53,41 @@ enum {
47 53
 
48 54
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
49 55
   if (event != LV_EVENT_RELEASED) return;
56
+  if (queue.length <= (BUFSIZE - 3)) {
57
+    float dist = uiCfg.move_dist;
58
+    switch (obj->mks_obj_id) {
59
+      case ID_M_X_N: dist *= -1; case ID_M_X_P: cur_label = 'X'; break;
60
+      case ID_M_Y_N: dist *= -1; case ID_M_Y_P: cur_label = 'Y'; break;
61
+      case ID_M_Z_N: dist *= -1; case ID_M_Z_P: cur_label = 'Z'; break;
62
+    }
63
+    sprintf_P(public_buf_l, PSTR("G91\nG1 %c%3.1f F%d\nG90"), cur_label, dist, uiCfg.moveSpeed);
64
+    queue.inject(public_buf_l);
65
+  }
66
+
50 67
   switch (obj->mks_obj_id) {
51
-    case ID_M_X_P:
52
-      if (queue.length <= (BUFSIZE - 3)) {
53
-        queue.enqueue_one_P(PSTR("G91"));
54
-        sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
55
-        queue.enqueue_one_now(public_buf_l);
56
-        queue.enqueue_one_P(PSTR("G90"));
57
-      }
58
-      break;
59
-    case ID_M_X_N:
60
-      if (queue.length <= (BUFSIZE - 3)) {
61
-        queue.enqueue_now_P(PSTR("G91"));
62
-        sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
63
-        queue.enqueue_one_now(public_buf_l);
64
-        queue.enqueue_now_P(PSTR("G90"));
65
-      }
66
-      break;
67
-    case ID_M_Y_P:
68
-      if (queue.length <= (BUFSIZE - 3)) {
69
-        queue.enqueue_now_P(PSTR("G91"));
70
-        sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
71
-        queue.enqueue_one_now(public_buf_l);
72
-        queue.enqueue_now_P(PSTR("G90"));
73
-      }
74
-      break;
75
-    case ID_M_Y_N:
76
-      if (queue.length <= (BUFSIZE - 3)) {
77
-        queue.enqueue_now_P(PSTR("G91"));
78
-        sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
79
-        queue.enqueue_one_now(public_buf_l);
80
-        queue.enqueue_now_P(PSTR("G90"));
81
-      }
82
-      break;
83
-    case ID_M_Z_P:
84
-      if (queue.length <= (BUFSIZE - 3)) {
85
-        queue.enqueue_now_P(PSTR("G91"));
86
-        sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
87
-        queue.enqueue_one_now(public_buf_l);
88
-        queue.enqueue_now_P(PSTR("G90"));
89
-      }
90
-      break;
91
-    case ID_M_Z_N:
92
-      if (queue.length <= (BUFSIZE - 3)) {
93
-        queue.enqueue_now_P(PSTR("G91"));
94
-        sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
95
-        queue.enqueue_one_now(public_buf_l);
96
-        queue.enqueue_now_P(PSTR("G90"));
97
-      }
98
-      break;
99 68
     case ID_M_STEP:
100 69
       if (abs(10 * (int)uiCfg.move_dist) == 100)
101 70
         uiCfg.move_dist = 0.1;
102 71
       else
103
-        uiCfg.move_dist *= (float)10;
72
+        uiCfg.move_dist *= 10.0f;
104 73
       disp_move_dist();
105 74
       break;
106 75
     case ID_M_RETURN:
107 76
       clear_cur_ui();
108 77
       draw_return_ui();
109
-      break;
78
+      return;
110 79
   }
80
+  disp_cur_pos();
81
+}
82
+
83
+void refresh_pos(lv_task_t *) {
84
+  switch (cur_label) {
85
+    case 'X': cur_pos = current_position.x; break;
86
+    case 'Y': cur_pos = current_position.y; break;
87
+    case 'Z': cur_pos = current_position.z; break;
88
+    default: return;
89
+  }
90
+  disp_cur_pos();
111 91
 }
112 92
 
113 93
 void lv_draw_move_motor(void) {
@@ -124,19 +104,28 @@ void lv_draw_move_motor(void) {
124 104
   buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
125 105
   labelV = lv_label_create_empty(buttonV);
126 106
   #if HAS_ROTARY_ENCODER
127
-    if (gCfgItems.encoder_enable) {
128
-      lv_group_add_obj(g, buttonV);
129
-    }
107
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonV);
130 108
   #endif
131 109
 
132 110
   lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
133 111
 
112
+  // We need to patch the title to leave some space on the right for displaying the status
113
+  lv_obj_t * title = lv_obj_get_child_back(scr, NULL);
114
+  if (title != NULL) lv_obj_set_width(title, TFT_WIDTH - 101);
115
+  labelP = lv_label_create(scr, TFT_WIDTH - 100, TITLE_YPOS, "Z:0.0mm");
116
+  if (labelP != NULL)
117
+    updatePosTask = lv_task_create(refresh_pos, 300, LV_TASK_PRIO_LOWEST, 0);
118
+
134 119
   disp_move_dist();
120
+  disp_cur_pos();
135 121
 }
136 122
 
137
-void disp_move_dist() {
138
-  // char buf[30] = {0};
123
+void disp_cur_pos() {
124
+  sprintf_P(public_buf_l, PSTR("%c:%3.1fmm"), cur_label, cur_pos);
125
+  if (labelP) lv_label_set_text(labelP, public_buf_l);
126
+}
139 127
 
128
+void disp_move_dist() {
140 129
   if ((int)(10 * uiCfg.move_dist) == 1)
141 130
     lv_imgbtn_set_src_both(buttonV, "F:/bmp_step_move0_1.bin");
142 131
   else if ((int)(10 * uiCfg.move_dist) == 10)
@@ -164,6 +153,7 @@ void lv_clear_move_motor() {
164 153
   #if HAS_ROTARY_ENCODER
165 154
     if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
166 155
   #endif
156
+  lv_task_del(updatePosTask);
167 157
   lv_obj_del(scr);
168 158
 }
169 159
 

+ 98
- 251
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp Vedi File

@@ -138,12 +138,10 @@ void gCfgItems_init() {
138 138
   gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30;
139 139
   gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2;
140 140
   gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2;
141
-  gCfgItems.cloud_enable  = true;
142
-  #if ENABLED(MKS_WIFI_MODULE)
143
-    gCfgItems.wifi_mode_sel = STA_MODEL;
144
-    gCfgItems.fileSysType   = FILE_SYS_SD;
145
-    gCfgItems.wifi_type     = ESP_WIFI;
146
-  #endif
141
+  gCfgItems.cloud_enable      = false;
142
+  gCfgItems.wifi_mode_sel = STA_MODEL;
143
+  gCfgItems.fileSysType   = FILE_SYS_SD;
144
+  gCfgItems.wifi_type     = ESP_WIFI;
147 145
   gCfgItems.filamentchange_load_length   = 200;
148 146
   gCfgItems.filamentchange_load_speed    = 1000;
149 147
   gCfgItems.filamentchange_unload_length = 200;
@@ -449,6 +447,7 @@ void titleText_cat(char *str, int strSize, char *addPart) {
449 447
 
450 448
 char *getDispText(int index) {
451 449
 
450
+  ZERO(public_buf_l);
452 451
 
453 452
   switch (disp_state_stack._disp_state[index]) {
454 453
     case PRINT_READY_UI:
@@ -593,7 +592,9 @@ char *creat_title_text() {
593 592
 
594 593
   if (strlen(public_buf_m) > MAX_TITLE_LEN) {
595 594
     ZERO(public_buf_m);
596
-    tmpText = getDispText(0);
595
+    tmpText = 0;
596
+    for (index = 0; index <= disp_state_stack._disp_index && (!tmpText || *tmpText == 0); index++)
597
+      tmpText = getDispText(index);
597 598
     if (*tmpText != 0) {
598 599
       titleText_cat(public_buf_m, sizeof(public_buf_m), tmpText);
599 600
       titleText_cat(public_buf_m, sizeof(public_buf_m), (char *)">...>");
@@ -639,253 +640,97 @@ char *creat_title_text() {
639 640
     #endif
640 641
   }
641 642
 
642
-  #if 1
643
-
644
-    void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
645
-      #if ENABLED(SDSUPPORT)
646
-        //uint8_t ress;
647
-        //uint32_t write;
648
-        volatile uint32_t i, j;
649
-        volatile uint16_t *p_index;
650
-        //int res;
651
-        char *cur_name;
652
-
653
-        cur_name = strrchr(path, '/');
654
-        card.openFileRead(cur_name);
655
-
656
-        if (gPicturePreviewStart <= 0) {
657
-          while (1) {
658
-            uint32_t br  = card.read(public_buf, 400);
659
-            uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
660
-            if (p1) {
661
-              gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
662
-              break;
663
-            }
664
-            else {
665
-              gPicturePreviewStart += br;
666
-            }
667
-            if (br < 400) break;
668
-          }
669
-        }
670
-
671
-        card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
672
-        SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
643
+  void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
644
+    #if ENABLED(SDSUPPORT)
645
+      volatile uint32_t i, j;
646
+      volatile uint16_t *p_index;
647
+      char *cur_name;
673 648
 
674
-        j = i = 0;
649
+      cur_name = strrchr(path, '/');
650
+      card.openFileRead(cur_name);
675 651
 
652
+      if (gPicturePreviewStart <= 0) {
676 653
         while (1) {
677
-          card.read(public_buf, 400);
678
-          for (i = 0; i < 400;) {
679
-            bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
680
-            i                += 2;
681
-            j++;
682
-          }
683
-          if (j >= 400) break;
684
-        }
685
-        for (i = 0; i < 400; i += 2) {
686
-          p_index  = (uint16_t *)(&bmp_public_buf[i]);
687
-          if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
688
-        }
689
-        SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
690
-        #if HAS_BAK_VIEW_IN_FLASH
691
-          W25QXX.init(SPI_QUARTER_SPEED);
692
-          if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
693
-          W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
694
-        #endif
695
-        row++;
696
-        if (row >= 200) {
697
-          size = 809;
698
-          row  = 0;
699
-
700
-          gcode_preview_over = false;
701
-          //flash_preview_begin = true;
702
-
703
-          card.closefile();
704
-
705
-          /*
706
-          if (gCurFileState.file_open_flag != 0xAA) {
707
-            reset_file_info();
708
-            res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
709
-            if (res == FR_OK) {
710
-              f_lseek(file,PREVIEW_SIZE+To_pre_view);
711
-              gCurFileState.file_open_flag = 0xAA;
712
-              //bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
713
-              srcfp = file;
714
-              mksReprint.mks_printer_state = MKS_WORKING;
715
-              once_flag = false;
716
-            }
717
-          }
718
-          */
719
-          char *cur_name;
720
-
721
-          cur_name = strrchr(list_file.file_name[sel_id], '/');
722
-
723
-          SdFile file;
724
-          SdFile *curDir;
725
-          card.endFilePrint();
726
-          const char * const fname = card.diveToFile(true, curDir, cur_name);
727
-          if (!fname) return;
728
-          if (file.open(curDir, fname, O_READ)) {
729
-            gCfgItems.curFilesize = file.fileSize();
730
-            file.close();
731
-            update_spi_flash();
654
+          uint32_t br  = card.read(public_buf, 400);
655
+          uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
656
+          if (p1) {
657
+            gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
658
+            break;
732 659
           }
733
-
734
-          card.openFileRead(cur_name);
735
-          if (card.isFileOpen()) {
736
-            feedrate_percentage = 100;
737
-            //saved_feedrate_percentage = feedrate_percentage;
738
-            planner.flow_percentage[0] = 100;
739
-            planner.e_factor[0]        = planner.flow_percentage[0] * 0.01;
740
-            #if HAS_MULTI_EXTRUDER
741
-              planner.flow_percentage[1] = 100;
742
-              planner.e_factor[1]        = planner.flow_percentage[1] * 0.01;
743
-            #endif
744
-            card.startFileprint();
745
-            TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
746
-            once_flag = false;
660
+          else {
661
+            gPicturePreviewStart += br;
747 662
           }
748
-          return;
663
+          if (br < 400) break;
749 664
         }
750
-        card.closefile();
751
-      #endif // SDSUPPORT
752
-    }
753
-
754
-  #else // if 1
755
-
756
-    void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
757
-      #if ENABLED(SDSUPPORT)
758
-        //uint8_t ress;
759
-        //uint32_t write;
760
-        volatile uint32_t i, j;
761
-        volatile uint16_t *p_index;
762
-        //int res;
763
-        char *cur_name;
764
-        uint16_t Color;
765
-
766
-        cur_name = strrchr(path, '/');
767
-        card.openFileRead(cur_name);
768
-
769
-        card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
770
-        #if HAS_TFT_LVGL_UI_SPI
771
-          SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
772
-        #else
773
-          LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
774
-          LCD_WriteRAM_Prepare();
775
-        #endif
776
-
777
-        j = 0;
778
-        i = 0;
665
+      }
779 666
 
780
-        while (1) {
781
-          card.read(public_buf, 400);
782
-          for (i = 0; i < 400;) {
783
-            bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
784
-            i += 2;
785
-            j++;
786
-          }
667
+      card.setIndex(gPicturePreviewStart + size * row + 8);
668
+      SPI_TFT.setWindow(xpos_pixel, ypos_pixel + row, 200, 1);
787 669
 
788
-          //if (i > 800) break;
789
-          //#ifdef TFT70
790
-          //  if (j > 400) {
791
-          //    f_read(file, buff_pic, 1, &read);
792
-          //    break;
793
-          //  }
794
-          //#elif defined(TFT35)
795
-          if (j >= 400)
796
-            //f_read(file, buff_pic, 1, &read);
797
-            break;
798
-          //#endif
670
+      j = i = 0;
799 671
 
672
+      while (1) {
673
+        card.read(public_buf, 400);
674
+        for (i = 0; i < 400;) {
675
+          bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
676
+          i                += 2;
677
+          j++;
800 678
         }
801
-        #if HAS_TFT_LVGL_UI_SPI
802
-          for (i = 0; i < 400;) {
803
-            p_index = (uint16_t *)(&bmp_public_buf[i]);
804
-
805
-            Color    = (*p_index >> 8);
806
-            *p_index = Color | ((*p_index & 0xFF) << 8);
807
-            i       += 2;
808
-            if (*p_index == 0x0000) *p_index = 0xC318;
809
-          }
810
-          TFT_CS_L;
811
-          TFT_DC_H;
812
-          SPI.dmaSend(bmp_public_buf, 400, true);
813
-          TFT_CS_H;
814
-
815
-        #else
816
-          for (i = 0; i < 400;) {
817
-            p_index = (uint16_t *)(&bmp_public_buf[i]);
818
-            if (*p_index == 0x0000) *p_index = 0x18C3;
819
-            LCD_IO_WriteData(*p_index);
820
-            i = i + 2;
821
-          }
822
-        #endif
679
+        if (j >= 400) break;
680
+      }
681
+      for (i = 0; i < 400; i += 2) {
682
+        p_index  = (uint16_t *)(&bmp_public_buf[i]);
683
+        if (*p_index == 0x0000) *p_index = LV_COLOR_BACKGROUND.full;
684
+      }
685
+      SPI_TFT.tftio.WriteSequence((uint16_t*)bmp_public_buf, 200);
686
+      #if HAS_BAK_VIEW_IN_FLASH
823 687
         W25QXX.init(SPI_QUARTER_SPEED);
824
-        if (row < 20)
825
-          W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
688
+        if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
826 689
         W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
827
-        row++;
828
-        if (row >= 200) {
829
-          size = 809;
830
-          row  = 0;
831
-
832
-          gcode_preview_over = false;
833
-          //flash_preview_begin = true;
834
-
835
-          card.closefile();
836
-
837
-          /*
838
-          if (gCurFileState.file_open_flag != 0xAA) {
839
-            reset_file_info();
840
-            res = f_open(file, curFileName, FA_OPEN_EXISTING | FA_READ);
841
-            if (res == FR_OK) {
842
-              f_lseek(file,PREVIEW_SIZE+To_pre_view);
843
-              gCurFileState.file_open_flag = 0xAA;
844
-              //bakup_file_path((uint8_t *)curFileName, strlen(curFileName));
845
-              srcfp = file;
846
-              mksReprint.mks_printer_state = MKS_WORKING;
847
-              once_flag = false;
848
-            }
849
-          }
850
-          */
851
-          char *cur_name;
852
-
853
-          cur_name = strrchr(list_file.file_name[sel_id], '/');
854
-
855
-          SdFile file;
856
-          SdFile *curDir;
857
-          card.endFilePrint();
858
-          const char * const fname = card.diveToFile(true, curDir, cur_name);
859
-          if (!fname) return;
860
-          if (file.open(curDir, fname, O_READ)) {
861
-            gCfgItems.curFilesize = file.fileSize();
862
-            file.close();
863
-            update_spi_flash();
864
-          }
690
+      #endif
691
+      row++;
692
+      if (row >= 200) {
693
+        size = 809;
694
+        row  = 0;
695
+
696
+        gcode_preview_over = false;
865 697
 
866
-          card.openFileRead(cur_name);
867
-          if (card.isFileOpen()) {
868
-            feedrate_percentage = 100;
869
-            //saved_feedrate_percentage = feedrate_percentage;
870
-            planner.flow_percentage[0] = 100;
871
-            planner.e_factor[0]        = planner.flow_percentage[0] * 0.01;
872
-            #if HAS_MULTI_EXTRUDER
873
-              planner.flow_percentage[1] = 100;
874
-              planner.e_factor[1]        = planner.flow_percentage[1] * 0.01;
875
-            #endif
876
-            card.startFileprint();
877
-            TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
878
-            once_flag = false;
879
-          }
880
-          return;
881
-        }
882 698
         card.closefile();
883
-      #endif // SDSUPPORT
884
-    }
699
+        char *cur_name;
885 700
 
886
-  #endif // if 1
701
+        cur_name = strrchr(list_file.file_name[sel_id], '/');
702
+
703
+        SdFile file;
704
+        SdFile *curDir;
705
+        card.endFilePrint();
706
+        const char * const fname = card.diveToFile(true, curDir, cur_name);
707
+        if (!fname) return;
708
+        if (file.open(curDir, fname, O_READ)) {
709
+          gCfgItems.curFilesize = file.fileSize();
710
+          file.close();
711
+          update_spi_flash();
712
+        }
887 713
 
888
-  void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
714
+        card.openFileRead(cur_name);
715
+        if (card.isFileOpen()) {
716
+          feedrate_percentage = 100;
717
+          planner.flow_percentage[0] = 100;
718
+          planner.e_factor[0]        = planner.flow_percentage[0] * 0.01;
719
+          #if HAS_MULTI_EXTRUDER
720
+            planner.flow_percentage[1] = 100;
721
+            planner.e_factor[1]        = planner.flow_percentage[1] * 0.01;
722
+          #endif
723
+          card.startFileprint();
724
+          TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
725
+          once_flag = false;
726
+        }
727
+        return;
728
+      }
729
+      card.closefile();
730
+    #endif // SDSUPPORT
731
+  }
732
+
733
+  void draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
889 734
     int index;
890 735
     int y_off = 0;
891 736
     W25QXX.init(SPI_QUARTER_SPEED);
@@ -914,12 +759,12 @@ char *creat_title_text() {
914 759
     #if HAS_BAK_VIEW_IN_FLASH
915 760
       if (flash_preview_begin) {
916 761
         flash_preview_begin = false;
917
-        Draw_default_preview(xpos_pixel, ypos_pixel, 1);
762
+        draw_default_preview(xpos_pixel, ypos_pixel, 1);
918 763
       }
919 764
     #endif
920 765
     #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
921 766
       if (default_preview_flg) {
922
-        Draw_default_preview(xpos_pixel, ypos_pixel, 0);
767
+        draw_default_preview(xpos_pixel, ypos_pixel, 0);
923 768
         default_preview_flg = false;
924 769
       }
925 770
     #endif
@@ -1005,12 +850,11 @@ void GUI_RefreshPage() {
1005 850
           temps_update_flag = false;
1006 851
         }
1007 852
         break;
1008
-    #endif
1009
-
1010
-    case BIND_UI:
1011
-      /*refresh_bind_ui();*/
1012
-      break;
1013 853
 
854
+      case BIND_UI:
855
+        refresh_bind_ui();
856
+        break;
857
+    #endif
1014 858
     case FILAMENTCHANGE_UI:
1015 859
       if (temps_update_flag) {
1016 860
         temps_update_flag = false;
@@ -1097,8 +941,7 @@ void clear_cur_ui() {
1097 941
   last_disp_state = disp_state_stack._disp_state[disp_state_stack._disp_index];
1098 942
 
1099 943
   switch (disp_state_stack._disp_state[disp_state_stack._disp_index]) {
1100
-    case PRINT_READY_UI:
1101
-                                      lv_clear_ready_print(); break;
944
+    case PRINT_READY_UI:              lv_clear_ready_print(); break;
1102 945
     case PRINT_FILE_UI:               lv_clear_print_file(); break;
1103 946
     case PRINTING_UI:                 lv_clear_printing(); break;
1104 947
     case MOVE_MOTOR_UI:               lv_clear_move_motor(); break;
@@ -1119,14 +962,16 @@ void clear_cur_ui() {
1119 962
     #if ENABLED(MKS_WIFI_MODULE)
1120 963
       case WIFI_UI:                   lv_clear_wifi(); break;
1121 964
     #endif
1122
-    case MORE_UI:                     /* Clear_more(); */ break;
965
+    case MORE_UI:                     lv_clear_more(); break;
1123 966
     case FILETRANSFER_UI:             break;
1124 967
     case DIALOG_UI:                   lv_clear_dialog(); break;
1125 968
     case FILETRANSFERSTATE_UI:        break;
1126 969
     case PRINT_MORE_UI:               break;
1127 970
     case FILAMENTCHANGE_UI:           lv_clear_filament_change(); break;
1128 971
     case LEVELING_UI:                 lv_clear_manualLevel(); break;
1129
-    case BIND_UI:                     /* Clear_Bind(); */ break;
972
+    #if ENABLED(MKS_WIFI_MODULE)
973
+      case BIND_UI:                   lv_clear_cloud_bind(); break;
974
+    #endif
1130 975
     #if HAS_BED_PROBE
1131 976
       case NOZZLE_PROBE_OFFSET_UI:    lv_clear_auto_level_offset_settings(); break;
1132 977
     #endif
@@ -1224,11 +1069,13 @@ void draw_return_ui() {
1224 1069
       #if ENABLED(MKS_WIFI_MODULE)
1225 1070
         case WIFI_UI:                   lv_draw_wifi(); break;
1226 1071
       #endif
1227
-      case PRINT_MORE_UI:               /* draw_printmore(); */ break;
1228 1072
       case MORE_UI:                     break;
1073
+      case PRINT_MORE_UI:               lv_draw_more(); break;
1229 1074
       case FILAMENTCHANGE_UI:           lv_draw_filament_change(); break;
1230 1075
       case LEVELING_UI:                 lv_draw_manualLevel(); break;
1231
-      case BIND_UI:                     /* draw_bind(); */ break;
1076
+      #if ENABLED(MKS_WIFI_MODULE)
1077
+        case BIND_UI:                   lv_draw_cloud_bind(); break;
1078
+      #endif
1232 1079
       #if HAS_BED_PROBE
1233 1080
         case NOZZLE_PROBE_OFFSET_UI:    lv_draw_auto_level_offset_settings(); break;
1234 1081
       #endif

+ 15
- 3
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h Vedi File

@@ -46,6 +46,7 @@
46 46
 #include "draw_preHeat.h"
47 47
 #include "draw_extrusion.h"
48 48
 #include "draw_home.h"
49
+#include "draw_more.h"
49 50
 #include "draw_move_motor.h"
50 51
 #include "draw_fan.h"
51 52
 #include "draw_about.h"
@@ -76,6 +77,8 @@
76 77
 #include "draw_keyboard.h"
77 78
 #include "draw_encoder_settings.h"
78 79
 
80
+#include "../../inc/MarlinConfigPre.h"
81
+
79 82
 #if ENABLED(MKS_WIFI_MODULE)
80 83
   #include "wifiSerial.h"
81 84
   #include "wifi_module.h"
@@ -84,11 +87,15 @@
84 87
   #include "draw_wifi.h"
85 88
   #include "draw_wifi_list.h"
86 89
   #include "draw_wifi_tips.h"
90
+  #include "draw_cloud_bind.h"
87 91
 #endif
88 92
 
89
-#include "../../../../inc/MarlinConfigPre.h"
90
-#define FILE_SYS_USB  0
91
-#define FILE_SYS_SD 1
93
+#define ESP_WIFI          0x02
94
+#define AP_MODEL          0x01
95
+#define STA_MODEL         0x02
96
+
97
+#define FILE_SYS_USB      0
98
+#define FILE_SYS_SD       1
92 99
 
93 100
 #define TICK_CYCLE 1
94 101
 
@@ -157,6 +164,10 @@
157 164
   #define PARA_UI_BACK_BTN_X_SIZE   70
158 165
   #define PARA_UI_BACK_BTN_Y_SIZE   40
159 166
 
167
+  #define QRCODE_X                  20
168
+  #define QRCODE_Y                  40
169
+  #define QRCODE_WIDTH              160
170
+
160 171
 #else // ifdef TFT35
161 172
 
162 173
   #define TFT_WIDTH     320
@@ -237,6 +248,7 @@ typedef struct {
237 248
   float desireSprayerTempBak;
238 249
   float current_x_position_bak;
239 250
   float current_y_position_bak;
251
+  float current_z_position_bak;
240 252
   float current_e_position_bak;
241 253
 } UI_CFG;
242 254
 

+ 29
- 25
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp Vedi File

@@ -41,60 +41,64 @@ enum {
41 41
 
42 42
 static void event_handler(lv_obj_t *obj, lv_event_t event) {
43 43
   if (event != LV_EVENT_RELEASED) return;
44
+  clear_cur_ui();
44 45
   switch (obj->mks_obj_id) {
45 46
     case ID_W_RETURN:
46
-      clear_cur_ui();
47 47
       lv_draw_set();
48 48
       break;
49 49
     case ID_W_CLOUD:
50
-      //clear_cur_ui();
51
-      //draw_return_ui();
52
-      break;
53
-    case ID_W_RECONNECT:
54
-      clear_cur_ui();
55
-      lv_draw_wifi_list();
50
+      lv_draw_cloud_bind();
56 51
       break;
52
+    #if ENABLED(MKS_WIFI_MODULE)
53
+      case ID_W_RECONNECT: {
54
+        uint8_t cmd_wifi_list[] = { 0xA5, 0x07, 0x00, 0x00, 0xFC };
55
+        raw_send_to_wifi(cmd_wifi_list, COUNT(cmd_wifi_list));
56
+        lv_draw_wifi_list();
57
+      } break;
58
+    #endif
57 59
   }
58 60
 }
59 61
 
60 62
 void lv_draw_wifi(void) {
61 63
   scr = lv_screen_create(WIFI_UI);
62 64
 
63
-  // Create an Image button
64
-  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
65
-  #if HAS_ROTARY_ENCODER
66
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
67
-  #endif
68
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
69
-
70 65
   lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr;
66
+  lv_obj_t *buttonCloud = nullptr, *label_Cloud = nullptr;
67
+
68
+  const bool enc_ena = TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable);
71 69
 
72 70
   if (gCfgItems.wifi_mode_sel == STA_MODEL) {
73 71
 
74
-    buttonReconnect = lv_imgbtn_create(scr, nullptr);
72
+    if (gCfgItems.cloud_enable)
73
+      buttonCloud = lv_imgbtn_create(scr, "F:/bmp_cloud.bin", BTN_X_PIXEL+INTERVAL_V*2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_CLOUD);
75 74
 
76
-    lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, "", 0);
77
-    lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
78
-    lv_imgbtn_use_label_style(buttonReconnect);
75
+    buttonReconnect = lv_imgbtn_create(scr, "F:/bmp_wifi.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RECONNECT);
79 76
 
80 77
     #if HAS_ROTARY_ENCODER
81
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect);
78
+      if (gCfgItems.cloud_enable) lv_group_add_obj(g, buttonCloud);
79
+      if (enc_ena) lv_group_add_obj(g, buttonReconnect);
82 80
     #endif
83 81
 
84
-    lv_obj_set_pos(buttonReconnect, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
85
-    lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
86
-
87 82
     label_Reconnect = lv_label_create_empty(buttonReconnect);
83
+    if (gCfgItems.cloud_enable) label_Cloud = lv_label_create_empty(buttonCloud);
88 84
   }
89 85
 
90
-  if (gCfgItems.multiple_language) {
91
-    lv_label_set_text(label_Back, common_menu.text_back);
92
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
86
+  // Create an Image button
87
+  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
88
+  if (enc_ena) lv_group_add_obj(g, buttonBack);
89
+  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
93 90
 
91
+  if (gCfgItems.multiple_language) {
94 92
     if (gCfgItems.wifi_mode_sel == STA_MODEL) {
93
+      if (gCfgItems.cloud_enable) {
94
+        lv_label_set_text(label_Cloud, wifi_menu.cloud);
95
+        lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
96
+      }
95 97
       lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
96 98
       lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
97 99
     }
100
+    lv_label_set_text(label_Back, common_menu.text_back);
101
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
98 102
   }
99 103
 
100 104
   wifi_ip_text = lv_label_create_empty(scr);

+ 4
- 14
Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp Vedi File

@@ -46,20 +46,10 @@
46 46
 #define WIFI_IO1_RESET()  WRITE(WIFI_IO1_PIN, LOW);
47 47
 
48 48
 void __irq_usart1(void) {
49
-  WIFISERIAL.wifi_usart_irq(USART1_BASE);
50
-  if (wifi_link_state == WIFI_TRANS_FILE) {
51
-    if (WIFISERIAL.available() == (400)) WIFI_IO1_SET();
52
-    if (WIFISERIAL.wifi_rb_is_full()) {
53
-      if (esp_state == TRANSFER_IDLE) esp_state = TRANSFERING;
54
-      if (storeRcvData(UART_RX_BUFFER_SIZE)) {
55
-        if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
56
-      }
57
-      else {
58
-        WIFI_IO1_SET();
59
-        esp_state = TRANSFER_STORE;
60
-      }
61
-    }
62
-  }
49
+   if ((USART1_BASE->CR1 & USART_CR1_RXNEIE) && (USART1_BASE->SR & USART_SR_RXNE))
50
+     WRITE(WIFI_IO1_PIN, HIGH);
51
+
52
+   WIFISERIAL.wifi_usart_irq(USART1_BASE);
63 53
 }
64 54
 
65 55
 #ifdef __cplusplus

+ 34
- 26
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp Vedi File

@@ -42,7 +42,7 @@ extern uint16_t DeviceCode;
42 42
 #endif
43 43
 
44 44
 static const char assets[][LONG_FILENAME_LENGTH] = {
45
-  //homing screen
45
+  // Homing screen
46 46
   "bmp_zeroAll.bin",
47 47
   "bmp_zero.bin",
48 48
   "bmp_zeroX.bin",
@@ -50,14 +50,15 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
50 50
   "bmp_zeroZ.bin",
51 51
   "bmp_manual_off.bin",
52 52
 
53
-  //tool screen
53
+  // Tool screen
54 54
   "bmp_preHeat.bin",
55 55
   "bmp_extruct.bin",
56 56
   "bmp_mov.bin",
57 57
   "bmp_leveling.bin",
58 58
   "bmp_filamentchange.bin",
59
+  "bmp_more.bin",
59 60
 
60
-  //fan screen
61
+  // Fan screen
61 62
   "bmp_Add.bin",
62 63
   "bmp_Dec.bin",
63 64
   "bmp_speed255.bin",
@@ -70,7 +71,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
70 71
   "bmp_step5_degree.bin",
71 72
   "bmp_step10_degree.bin",
72 73
 
73
-  //extrusion screen
74
+  // Extrusion screen
74 75
   "bmp_in.bin",
75 76
   "bmp_out.bin",
76 77
   "bmp_extru1.bin",
@@ -84,15 +85,15 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
84 85
   "bmp_step5_mm.bin",
85 86
   "bmp_step10_mm.bin",
86 87
 
87
-  //select file screen
88
+  // Select file screen
88 89
   "bmp_pageUp.bin",
89 90
   "bmp_pageDown.bin",
90 91
   "bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back)
91 92
   "bmp_dir.bin",
92 93
   "bmp_file.bin",
93 94
 
94
-  //move motor screen
95
-  //TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
95
+  // Move motor screen
96
+  // TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
96 97
   "bmp_xAdd.bin",
97 98
   "bmp_xDec.bin",
98 99
   "bmp_yAdd.bin",
@@ -103,7 +104,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
103 104
   "bmp_step_move1.bin",
104 105
   "bmp_step_move10.bin",
105 106
 
106
-  //operation screen
107
+  // Operation screen
107 108
   "bmp_auto_off.bin",
108 109
   "bmp_speed.bin",
109 110
   "bmp_fan.bin",
@@ -111,7 +112,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
111 112
   "bmp_extrude_opr.bin",
112 113
   "bmp_move_opr.bin",
113 114
 
114
-  //change speed screen
115
+  // Change speed screen
115 116
   "bmp_step1_percent.bin",
116 117
   "bmp_step5_percent.bin",
117 118
   "bmp_step10_percent.bin",
@@ -120,7 +121,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
120 121
   "bmp_mov_sel.bin",
121 122
   "bmp_speed_extruct.bin",
122 123
 
123
-  //printing screen
124
+  // Printing screen
124 125
   "bmp_pause.bin",
125 126
   "bmp_resume.bin",
126 127
   "bmp_stop.bin",
@@ -134,7 +135,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
134 135
   "bmp_zpos_state.bin",
135 136
   "bmp_operate.bin",
136 137
 
137
-  //manual leval screen (only if disabled auto level)
138
+  // Manual Level screen (only if auto level is disabled)
138 139
   #if DISABLED(AUTO_BED_LEVELING_BILINEAR)
139 140
     "bmp_leveling1.bin",
140 141
     "bmp_leveling2.bin",
@@ -143,7 +144,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
143 144
     "bmp_leveling5.bin",
144 145
   #endif
145 146
 
146
-  //lang select screen
147
+  // Language Select screen
147 148
   #if HAS_LANG_SELECT_SCREEN
148 149
     "bmp_language.bin",
149 150
     "bmp_simplified_cn.bin",
@@ -162,7 +163,7 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
162 163
     "bmp_italy_sel.bin",
163 164
   #endif // HAS_LANG_SELECT_SCREEN
164 165
 
165
-  // gcode preview
166
+  // G-code preview
166 167
   #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
167 168
     "bmp_preview.bin",
168 169
   #endif
@@ -171,20 +172,18 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
171 172
     "bmp_logo.bin",
172 173
   #endif
173 174
 
174
-  // settings screen
175
+  // Settings screen
175 176
   "bmp_about.bin",
177
+  "bmp_eeprom_settings.bin",
178
+  "bmp_machine_para.bin",
179
+  "bmp_function1.bin",
176 180
 
177
-  //start screen
181
+  // Start screen
178 182
   "bmp_printing.bin",
179 183
   "bmp_set.bin",
180 184
   "bmp_tool.bin",
181 185
 
182
-  // settings screen
183
-  "bmp_eeprom_settings.bin",
184
-  "bmp_machine_para.bin",
185
-  "bmp_function1.bin",
186
-
187
-  // base icons
186
+  // Base icons
188 187
   "bmp_arrow.bin",
189 188
   "bmp_back70x40.bin",
190 189
   "bmp_value_blank.bin",
@@ -194,14 +193,24 @@ static const char assets[][LONG_FILENAME_LENGTH] = {
194 193
   "bmp_return.bin",
195 194
 
196 195
   #if ENABLED(MKS_WIFI_MODULE)
197
-    // wifi screen
196
+    // Wifi screen
198 197
     "bmp_wifi.bin",
198
+    "bmp_cloud.bin",
199 199
   #endif
200 200
 
201
-  // babystep screen
201
+  // Babystep screen
202 202
   "bmp_baby_move0_01.bin",
203 203
   "bmp_baby_move0_05.bin",
204
-  "bmp_baby_move0_1.bin"
204
+  "bmp_baby_move0_1.bin",
205
+
206
+  // More screen
207
+  "bmp_custom1.bin",
208
+  "bmp_custom2.bin",
209
+  "bmp_custom3.bin",
210
+  "bmp_custom4.bin",
211
+  "bmp_custom5.bin",
212
+  "bmp_custom6.bin",
213
+  "bmp_custom7.bin"
205 214
 };
206 215
 
207 216
 #if HAS_SPI_FLASH_FONT
@@ -235,14 +244,13 @@ uint32_t lv_get_pic_addr(uint8_t *Pname) {
235 244
     } while (PIC.name[j++] != '\0');
236 245
 
237 246
     if ((strcasecmp((char*)Pname, (char*)PIC.name)) == 0) {
238
-      if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761))
247
+      if (DeviceCode == 0x9488 || DeviceCode == 0x5761)
239 248
         addr = PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35;
240 249
       else
241 250
         addr = PIC_DATA_ADDR_TFT32 + i * PER_PIC_MAX_SPACE_TFT32;
242 251
       return addr;
243 252
     }
244 253
   }
245
-
246 254
   return addr;
247 255
 }
248 256
 

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h Vedi File

@@ -120,7 +120,7 @@
120 120
 
121 121
 // SD card information first addr
122 122
 #define VAR_INF_ADDR                    0x000000
123
-#define FLASH_INF_VALID_FLAG            0x20200831
123
+#define FLASH_INF_VALID_FLAG            0x20201118
124 124
 
125 125
 //Store some gcode commands, such as auto leveling commands
126 126
 #define GCODE_COMMAND_ADDR              VAR_INF_ADDR + 3*1024

+ 5
- 4
Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp Vedi File

@@ -32,6 +32,7 @@
32 32
 #include "../../../../sd/cardreader.h"
33 33
 #include "../../../../inc/MarlinConfig.h"
34 34
 #include "../../../../MarlinCore.h"
35
+#include "../../../../gcode/queue.h"
35 36
 
36 37
 #if ENABLED(POWER_LOSS_RECOVERY)
37 38
   #include "../../../../feature/powerloss.h"
@@ -55,6 +56,7 @@ void printer_state_polling() {
55 56
         //save the positon
56 57
         uiCfg.current_x_position_bak = current_position.x;
57 58
         uiCfg.current_y_position_bak = current_position.y;
59
+        uiCfg.current_z_position_bak = current_position.z;
58 60
 
59 61
         if (gCfgItems.pausePosZ != (float)-1) {
60 62
           gcode.process_subcommands_now_P(PSTR("G91"));
@@ -87,10 +89,9 @@ void printer_state_polling() {
87 89
         gcode.process_subcommands_now(public_buf_m);
88 90
       }
89 91
       if (gCfgItems.pausePosZ != (float)-1) {
90
-        gcode.process_subcommands_now_P(PSTR("G91"));
91
-        sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
92
-        gcode.process_subcommands_now(public_buf_l);
93
-        gcode.process_subcommands_now_P(PSTR("G90"));
92
+        ZERO(public_buf_m);
93
+        sprintf_P(public_buf_m, PSTR("G1 Z%.1f"), uiCfg.current_z_position_bak);
94
+        gcode.process_subcommands_now(public_buf_m);
94 95
       }
95 96
       gcode.process_subcommands_now_P(M24_STR);
96 97
       uiCfg.print_state = WORKING;

+ 9
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h Vedi File

@@ -114,6 +114,7 @@
114 114
 #define PROBE_Z_SPEED_EN                "Probe Z-axis speed"
115 115
 #define ENABLE_EN                       "YES"
116 116
 #define DISABLE_EN                      "NO"
117
+#define LOCKED_EN                       "N/A"
117 118
 #define Z_MIN_EN                        "ZMin"
118 119
 #define Z_MAX_EN                        "ZMax"
119 120
 
@@ -725,3 +726,11 @@
725 726
 #define EEPROM_STORE_TIPS_EN  "Store settings to EEPROM?"
726 727
 #define EEPROM_READ_TIPS_EN   "Read settings from EEPROM?"
727 728
 #define EEPROM_REVERT_TIPS_EN "Revert settings to factory defaults?"
729
+
730
+#define MORE_CUSTOM1_TEXT_EN  USER_DESC_1
731
+#define MORE_CUSTOM2_TEXT_EN  USER_DESC_2
732
+#define MORE_CUSTOM3_TEXT_EN  USER_DESC_3
733
+#define MORE_CUSTOM4_TEXT_EN  USER_DESC_4
734
+#define MORE_CUSTOM5_TEXT_EN  USER_DESC_5
735
+#define MORE_CUSTOM6_TEXT_EN  USER_DESC_6
736
+#define MORE_CUSTOM7_TEXT_EN  USER_DESC_7

+ 8
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h Vedi File

@@ -257,3 +257,11 @@
257 257
 #define EEPROM_STORE_TIPS_FR  "Stocker les paramètres dans l'EEPROM?"
258 258
 #define EEPROM_READ_TIPS_FR   "Lire les paramètres de l'EEPROM?"
259 259
 #define EEPROM_REVERT_TIPS_FR "Rétablir les paramètres par défaut d'usine?"
260
+
261
+#define MORE_CUSTOM1_TEXT_FR  USER_DESC_1
262
+#define MORE_CUSTOM2_TEXT_FR  USER_DESC_2
263
+#define MORE_CUSTOM3_TEXT_FR  USER_DESC_3
264
+#define MORE_CUSTOM4_TEXT_FR  USER_DESC_4
265
+#define MORE_CUSTOM5_TEXT_FR  USER_DESC_5
266
+#define MORE_CUSTOM6_TEXT_FR  USER_DESC_6
267
+#define MORE_CUSTOM7_TEXT_FR  USER_DESC_7

+ 8
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h Vedi File

@@ -254,3 +254,11 @@
254 254
 #define EEPROM_STORE_TIPS_IT              "Memorizzare le impostazioni su EEPROM?"
255 255
 #define EEPROM_READ_TIPS_IT               "Leggi le impostazioni dalla EEPROM?"
256 256
 #define EEPROM_REVERT_TIPS_IT             "Ripristinare le impostazioni predefinite?"
257
+
258
+#define MORE_CUSTOM1_TEXT_IT  USER_DESC_1
259
+#define MORE_CUSTOM2_TEXT_IT  USER_DESC_2
260
+#define MORE_CUSTOM3_TEXT_IT  USER_DESC_3
261
+#define MORE_CUSTOM4_TEXT_IT  USER_DESC_4
262
+#define MORE_CUSTOM5_TEXT_IT  USER_DESC_5
263
+#define MORE_CUSTOM6_TEXT_IT  USER_DESC_6
264
+#define MORE_CUSTOM7_TEXT_IT  USER_DESC_7

+ 143
- 34
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h Vedi File

@@ -29,7 +29,7 @@
29 29
 #define PRINT_TEXT_RU                   " печать"
30 30
 #define EXTRUDE_TEXT_RU                 "экструзия"
31 31
 #define LEVELING_TEXT_RU                "уровень"
32
-#define AUTO_LEVELING_TEXT_RU           "aвто"
32
+#define AUTO_LEVELING_TEXT_RU           "aвтоуровень"
33 33
 #define SET_TEXT_RU                     "настройки"
34 34
 #define MORE_TEXT_RU                    "больше"
35 35
 
@@ -46,23 +46,23 @@
46 46
 #define BACK_TEXT_RU                    "назад"
47 47
 
48 48
 #define TOOL_PREHEAT_RU                 "нагрев"
49
-#define TOOL_EXTRUDE_RU                 "экструзия"
49
+#define TOOL_EXTRUDE_RU                 "экструдер"
50 50
 #define TOOL_MOVE_RU                    "движение"
51 51
 #define TOOL_HOME_RU                    "домой"
52 52
 #define TOOL_LEVELING_RU                "уровень"
53
-#define TOOL_AUTO_LEVELING_RU           "aвто"
53
+#define TOOL_AUTO_LEVELING_RU           "aвтоуровень"
54 54
 #define TOOL_FILAMENT_RU                "замена"
55 55
 #define TOOL_MORE_RU                    "больше"
56 56
 
57
-#define AXIS_X_ADD_TEXT_RU              "X+"
58
-#define AXIS_X_DEC_TEXT_RU              "X-"
59
-#define AXIS_Y_ADD_TEXT_RU              "Y+"
60
-#define AXIS_Y_DEC_TEXT_RU              "Y-"
61
-#define AXIS_Z_ADD_TEXT_RU              "Z+"
62
-#define AXIS_Z_DEC_TEXT_RU              "Z-"
63
-#define TEXT_01MM_RU                    "0.1mm"
64
-#define TEXT_1MM_RU                     "1mm"
65
-#define TEXT_10MM_RU                    "10mm"
57
+#define AXIS_X_ADD_TEXT_RU              "X +"
58
+#define AXIS_X_DEC_TEXT_RU              "X -"
59
+#define AXIS_Y_ADD_TEXT_RU              "Y +"
60
+#define AXIS_Y_DEC_TEXT_RU              "Y -"
61
+#define AXIS_Z_ADD_TEXT_RU              "Z +"
62
+#define AXIS_Z_DEC_TEXT_RU              "Z -"
63
+#define TEXT_01MM_RU                    "0.1 mm"
64
+#define TEXT_1MM_RU                     "1 mm"
65
+#define TEXT_10MM_RU                    "10 mm"
66 66
 
67 67
 #define HOME_X_TEXT_RU                  "X"
68 68
 #define HOME_Y_TEXT_RU                  "Y"
@@ -75,18 +75,18 @@
75 75
 
76 76
 #define EXTRUDER_IN_TEXT_RU             "втянуть"
77 77
 #define EXTRUDER_OUT_TEXT_RU            "выдавить"
78
-#define EXTRUDE_1MM_TEXT_RU             "1mm"
79
-#define EXTRUDE_5MM_TEXT_RU             "5mm"
80
-#define EXTRUDE_10MM_TEXT_RU            "10mm"
78
+#define EXTRUDE_1MM_TEXT_RU             "1 mm"
79
+#define EXTRUDE_5MM_TEXT_RU             "5 mm"
80
+#define EXTRUDE_10MM_TEXT_RU            "10 mm"
81 81
 #define EXTRUDE_LOW_SPEED_TEXT_RU       "мин"
82 82
 #define EXTRUDE_MEDIUM_SPEED_TEXT_RU    "сред"
83 83
 #define EXTRUDE_HIGH_SPEED_TEXT_RU      "выс"
84 84
 
85
-#define LEVELING_POINT1_TEXT_RU         "1точка"
86
-#define LEVELING_POINT2_TEXT_RU         "2точка"
87
-#define LEVELING_POINT3_TEXT_RU         "3точка"
88
-#define LEVELING_POINT4_TEXT_RU         "4точка"
89
-#define LEVELING_POINT5_TEXT_RU         "5точка"
85
+#define LEVELING_POINT1_TEXT_RU         "1 точка"
86
+#define LEVELING_POINT2_TEXT_RU         "2 точка"
87
+#define LEVELING_POINT3_TEXT_RU         "3 точка"
88
+#define LEVELING_POINT4_TEXT_RU         "4 точка"
89
+#define LEVELING_POINT5_TEXT_RU         "5 точка"
90 90
 
91 91
 #define FILESYS_TEXT_RU                 "система"
92 92
 #define WIFI_TEXT_RU                    "WiFi"
@@ -95,11 +95,10 @@
95 95
 #define BREAK_POINT_TEXT_RU             "продолжить"
96 96
 #define FILAMENT_TEXT_RU                "замена"
97 97
 #define LANGUAGE_TEXT_RU                "язык"
98
-#define MOTOR_OFF_TEXT_RU               "отклмотор"
98
+#define MOTOR_OFF_TEXT_RU               "откл. мотор"
99 99
 #define MOTOR_OFF_XY_TEXT_RU            "Off-XY"
100 100
 #define SHUTDOWN_TEXT_RU                "выключение"
101 101
 #define MACHINE_PARA_RU                 "конфиг"
102
-#define EEPROM_SETTINGS_RU              "Eeprom Set"
103 102
 
104 103
 #define U_DISK_TEXT_RU                  "U диск"
105 104
 #define SD_CARD_TEXT_RU                 "SD диск"
@@ -111,14 +110,14 @@
111 110
 #define WIFI_CONNECTED_TEXT_RU          "подключен"
112 111
 #define WIFI_DISCONNECTED_TEXT_RU       "не подключен"
113 112
 #define WIFI_EXCEPTION_TEXT_RU          "исключение"
114
-#define WIFI_RECONNECT_TEXT_RU          "Reconnect"
113
+#define WIFI_RECONNECT_TEXT_RU          "выбор сети"
115 114
 #define CLOUD_TEXT_RU                   "облако"
116 115
 #define CLOUD_BIND_RU                   "соединён"
117
-#define CLOUD_UNBIND_RU                 "не соединён"
118
-#define CLOUD_UNBINDING_RU              "Unbinding"
119
-#define CLOUD_DISCONNECTED_RU           "Disconnected"
120
-#define CLOUD_UNBINDED_RU               "Unbinded"
121
-#define CLOUD_BINDED_RU                 "Binded"
116
+#define CLOUD_UNBIND_RU                 "отсоед."
117
+#define CLOUD_UNBINDING_RU              "отвязано"
118
+#define CLOUD_DISCONNECTED_RU           "отключено"
119
+#define CLOUD_UNBINDED_RU               "несвяз."
120
+#define CLOUD_BINDED_RU                 "связано"
122 121
 #define CLOUD_DISABLE_RU                "Disable"
123 122
 
124 123
 #define FAN_ADD_TEXT_RU                 "добавить"
@@ -169,11 +168,11 @@
169 168
 #define ABOUT_VERSION_TEXT_RU               "Firmware: "
170 169
 #define ABOUT_WIFI_TEXT_RU                  "WiFi: "
171 170
 
172
-#define PRINTING_OPERATION_RU               "управление"
171
+#define PRINTING_OPERATION_RU               "опции"
173 172
 #define PRINTING_PAUSE_RU                   "пауза"
174 173
 #define PRINTING_TEMP_RU                    "темп"
175 174
 #define PRINTING_CHANGESPEED_RU             "скорости"
176
-#define PRINTING_RESUME_RU                  "возобновить"
175
+#define PRINTING_RESUME_RU                  "возобн.   "
177 176
 #define PRINTING_STOP_RU                    "стоп"
178 177
 #define PRINTING_MORE_RU                    "больше"
179 178
 #define PRINTING_EXTRUDER_RU                "экстр"
@@ -193,6 +192,7 @@
193 192
 #define TITLE_HOME_RU                       "Home"
194 193
 #define TITLE_EXTRUDE_RU                    "экструзия"
195 194
 #define TITLE_LEVELING_RU                   "уровень"
195
+#define TITLE_MLEVELING_RU                  "углы"
196 196
 #define TITLE_SET_RU                        "настройки"
197 197
 #define TITLE_MORE_RU                       "больше"
198 198
 #define TITLE_CHOOSEFILE_RU                 "файла"
@@ -230,7 +230,7 @@
230 230
 #define DIALOG_CLOSE_MACHINE_RU             "Closing machine......"
231 231
 #define DIALOG_UNBIND_PRINTER_RU            "Unbind the printer?"
232 232
 #define DIALOG_FILAMENT_NO_PRESS_RU         "Filament detection switch is not pressed"
233
-#define DIALOG_PRINT_FINISH_RU              "Печать завершена!"
233
+#define DIALOG_PRINT_FINISH_RU              "печать завершена!"
234 234
 #define DIALOG_PRINT_TIME_RU                "Время печати: "
235 235
 #define DIALOG_REPRINT_RU                   "Print again"
236 236
 #define DIALOG_WIFI_ENABLE_TIPS_RU          "The wifi module is being configured,\nplease wait a moment....."
@@ -253,6 +253,115 @@
253 253
 #define EEPROM_SETTINGS_READ_RU       "Чтение настроек из EEPROM"
254 254
 #define EEPROM_SETTINGS_REVERT_RU     "Bосстановить заводские настройки по умолчанию"
255 255
 
256
-#define EEPROM_STORE_TIPS_RU          "Сохранить настройки в EEPROM?"
257
-#define EEPROM_READ_TIPS_RU           "Читать настройки из EEPROM?"
258
-#define EEPROM_REVERT_TIPS_RU         "Revert settings to factory defaults?"
256
+#define MORE_CUSTOM1_TEXT_RU  USER_DESC_1
257
+#define MORE_CUSTOM2_TEXT_RU  USER_DESC_2
258
+#define MORE_CUSTOM3_TEXT_RU  USER_DESC_3
259
+#define MORE_CUSTOM4_TEXT_RU  USER_DESC_4
260
+#define MORE_CUSTOM5_TEXT_RU  USER_DESC_5
261
+#define MORE_CUSTOM6_TEXT_RU  USER_DESC_6
262
+#define MORE_CUSTOM7_TEXT_RU  USER_DESC_7
263
+
264
+//Malderin translate
265
+//
266
+//
267
+#define EEPROM_STORE_TIPS_RU          "Cохранить настройки в EEPROM?"
268
+#define EEPROM_READ_TIPS_RU           "читать настройки из EEPROM?"
269
+#define EEPROM_REVERT_TIPS_RU         "Cбросить настройки к значениям по умолчанию?"
270
+#define EEPROM_SETTINGS_RU            "EEPROM"
271
+
272
+#define NEXT_RU                       "след."
273
+#define PREVIOUS_RU                   "пред."
274
+#define ENABLE_RU                     "да "
275
+#define DISABLE_RU                    "нет"
276
+#define KEY_CONFIRM_RU                "OK"
277
+
278
+#define MACHINE_PARA_TITLE_RU          "настройки"
279
+#define MACHINE_TYPE_CNOFIG_RU         "Hастройки принтера"
280
+#define MOTOR_CONFIG_RU                "Hастройки моторов"
281
+#define MACHINE_LEVELING_CONFIG_RU     "Hастройки уровня"
282
+#define ADVANCE_CONFIG_RU              "Pасширенные настройки"
283
+#define MACHINE_FILAMENT_CONFIG_RU     "Hастройки филамента"
284
+#define ENCODER_SETTINGS_RU            "Hастройки энкодера"
285
+
286
+#define LEVELING_CONF_TITLE_RU          "Hастройки принтера>Hастройки уровня"
287
+#define LEVELING_PARA_CONF_RU           "настройки уровня"
288
+#define LEVELING_MANUAL_POS_RU          "настройки координат для уровня"
289
+#define LEVELING_AUTO_COMMAND_RU        "настройки комманд увтоуровня"
290
+#define LEVELING_AUTO_ZOFFSET_RU        "координаты смещения сопла"
291
+
292
+#define MACHINE_CONFIG_TITLE_RU         "Hастройки принтера>настройки притера"
293
+#define MAXFEEDRATE_CONF_RU             "настройки максимальной скорости"
294
+#define ACCELERATION_CONF_RU            "настройки ускорений"
295
+#define JERKCONF_RU                     "настройки рывков"
296
+
297
+#define MOTOR_CONF_TITLE_RU             "Hастройки принтера>Hастройки моторов"
298
+#define STEPSCONF_RU                    "настройки шагов"
299
+#define TMC_CURRENT_RU                  "TMC настройки токов"
300
+#define TMC_STEP_MODE_RU                "TMC настрйоки режима шагов"
301
+
302
+#define ACCELERATION_CONF_TITLE_RU      "Hастройки принтера>ускорения"
303
+#define PRINT_ACCELERATION_RU           "ускорение печати"
304
+#define RETRACT_ACCELERATION_RU         "ускорение ретракта"
305
+#define TRAVEL_ACCELERATION_RU          "ускорение перемещений"
306
+#define X_ACCELERATION_RU               "ускорение оси X"
307
+#define Y_ACCELERATION_RU               "ускорение оси Y"
308
+#define Z_ACCELERATION_RU               "ускорение оси Z"
309
+#define E0_ACCELERATION_RU              "ускорение E0"
310
+#define E1_ACCELERATION_RU              "ускорение E1"
311
+
312
+#define MAXFEEDRATE_CONF_TITLE_RU       "Hастройки принтера>максимальная скорость"
313
+#define X_MAXFEEDRATE_RU                "максимальная скорость оси X"
314
+#define Y_MAXFEEDRATE_RU                "максимальная скорость оси Y"
315
+#define Z_MAXFEEDRATE_RU                "максимальная скорость оси Z"
316
+#define E0_MAXFEEDRATE_RU               "максимальная скорость E0"
317
+#define E1_MAXFEEDRATE_RU               "максимальная скорость E1"
318
+
319
+#define JERK_CONF_TITLE_RU              "Hастройки принтера>скорость рывка"
320
+#define X_JERK_RU                       "скорость рывка оси X"
321
+#define Y_JERK_RU                       "скорость рывка оси Y"
322
+#define Z_JERK_RU                       "скорость рывка оси Z"
323
+#define E_JERK_RU                       "скорость рывка оси E"
324
+
325
+#define STEPS_CONF_TITLE_RU             "Hастройки принтера>настройки шагов"
326
+#define X_STEPS_RU                      "шаги оси X"
327
+#define Y_STEPS_RU                      "шаги оси Y"
328
+#define Z_STEPS_RU                      "шаги оси Z"
329
+#define E0_STEPS_RU                     "шаги E0"
330
+#define E1_STEPS_RU                     "шаги E1"
331
+
332
+#define TMC_CURRENT_CONF_TITLE_RU       "Hастройки принтера>TMC настройка токов"
333
+#define X_TMC_CURRENT_RU                "ток оси X (mA)"
334
+#define Y_TMC_CURRENT_RU                "ток оси Y (mA)"
335
+#define Z_TMC_CURRENT_RU                "ток оси Z (mA)"
336
+#define E0_TMC_CURRENT_RU               "ток E0 (mA)"
337
+#define E1_TMC_CURRENT_RU               "ток E1 (mA)"
338
+
339
+#define TMC_MODE_CONF_TITLE_RU          "Hастройки принтера>TMC настройки режима шагов"
340
+#define X_TMC_MODE_RU                   "включает ли двигатель X режим StealthChop"
341
+#define Y_TMC_MODE_RU                   "включает ли ось Y режим StealthChop"
342
+#define Z_TMC_MODE_RU                   "включает ли ось Z режим StealthChop"
343
+#define E0_TMC_MODE_RU                  "включает ли E0 режим StealthChop"
344
+#define E1_TMC_MODE_RU                  "включает ли E1 режим StealthChop"
345
+
346
+#define ADVANCED_CONF_TITLE_RU          "Hастройки принтера>Pасширенные"
347
+#define PAUSE_POSITION_RU    "Hастройки позиции паузы печати"
348
+#define PAUSE_POSITION_X_RU  "положение по X (абс. полож., -1 недействит.)"
349
+#define PAUSE_POSITION_Y_RU  "положение по Y (абс. полож., -1 недействит.)"
350
+#define PAUSE_POSITION_Z_RU  "положение по Z (абс. полож., -1 недействит.)"
351
+
352
+#define OFFSET_TITLE_RU  "Hастройки принтера>отступ"
353
+#define OFFSET_X_RU      "X отступ"
354
+#define OFFSET_Y_RU      "Y отступ"
355
+#define OFFSET_Z_RU      "Z отступ"
356
+
357
+#define FILAMENT_CONF_TITLE_RU          "Hастройки принтера>Hастройки филамента"
358
+#define FILAMENT_IN_LENGTH_RU           "длинна загрузки"
359
+#define FILAMENT_IN_SPEED_RU            "скорость загрузки"
360
+#define FILAMENT_TEMPERATURE_RU         "температура филамента"
361
+#define FILAMENT_OUT_LENGTH_RU          "длинна извлечения"
362
+#define FILAMENT_OUT_SPEED_RU           "скорость извлечения"
363
+
364
+#define ENCODER_CONF_TITLE_RU           "Hастройки принтера>Hастройки энкодера"
365
+#define ENCODER_CONF_TEXT_RU            "энкодер используется?"
366
+
367
+//end of Malderin translate

+ 9
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h Vedi File

@@ -99,6 +99,7 @@
99 99
 #define PROBE_Z_SPEED_CN              "探针Z方向移动速度"
100 100
 #define ENABLE_CN                     "是"
101 101
 #define DISABLE_CN                    "否"
102
+#define LOCKED_CN                     "否"
102 103
 #define Z_MIN_CN                      "ZMin"
103 104
 #define Z_MAX_CN                      "ZMax"
104 105
 
@@ -491,3 +492,11 @@
491 492
 #define EEPROM_STORE_TIPS_CN  "是否保存参数到EEPROM?"
492 493
 #define EEPROM_READ_TIPS_CN   "是否使用EEPROM参数?"
493 494
 #define EEPROM_REVERT_TIPS_CN "是否恢复默认参数?"
495
+
496
+#define MORE_CUSTOM1_TEXT_CN  USER_DESC_1
497
+#define MORE_CUSTOM2_TEXT_CN  USER_DESC_2
498
+#define MORE_CUSTOM3_TEXT_CN  USER_DESC_3
499
+#define MORE_CUSTOM4_TEXT_CN  USER_DESC_4
500
+#define MORE_CUSTOM5_TEXT_CN  USER_DESC_5
501
+#define MORE_CUSTOM6_TEXT_CN  USER_DESC_6
502
+#define MORE_CUSTOM7_TEXT_CN  USER_DESC_7

+ 10
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h Vedi File

@@ -29,6 +29,7 @@
29 29
 #define PRINT_TEXT_SP           "Imprimir"
30 30
 #define EXTRUDE_TEXT_SP         "Extrusor"
31 31
 #define LEVELING_TEXT_SP        "Leveling"
32
+#define MLEVELING_TEXT_SP       "Leveling"
32 33
 #define AUTO_LEVELING_TEXT_SP   "Autolevel"
33 34
 #define SET_TEXT_SP             "Config"
34 35
 #define MORE_TEXT_SP            "Más"
@@ -50,6 +51,7 @@
50 51
 #define TOOL_MOVE_SP            "Mover"
51 52
 #define TOOL_HOME_SP            "Origen"
52 53
 #define TOOL_LEVELING_SP        "Leveling"
54
+#define TOOL_MLEVELING_SP       "Leveling"
53 55
 #define TOOL_AUTO_LEVELING_SP   "Autolevel"
54 56
 #define TOOL_FILAMENT_SP        "Filamento"
55 57
 #define TOOL_MORE_SP            "Más"
@@ -261,3 +263,11 @@
261 263
 #define EEPROM_STORE_TIPS_SP  "¿Guardar ajustes en EEPROM?"
262 264
 #define EEPROM_READ_TIPS_SP   "Leer la configuración de EEPROM?"
263 265
 #define EEPROM_REVERT_TIPS_SP "Revert settings to factory defaults?"
266
+
267
+#define MORE_CUSTOM1_TEXT_SP  USER_DESC_1
268
+#define MORE_CUSTOM2_TEXT_SP  USER_DESC_2
269
+#define MORE_CUSTOM3_TEXT_SP  USER_DESC_3
270
+#define MORE_CUSTOM4_TEXT_SP  USER_DESC_4
271
+#define MORE_CUSTOM5_TEXT_SP  USER_DESC_5
272
+#define MORE_CUSTOM6_TEXT_SP  USER_DESC_6
273
+#define MORE_CUSTOM7_TEXT_SP  USER_DESC_7

+ 9
- 0
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h Vedi File

@@ -99,6 +99,7 @@
99 99
 #define PROBE_Z_SPEED_T_CN              "探针Z方向移動速度"
100 100
 #define ENABLE_T_CN                     "是"
101 101
 #define DISABLE_T_CN                    "否"
102
+#define LOCKED_T_CN                     "否"
102 103
 #define Z_MIN_T_CN                      "ZMin"
103 104
 #define Z_MAX_T_CN                      "ZMax"
104 105
 
@@ -489,3 +490,11 @@
489 490
 #define EEPROM_STORE_TIPS_T_CN        "是否保存參數到EEPROM?"
490 491
 #define EEPROM_READ_TIPS_T_CN         "是否使用EEPROM參數?"
491 492
 #define EEPROM_REVERT_TIPS_T_CN       "是否恢復默認參數?"
493
+
494
+#define MORE_CUSTOM1_TEXT_T_CN  USER_DESC_1
495
+#define MORE_CUSTOM2_TEXT_T_CN  USER_DESC_2
496
+#define MORE_CUSTOM3_TEXT_T_CN  USER_DESC_3
497
+#define MORE_CUSTOM4_TEXT_T_CN  USER_DESC_4
498
+#define MORE_CUSTOM5_TEXT_T_CN  USER_DESC_5
499
+#define MORE_CUSTOM6_TEXT_T_CN  USER_DESC_6
500
+#define MORE_CUSTOM7_TEXT_T_CN  USER_DESC_7

+ 36
- 26
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp Vedi File

@@ -19,12 +19,6 @@
19 19
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20 20
  *
21 21
  */
22
-
23
-/**
24
- * @file tft_lvgl_configuration.cpp
25
- * @date    2020-02-21
26
- */
27
-
28 22
 #include "../../../../inc/MarlinConfigPre.h"
29 23
 
30 24
 #if HAS_TFT_LVGL_UI
@@ -56,6 +50,10 @@ XPT2046 touch;
56 50
   #include "draw_touch_calibration.h"
57 51
 #endif
58 52
 
53
+#if ENABLED(MKS_WIFI_MODULE)
54
+  #include "wifi_module.h"
55
+#endif
56
+
59 57
 #include <SPI.h>
60 58
 
61 59
 #ifndef TFT_WIDTH
@@ -120,6 +118,10 @@ void tft_lvgl_init() {
120 118
 
121 119
   watchdog_refresh();     // LVGL init takes time
122 120
 
121
+  #if MB(MKS_ROBIN_NANO)
122
+    OUT_WRITE(PB0, LOW);  // HE1
123
+  #endif
124
+
123 125
   // Init TFT first!
124 126
   SPI_TFT.spi_init(SPI_FULL_SPEED);
125 127
   SPI_TFT.LCD_init();
@@ -137,19 +139,19 @@ void tft_lvgl_init() {
137 139
 
138 140
   lv_init();
139 141
 
140
-  lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 14); /*Initialize the display buffer*/
142
+  lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 14); // Initialize the display buffer
141 143
 
142
-  lv_disp_drv_t disp_drv;     /*Descriptor of a display driver*/
143
-  lv_disp_drv_init(&disp_drv);    /*Basic initialization*/
144
-  disp_drv.flush_cb = my_disp_flush; /*Set your driver function*/
145
-  disp_drv.buffer = &disp_buf;    /*Assign the buffer to the display*/
146
-  lv_disp_drv_register(&disp_drv);  /*Finally register the driver*/
144
+  lv_disp_drv_t disp_drv;     // Descriptor of a display driver
145
+  lv_disp_drv_init(&disp_drv);    // Basic initialization
146
+  disp_drv.flush_cb = my_disp_flush; // Set your driver function
147
+  disp_drv.buffer = &disp_buf;    // Assign the buffer to the display
148
+  lv_disp_drv_register(&disp_drv);  // Finally register the driver
147 149
 
148 150
   lv_indev_drv_t indev_drv;
149
-  lv_indev_drv_init(&indev_drv);     /*Descriptor of a input device driver*/
150
-  indev_drv.type = LV_INDEV_TYPE_POINTER; /*Touch pad is a pointer-like device*/
151
-  indev_drv.read_cb = my_touchpad_read;  /*Set your driver function*/
152
-  lv_indev_drv_register(&indev_drv);   /*Finally register the driver*/
151
+  lv_indev_drv_init(&indev_drv);     // Descriptor of a input device driver
152
+  indev_drv.type = LV_INDEV_TYPE_POINTER; // Touch pad is a pointer-like device
153
+  indev_drv.read_cb = my_touchpad_read;  // Set your driver function
154
+  lv_indev_drv_register(&indev_drv);   // Finally register the driver
153 155
 
154 156
   #if HAS_ROTARY_ENCODER
155 157
     g = lv_group_create();
@@ -193,6 +195,8 @@ void tft_lvgl_init() {
193 195
 
194 196
   lv_encoder_pin_init();
195 197
 
198
+  TERN_(MKS_WIFI_MODULE, mks_wifi_firmware_update());
199
+
196 200
   bool ready = true;
197 201
   #if ENABLED(POWER_LOSS_RECOVERY)
198 202
     recovery.load();
@@ -212,12 +216,9 @@ void tft_lvgl_init() {
212 216
     }
213 217
   #endif
214 218
 
215
-  if (ready) {
216
-    lv_draw_ready_print();
217
-  }
219
+  if (ready) lv_draw_ready_print();
218 220
 
219
-  if (mks_test_flag == 0x1E)
220
-    mks_gpio_test();
221
+  if (mks_test_flag == 0x1E) mks_gpio_test();
221 222
 }
222 223
 
223 224
 void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
@@ -229,8 +230,17 @@ void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * co
229 230
   for (uint16_t i = 0; i < height; i++)
230 231
     SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
231 232
 
232
-  lv_disp_flush_ready(disp);       /* Indicate you are ready with the flushing*/
233
+  lv_disp_flush_ready(disp); // Indicate you are ready with the flushing
234
+
235
+  W25QXX.init(SPI_QUARTER_SPEED);
236
+}
233 237
 
238
+void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color) {
239
+  uint16_t width, height;
240
+  width = x2 - x1 + 1;
241
+  height = y2 - y1 + 1;
242
+  SPI_TFT.setWindow((uint16_t)x1, (uint16_t)y1, width, height);
243
+  SPI_TFT.tftio.WriteMultiple(bk_color.full, width * height);
234 244
   W25QXX.init(SPI_QUARTER_SPEED);
235 245
 }
236 246
 
@@ -298,13 +308,13 @@ int16_t enc_diff = 0;
298 308
 lv_indev_state_t state = LV_INDEV_STATE_REL;
299 309
 
300 310
 bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) {
301
-  (void) indev_drv;   /*Unused*/
311
+  (void) indev_drv;   // Unused
302 312
 
303 313
   data->state = state;
304 314
   data->enc_diff = enc_diff;
305 315
   enc_diff = 0;
306 316
 
307
-  return false;       /*No more data to read so return false*/
317
+  return false;       // No more data to read so return false
308 318
 }
309 319
 
310 320
 extern uint8_t currentFlashPage;
@@ -327,7 +337,7 @@ lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * pa
327 337
 
328 338
 lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p) {
329 339
   lv_fs_res_t res = LV_FS_RES_OK;
330
-  /* Add your code here*/
340
+  /* Add your code here */
331 341
   pic_read_addr_offset = pic_read_base_addr;
332 342
   return res;
333 343
 }
@@ -379,7 +389,7 @@ lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_
379 389
 }
380 390
 
381 391
 lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p) {
382
-  /* Add your code here*/
392
+  /* Add your code here */
383 393
   lv_close_gcode_file();
384 394
   return LV_FS_RES_OK;
385 395
 }

+ 5
- 1
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h Vedi File

@@ -33,7 +33,9 @@
33 33
 #include <lvgl.h>
34 34
 
35 35
 //#define TFT_ROTATION TFT_ROTATE_180
36
-#define MKS_WIFI_MODULE 0
36
+
37
+extern uint8_t bmp_public_buf[14 * 1024];
38
+extern uint8_t public_buf[513];
37 39
 
38 40
 extern uint8_t bmp_public_buf[14 * 1024];
39 41
 extern uint8_t public_buf[513];
@@ -63,6 +65,8 @@ extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uin
63 65
 extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
64 66
 extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
65 67
 
68
+extern void lv_fill_rect(lv_coord_t x1, lv_coord_t y1, lv_coord_t x2, lv_coord_t y2, lv_color_t bk_color);
69
+
66 70
 #ifdef __cplusplus
67 71
   } /* C-declarations for C++ */
68 72
 #endif

+ 286
- 12
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp Vedi File

@@ -136,6 +136,7 @@ void machine_setting_disp() {
136 136
     machine_menu.ProbeZspeed          = PROBE_Z_SPEED_CN;
137 137
     machine_menu.enable               = ENABLE_CN;
138 138
     machine_menu.disable              = DISABLE_CN;
139
+    machine_menu.locked               = LOCKED_CN;
139 140
     machine_menu.z_min                = Z_MIN_CN;
140 141
     machine_menu.z_max                = Z_MAX_CN;
141 142
 
@@ -363,6 +364,7 @@ void machine_setting_disp() {
363 364
     machine_menu.ProbeZspeed          = PROBE_Z_SPEED_T_CN;
364 365
     machine_menu.enable               = ENABLE_T_CN;
365 366
     machine_menu.disable              = DISABLE_T_CN;
367
+    machine_menu.locked               = LOCKED_T_CN;
366 368
     machine_menu.z_min                = Z_MIN_T_CN;
367 369
     machine_menu.z_max                = Z_MAX_T_CN;
368 370
 
@@ -591,6 +593,7 @@ void machine_setting_disp() {
591 593
     machine_menu.ProbeZspeed          = PROBE_Z_SPEED_EN;
592 594
     machine_menu.enable               = ENABLE_EN;
593 595
     machine_menu.disable              = DISABLE_EN;
596
+    machine_menu.locked               = LOCKED_EN;
594 597
     machine_menu.z_min                = Z_MIN_EN;
595 598
     machine_menu.z_max                = Z_MAX_EN;
596 599
 
@@ -941,7 +944,28 @@ void disp_language_init() {
941 944
       filesys_menu.sd_sys  = SD_CARD_TEXT_CN;
942 945
       filesys_menu.usb_sys = U_DISK_TEXT_CN;
943 946
       //
944
-      more_menu.title       = TITLE_MORE_CN;
947
+      more_menu.title = TITLE_MORE_CN;
948
+      #if ENABLED(USER_CMD_1_ENABLE)
949
+        more_menu.custom1 = MORE_CUSTOM1_TEXT_CN;
950
+      #endif
951
+      #if ENABLED(USER_CMD_2_ENABLE)
952
+        more_menu.custom2 = MORE_CUSTOM2_TEXT_CN;
953
+      #endif
954
+      #if ENABLED(USER_CMD_3_ENABLE)
955
+        more_menu.custom3 = MORE_CUSTOM3_TEXT_CN;
956
+      #endif
957
+      #if ENABLED(USER_CMD_4_ENABLE)
958
+        more_menu.custom4 = MORE_CUSTOM4_TEXT_CN;
959
+      #endif
960
+      #if ENABLED(USER_CMD_5_ENABLE)
961
+        more_menu.custom5 = MORE_CUSTOM5_TEXT_CN;
962
+      #endif
963
+      #if ENABLED(USER_CMD_6_ENABLE)
964
+        more_menu.custom6 = MORE_CUSTOM6_TEXT_CN;
965
+      #endif
966
+      #if ENABLED(USER_CMD_7_ENABLE)
967
+        more_menu.custom7 = MORE_CUSTOM7_TEXT_CN;
968
+      #endif
945 969
       // WIFI
946 970
       wifi_menu.title = WIFI_TEXT;
947 971
       wifi_menu.cloud     = CLOUD_TEXT_CN;
@@ -953,6 +977,7 @@ void disp_language_init() {
953 977
       cloud_menu.unbind       = CLOUD_UNBIND_CN;
954 978
       cloud_menu.unbinding    = CLOUD_UNBINDED_CN;
955 979
       cloud_menu.disconnected = CLOUD_DISCONNECTED_CN;
980
+      cloud_menu.unbinded     = CLOUD_UNBINDED_CN;
956 981
       cloud_menu.disable      = CLOUD_DISABLE_CN;
957 982
       //
958 983
       about_menu.title   = ABOUT_TEXT_CN;
@@ -1166,9 +1191,30 @@ void disp_language_init() {
1166 1191
             filesys_menu.sd_sys   = SD_CARD_TEXT_T_CN;
1167 1192
             filesys_menu.usb_sys  = U_DISK_TEXT_T_CN;
1168 1193
             //
1169
-            more_menu.title       = TITLE_MORE_T_CN;
1194
+            more_menu.title     = TITLE_MORE_T_CN;
1195
+            #if ENABLED(USER_CMD_1_ENABLE)
1196
+              more_menu.custom1 = MORE_CUSTOM1_TEXT_T_CN;
1197
+            #endif
1198
+            #if ENABLED(USER_CMD_2_ENABLE)
1199
+              more_menu.custom2 = MORE_CUSTOM2_TEXT_T_CN;
1200
+            #endif
1201
+            #if ENABLED(USER_CMD_3_ENABLE)
1202
+              more_menu.custom3 = MORE_CUSTOM3_TEXT_T_CN;
1203
+            #endif
1204
+            #if ENABLED(USER_CMD_4_ENABLE)
1205
+              more_menu.custom4 = MORE_CUSTOM4_TEXT_T_CN;
1206
+            #endif
1207
+            #if ENABLED(USER_CMD_5_ENABLE)
1208
+              more_menu.custom5 = MORE_CUSTOM5_TEXT_T_CN;
1209
+            #endif
1210
+            #if ENABLED(USER_CMD_6_ENABLE)
1211
+              more_menu.custom6 = MORE_CUSTOM6_TEXT_T_CN;
1212
+            #endif
1213
+            #if ENABLED(USER_CMD_7_ENABLE)
1214
+              more_menu.custom7 = MORE_CUSTOM7_TEXT_T_CN;
1215
+            #endif
1170 1216
             // WIFI
1171
-            wifi_menu.title = WIFI_TEXT;
1217
+            wifi_menu.title     = WIFI_TEXT;
1172 1218
             wifi_menu.cloud     = CLOUD_TEXT_T_CN;
1173 1219
             wifi_menu.reconnect = WIFI_RECONNECT_TEXT_T_CN;
1174 1220
             // CLOUD
@@ -1178,6 +1224,7 @@ void disp_language_init() {
1178 1224
             cloud_menu.unbind       = CLOUD_UNBIND_T_CN;
1179 1225
             cloud_menu.unbinding    = CLOUD_UNBINDED_T_CN;
1180 1226
             cloud_menu.disconnected = CLOUD_DISCONNECTED_T_CN;
1227
+            cloud_menu.unbinded     = CLOUD_UNBINDED_T_CN;
1181 1228
             cloud_menu.disable      = CLOUD_DISABLE_T_CN;
1182 1229
             //
1183 1230
             about_menu.title   = ABOUT_TEXT_T_CN;
@@ -1334,7 +1381,7 @@ void disp_language_init() {
1334 1381
             preheat_menu.hotbed       = HEATBED_TEXT_EN;
1335 1382
             preheat_menu.off          = CLOSE_TEXT_EN;
1336 1383
             //
1337
-            move_menu.title = TITLE_MOVE_EN;
1384
+            move_menu.title    = TITLE_MOVE_EN;
1338 1385
             //
1339 1386
             home_menu.title    = TITLE_HOME_EN;
1340 1387
             home_menu.stopmove = HOME_STOPMOVE_EN;
@@ -1377,12 +1424,34 @@ void disp_language_init() {
1377 1424
             set_menu.machine_para = MACHINE_PARA_EN;
1378 1425
             set_menu.eepromSet    = EEPROM_SETTINGS_EN;
1379 1426
             more_menu.title       = TITLE_MORE_EN;
1427
+            #if ENABLED(USER_CMD_1_ENABLE)
1428
+              more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
1429
+            #endif
1430
+            #if ENABLED(USER_CMD_2_ENABLE)
1431
+              more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
1432
+            #endif
1433
+            #if ENABLED(USER_CMD_3_ENABLE)
1434
+              more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
1435
+            #endif
1436
+            #if ENABLED(USER_CMD_4_ENABLE)
1437
+              more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
1438
+            #endif
1439
+            #if ENABLED(USER_CMD_5_ENABLE)
1440
+              more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
1441
+            #endif
1442
+            #if ENABLED(USER_CMD_6_ENABLE)
1443
+              more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
1444
+            #endif
1445
+            #if ENABLED(USER_CMD_7_ENABLE)
1446
+              more_menu.custom7 = MORE_CUSTOM7_TEXT_EN;
1447
+            #endif
1448
+
1380 1449
             //
1381 1450
             filesys_menu.title   = TITLE_FILESYS_EN;
1382 1451
             filesys_menu.sd_sys  = SD_CARD_TEXT_EN;
1383 1452
             filesys_menu.usb_sys = U_DISK_TEXT_EN;
1384 1453
             // WIFI
1385
-            wifi_menu.title = WIFI_TEXT;
1454
+            wifi_menu.title     = WIFI_TEXT;
1386 1455
             wifi_menu.cloud     = CLOUD_TEXT_EN;
1387 1456
             wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN;
1388 1457
 
@@ -1392,6 +1461,7 @@ void disp_language_init() {
1392 1461
             cloud_menu.unbind       = CLOUD_UNBIND_EN;
1393 1462
             cloud_menu.unbinding    = CLOUD_UNBINDED_EN;
1394 1463
             cloud_menu.disconnected = CLOUD_DISCONNECTED_EN;
1464
+            cloud_menu.unbinded     = CLOUD_UNBINDED_EN;
1395 1465
             cloud_menu.disable      = CLOUD_DISABLE_EN;
1396 1466
             //
1397 1467
             about_menu.title   = TITLE_ABOUT_EN;
@@ -1545,7 +1615,7 @@ void disp_language_init() {
1545 1615
             preheat_menu.hotbed       = HEATBED_TEXT_RU;
1546 1616
             preheat_menu.off          = CLOSE_TEXT_RU;
1547 1617
             //
1548
-            move_menu.title = MOVE_TEXT_RU;
1618
+            move_menu.title    = MOVE_TEXT_RU;
1549 1619
             //
1550 1620
             home_menu.title    = TITLE_HOME_RU;
1551 1621
             home_menu.stopmove = HOME_STOPMOVE_RU;
@@ -1588,21 +1658,137 @@ void disp_language_init() {
1588 1658
             set_menu.machine_para = MACHINE_PARA_RU;
1589 1659
             set_menu.eepromSet    = EEPROM_SETTINGS_RU;
1590 1660
             more_menu.title       = TITLE_MORE_RU;
1661
+            #if ENABLED(USER_CMD_1_ENABLE)
1662
+              more_menu.custom1 = MORE_CUSTOM1_TEXT_RU;
1663
+            #endif
1664
+            #if ENABLED(USER_CMD_2_ENABLE)
1665
+              more_menu.custom2 = MORE_CUSTOM2_TEXT_RU;
1666
+            #endif
1667
+            #if ENABLED(USER_CMD_3_ENABLE)
1668
+              more_menu.custom3 = MORE_CUSTOM3_TEXT_RU;
1669
+            #endif
1670
+            #if ENABLED(USER_CMD_4_ENABLE)
1671
+              more_menu.custom4 = MORE_CUSTOM4_TEXT_RU;
1672
+            #endif
1673
+            #if ENABLED(USER_CMD_5_ENABLE)
1674
+              more_menu.custom5 = MORE_CUSTOM5_TEXT_RU;
1675
+            #endif
1676
+            #if ENABLED(USER_CMD_6_ENABLE)
1677
+              more_menu.custom6 = MORE_CUSTOM6_TEXT_RU;
1678
+            #endif
1679
+            #if ENABLED(USER_CMD_7_ENABLE)
1680
+              more_menu.custom7 = MORE_CUSTOM7_TEXT_RU;
1681
+            #endif
1591 1682
             //
1592 1683
             filesys_menu.title   = TITLE_FILESYS_RU;
1593 1684
             filesys_menu.sd_sys  = SD_CARD_TEXT_RU;
1594 1685
             filesys_menu.usb_sys = U_DISK_TEXT_RU;
1595 1686
             // WIFI
1596
-            wifi_menu.title = WIFI_TEXT;
1687
+            wifi_menu.title     = WIFI_TEXT;
1597 1688
             wifi_menu.cloud     = CLOUD_TEXT_RU;
1598 1689
             wifi_menu.reconnect = WIFI_RECONNECT_TEXT_RU;
1599 1690
 
1691
+            machine_menu.next          = NEXT_RU;
1692
+            machine_menu.previous      = PREVIOUS_RU;
1693
+            machine_menu.enable        = ENABLE_RU;
1694
+            machine_menu.disable       = DISABLE_RU;
1695
+            machine_menu.key_confirm   = KEY_CONFIRM_RU;
1696
+
1697
+            MachinePara_menu.MachineSetting    = MACHINE_TYPE_CNOFIG_RU;
1698
+            MachinePara_menu.title             = MACHINE_PARA_TITLE_RU;
1699
+            machine_menu.MachineConfigTitle    = MACHINE_CONFIG_TITLE_RU;
1700
+            MachinePara_menu.MotorSetting      = MOTOR_CONFIG_RU;
1701
+            MachinePara_menu.leveling          = MACHINE_LEVELING_CONFIG_RU;
1702
+            MachinePara_menu.AdvanceSetting    = ADVANCE_CONFIG_RU;
1703
+            machine_menu.MotorConfTitle        = MOTOR_CONF_TITLE_RU;
1704
+            machine_menu.MaxFeedRateConf       = MAXFEEDRATE_CONF_RU;
1705
+            machine_menu.AccelerationConf      = ACCELERATION_CONF_RU;
1706
+            machine_menu.JerkConf              = JERKCONF_RU;
1707
+            machine_menu.StepsConf             = STEPSCONF_RU;
1708
+            machine_menu.TMCcurrentConf        = TMC_CURRENT_RU;
1709
+            machine_menu.TMCStepModeConf       = TMC_STEP_MODE_RU;
1710
+            machine_menu.PausePosition         = PAUSE_POSITION_RU;
1711
+            machine_menu.FilamentConf          = MACHINE_FILAMENT_CONFIG_RU;
1712
+            machine_menu.EncoderSettings       = ENCODER_SETTINGS_RU;
1713
+            machine_menu.AdvancedConfTitle     = ADVANCED_CONF_TITLE_RU;
1714
+
1715
+            machine_menu.LevelingParaConfTitle   = LEVELING_CONF_TITLE_RU;
1716
+            machine_menu.LevelingParaConf        = LEVELING_PARA_CONF_RU;
1717
+            machine_menu.LevelingManuPosConf     = LEVELING_MANUAL_POS_RU;
1718
+            machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_RU;
1719
+            machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_RU;
1720
+
1721
+            machine_menu.AccelerationConfTitle = ACCELERATION_CONF_TITLE_RU;
1722
+            machine_menu.PrintAcceleration     = PRINT_ACCELERATION_RU;
1723
+            machine_menu.RetractAcceleration   = RETRACT_ACCELERATION_RU;
1724
+            machine_menu.TravelAcceleration    = TRAVEL_ACCELERATION_RU;
1725
+            machine_menu.X_Acceleration        = X_ACCELERATION_RU;
1726
+            machine_menu.Y_Acceleration        = Y_ACCELERATION_RU;
1727
+            machine_menu.Z_Acceleration        = Z_ACCELERATION_RU;
1728
+            machine_menu.E0_Acceleration       = E0_ACCELERATION_RU;
1729
+            machine_menu.E1_Acceleration       = E1_ACCELERATION_RU;
1730
+
1731
+            machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_RU;
1732
+            machine_menu.XMaxFeedRate         = X_MAXFEEDRATE_RU;
1733
+            machine_menu.YMaxFeedRate         = Y_MAXFEEDRATE_RU;
1734
+            machine_menu.ZMaxFeedRate         = Z_MAXFEEDRATE_RU;
1735
+            machine_menu.E0MaxFeedRate        = E0_MAXFEEDRATE_RU;
1736
+            machine_menu.E1MaxFeedRate        = E1_MAXFEEDRATE_RU;
1737
+
1738
+            machine_menu.JerkConfTitle = JERK_CONF_TITLE_RU;
1739
+            machine_menu.X_Jerk        = X_JERK_RU;
1740
+            machine_menu.Y_Jerk        = Y_JERK_RU;
1741
+            machine_menu.Z_Jerk        = Z_JERK_RU;
1742
+            machine_menu.E_Jerk        = E_JERK_RU;
1743
+
1744
+            machine_menu.StepsConfTitle = STEPS_CONF_TITLE_RU;
1745
+            machine_menu.X_Steps        = X_STEPS_RU;
1746
+            machine_menu.Y_Steps        = Y_STEPS_RU;
1747
+            machine_menu.Z_Steps        = Z_STEPS_RU;
1748
+            machine_menu.E0_Steps       = E0_STEPS_RU;
1749
+            machine_menu.E1_Steps       = E1_STEPS_RU;
1750
+
1751
+            machine_menu.TmcCurrentConfTitle = TMC_CURRENT_CONF_TITLE_RU;
1752
+            machine_menu.X_Current           = X_TMC_CURRENT_RU;
1753
+            machine_menu.Y_Current           = Y_TMC_CURRENT_RU;
1754
+            machine_menu.Z_Current           = Z_TMC_CURRENT_RU;
1755
+            machine_menu.E0_Current          = E0_TMC_CURRENT_RU;
1756
+            machine_menu.E1_Current          = E1_TMC_CURRENT_RU;
1757
+
1758
+            machine_menu.TmcStepModeConfTitle = TMC_MODE_CONF_TITLE_RU;
1759
+            machine_menu.X_StepMode           = X_TMC_MODE_RU;
1760
+            machine_menu.Y_StepMode           = Y_TMC_MODE_RU;
1761
+            machine_menu.Z_StepMode           = Z_TMC_MODE_RU;
1762
+            machine_menu.E0_StepMode          = E0_TMC_MODE_RU;
1763
+            machine_menu.E1_StepMode          = E1_TMC_MODE_RU;
1764
+
1765
+            machine_menu.PausePosText   = PAUSE_POSITION_RU;
1766
+            machine_menu.xPos           = PAUSE_POSITION_X_RU;
1767
+            machine_menu.yPos           = PAUSE_POSITION_Y_RU;
1768
+            machine_menu.zPos           = PAUSE_POSITION_Z_RU;
1769
+
1770
+            machine_menu.OffsetConfTitle = OFFSET_TITLE_RU;
1771
+            machine_menu.Xoffset         = OFFSET_X_RU;
1772
+            machine_menu.Yoffset         = OFFSET_Y_RU;
1773
+            machine_menu.Zoffset         = OFFSET_Z_RU;
1774
+
1775
+            machine_menu.FilamentConfTitle   = FILAMENT_CONF_TITLE_RU;
1776
+            machine_menu.InLength            = FILAMENT_IN_LENGTH_RU;
1777
+            machine_menu.InSpeed             = FILAMENT_IN_SPEED_RU;
1778
+            machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_RU;
1779
+            machine_menu.OutLength           = FILAMENT_OUT_LENGTH_RU;
1780
+            machine_menu.OutSpeed            = FILAMENT_OUT_SPEED_RU;
1781
+
1782
+            machine_menu.EncoderConfTitle    = ENCODER_CONF_TITLE_RU;
1783
+            machine_menu.EncoderConfText     = ENCODER_CONF_TEXT_RU;
1784
+
1600 1785
             cloud_menu.title        = TITLE_CLOUD_TEXT_RU;
1601 1786
             cloud_menu.bind         = CLOUD_BINDED_RU;
1602 1787
             cloud_menu.binded       = CLOUD_BINDED_RU;
1603 1788
             cloud_menu.unbind       = CLOUD_UNBIND_RU;
1604 1789
             cloud_menu.unbinding    = CLOUD_UNBINDED_RU;
1605 1790
             cloud_menu.disconnected = CLOUD_DISCONNECTED_RU;
1791
+            cloud_menu.unbinded     = CLOUD_UNBINDED_RU;
1606 1792
             cloud_menu.disable      = CLOUD_DISABLE_RU;
1607 1793
             //
1608 1794
             about_menu.title   = ABOUT_TEXT_RU;
@@ -1802,13 +1988,34 @@ void disp_language_init() {
1802 1988
             set_menu.machine_para = MACHINE_PARA_SP;
1803 1989
             set_menu.eepromSet    = EEPROM_SETTINGS_SP;
1804 1990
             more_menu.title       = TITLE_MORE_SP;
1991
+            #if ENABLED(USER_CMD_1_ENABLE)
1992
+              more_menu.custom1 = MORE_CUSTOM1_TEXT_SP;
1993
+            #endif
1994
+            #if ENABLED(USER_CMD_2_ENABLE)
1995
+              more_menu.custom2 = MORE_CUSTOM2_TEXT_SP;
1996
+            #endif
1997
+            #if ENABLED(USER_CMD_3_ENABLE)
1998
+              more_menu.custom3 = MORE_CUSTOM3_TEXT_SP;
1999
+            #endif
2000
+            #if ENABLED(USER_CMD_4_ENABLE)
2001
+              more_menu.custom4 = MORE_CUSTOM4_TEXT_SP;
2002
+            #endif
2003
+            #if ENABLED(USER_CMD_5_ENABLE)
2004
+              more_menu.custom5 = MORE_CUSTOM5_TEXT_SP;
2005
+            #endif
2006
+            #if ENABLED(USER_CMD_6_ENABLE)
2007
+              more_menu.custom6 = MORE_CUSTOM6_TEXT_SP;
2008
+            #endif
2009
+            #if ENABLED(USER_CMD_7_ENABLE)
2010
+              more_menu.custom7 = MORE_CUSTOM7_TEXT_SP;
2011
+            #endif
1805 2012
             //
1806 2013
             filesys_menu.title   = TITLE_FILESYS_SP;
1807 2014
             filesys_menu.sd_sys  = SD_CARD_TEXT_SP;
1808 2015
             filesys_menu.usb_sys = U_DISK_TEXT_SP;
1809 2016
 
1810 2017
             // WIFI
1811
-            wifi_menu.title = WIFI_TEXT;
2018
+            wifi_menu.title     = WIFI_TEXT;
1812 2019
             wifi_menu.cloud     = CLOUD_TEXT_SP;
1813 2020
             wifi_menu.reconnect = WIFI_RECONNECT_TEXT_SP;
1814 2021
 
@@ -1818,6 +2025,7 @@ void disp_language_init() {
1818 2025
             cloud_menu.unbind       = CLOUD_UNBIND_SP;
1819 2026
             cloud_menu.unbinding    = CLOUD_UNBINDED_SP;
1820 2027
             cloud_menu.disconnected = CLOUD_DISCONNECTED_SP;
2028
+            cloud_menu.unbinded     = CLOUD_UNBINDED_SP;
1821 2029
             cloud_menu.disable      = CLOUD_DISABLE_SP;
1822 2030
             //
1823 2031
             about_menu.title   = ABOUT_TEXT_SP;
@@ -2015,6 +2223,27 @@ void disp_language_init() {
2015 2223
           set_menu.machine_para = MACHINE_PARA_FR;
2016 2224
           set_menu.eepromSet    = EEPROM_SETTINGS_FR;
2017 2225
           more_menu.title       = TITLE_MORE_FR;
2226
+          #if ENABLED(USER_CMD_1_ENABLE)
2227
+            more_menu.custom1 = MORE_CUSTOM1_TEXT_FR;
2228
+          #endif
2229
+          #if ENABLED(USER_CMD_2_ENABLE)
2230
+            more_menu.custom2 = MORE_CUSTOM2_TEXT_FR;
2231
+          #endif
2232
+          #if ENABLED(USER_CMD_3_ENABLE)
2233
+            more_menu.custom3 = MORE_CUSTOM3_TEXT_FR;
2234
+          #endif
2235
+          #if ENABLED(USER_CMD_4_ENABLE)
2236
+            more_menu.custom4 = MORE_CUSTOM4_TEXT_FR;
2237
+          #endif
2238
+          #if ENABLED(USER_CMD_5_ENABLE)
2239
+            more_menu.custom5 = MORE_CUSTOM5_TEXT_FR;
2240
+          #endif
2241
+          #if ENABLED(USER_CMD_6_ENABLE)
2242
+            more_menu.custom6 = MORE_CUSTOM6_TEXT_FR;
2243
+          #endif
2244
+          #if ENABLED(USER_CMD_7_ENABLE)
2245
+            more_menu.custom7 = MORE_CUSTOM7_TEXT_FR;
2246
+          #endif
2018 2247
           //
2019 2248
           filesys_menu.title          = TITLE_FILESYS_FR;
2020 2249
           filesys_menu.sd_sys         = SD_CARD_TEXT_FR;
@@ -2023,7 +2252,7 @@ void disp_language_init() {
2023 2252
           file_menu.no_file           = NO_FILE_FR;
2024 2253
           file_menu.no_file_and_check = NO_FILE_FR;
2025 2254
           // WIFI
2026
-          wifi_menu.title = WIFI_NAME_TEXT_FR;
2255
+          wifi_menu.title     = WIFI_NAME_TEXT_FR;
2027 2256
           wifi_menu.cloud     = CLOUD_TEXT_FR;
2028 2257
           wifi_menu.reconnect = WIFI_RECONNECT_TEXT_FR;
2029 2258
 
@@ -2033,6 +2262,7 @@ void disp_language_init() {
2033 2262
           cloud_menu.unbind       = CLOUD_UNBIND_FR;
2034 2263
           cloud_menu.unbinding    = CLOUD_UNBINDED_FR;
2035 2264
           cloud_menu.disconnected = CLOUD_DISCONNECTED_FR;
2265
+          cloud_menu.unbinded     = CLOUD_UNBINDED_FR;
2036 2266
           cloud_menu.disable      = CLOUD_DISABLE_FR;
2037 2267
           //
2038 2268
           about_menu.title   = ABOUT_TEXT_FR;
@@ -2229,13 +2459,34 @@ void disp_language_init() {
2229 2459
           set_menu.machine_para = MACHINE_PARA_IT;
2230 2460
           set_menu.eepromSet    = EEPROM_SETTINGS_IT;
2231 2461
           more_menu.title       = TITLE_MORE_IT;
2462
+          #if ENABLED(USER_CMD_1_ENABLE)
2463
+            more_menu.custom1 = MORE_CUSTOM1_TEXT_IT;
2464
+          #endif
2465
+          #if ENABLED(USER_CMD_2_ENABLE)
2466
+            more_menu.custom2 = MORE_CUSTOM2_TEXT_IT;
2467
+          #endif
2468
+          #if ENABLED(USER_CMD_3_ENABLE)
2469
+            more_menu.custom3 = MORE_CUSTOM3_TEXT_IT;
2470
+          #endif
2471
+          #if ENABLED(USER_CMD_4_ENABLE)
2472
+            more_menu.custom4 = MORE_CUSTOM4_TEXT_IT;
2473
+          #endif
2474
+          #if ENABLED(USER_CMD_5_ENABLE)
2475
+            more_menu.custom5 = MORE_CUSTOM5_TEXT_IT;
2476
+          #endif
2477
+          #if ENABLED(USER_CMD_6_ENABLE)
2478
+            more_menu.custom6 = MORE_CUSTOM6_TEXT_IT;
2479
+          #endif
2480
+          #if ENABLED(USER_CMD_7_ENABLE)
2481
+            more_menu.custom7 = MORE_CUSTOM7_TEXT_IT;
2482
+          #endif
2232 2483
           //
2233 2484
           filesys_menu.title   = TITLE_FILESYS_IT;
2234 2485
           filesys_menu.sd_sys  = SD_CARD_TEXT_IT;
2235 2486
           filesys_menu.usb_sys = U_DISK_TEXT_IT;
2236 2487
 
2237 2488
           // WIFI
2238
-          wifi_menu.title = WIFI_NAME_TEXT_IT;
2489
+          wifi_menu.title     = WIFI_NAME_TEXT_IT;
2239 2490
           wifi_menu.cloud     = CLOSE_TEXT_IT;
2240 2491
           wifi_menu.reconnect = WIFI_RECONNECT_TEXT_IT;
2241 2492
 
@@ -2245,6 +2496,7 @@ void disp_language_init() {
2245 2496
           cloud_menu.unbind       = CLOUD_UNBIND_IT;
2246 2497
           cloud_menu.unbinding    = CLOUD_UNBINDED_IT;
2247 2498
           cloud_menu.disconnected = CLOUD_DISCONNECTED_IT;
2499
+          cloud_menu.unbinded     = CLOUD_UNBINDED_IT;
2248 2500
           cloud_menu.disable      = CLOUD_DISABLE_IT;
2249 2501
           //
2250 2502
           about_menu.title   = ABOUT_TEXT_IT;
@@ -2442,13 +2694,34 @@ void disp_language_init() {
2442 2694
       set_menu.machine_para = MACHINE_PARA_EN;
2443 2695
       set_menu.eepromSet    = EEPROM_SETTINGS_EN;
2444 2696
       //
2445
-      more_menu.title       = TITLE_MORE_EN;
2697
+      more_menu.title     = TITLE_MORE_EN;
2698
+      #if ENABLED(USER_CMD_1_ENABLE)
2699
+        more_menu.custom1 = MORE_CUSTOM1_TEXT_EN;
2700
+      #endif
2701
+      #if ENABLED(USER_CMD_2_ENABLE)
2702
+        more_menu.custom2 = MORE_CUSTOM2_TEXT_EN;
2703
+      #endif
2704
+      #if ENABLED(USER_CMD_3_ENABLE)
2705
+        more_menu.custom3 = MORE_CUSTOM3_TEXT_EN;
2706
+      #endif
2707
+      #if ENABLED(USER_CMD_4_ENABLE)
2708
+        more_menu.custom4 = MORE_CUSTOM4_TEXT_EN;
2709
+      #endif
2710
+      #if ENABLED(USER_CMD_5_ENABLE)
2711
+        more_menu.custom5 = MORE_CUSTOM5_TEXT_EN;
2712
+      #endif
2713
+      #if ENABLED(USER_CMD_6_ENABLE)
2714
+        more_menu.custom6 = MORE_CUSTOM6_TEXT_EN;
2715
+      #endif
2716
+      #if ENABLED(USER_CMD_7_ENABLE)
2717
+        more_menu.custom7 = MORE_CUSTOM7_TEXT_EN;
2718
+      #endif
2446 2719
       //
2447 2720
       filesys_menu.title   = TITLE_FILESYS_EN;
2448 2721
       filesys_menu.sd_sys  = SD_CARD_TEXT_EN;
2449 2722
       filesys_menu.usb_sys = U_DISK_TEXT_EN;
2450 2723
       // WIFI
2451
-      wifi_menu.title = WIFI_TEXT;
2724
+      wifi_menu.title     = WIFI_TEXT;
2452 2725
       wifi_menu.cloud     = CLOUD_TEXT_EN;
2453 2726
       wifi_menu.reconnect = WIFI_RECONNECT_TEXT_EN;
2454 2727
 
@@ -2458,6 +2731,7 @@ void disp_language_init() {
2458 2731
       cloud_menu.unbind       = CLOUD_UNBIND_EN;
2459 2732
       cloud_menu.unbinding    = CLOUD_UNBINDED_EN;
2460 2733
       cloud_menu.disconnected = CLOUD_DISCONNECTED_EN;
2734
+      cloud_menu.unbinded     = CLOUD_UNBINDED_EN;
2461 2735
       cloud_menu.disable      = CLOUD_DISABLE_EN;
2462 2736
       //
2463 2737
       about_menu.title   = TITLE_ABOUT_EN;

+ 19
- 11
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h Vedi File

@@ -118,6 +118,7 @@ typedef struct machine_common_disp{
118 118
   const char *ProbeZspeed;
119 119
   const char *enable;
120 120
   const char *disable;
121
+  const char *locked;
121 122
   const char *z_min;
122 123
   const char *z_max;
123 124
 
@@ -456,6 +457,13 @@ extern filesys_menu_def filesys_menu;
456 457
 
457 458
 typedef struct more_menu_disp {
458 459
   const char *title;
460
+  const char *custom1;
461
+  const char *custom2;
462
+  const char *custom3;
463
+  const char *custom4;
464
+  const char *custom5;
465
+  const char *custom6;
466
+  const char *custom7;
459 467
   const char *back;
460 468
 } more_menu_def;
461 469
 
@@ -757,15 +765,15 @@ extern eeprom_def eeprom_menu;
757 765
 #define AXIS_Y_DEC_TEXT     "Y-"
758 766
 #define AXIS_Z_ADD_TEXT     "Z+"
759 767
 #define AXIS_Z_DEC_TEXT     "Z-"
760
-#define TEXT_001MM          "0.01mm"
761
-#define TEXT_005MM          "0.05mm"
762
-#define TEXT_01MM           "0.1mm"
763
-#define TEXT_1MM            "1mm"
764
-#define TEXT_10MM           "10mm"
768
+#define TEXT_001MM          "0.01 mm"
769
+#define TEXT_005MM          "0.05 mm"
770
+#define TEXT_01MM           "0.1 mm"
771
+#define TEXT_1MM            "1 mm"
772
+#define TEXT_10MM           "10 mm"
765 773
 
766
-#define EXTRUDE_1MM_TEXT    "1mm"
767
-#define EXTRUDE_5MM_TEXT    "5mm"
768
-#define EXTRUDE_10MM_TEXT   "10mm"
774
+#define EXTRUDE_1MM_TEXT    "1 mm"
775
+#define EXTRUDE_5MM_TEXT    "5 mm"
776
+#define EXTRUDE_10MM_TEXT   "10 mm"
769 777
 
770 778
 #define STEP_1PERCENT       "1%"
771 779
 #define STEP_5PERCENT       "5%"
@@ -819,6 +827,6 @@ extern eeprom_def eeprom_menu;
819 827
 #define DIALOG_UPDATE_WIFI_WEB_EN       "Updating wifi model web data"
820 828
 #define DIALOG_UPDATE_NO_DEVICE_EN      "Please check whether\nmemory device inserted!"
821 829
 
822
-#define ZOFFSET_STEP001                 "0.01mm"
823
-#define ZOFFSET_STEP01                  "0.1mm"
824
-#define ZOFFSET_STEP1                   "1mm"
830
+#define ZOFFSET_STEP001                 "0.01 mm"
831
+#define ZOFFSET_STEP01                  "0.1 mm"
832
+#define ZOFFSET_STEP1                   "1 mm"

+ 20
- 1
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp Vedi File

@@ -55,10 +55,29 @@ WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) {
55 55
   static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) {
56 56
     if (dev) timer_set_mode(dev, ch, TIMER_DISABLED);
57 57
   }
58
+  static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) {
59
+    if (with_irq) usart_enable(usart_device);
60
+    else {
61
+      usart_reg_map *regs = usart_device->regs;
62
+	    regs->CR1 |= (USART_CR1_TE | USART_CR1_RE);// don't change the word length etc, and 'or' in the patten not overwrite |USART_CR1_M_8N1);
63
+      regs->CR1 |= USART_CR1_UE;
64
+    }
65
+  }
66
+
58 67
 #elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4
59 68
   #define disable_timer_if_necessary(dev, ch) ((void)0)
69
+
70
+  static void usart_enable_no_irq(usart_dev *usart_device, bool with_irq) {
71
+    if (with_irq) usart_enable(usart_device);
72
+    else {
73
+      usart_reg_map *regs = usart_device->regs;
74
+	    regs->CR1 |= (USART_CR1_TE | USART_CR1_RE);// don't change the word length etc, and 'or' in the patten not overwrite |USART_CR1_M_8N1);
75
+      regs->CR1 |= USART_CR1_UE;
76
+    }
77
+  }
60 78
 #else
61 79
   #warning "Unsupported STM32 series; timer conflicts are possible"
80
+  #define usart_enable_no_irq(X, Y) usart_enable(X)
62 81
 #endif
63 82
 
64 83
 void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); }
@@ -89,7 +108,7 @@ void WifiSerial::begin(uint32 baud, uint8_t config) {
89 108
                            txi->gpio_device, txi->gpio_bit,
90 109
                            config);
91 110
   usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud);
92
-  usart_enable(this->usart_device);
111
+  usart_enable_no_irq(this->usart_device, baud == WIFI_BAUDRATE);
93 112
 }
94 113
 
95 114
 void WifiSerial::end(void) {

+ 2
- 1
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h Vedi File

@@ -89,8 +89,9 @@ class WifiSerial {
89 89
 
90 90
     int wifi_rb_is_full(void);
91 91
 
92
-  private:
92
+
93 93
     struct usart_dev *usart_device;
94
+    private:
94 95
     uint8 tx_pin;
95 96
     uint8 rx_pin;
96 97
 };

+ 316
- 293
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp Vedi File

@@ -26,6 +26,7 @@
26 26
 #include "draw_ui.h"
27 27
 #include "wifi_module.h"
28 28
 #include "wifi_upload.h"
29
+#include "SPI_TFT.h"
29 30
 
30 31
 #if ENABLED(MKS_WIFI_MODULE)
31 32
 
@@ -36,6 +37,8 @@
36 37
 #include "../../../../lcd/marlinui.h"
37 38
 #include "../../../../sd/cardreader.h"
38 39
 #include "../../../../module/planner.h"
40
+#include "../../../../module/servo.h"
41
+#include "../../../../module/probe.h"
39 42
 #if ENABLED(POWER_LOSS_RECOVERY)
40 43
   #include "../../../../feature/powerloss.h"
41 44
 #endif
@@ -109,10 +112,9 @@ extern IP_PARA ipPara;
109 112
 extern CLOUD_PARA cloud_para;
110 113
 
111 114
 extern bool once_flag, flash_preview_begin, default_preview_flg, gcode_preview_over;
115
+extern bool flash_dma_mode;
112 116
 
113
-uint32_t getWifiTick() {
114
-  return millis();
115
-}
117
+uint32_t getWifiTick() { return millis(); }
116 118
 
117 119
 uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick) {
118 120
   if (lastTick <= curTick)
@@ -149,40 +151,123 @@ void mount_file_sys(uint8_t disk_type) {
149 151
   }
150 152
 }
151 153
 
152
-static void dma_init() {
153
-  #if 0
154
-  __HAL_RCC_DMA1_CLK_ENABLE();
155
-
156
-  //HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
157
-  HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 4, 0);
158
-  HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
159
-
160
-  hdma_usart1_rx.Instance = DMA1_Channel5;
161
-  //hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4;
162
-  hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
163
-  hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
164
-  hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
165
-  hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
166
-  hdma_usart1_rx.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE;
167
-  hdma_usart1_rx.Init.Mode = DMA_NORMAL;
168
-  hdma_usart1_rx.Init.Priority = DMA_PRIORITY_VERY_HIGH;
169
-  if (HAL_DMA_Init((DMA_HandleTypeDef *)&hdma_usart1_rx) != HAL_OK) {
170
-    Error_Handler();
154
+#include <libmaple/timer.h>
155
+#include <libmaple/util.h>
156
+#include <libmaple/rcc.h>
157
+
158
+#include <boards.h>
159
+#include <wirish.h>
160
+
161
+#include <libmaple/dma.h>
162
+#include <libmaple/bitband.h>
163
+
164
+#include <libmaple/libmaple.h>
165
+#include <libmaple/gpio.h>
166
+#include <libmaple/usart.h>
167
+#include <libmaple/ring_buffer.h>
168
+
169
+void changeFlashMode(const bool dmaMode) {
170
+  if (flash_dma_mode != dmaMode) {
171
+    flash_dma_mode = dmaMode;
172
+    if (!flash_dma_mode) {
173
+      dma_disable(DMA1, DMA_CH5);
174
+      dma_clear_isr_bits(DMA1, DMA_CH4);
175
+    }
171 176
   }
177
+}
172 178
 
179
+static bool longName2DosName(const char *longName, uint8_t *dosName) {
180
+  uint8_t i;
181
+  for (i = FILENAME_LENGTH; i--;) dosName[i] = '\0';
182
+  while (*longName) {
183
+    uint8_t c = *longName++;
184
+    if (c == '.') { // For a dot...
185
+      if (i == 0) return false;
186
+      strcat((char *)dosName, ".GCO");
187
+      break;
188
+    }
189
+    else {
190
+      if (c < 0x21 || c == 0x7F) return false;                  // Check size, non-printable characters
191
+      // Fail for illegal characters
192
+      PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
193
+      while (const uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
194
+      dosName[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0); // Uppercase required for 8.3 name
195
+    }
196
+    if (i >= 5) {
197
+      strcat((char *)dosName, "~1.GCO");
198
+      break;
199
+    }
200
+  }
201
+  return dosName[0] != '\0'; // Return true if any name was set
202
+}
173 203
 
174
-  HAL_DMA_Start_IT((DMA_HandleTypeDef *)&hdma_usart1_rx,
175
-      (uint32_t)&huart1.Instance->DR,
176
-      (uint32_t)(&WifiRxFifo.uartTxBuffer[0]),
177
-      UART_RX_BUFFER_SIZE);
204
+static int storeRcvData(volatile uint8_t *bufToCpy, int32_t len) {
205
+  unsigned char tmpW = wifiDmaRcvFifo.write_cur;
178 206
 
179
-    //HAL_UART_Receive_DMA(&huart1,(uint8_t*)&WifiRxFifo.uartTxBuffer[0], UART_RX_BUFFER_SIZE);
207
+  if (len > UDISKBUFLEN) return 0;
180 208
 
181
-      /* Enable the DMA transfer for the receiver request by setting the DMAR bit
182
-       in the UART CR3 register */
183
-      SET_BIT(huart1.Instance->CR3, USART_CR3_DMAR);
209
+  if (wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) {
210
+    memcpy((unsigned char *) wifiDmaRcvFifo.bufferAddr[tmpW], (uint8_t *)bufToCpy, len);
211
+    wifiDmaRcvFifo.state[tmpW] = udisk_buf_full;
212
+    wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM;
213
+    return 1;
214
+  }
215
+
216
+  return 0;
217
+}
218
+
219
+static void esp_dma_pre() {
220
+  dma_channel_reg_map *channel_regs = dma_tube_regs(DMA1, DMA_CH5);
221
+
222
+  CBI32(channel_regs->CCR, 0);
223
+  channel_regs->CMAR = (uint32_t)WIFISERIAL.usart_device->rb->buf;
224
+  channel_regs->CNDTR = 0x0000;
225
+  channel_regs->CNDTR = UART_RX_BUFFER_SIZE;
226
+  DMA1->regs->IFCR = 0xF0000;
227
+  SBI32(channel_regs->CCR, 0);
228
+}
229
+
230
+static void dma_ch5_irq_handle() {
231
+    uint8 status_bits = dma_get_isr_bits(DMA1, DMA_CH5);
232
+    dma_clear_isr_bits(DMA1, DMA_CH5);
233
+    if (status_bits & 0x8) {
234
+      // DMA transmit Error
235
+    }
236
+    else if (status_bits & 0x2) {
237
+      // DMA transmit complete
238
+      if (esp_state == TRANSFER_IDLE)
239
+        esp_state = TRANSFERING;
240
+
241
+      if (storeRcvData(WIFISERIAL.usart_device->rb->buf, UART_RX_BUFFER_SIZE)) {
242
+        esp_dma_pre();
243
+        if (wifiTransError.flag != 0x1)
244
+          WIFI_IO1_RESET();
245
+      }
246
+      else {
247
+        WIFI_IO1_SET();
248
+        esp_state = TRANSFER_STORE;
249
+      }
250
+    }
251
+    else if (status_bits & 0x4) {
252
+      // DMA transmit half
253
+      WIFI_IO1_SET();
254
+    }
255
+}
256
+static void wifi_usart_dma_init() {
257
+  dma_init(DMA1);
258
+  uint32_t flags = ( DMA_MINC_MODE | DMA_TRNS_CMPLT | DMA_HALF_TRNS | DMA_TRNS_ERR);
259
+  dma_xfer_size dma_bit_size = DMA_SIZE_8BITS;
260
+  dma_setup_transfer(DMA1, DMA_CH5, &USART1_BASE->DR, dma_bit_size,
261
+             (volatile void*)WIFISERIAL.usart_device->rb->buf, dma_bit_size, flags);// Transmit buffer DMA
262
+  dma_set_priority(DMA1, DMA_CH5, DMA_PRIORITY_LOW);
263
+  dma_attach_interrupt(DMA1, DMA_CH5, &dma_ch5_irq_handle);
264
+
265
+  dma_clear_isr_bits(DMA1, DMA_CH5);
266
+  dma_set_num_transfers(DMA1, DMA_CH5, UART_RX_BUFFER_SIZE);
267
+
268
+  bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 1);
269
+  dma_enable(DMA1, DMA_CH5);   // enable transmit
184 270
 
185
-  #endif
186 271
   for (uint8_t i = 0; i < TRANS_RCV_FIFO_BLOCK_NUM; i++) {
187 272
     wifiDmaRcvFifo.bufferAddr[i] = &bmp_public_buf[1024 * i];
188 273
     wifiDmaRcvFifo.state[i] = udisk_buf_empty;
@@ -193,113 +278,39 @@ static void dma_init() {
193 278
   wifiDmaRcvFifo.write_cur = 0;
194 279
 }
195 280
 
196
-static void wifi_deInit() {
197
-  #if 0
198
-  HAL_DMA_Abort((DMA_HandleTypeDef *)&hdma_usart1_rx);
199
-  HAL_DMA_DeInit((DMA_HandleTypeDef *)&hdma_usart1_rx);
200
-  __HAL_DMA_DISABLE((DMA_HandleTypeDef *)&hdma_usart1_rx);
201
-  #endif
202
-}
203
-
204
-extern uint8_t mksUsart1Rx;
205
-
206 281
 void esp_port_begin(uint8_t interrupt) {
207 282
   WifiRxFifo.uart_read_point = 0;
208 283
   WifiRxFifo.uart_write_point = 0;
209
-  #if 0
210
-  NVIC_InitTypeDef NVIC_InitStructure;
211 284
 
212
-  USART_InitTypeDef USART_InitStructure;
213
-  GPIO_InitTypeDef GPIO_InitStruct;
285
+  #if 1
214 286
 
215
-  WifiRxFifo.uart_read_point = 0;
216
-  WifiRxFifo.uart_write_point = 0;
217
-  memset((uint8_t*)WifiRxFifo.uartTxBuffer, 0, sizeof(WifiRxFifo.uartTxBuffer));
218
-
219
-  if (interrupt) {
220
-  #if TAN
221
-    wifi_deInit ();
222
-
223
-    //SZ_STM32_COMInit(COM1, 115200);
224
-    __HAL_UART_ENABLE_IT(USART1, USART_IT_RXNE);
225
-
226
-    USART_InitStructure.USART_BaudRate = 115200;        //���ڵIJ����ʣ�����115200 ��ߴ�4.5Mbits/s
227
-    USART_InitStructure.USART_WordLength = USART_WordLength_8b; //�����ֳ���(8λ��9λ)
228
-    USART_InitStructure.USART_StopBits = USART_StopBits_1;    //�����õ�ֹͣλ-֧��1��2��ֹͣλ
229
-    USART_InitStructure.USART_Parity = USART_Parity_No;     //����żУ��
230
-    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //��Ӳ��������
231
-    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //˫��ģʽ��ʹ�ܷ��ͺͽ���
232
-
233
-    __HAL_RCC_USART1_CLK_ENABLE();
234
-
235
-    GPIO_InitStruct.Pin = TFT_WIFI_TX_Pin|TFT_WIFI_RX_Pin;
236
-    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
237
-    GPIO_InitStruct.Pull = GPIO_PULLUP;
238
-    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
239
-    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
240
-    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
241
-      GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
242
-      GPIO_InitStruct.Pin = TFT_WIFI_RX_Pin;
243
-      HAL_GPIO_Init(GPIOA,&GPIO_InitStruct);
244
-
245
-    USART_Init(USART1, &USART_InitStructure);
246
-
247
-    NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
248
-  //  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
249
-  //  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
250
-    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
251
-    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
252
-    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
253
-
254
-    NVIC_Init(&NVIC_InitStructure);
255
-    #else
256
-    HAL_UART_DeInit(&huart1);
257
-    MX_USART1_UART_Init(3);
258
-    //__HAL_UART_ENABLE_IT(&huart1, UART_IT_RXNE);
259
-    HAL_UART_Receive_IT(&huart1,&mksUsart1Rx,1);
287
+    #if ENABLED(MKS_WIFI_MODULE)
288
+      WIFISERIAL.end();
289
+      if (interrupt) {
290
+        for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
291
+        WIFISERIAL.begin(WIFI_BAUDRATE);
292
+        uint32_t serial_connect_timeout = millis() + 1000UL;
293
+        while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
294
+      }
295
+      else {
296
+        WIFISERIAL.usart_device->regs->CR1 &= ~USART_CR1_RXNEIE;
297
+        WIFISERIAL.begin(WIFI_UPLOAD_BAUDRATE);
298
+        wifi_usart_dma_init();
299
+      }
260 300
     #endif
261
-  }
262
-  else{
263
-    #if 0
264
-    NVIC_DisableIRQ(SZ_STM32_COM1_IRQn);
265
-
266
-    USART_Cmd(SZ_STM32_COM1, DISABLE);
267
-
268
-    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, DISABLE);
269
-    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
270 301
 
271
-    SZ_STM32_COMInit(COM1, 1958400);
302
+  #else
272 303
 
273
-    USART_Cmd(SZ_STM32_COM1, ENABLE);
274
-
275
-    wifi_delay(10);
276
-
277
-    dma_init();
304
+    #if MKS_WIFI_MODULE
305
+      WIFISERIAL.end();
306
+      for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
307
+      WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
308
+      uint32_t serial_connect_timeout = millis() + 1000UL;
309
+      while (PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
278 310
     #endif
279
-    HAL_UART_DeInit(&huart1);
280
-    MX_USART1_UART_Init(5);
281
-        //dma1_5_IRQ_sel = 1;
282
-    dma_init();
283
-  }
284
-  #endif
285
-
286
-  #if ENABLED(MKS_WIFI_MODULE)
287
-    WIFISERIAL.end();
288
-    for (uint16_t i = 0; i < 65535; i++) { /*nada*/ }
289
-    WIFISERIAL.begin(interrupt ? WIFI_BAUDRATE : WIFI_UPLOAD_BAUDRATE);
311
+    if (!interrupt) wifi_usart_dma_init();
290 312
 
291
-    const millis_t serial_connect_timeout = millis() + 1000UL;
292
-    while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
293
-
294
-    if (interrupt) {
295
-      //for (uint8_t i=0;i<100;i++) WIFISERIAL.write(0x33);
296
-    }
297
-    else {
298
-      //for (uint16_t i=0;i<65535;i++); //WIFISERIAL.write(0x33);
299
-    }
300 313
   #endif
301
-
302
-  if (!interrupt) dma_init();
303 314
 }
304 315
 
305 316
 #if ENABLED(MKS_WIFI_MODULE)
@@ -441,10 +452,12 @@ int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len) {
441 452
     ZERO(buf_to_wifi);
442 453
     index_to_wifi = 0;
443 454
   }
455
+  return 1;
444 456
 }
445 457
 
446 458
 
447
-int send_to_wifi(char *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); }
459
+#define SEND_OK_TO_WIFI send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n"))
460
+int send_to_wifi(uint8_t *buf, int len) { return package_to_wifi(WIFI_TRANS_INF, buf, len); }
448 461
 
449 462
 void set_cur_file_sys(int fileType) { gCfgItems.fileSysType = fileType; }
450 463
 
@@ -463,9 +476,9 @@ void get_file_list(char *path) {
463 476
 char wait_ip_back_flag = 0;
464 477
 
465 478
 typedef struct {
466
-  char write_buf[513];
467 479
   int write_index;
468 480
   uint8_t saveFileName[30];
481
+  uint8_t fileTransfer;
469 482
   uint32_t fileLen;
470 483
   uint32_t tick_begin;
471 484
   uint32_t tick_end;
@@ -475,22 +488,43 @@ FILE_WRITER file_writer;
475 488
 
476 489
 int32_t lastFragment = 0;
477 490
 
478
-char lastBinaryCmd[50] = { 0 };
491
+char saveFilePath[50];
479 492
 
480
-int total_write = 0;
481
-char binary_head[2] = { 0, 0 };
482
-unsigned char binary_data_len = 0;
493
+static SdFile upload_file, *upload_curDir;
494
+static filepos_t pos;
483 495
 
484 496
 int write_to_file(char *buf, int len) {
485
-  for (int i = 0; i < len; i++) {
486
-    file_writer.write_buf[file_writer.write_index++] = buf[i];
497
+  int i;
498
+  int res = 0;
499
+
500
+  for (i = 0; i < len; i++) {
501
+    public_buf[file_writer.write_index++] = buf[i];
487 502
     if (file_writer.write_index >= 512) {
488
-      int res = card.write(file_writer.write_buf, file_writer.write_index);
489
-      if (res == -1) return -1;
490
-      ZERO(file_writer.write_buf);
503
+      res = upload_file.write(public_buf, file_writer.write_index);
504
+
505
+      if (res == -1) {
506
+        upload_file.close();
507
+        const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
508
+
509
+        if (upload_file.open(upload_curDir, fname, O_WRITE)) {
510
+          upload_file.setpos(&pos);
511
+          res = upload_file.write(public_buf, file_writer.write_index);
512
+        }
513
+      }
514
+      if (res == -1) {
515
+        return  -1;
516
+      }
517
+      upload_file.getpos(&pos);
491 518
       file_writer.write_index = 0;
492 519
     }
493 520
   }
521
+
522
+  if (res == -1) {
523
+    memset(public_buf, 0, sizeof(public_buf));
524
+    file_writer.write_index = 0;
525
+    return  -1;
526
+  }
527
+
494 528
   return 0;
495 529
 }
496 530
 
@@ -543,10 +577,8 @@ uint8_t Explore_Disk(char* path , uint8_t recu_level) {
543 577
   for (uint8_t i = 0; i < fileCnt; i++) {
544 578
     card.getfilename_sorted(SD_ORDER(i, fileCnt));
545 579
 
546
-    //if (card.longFilename[0] == 0)
547
-      strcpy(tmp, card.filename);
548
-    //else
549
-    //  strcpy(tmp, card.longFilename);
580
+    memset(tmp, 0, sizeof(tmp));
581
+    strcpy(tmp, card.filename);
550 582
 
551 583
     ZERO(Fstream);
552 584
     strcpy(Fstream, tmp);
@@ -584,6 +616,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
584 616
       switch (cmd_value) {
585 617
 
586 618
         case 20: // M20: Print SD / µdisk file
619
+          file_writer.fileTransfer = 0;
587 620
           if (uiCfg.print_state == IDLE) {
588 621
             int index = 0;
589 622
 
@@ -591,8 +624,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
591 624
               gCfgItems.fileSysType = FILE_SYS_SD;
592 625
               send_to_wifi((uint8_t *)"Begin file list\r\n", strlen("Begin file list\r\n"));
593 626
               get_file_list((char *)"0:/");
594
-              send_to_wifi((char *)"End file list\r\n", strlen("End file list\r\n"));
595
-              send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
627
+              send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n"));
628
+              SEND_OK_TO_WIFI;
596 629
               break;
597 630
             }
598 631
 
@@ -613,14 +646,14 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
613 646
                 get_file_list(path);
614 647
                 send_to_wifi((uint8_t *)"End file list\r\n", strlen("End file list\r\n"));
615 648
               }
616
-              send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
649
+              SEND_OK_TO_WIFI;
617 650
             }
618 651
           }
619 652
           break;
620 653
 
621 654
         case 21:
622 655
           /*init sd card*/
623
-          send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
656
+          SEND_OK_TO_WIFI;
624 657
           break;
625 658
 
626 659
         case 23:
@@ -632,15 +665,40 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
632 665
             if (strstr((char *)&tmpStr[index], ".g") || strstr((char *)&tmpStr[index], ".G")) {
633 666
               if (strlen((char *)&tmpStr[index]) < 80) {
634 667
                 ZERO(list_file.file_name[sel_id]);
668
+                ZERO(list_file.long_name[sel_id]);
669
+                uint8_t has_path_selected = 0;
635 670
 
636 671
                 if (gCfgItems.wifi_type == ESP_WIFI) {
637
-                  if (strncmp((char *)&tmpStr[index], "1:", 2) == 0)
672
+                  if (strncmp((char *)&tmpStr[index], "1:", 2) == 0) {
638 673
                     gCfgItems.fileSysType = FILE_SYS_SD;
639
-                  else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0)
674
+                    has_path_selected = 1;
675
+                  }
676
+                  else if (strncmp((char *)&tmpStr[index], "0:", 2) == 0) {
640 677
                     gCfgItems.fileSysType = FILE_SYS_USB;
678
+                    has_path_selected = 1;
679
+                  }
641 680
                   else if (tmpStr[index] != '/')
642
-                    strcat((char *)list_file.file_name[0], "/");
643
-                  strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
681
+                      strcat((char *)list_file.file_name[sel_id], "/");
682
+
683
+                  if (file_writer.fileTransfer == 1) {
684
+                    uint8_t dosName[FILENAME_LENGTH];
685
+                    uint8_t fileName[sizeof(list_file.file_name[sel_id])];
686
+                    fileName[0] = '\0';
687
+                    if (has_path_selected == 1) {
688
+                      strcat((char *)fileName, (char *)&tmpStr[index + 3]);
689
+                      strcat((char *)list_file.file_name[sel_id], "/");
690
+                    }
691
+                    else strcat((char *)fileName, (char *)&tmpStr[index]);
692
+                    if (!longName2DosName((const char *)fileName, dosName)) {
693
+                      strcpy(list_file.file_name[sel_id], "notValid");
694
+                    }
695
+                    strcat((char *)list_file.file_name[sel_id], (char *)dosName);
696
+                    strcat((char *)list_file.long_name[sel_id], (char *)dosName);
697
+                  }
698
+                  else {
699
+                    strcat((char *)list_file.file_name[sel_id], (char *)&tmpStr[index]);
700
+                    strcat((char *)list_file.long_name[sel_id], (char *)&tmpStr[index]);
701
+                  }
644 702
 
645 703
                 }
646 704
                 else
@@ -656,7 +714,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
656 714
                   send_to_wifi((uint8_t *)"file.open failed\r\n", strlen("file.open failed\r\n"));
657 715
                   strcpy(list_file.file_name[sel_id], "notValid");
658 716
                 }
659
-                send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
717
+                SEND_OK_TO_WIFI;
660 718
               }
661 719
             }
662 720
           }
@@ -680,6 +738,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
680 738
 
681 739
                   SdFile file;
682 740
                   SdFile *curDir;
741
+                  card.endFilePrint();
683 742
                   const char * const fname = card.diveToFile(true, curDir, cur_name);
684 743
                   if (!fname) return;
685 744
                   if (file.open(curDir, fname, O_READ)) {
@@ -726,7 +785,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
726 785
               lv_draw_printing();
727 786
             }
728 787
           }
729
-          send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
788
+          SEND_OK_TO_WIFI;
730 789
           break;
731 790
 
732 791
         case 25:
@@ -745,7 +804,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
745 804
             else
746 805
               default_preview_flg = true;
747 806
             lv_draw_printing();
748
-            send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
807
+            SEND_OK_TO_WIFI;
749 808
           }
750 809
           break;
751 810
 
@@ -762,7 +821,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
762 821
 
763 822
             lv_draw_ready_print();
764 823
 
765
-            send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
824
+            SEND_OK_TO_WIFI;
766 825
           }
767 826
           break;
768 827
 
@@ -805,8 +864,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
805 864
                   ZERO(tempBuf);
806 865
                   sprintf((char *)tempBuf, "Writing to file: %s\r\n", (char *)file_writer.saveFileName);
807 866
                   wifi_ret_ack();
808
-                  send_to_wifi((char *)tempBuf, strlen((char *)tempBuf));
809
-                  total_write = 0;
867
+                  send_to_wifi((uint8_t *)tempBuf, strlen((char *)tempBuf));
810 868
                   wifi_link_state = WIFI_WAIT_TRANS_START;
811 869
                 }
812 870
                 else {
@@ -822,7 +880,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
822 880
         case 991:
823 881
           ZERO(tempBuf);
824 882
           if (cmd_value == 105) {
825
-            send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
883
+            SEND_OK_TO_WIFI;
826 884
             sprintf((char *)tempBuf,"T:%.1f /%.1f B:%.1f /%.1f T0:%.1f /%.1f T1:%.1f /%.1f @:0 B@:0\r\n",
827 885
 
828 886
             (float)thermalManager.temp_hotend[0].celsius, (float)thermalManager.temp_hotend[0].target,
@@ -891,7 +949,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
891 949
           }
892 950
           else if (uiCfg.print_state == PAUSED) {
893 951
             wifi_ret_ack();
894
-            send_to_wifi((char *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n"));
952
+            send_to_wifi((uint8_t *)"M997 PAUSE\r\n", strlen("M997 PAUSE\r\n"));
895 953
           }
896 954
           else if (uiCfg.print_state == REPRINTING) {
897 955
             wifi_ret_ack();
@@ -913,8 +971,8 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
913 971
 
914 972
         case 115:
915 973
           ZERO(tempBuf);
916
-          send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
917
-          send_to_wifi((char *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n"));
974
+          SEND_OK_TO_WIFI;
975
+          send_to_wifi((uint8_t *)"FIRMWARE_NAME:Robin_nano\r\n", strlen("FIRMWARE_NAME:Robin_nano\r\n"));
918 976
           break;
919 977
 
920 978
         default:
@@ -935,7 +993,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
935 993
                 index++;
936 994
               }
937 995
               if (left - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line))
938
-                send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
996
+                SEND_OK_TO_WIFI;
939 997
               else
940 998
                 need_ok_later = true;
941 999
             }
@@ -961,7 +1019,7 @@ static void wifi_gcode_exec(uint8_t *cmd_line) {
961 1019
             index++;
962 1020
           }
963 1021
           if (left_g - WIFI_GCODE_BUFFER_LEAST_SIZE >= strlen((const char *)cmd_line))
964
-            send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
1022
+            SEND_OK_TO_WIFI;
965 1023
           else
966 1024
             need_ok_later = true;
967 1025
         }
@@ -1191,29 +1249,6 @@ void utf8_2_unicode(uint8_t *source,uint8_t Len) {
1191 1249
   COPY(source, FileName_unicode);
1192 1250
 }
1193 1251
 
1194
-char saveFilePath[50];
1195
-
1196
-static bool longName2DosName(const char* longName, uint8_t* dosName) {
1197
-  uint8_t i = 11;
1198
-  while (i--) dosName[i] = '\0';
1199
-  while (*longName) {
1200
-    uint8_t c = *longName++;
1201
-    if (c == '.') {                   // For a dot...
1202
-      if (i == 0) return false;
1203
-      else { strcat((char *)dosName,".GCO"); return dosName[0] != '\0'; }
1204
-    }
1205
-    else {
1206
-      // Fail for illegal characters
1207
-      PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
1208
-      while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
1209
-      if (c < 0x21 || c == 0x7F) return false;           // Check size, non-printable characters
1210
-      dosName[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name
1211
-    }
1212
-    if (i >= 5) strcat((char *)dosName,"~1.GCO");
1213
-  }
1214
-  return dosName[0] != '\0';              // Return true if any name was set
1215
-}
1216
-
1217 1252
 static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1218 1253
   uint8_t fileNameLen = *msg;
1219 1254
 
@@ -1226,7 +1261,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1226 1261
 
1227 1262
   utf8_2_unicode(file_writer.saveFileName,fileNameLen);
1228 1263
 
1229
-  ZERO(file_writer.write_buf);
1264
+  ZERO(public_buf);
1230 1265
 
1231 1266
   if (strlen((const char *)file_writer.saveFileName) > sizeof(saveFilePath))
1232 1267
     return;
@@ -1234,11 +1269,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1234 1269
   ZERO(saveFilePath);
1235 1270
 
1236 1271
   if (gCfgItems.fileSysType == FILE_SYS_SD) {
1237
-    //sprintf((char *)saveFilePath, "/%s", file_writer.saveFileName);
1238
-    card.mount();
1239
-
1240
-    //ZERO(list_file.long_name[sel_id]);
1241
-    //memcpy(list_file.long_name[sel_id],file_writer.saveFileName,sizeof(list_file.long_name[sel_id]));
1272
+    TERN_(SDSUPPORT, card.mount());
1242 1273
   }
1243 1274
   else if (gCfgItems.fileSysType == FILE_SYS_USB) {
1244 1275
 
@@ -1266,26 +1297,19 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1266 1297
       lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
1267 1298
       return;
1268 1299
     }
1269
-    sprintf((char *)saveFilePath, "/%s", dosName);
1270
-
1271
-    ZERO(list_file.long_name[sel_id]);
1272
-    memcpy(list_file.long_name[sel_id], dosName, sizeof(dosName));
1300
+    sprintf((char *)saveFilePath, "%s", dosName);
1273 1301
 
1274
-    char *cur_name=strrchr((const char *)saveFilePath,'/');
1302
+    card.cdroot();
1303
+    upload_file.close();
1304
+    const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
1275 1305
 
1276
-    SdFile file;
1277
-    SdFile *curDir;
1278
-    card.endFilePrint();
1279
-    const char * const fname = card.diveToFile(true, curDir, cur_name);
1280
-    if (!fname) return;
1281
-    if (file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
1282
-      gCfgItems.curFilesize = file.fileSize();
1283
-    }
1284
-    else {
1306
+    if (!upload_file.open(upload_curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
1285 1307
       clear_cur_ui();
1286 1308
       upload_result = 2;
1309
+
1287 1310
       wifiTransError.flag = 1;
1288 1311
       wifiTransError.start_tick = getWifiTick();
1312
+
1289 1313
       lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
1290 1314
       return;
1291 1315
     }
@@ -1302,22 +1326,23 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1302 1326
   lv_task_handler();
1303 1327
 
1304 1328
   file_writer.tick_begin = getWifiTick();
1329
+
1330
+  file_writer.fileTransfer = 1;
1305 1331
 }
1306 1332
 
1307
-#define FRAG_MASK _BV32(31)
1333
+#define FRAG_MASK ~_BV32(31)
1308 1334
 
1309 1335
 static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
1310 1336
   uint32_t frag = *((uint32_t *)msg);
1311
-
1312 1337
   if ((frag & FRAG_MASK) != (uint32_t)(lastFragment + 1)) {
1313
-    ZERO(file_writer.write_buf);
1338
+    ZERO(public_buf);
1314 1339
     file_writer.write_index = 0;
1315 1340
     wifi_link_state = WIFI_CONNECTED;
1316 1341
     upload_result = 2;
1317 1342
   }
1318 1343
   else {
1319 1344
     if (write_to_file((char *)msg + 4, msgLen - 4) < 0) {
1320
-      ZERO(file_writer.write_buf);
1345
+      ZERO(public_buf);
1321 1346
       file_writer.write_index = 0;
1322 1347
       wifi_link_state = WIFI_CONNECTED;
1323 1348
       upload_result = 2;
@@ -1325,16 +1350,31 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
1325 1350
     }
1326 1351
     lastFragment = frag;
1327 1352
 
1328
-    if ((frag & (~FRAG_MASK))) {
1329
-      int res = card.write(file_writer.write_buf, file_writer.write_index);
1353
+    if ((frag & (~FRAG_MASK)) != 0) {
1354
+      int res = upload_file.write(public_buf, file_writer.write_index);
1330 1355
       if (res == -1) {
1331
-        ZERO(file_writer.write_buf);
1356
+        upload_file.close();
1357
+        const char * const fname = card.diveToFile(true, upload_curDir, saveFilePath);
1358
+        if (upload_file.open(upload_curDir, fname, O_WRITE)) {
1359
+          upload_file.setpos(&pos);
1360
+          res = upload_file.write(public_buf, file_writer.write_index);
1361
+        }
1362
+      }
1363
+      upload_file.close();
1364
+      SdFile file, *curDir;
1365
+      const char * const fname = card.diveToFile(true, curDir, saveFilePath);
1366
+      if (file.open(curDir, fname, O_RDWR)) {
1367
+        gCfgItems.curFilesize = file.fileSize();
1368
+        file.close();
1369
+      }
1370
+      else {
1371
+        ZERO(public_buf);
1332 1372
         file_writer.write_index = 0;
1333 1373
         wifi_link_state = WIFI_CONNECTED;
1334 1374
         upload_result = 2;
1335 1375
         return;
1336 1376
       }
1337
-      ZERO(file_writer.write_buf);
1377
+      ZERO(public_buf);
1338 1378
       file_writer.write_index = 0;
1339 1379
       file_writer.tick_end = getWifiTick();
1340 1380
       upload_time = getWifiTickDiff(file_writer.tick_begin, file_writer.tick_end) / 1000;
@@ -1342,7 +1382,6 @@ static void file_fragment_msg_handle(uint8_t * msg, uint16_t msgLen) {
1342 1382
       wifi_link_state = WIFI_CONNECTED;
1343 1383
       upload_result = 3;
1344 1384
     }
1345
-
1346 1385
   }
1347 1386
 }
1348 1387
 
@@ -1453,7 +1492,6 @@ void esp_data_parser(char *cmdRxBuf, int len) {
1453 1492
         esp_msg_index = 0;
1454 1493
         return;
1455 1494
       }
1456
-
1457 1495
       if ((charAtArray(esp_msg_buf, esp_msg_index,  ESP_PROTOC_HEAD) != -1) && (charAtArray(esp_msg_buf, esp_msg_index, ESP_PROTOC_TAIL) != -1))
1458 1496
         loop_again = true;
1459 1497
     }
@@ -1461,19 +1499,6 @@ void esp_data_parser(char *cmdRxBuf, int len) {
1461 1499
 }
1462 1500
 
1463 1501
 int32_t tick_net_time1, tick_net_time2;
1464
-
1465
-int storeRcvData(int32_t len) {
1466
-  unsigned char tmpW = wifiDmaRcvFifo.write_cur;
1467
-  if (len <= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpW] == udisk_buf_empty) {
1468
-    for (uint16_t i = 0; i < len; i++)
1469
-      wifiDmaRcvFifo.bufferAddr[tmpW][i] = WIFISERIAL.read();
1470
-    wifiDmaRcvFifo.state[tmpW] = udisk_buf_full;
1471
-    wifiDmaRcvFifo.write_cur = (tmpW + 1) % TRANS_RCV_FIFO_BLOCK_NUM;
1472
-    return 1;
1473
-  }
1474
-  return 0;
1475
-}
1476
-
1477 1502
 int32_t readWifiFifo(uint8_t *retBuf, uint32_t bufLen) {
1478 1503
   unsigned char tmpR = wifiDmaRcvFifo.read_cur;
1479 1504
   if (bufLen >= UDISKBUFLEN && wifiDmaRcvFifo.state[tmpR] == udisk_buf_full) {
@@ -1496,20 +1521,33 @@ void stopEspTransfer() {
1496 1521
     wifiTransError.start_tick = getWifiTick();
1497 1522
     card.removeFile((const char *)saveFilePath);
1498 1523
   }
1499
-  else {
1500
-  }
1524
+
1501 1525
   wifi_delay(200);
1502 1526
   WIFI_IO1_SET();
1503
-  //exchangeFlashMode(1);  //change spi flash to use dma mode
1527
+
1528
+  // disable dma
1529
+  dma_clear_isr_bits(DMA1, DMA_CH5);
1530
+  bb_peri_set_bit(&USART1_BASE->CR3, USART_CR3_DMAR_BIT, 0);
1531
+  dma_disable(DMA1, DMA_CH5);
1532
+
1533
+  wifi_delay(200);
1534
+  changeFlashMode(true); // Set SPI flash to use DMA mode
1504 1535
   esp_port_begin(1);
1536
+  wifi_delay(200);
1537
+
1538
+  W25QXX.init(SPI_QUARTER_SPEED);
1539
+
1540
+  TERN_(HAS_TFT_LVGL_UI_SPI, SPI_TFT.spi_init(SPI_FULL_SPEED));
1541
+  TERN_(HAS_SERVOS, servo_init());
1542
+  TERN_(HAS_Z_SERVO_PROBE, probe.servo_probe_init());
1543
+
1505 1544
   if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
1506 1545
 }
1507 1546
 
1508 1547
 void wifi_rcv_handle() {
1509 1548
   int32_t len = 0;
1510
-  uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = { 0 };
1549
+  uint8_t ucStr[(UART_RX_BUFFER_SIZE) + 1] = {0};
1511 1550
   int8_t getDataF = 0;
1512
-
1513 1551
   if (wifi_link_state == WIFI_TRANS_FILE) {
1514 1552
     #if 0
1515 1553
       if (WIFISERIAL.available() == UART_RX_BUFFER_SIZE) {
@@ -1531,9 +1569,9 @@ void wifi_rcv_handle() {
1531 1569
       getDataF = 1;
1532 1570
     }
1533 1571
     if (esp_state == TRANSFER_STORE) {
1534
-      if (storeRcvData(UART_RX_BUFFER_SIZE)) {
1572
+      if (storeRcvData(WIFISERIAL.usart_device->rb->buf, UART_RX_BUFFER_SIZE)) {
1535 1573
         esp_state = TRANSFERING;
1536
-        //esp_dma_pre();
1574
+        esp_dma_pre();
1537 1575
         if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
1538 1576
       }
1539 1577
       else
@@ -1541,13 +1579,11 @@ void wifi_rcv_handle() {
1541 1579
     }
1542 1580
   }
1543 1581
   else {
1544
-    //len = readUsartFifo((SZ_USART_FIFO *)&WifiRxFifo, (int8_t *)ucStr, UART_RX_BUFFER_SIZE);
1545 1582
     len = readWifiBuf((int8_t *)ucStr, UART_RX_BUFFER_SIZE);
1546 1583
     if (len > 0) {
1547 1584
       esp_data_parser((char *)ucStr, len);
1548
-
1549 1585
       if (wifi_link_state == WIFI_TRANS_FILE) {
1550
-        //exchangeFlashMode(0);  //change spi flash not use dma mode
1586
+        changeFlashMode(false); // Set SPI flash to use non-DMA mode
1551 1587
         wifi_delay(10);
1552 1588
         esp_port_begin(0);
1553 1589
         wifi_delay(10);
@@ -1558,7 +1594,7 @@ void wifi_rcv_handle() {
1558 1594
     }
1559 1595
     if (need_ok_later &&  (queue.length < BUFSIZE)) {
1560 1596
       need_ok_later = false;
1561
-      send_to_wifi((char *)"ok\r\n", strlen("ok\r\n"));
1597
+      send_to_wifi((uint8_t *)"ok\r\n", strlen("ok\r\n"));
1562 1598
     }
1563 1599
   }
1564 1600
 
@@ -1569,7 +1605,7 @@ void wifi_rcv_handle() {
1569 1605
     tick_net_time2 = getWifiTick();
1570 1606
 
1571 1607
     if (wifi_link_state == WIFI_TRANS_FILE) {
1572
-      if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 4500)) {
1608
+      if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 8000) {
1573 1609
         wifi_link_state = WIFI_CONNECTED;
1574 1610
         upload_result = 2;
1575 1611
         clear_cur_ui();
@@ -1577,11 +1613,10 @@ void wifi_rcv_handle() {
1577 1613
         lv_draw_dialog(DIALOG_TYPE_UPLOAD_FILE);
1578 1614
       }
1579 1615
     }
1580
-
1581
-    if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 10000))
1616
+    if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 10000)
1582 1617
       wifi_link_state = WIFI_NOT_CONFIG;
1583 1618
 
1584
-    if ((tick_net_time1 != 0) && (getWifiTickDiff(tick_net_time1, tick_net_time2) > 120000)) {
1619
+    if (tick_net_time1 && getWifiTickDiff(tick_net_time1, tick_net_time2) > 120000) {
1585 1620
       wifi_link_state = WIFI_NOT_CONFIG;
1586 1621
       wifi_reset();
1587 1622
       tick_net_time1 = getWifiTick();
@@ -1598,7 +1633,10 @@ void wifi_rcv_handle() {
1598 1633
 }
1599 1634
 
1600 1635
 void wifi_looping() {
1601
-  do { wifi_rcv_handle(); } while (wifi_link_state == WIFI_TRANS_FILE);
1636
+  do {
1637
+    wifi_rcv_handle();
1638
+    watchdog_refresh();
1639
+  } while (wifi_link_state == WIFI_TRANS_FILE);
1602 1640
 }
1603 1641
 
1604 1642
 void mks_esp_wifi_init() {
@@ -1616,32 +1654,8 @@ void mks_esp_wifi_init() {
1616 1654
   wifi_reset();
1617 1655
 
1618 1656
   #if 0
1619
-    res = f_open(&esp_upload.uploadFile, ESP_FIRMWARE_FILE,  FA_OPEN_EXISTING | FA_READ);
1620
-
1621
-    if (res ==  FR_OK) {
1622
-      f_close(&esp_upload.uploadFile);
1623
-
1624
-      wifi_delay(2000);
1625
-
1626
-      if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20) {
1627
-        return;
1628
-      }
1629
-
1630
-      clear_cur_ui();
1631
-
1632
-      draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE);
1633
-
1634
-      if (wifi_upload(0) >= 0) {
1635
-
1636
-        f_unlink("1:/MKS_WIFI_CUR");
1637
-        f_rename(ESP_FIRMWARE_FILE,"/MKS_WIFI_CUR");
1638
-      }
1639
-      draw_return_ui();
1640
-
1641
-      update_flag = 1;
1642
-    }
1643
-    if (update_flag == 0) {
1644
-      res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE,  FA_OPEN_EXISTING | FA_READ);
1657
+  if (update_flag == 0) {
1658
+    res = f_open(&esp_upload.uploadFile, ESP_WEB_FIRMWARE_FILE,  FA_OPEN_EXISTING | FA_READ);
1645 1659
 
1646 1660
       if (res ==  FR_OK) {
1647 1661
         f_close(&esp_upload.uploadFile);
@@ -1694,32 +1708,42 @@ void mks_esp_wifi_init() {
1694 1708
   wifi_link_state = WIFI_NOT_CONFIG;
1695 1709
 }
1696 1710
 
1697
-#define BUF_INC_POINTER(p)  ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0 : (p + 1))
1698 1711
 
1699
-int usartFifoAvailable(SZ_USART_FIFO *fifo) {
1700
-  int diff = fifo->uart_write_point - fifo->uart_read_point;
1701
-  if (diff < 0) diff += UART_FIFO_BUFFER_SIZE;
1702
-  return diff;
1703
-}
1712
+void mks_wifi_firmware_update() {
1713
+  card.openFileRead((char *)ESP_FIRMWARE_FILE);
1714
+
1715
+  if (card.isFileOpen()) {
1716
+    card.closefile();
1717
+
1718
+    wifi_delay(2000);
1704 1719
 
1705
-int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) {
1706
-  int i = 0 ;
1707
-  while (i < len && fifo->uart_read_point != fifo->uart_write_point) {
1708
-    buf[i++] = fifo->uartTxBuffer[fifo->uart_read_point];
1709
-    fifo->uart_read_point = BUF_INC_POINTER(fifo->uart_read_point);
1720
+    if (usartFifoAvailable((SZ_USART_FIFO *)&WifiRxFifo) < 20)
1721
+      return;
1722
+
1723
+    clear_cur_ui();
1724
+
1725
+    lv_draw_dialog(DIALOG_TYPE_UPDATE_ESP_FIRMARE);
1726
+
1727
+    lv_task_handler();
1728
+    watchdog_refresh();
1729
+
1730
+    if (wifi_upload(0) >= 0) {
1731
+      card.removeFile((char *)ESP_FIRMWARE_FILE_RENAME);
1732
+      SdFile file, *curDir;
1733
+      const char * const fname = card.diveToFile(true, curDir, ESP_FIRMWARE_FILE);
1734
+      if (file.open(curDir, fname, O_READ)) {
1735
+        file.rename(curDir, (char *)ESP_FIRMWARE_FILE_RENAME);
1736
+        file.close();
1737
+      }
1738
+    }
1739
+    clear_cur_ui();
1710 1740
   }
1711
-  return i;
1712 1741
 }
1713 1742
 
1714
-int writeUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len) {
1715
-  if (buf == 0 || len <= 0) return -1;
1743
+#define BUF_INC_POINTER(p)  ((p + 1 == UART_FIFO_BUFFER_SIZE) ? 0:(p + 1))
1716 1744
 
1717
-  int i = 0 ;
1718
-  while (i < len && fifo->uart_read_point != BUF_INC_POINTER(fifo->uart_write_point)) {
1719
-    fifo->uartTxBuffer[fifo->uart_write_point] = buf[i++];
1720
-    fifo->uart_write_point = BUF_INC_POINTER(fifo->uart_write_point);
1721
-  }
1722
-  return i;
1745
+int usartFifoAvailable(SZ_USART_FIFO *fifo) {
1746
+  return WIFISERIAL.available();
1723 1747
 }
1724 1748
 
1725 1749
 void get_wifi_commands() {
@@ -1791,10 +1815,9 @@ void get_wifi_commands() {
1791 1815
         if (!wifi_comment_mode) wifi_line_buffer[wifi_read_count++] = wifi_char;
1792 1816
       }
1793 1817
     }
1794
-  }// queue has space, serial has data
1795
-  else {
1818
+  } // queue has space, serial has data
1819
+  else
1796 1820
     espGcodeFifo.wait_tick++;
1797
-  }
1798 1821
 }
1799 1822
 
1800 1823
 int readWifiBuf(int8_t *buf, int32_t len) {

+ 3
- 8
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h Vedi File

@@ -34,11 +34,6 @@
34 34
 #define UART_RX_BUFFER_SIZE   1024
35 35
 #define UART_FIFO_BUFFER_SIZE 1024
36 36
 
37
-#define ESP_WIFI              0x02
38
-
39
-#define AP_MODEL              0x01
40
-#define STA_MODEL             0x02
41
-
42 37
 #define WIFI_DECODE_TYPE      1
43 38
 
44 39
 #define IP_DHCP_FLAG          1
@@ -66,7 +61,7 @@ typedef enum{
66 61
   udisk_buf_full,
67 62
 } UDISK_DATA_BUFFER_STATE;
68 63
 
69
-#define TRANS_RCV_FIFO_BLOCK_NUM    8
64
+#define TRANS_RCV_FIFO_BLOCK_NUM  14
70 65
 
71 66
 typedef struct {
72 67
   unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
@@ -164,7 +159,7 @@ typedef enum {
164 159
 typedef struct {
165 160
   uint32_t uart_read_point;
166 161
   uint32_t uart_write_point;
167
-  uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
162
+  //uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
168 163
 } SZ_USART_FIFO;
169 164
 
170 165
 #define WIFI_GCODE_BUFFER_LEAST_SIZE    96
@@ -195,7 +190,7 @@ extern int  package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
195 190
 extern void get_wifi_list_command_send();
196 191
 extern void get_wifi_commands();
197 192
 extern int  readWifiBuf(int8_t *buf, int32_t len);
198
-extern int  storeRcvData(int32_t len);
193
+extern void mks_wifi_firmware_update();
199 194
 
200 195
 #ifdef __cplusplus
201 196
   } /* C-declarations for C++ */

+ 158
- 278
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp Vedi File

@@ -28,6 +28,7 @@
28 28
 #include "wifi_upload.h"
29 29
 
30 30
 #include "../../../../MarlinCore.h"
31
+#include "../../../../sd/cardreader.h"
31 32
 
32 33
 #define WIFI_SET()        WRITE(WIFI_RESET_PIN, HIGH);
33 34
 #define WIFI_RESET()      WRITE(WIFI_RESET_PIN, LOW);
@@ -85,6 +86,7 @@ static const uint32_t defaultTimeout = 500;
85 86
 static const uint32_t eraseTimeout = 15000;
86 87
 static const uint32_t blockWriteTimeout = 200;
87 88
 static const uint32_t blockWriteInterval = 15;      // 15ms is long enough, 10ms is mostly too short
89
+static SdFile update_file, *update_curDir;
88 90
 
89 91
 // Messages corresponding to result codes, should make sense when followed by " error"
90 92
 const char *resultMessages[] = {
@@ -113,23 +115,15 @@ signed char IsReady() {
113 115
   return esp_upload.state == upload_idle;
114 116
 }
115 117
 
116
-void uploadPort_write(const uint8_t *buf, size_t len) {
117
-  #if 0
118
-  int i;
119
-
120
-  for (i = 0; i < len; i++) {
121
-    while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET) { /* nada */ }
122
-    USART_SendData(USART1, *(buf + i));
123
-  }
124
-  #endif
118
+void uploadPort_write(const uint8_t *buf, const size_t len) {
119
+  for (size_t i = 0; i < len; i++)
120
+    WIFISERIAL.write(*(buf + i));
125 121
 }
126 122
 
127 123
 char uploadPort_read() {
128 124
   uint8_t retChar;
129
-  if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1)
130
-    return retChar;
131
-  else
132
-    return 0;
125
+  retChar = WIFISERIAL.read();
126
+  return _MAX(retChar, 0);
133 127
 }
134 128
 
135 129
 int uploadPort_available() {
@@ -156,25 +150,21 @@ void flushInput() {
156 150
 // Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset
157 151
 uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) {
158 152
   uint32_t val = 0;
159
-
160 153
   if (buf && byteCnt) {
161 154
     unsigned int shiftCnt = 0;
162
-    if (byteCnt > 4)
163
-      byteCnt = 4;
164
-    do{
155
+    NOMORE(byteCnt, 4);
156
+    do {
165 157
       val |= (uint32_t)buf[ofst++] << shiftCnt;
166 158
       shiftCnt += 8;
167 159
     } while (--byteCnt);
168 160
   }
169
-  return(val);
161
+  return val;
170 162
 }
171 163
 
172 164
 // Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset.
173 165
 void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
174 166
   if (buf && byteCnt) {
175
-    if (byteCnt > 4) {
176
-      byteCnt = 4;
177
-    }
167
+    NOMORE(byteCnt, 4);
178 168
     do {
179 169
       buf[ofst++] = (uint8_t)(val & 0xFF);
180 170
       val >>= 8;
@@ -191,44 +181,25 @@ void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
191 181
 //   -2 - a SLIP escape byte was found but the following byte wasn't available
192 182
 //   -3 - a SLIP escape byte was followed by an invalid byte
193 183
 int ReadByte(uint8_t *data, signed char slipDecode) {
194
-  if (uploadPort_available() == 0) {
195
-    return(0);
196
-  }
184
+  if (uploadPort_available() == 0) return 0;
197 185
 
198
-  // at least one byte is available
186
+  // At least one byte is available
199 187
   *data = uploadPort_read();
200
-  if (!slipDecode) {
201
-    return(1);
202
-  }
203 188
 
204
-  if (*data == 0xC0) {
205
-    // this shouldn't happen
206
-    return(-1);
207
-  }
189
+  if (!slipDecode) return 1;
208 190
 
209
-  // if not the SLIP escape, we're done
210
-  if (*data != 0xDB) {
211
-    return(1);
212
-  }
191
+  if (*data == 0xC0) return -1; // This shouldn't happen
192
+  if (*data != 0xDB) return 1;  // If not the SLIP escape, we're done
213 193
 
214 194
   // SLIP escape, check availability of subsequent byte
215
-  if (uploadPort_available() == 0) {
216
-    return(-2);
217
-  }
195
+  if (uploadPort_available() == 0) return -2;
218 196
 
219 197
   // process the escaped byte
220 198
   *data = uploadPort_read();
221
-  if (*data == 0xDC) {
222
-    *data = 0xC0;
223
-    return(2);
224
-  }
199
+  if (*data == 0xDC) { *data = 0xC0; return 2; }
200
+  if (*data == 0xDD) { *data = 0xDB; return 2; }
225 201
 
226
-  if (*data == 0xDD) {
227
-    *data = 0xDB;
228
-    return(2);
229
-  }
230
-  // invalid
231
-  return(-3);
202
+  return -3; // invalid
232 203
 }
233 204
 // When we write a sync packet, there must be no gaps between most of the characters.
234 205
 // So use this function, which does a block write to the UART buffer in the latest CoreNG.
@@ -242,7 +213,7 @@ void WriteByteRaw(uint8_t b) {
242 213
 }
243 214
 
244 215
 // Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
245
-void WriteByteSlip(uint8_t b) {
216
+void WriteByteSlip(const uint8_t b) {
246 217
   if (b == 0xC0) {
247 218
     WriteByteRaw(0xDB);
248 219
     WriteByteRaw(0xDC);
@@ -251,9 +222,8 @@ void WriteByteSlip(uint8_t b) {
251 222
     WriteByteRaw(0xDB);
252 223
     WriteByteRaw(0xDD);
253 224
   }
254
-  else {
225
+  else
255 226
     uploadPort_write((const uint8_t *)&b, 1);
256
-  }
257 227
 }
258 228
 
259 229
 // Wait for a data packet to be returned.  If the body of the packet is
@@ -295,10 +265,10 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
295 265
     EspUploadResult stat;
296 266
 
297 267
     //IWDG_ReloadCounter();
268
+    watchdog_refresh();
298 269
 
299
-    if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) {
300
-      return(timeout);
301
-    }
270
+    if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout)
271
+      return timeout;
302 272
 
303 273
     if (uploadPort_available() < needBytes) {
304 274
       // insufficient data available
@@ -310,9 +280,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
310 280
     switch (state) {
311 281
       case begin: // expecting frame start
312 282
         c = uploadPort_read();
313
-        if (c != (uint8_t)0xC0) {
314
-          break;
315
-        }
283
+        if (c == (uint8_t)0xC0) break;
316 284
         state = header;
317 285
         needBytes = 2;
318 286
         break;
@@ -323,50 +291,45 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
323 291
         break;
324 292
 
325 293
       case header:  // reading an 8-byte header
326
-      case body:    // reading the response body
327
-        {
328
-          int rslt;
329
-          // retrieve a byte with SLIP decoding
330
-          rslt = ReadByte(&c, 1);
331
-          if (rslt != 1 && rslt != 2) {
332
-            // some error occurred
333
-            stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame;
334
-            return stat;
335
-          }
336
-          else if (state == header) {
337
-            //store the header byte
338
-            hdr[hdrIdx++] = c;
339
-            if (hdrIdx >= headerLength) {
340
-              // get the body length, prepare a buffer for it
341
-              *bodyLen = (uint16_t)getData(2, hdr, 2);
342
-
343
-              // extract the value, if requested
344
-              if (valp != 0) {
345
-                *valp = getData(4, hdr, 4);
346
-              }
347
-
348
-              if (*bodyLen != 0) {
349
-                state = body;
350
-              }
351
-              else {
352
-                needBytes = 1;
353
-                state = end;
354
-              }
355
-            }
356
-          }
357
-          else {
358
-            // Store the response body byte, check for completion
359
-            if (bodyIdx < ARRAY_SIZE(respBuf)) {
360
-              respBuf[bodyIdx] = c;
361
-            }
362
-            ++bodyIdx;
363
-            if (bodyIdx >= *bodyLen) {
294
+      case body: {  // reading the response body
295
+        int rslt;
296
+        // retrieve a byte with SLIP decoding
297
+        rslt = ReadByte(&c, 1);
298
+        if (rslt != 1 && rslt != 2) {
299
+          // some error occurred
300
+          stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame;
301
+          return stat;
302
+        }
303
+        else if (state == header) {
304
+          //store the header byte
305
+          hdr[hdrIdx++] = c;
306
+          if (hdrIdx >= headerLength) {
307
+            // get the body length, prepare a buffer for it
308
+            *bodyLen = (uint16_t)getData(2, hdr, 2);
309
+
310
+            // extract the value, if requested
311
+            if (valp)
312
+              *valp = getData(4, hdr, 4);
313
+
314
+            if (*bodyLen != 0)
315
+              state = body;
316
+            else {
364 317
               needBytes = 1;
365 318
               state = end;
366 319
             }
367 320
           }
368 321
         }
369
-        break;
322
+        else {
323
+          // Store the response body byte, check for completion
324
+          if (bodyIdx < ARRAY_SIZE(respBuf))
325
+            respBuf[bodyIdx] = c;
326
+
327
+          if (++bodyIdx >= *bodyLen) {
328
+            needBytes = 1;
329
+            state = end;
330
+          }
331
+        }
332
+      } break;
370 333
 
371 334
       default: return slipState;  // this shouldn't happen
372 335
     }
@@ -376,9 +339,7 @@ EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t
376 339
   resp = (uint8_t)getData(1, hdr, 0);
377 340
   opRet = (uint8_t)getData(1, hdr, 1);
378 341
   // Sync packets often provoke a response with a zero opcode instead of ESP_SYNC
379
-  if (resp != 0x01 || opRet != op) {
380
-    return respHeader;
381
-  }
342
+  if (resp != 0x01 || opRet != op) return respHeader;
382 343
 
383 344
   return success;
384 345
 }
@@ -483,6 +444,7 @@ EspUploadResult Sync(uint16_t timeout) {
483 444
     for (;;) {
484 445
       size_t bodyLen;
485 446
       EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout);
447
+      watchdog_refresh();
486 448
       if (rc != success || bodyLen != 2) break;
487 449
     }
488 450
   }
@@ -527,7 +489,6 @@ uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
527 489
 }
528 490
 
529 491
 EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
530
-  #if 0
531 492
   const uint32_t blkSize = EspFlashBlockSize;
532 493
   int i;
533 494
 
@@ -548,15 +509,14 @@ EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
548 509
   putData(0, 4, blkBuf, hdrOfst + 12);
549 510
 
550 511
   // Get the data for the block
551
-  f_read(&esp_upload.uploadFile, blkBuf + dataOfst,  blkSize, &cnt );//->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
512
+  cnt = update_file.read(blkBuf + dataOfst, blkSize); //->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
552 513
   if (cnt != blkSize) {
553
-    if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) {
514
+    if (update_file.curPosition() == esp_upload.fileSize) {
554 515
       // partial last block, fill the remainder
555 516
       memset(blkBuf + dataOfst + cnt, 0xFF, blkSize - cnt);
556 517
     }
557
-    else {
518
+    else
558 519
       return fileRead;
559
-    }
560 520
   }
561 521
 
562 522
   // Patch the flash parameters into the first block if it is loaded at address 0
@@ -573,212 +533,132 @@ EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
573 533
     if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success)
574 534
       break;
575 535
   return stat;
576
-  #else
577
-    return success;
578
-  #endif
579 536
 }
580 537
 
581 538
 void upload_spin() {
582
-  #if 0
583
-  switch (esp_upload.state) {
584
-  case resetting:
585
-
586
-    if (esp_upload.connectAttemptNumber == 9) {
587
-      // Time to give up
588
-      //Network::ResetWiFi();
589
-      esp_upload.uploadResult = connected;
590
-      esp_upload.state = done;
591
-    }
592
-    else {
593
-
594
-      // Reset the serial port at the new baud rate. Also reset the ESP8266.
595
-      //  const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate];
596
-      if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) {
597
-      }
598
-      //uploadPort.begin(baud);
599
-      //uploadPort_close();
600
-
601
-      uploadPort_begin();
602
-
603
-      wifi_delay(2000);
604
-
605
-      flushInput();
606
-
607
-      esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
608
-      esp_upload.state = connecting;
609
-    }
610 539
 
611
-    break;
612
-
613
-  case connecting:
614
-    if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
615
-      // Attempt to establish a connection to the ESP8266.
616
-      EspUploadResult res = Sync(5000);
617
-      esp_upload.lastAttemptTime = getWifiTick();
618
-      if (res == success) {
619
-        // Successful connection
620
-        //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1);
621
-        //printf("connect success\n");
622
-        esp_upload.state = erasing;
623
-      }
624
-      else {
625
-        // This attempt failed
626
-        esp_upload.connectAttemptNumber++;
627
-        if (esp_upload.connectAttemptNumber % retriesPerReset == 0) {
628
-          esp_upload.state = resetting;   // try a reset and a lower baud rate
629
-        }
630
-      }
631
-    }
632
-    break;
633
-
634
-  case erasing:
635
-    if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
636
-      uint32_t eraseSize;
637
-      const uint32_t sectorsPerBlock = 16;
638
-      const uint32_t sectorSize = 4096;
639
-      const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
640
-      const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
641
-
642
-      uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
643
-      NOMORE(headSectors, numSectors);
644
-
645
-      eraseSize = (numSectors < 2 * headSectors)
646
-                ? (numSectors + 1) / 2 * sectorSize
647
-                : (numSectors - headSectors) * sectorSize;
648
-
649
-      //MessageF("Erasing %u bytes...\n", fileSize);
650
-      esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
651
-      if (esp_upload.uploadResult == success) {
652
-        //MessageF("Uploading file...\n");
653
-        esp_upload.uploadBlockNumber = 0;
654
-        esp_upload.uploadNextPercentToReport = percentToReportIncrement;
655
-        esp_upload.lastAttemptTime = getWifiTick();
656
-        esp_upload.state = uploading;
540
+  switch (esp_upload.state) {
541
+    case resetting:
542
+      if (esp_upload.connectAttemptNumber == 9) {
543
+        esp_upload.uploadResult = connected;
544
+        esp_upload.state = done;
657 545
       }
658 546
       else {
659
-        //MessageF("Erase failed\n");
660
-        esp_upload.state = done;
547
+        uploadPort_begin();
548
+        wifi_delay(2000);
549
+        flushInput();
550
+        esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
551
+        esp_upload.state = connecting;
661 552
       }
662
-    }
663
-    break;
664
-
665
-  case uploading:
666
-    // The ESP needs several milliseconds to recover from one packet before it will accept another
667
-    if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) {
668
-      unsigned int percentComplete;
669
-      const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
670
-      if (esp_upload.uploadBlockNumber < blkCnt) {
671
-        esp_upload.uploadResult = flashWriteBlock(0, 0);
553
+      break;
554
+
555
+    case connecting:
556
+      if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
557
+        EspUploadResult res = Sync(5000);
672 558
         esp_upload.lastAttemptTime = getWifiTick();
673
-        if (esp_upload.uploadResult != success) {
674
-          //MessageF("Flash block upload failed\n");
675
-          esp_upload.state = done;
559
+        if (res == success)
560
+          esp_upload.state = erasing;
561
+        else {
562
+          esp_upload.connectAttemptNumber++;
563
+          if (esp_upload.connectAttemptNumber % retriesPerReset == 0)
564
+            esp_upload.state = resetting;
676 565
         }
677
-        percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
678
-        ++esp_upload.uploadBlockNumber;
679
-        if (percentComplete >= esp_upload.uploadNextPercentToReport) {
680
-          //MessageF("%u%% complete\n", percentComplete);
681
-          esp_upload.uploadNextPercentToReport += percentToReportIncrement;
682
-        }
683
-      }
684
-      else {
685
-        esp_upload.state = done;
686 566
       }
687
-    }
688
-    break;
567
+      break;
689 568
 
690
-  case done:
691
-    f_close(&esp_upload.uploadFile);
692
-    //uploadPort.end();
693
-    //uploadPort_close();
569
+    case erasing:
570
+      if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
571
+        uint32_t eraseSize;
572
+        const uint32_t sectorsPerBlock = 16;
573
+        const uint32_t sectorSize = 4096;
574
+        const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
575
+        const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
576
+
577
+        uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
578
+        NOMORE(headSectors, numSectors);
579
+
580
+        eraseSize = (numSectors < 2 * headSectors)
581
+                  ? (numSectors + 1) / 2 * sectorSize
582
+                  : (numSectors - headSectors) * sectorSize;
583
+
584
+        esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
585
+        if (esp_upload.uploadResult == success) {
586
+          esp_upload.uploadBlockNumber = 0;
587
+          esp_upload.uploadNextPercentToReport = percentToReportIncrement;
588
+          esp_upload.lastAttemptTime = getWifiTick();
589
+          esp_upload.state = uploading;
590
+        }
591
+        else
592
+          esp_upload.state = done;
593
+      }
594
+      break;
694 595
 
695
-    //WIFI_COM.begin(115200, true);
696
-    //wifi_init();
596
+    case uploading:
597
+      // The ESP needs several milliseconds to recover from one packet before it will accept another
598
+      if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) {
599
+        unsigned int percentComplete;
600
+        const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
601
+        if (esp_upload.uploadBlockNumber < blkCnt) {
602
+          esp_upload.uploadResult = flashWriteBlock(0, 0);
603
+          esp_upload.lastAttemptTime = getWifiTick();
604
+          if (esp_upload.uploadResult != success)
605
+            esp_upload.state = done;
606
+          percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
607
+          ++esp_upload.uploadBlockNumber;
608
+          if (percentComplete >= esp_upload.uploadNextPercentToReport)
609
+            esp_upload.uploadNextPercentToReport += percentToReportIncrement;
610
+        }
611
+        else
612
+          esp_upload.state = done;
613
+      }
614
+      break;
697 615
 
698
-    if (esp_upload.uploadResult == success) {
699
-      //printf("upload successfully\n");
700
-    }
701
-    else {
702
-      //printf("upload failed\n");
703
-    }
704
-    esp_upload.state = upload_idle;//idle;
705
-    break;
616
+    case done:
617
+      update_file.close();
618
+      esp_upload.state = upload_idle;
619
+      break;
706 620
 
707 621
     default: break;
708 622
   }
709
-  #endif
710 623
 }
711 624
 
712 625
 // Try to upload the given file at the given address
713 626
 void SendUpdateFile(const char *file, uint32_t address) {
714
-  #if 0
715
-  FRESULT res = f_open(&esp_upload.uploadFile, file,  FA_OPEN_EXISTING | FA_READ);
627
+  const char * const fname = card.diveToFile(true, update_curDir, ESP_FIRMWARE_FILE);
628
+  if (!update_file.open(update_curDir, fname, O_READ)) return;
716 629
 
717
-  if (res !=  FR_OK) return;
630
+  esp_upload.fileSize = update_file.fileSize();
718 631
 
719
-  esp_upload.fileSize = f_size(&esp_upload.uploadFile);
720 632
   if (esp_upload.fileSize == 0) {
721
-    f_close(&esp_upload.uploadFile);
633
+    update_file.close();
722 634
     return;
723 635
   }
724
-  f_lseek(&esp_upload.uploadFile, 0);
725 636
 
726 637
   esp_upload.uploadAddress = address;
727 638
   esp_upload.connectAttemptNumber = 0;
728 639
   esp_upload.state = resetting;
729
-  #endif
730 640
 }
731 641
 
732 642
 static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000;
733 643
 
734 644
 void ResetWiFiForUpload(int begin_or_end) {
735
-  #if 0
736
-    uint32_t start, now;
737
-
738
-    GPIO_InitTypeDef GPIO_InitStructure;
739
-
740
-    #if V1_0_V1_1
741
-      GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
742
-      GPIO_InitStructure.Pin = GPIO_Pin_8;
743
-      GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
744
-      HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
745
-    #else
746
-      GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
747
-      GPIO_InitStructure.Pin = GPIO_Pin_13;
748
-      GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
749
-      HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
750
-    #endif
751
-    start = getWifiTick();
752
-    now = start;
753
-
754
-    if (begin_or_end == 0) {
755
-      #if V1_0_V1_1
756
-        HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode
757
-      #else
758
-        HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_RESET); //update mode
759
-      #endif
760
-    }
761
-    else {
762
-      #if V1_0_V1_1
763
-        #if V1_0_V1_1
764
-          HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_SET); //boot mode
765
-          GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
766
-          GPIO_InitStructure.Pin = GPIO_Pin_8;
767
-          GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
768
-          HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
769
-        #endif
770
-      #else
771
-        HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_SET); //boot mode
772
-        GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
773
-        GPIO_InitStructure.Pin = GPIO_Pin_13;
774
-        GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
775
-        HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
776
-      #endif
777
-    }
778
-    WIFI_RESET();
779
-    while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
780
-    WIFI_SET();
781
-  #endif
645
+  //#if 0
646
+  uint32_t start, now;
647
+
648
+  start = getWifiTick();
649
+  now = start;
650
+
651
+  if (begin_or_end == 0) {
652
+    SET_OUTPUT(WIFI_IO0_PIN);
653
+    WRITE(WIFI_IO0_PIN, LOW);
654
+  }
655
+  else
656
+    SET_INPUT_PULLUP(WIFI_IO0_PIN);
657
+
658
+  WIFI_RESET();
659
+  while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
660
+  WIFI_SET();
661
+  //#endif
782 662
 }
783 663
 
784 664
 int32_t wifi_upload(int type) {
@@ -797,7 +677,7 @@ int32_t wifi_upload(int type) {
797 677
 
798 678
   while (esp_upload.state != upload_idle) {
799 679
     upload_spin();
800
-    //IWDG_ReloadCounter();
680
+    watchdog_refresh();
801 681
   }
802 682
 
803 683
   ResetWiFiForUpload(1);

+ 4
- 3
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h Vedi File

@@ -25,9 +25,10 @@
25 25
   extern "C" { /* C-declarations for C++ */
26 26
 #endif
27 27
 
28
-#define ESP_FIRMWARE_FILE     "1:/MksWifi.bin"
29
-#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin"
30
-#define ESP_WEB_FILE          "1:/MksWifi_WebView.bin"
28
+#define ESP_FIRMWARE_FILE         "MksWifi.bin"
29
+#define ESP_FIRMWARE_FILE_RENAME  "MKSWIFI.CUR"
30
+#define ESP_WEB_FIRMWARE_FILE     "1:/MksWifi_Web.bin"
31
+#define ESP_WEB_FILE              "1:/MksWifi_WebView.bin"
31 32
 
32 33
 typedef enum {
33 34
   upload_idle,

+ 56
- 54
Marlin/src/libs/W25Qxx.cpp Vedi File

@@ -49,6 +49,8 @@ MarlinSPI W25QXXFlash::mySPI(SPI_FLASH_MOSI_PIN, SPI_FLASH_MISO_PIN, SPI_FLASH_S
49 49
 #define W25QXX_CS_H OUT_WRITE(SPI_FLASH_CS_PIN, HIGH)
50 50
 #define W25QXX_CS_L OUT_WRITE(SPI_FLASH_CS_PIN, LOW)
51 51
 
52
+bool flash_dma_mode = true;
53
+
52 54
 void W25QXXFlash::init(uint8_t spiRate) {
53 55
 
54 56
   OUT_WRITE(SPI_FLASH_CS_PIN, HIGH);
@@ -144,11 +146,11 @@ uint16_t W25QXXFlash::W25QXX_ReadID(void) {
144 146
 }
145 147
 
146 148
 void W25QXXFlash::SPI_FLASH_WriteEnable(void) {
147
-  /* Select the FLASH: Chip Select low */
149
+  // Select the FLASH: Chip Select low
148 150
   W25QXX_CS_L;
149
-  /* Send "Write Enable" instruction */
151
+  // Send "Write Enable" instruction
150 152
   spi_flash_Send(W25X_WriteEnable);
151
-  /* Deselect the FLASH: Chip Select high */
153
+  // Deselect the FLASH: Chip Select high
152 154
   W25QXX_CS_H;
153 155
 }
154 156
 
@@ -164,54 +166,54 @@ void W25QXXFlash::SPI_FLASH_WriteEnable(void) {
164 166
 void W25QXXFlash::SPI_FLASH_WaitForWriteEnd(void) {
165 167
   uint8_t FLASH_Status = 0;
166 168
 
167
-  /* Select the FLASH: Chip Select low */
169
+  // Select the FLASH: Chip Select low
168 170
   W25QXX_CS_L;
169
-  /* Send "Read Status Register" instruction */
171
+  // Send "Read Status Register" instruction
170 172
   spi_flash_Send(W25X_ReadStatusReg);
171 173
 
172
-  /* Loop as long as the memory is busy with a write cycle */
174
+  // Loop as long as the memory is busy with a write cycle
173 175
   do
174 176
     /* Send a dummy byte to generate the clock needed by the FLASH
175 177
     and put the value of the status register in FLASH_Status variable */
176 178
     FLASH_Status = spi_flash_Rec();
177
-  while ((FLASH_Status & WIP_Flag) == 0x01); /* Write in progress */
179
+  while ((FLASH_Status & WIP_Flag) == 0x01); // Write in progress
178 180
 
179
-  /* Deselect the FLASH: Chip Select high */
181
+  // Deselect the FLASH: Chip Select high
180 182
   W25QXX_CS_H;
181 183
 }
182 184
 
183 185
 void W25QXXFlash::SPI_FLASH_SectorErase(uint32_t SectorAddr) {
184
-  /* Send write enable instruction */
186
+  // Send write enable instruction
185 187
   SPI_FLASH_WriteEnable();
186 188
 
187
-  /* Sector Erase */
188
-  /* Select the FLASH: Chip Select low */
189
+  // Sector Erase
190
+  // Select the FLASH: Chip Select low
189 191
   W25QXX_CS_L;
190
-  /* Send Sector Erase instruction */
192
+  // Send Sector Erase instruction
191 193
   spi_flash_Send(W25X_SectorErase);
192
-  /* Send SectorAddr high nibble address byte */
194
+  // Send SectorAddr high nibble address byte
193 195
   spi_flash_Send((SectorAddr & 0xFF0000) >> 16);
194
-  /* Send SectorAddr medium nibble address byte */
196
+  // Send SectorAddr medium nibble address byte
195 197
   spi_flash_Send((SectorAddr & 0xFF00) >> 8);
196
-  /* Send SectorAddr low nibble address byte */
198
+  // Send SectorAddr low nibble address byte
197 199
   spi_flash_Send(SectorAddr & 0xFF);
198
-  /* Deselect the FLASH: Chip Select high */
200
+  // Deselect the FLASH: Chip Select high
199 201
 
200 202
   W25QXX_CS_H;
201
-  /* Wait the end of Flash writing */
203
+  // Wait the end of Flash writing
202 204
   SPI_FLASH_WaitForWriteEnd();
203 205
 }
204 206
 
205 207
 void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
206 208
   SPI_FLASH_WriteEnable();
207 209
   W25QXX_CS_L;
208
-  /* Send Sector Erase instruction */
210
+  // Send Sector Erase instruction
209 211
   spi_flash_Send(W25X_BlockErase);
210
-  /* Send SectorAddr high nibble address byte */
212
+  // Send SectorAddr high nibble address byte
211 213
   spi_flash_Send((BlockAddr & 0xFF0000) >> 16);
212
-  /* Send SectorAddr medium nibble address byte */
214
+  // Send SectorAddr medium nibble address byte
213 215
   spi_flash_Send((BlockAddr & 0xFF00) >> 8);
214
-  /* Send SectorAddr low nibble address byte */
216
+  // Send SectorAddr low nibble address byte
215 217
   spi_flash_Send(BlockAddr & 0xFF);
216 218
 
217 219
   W25QXX_CS_H;
@@ -227,18 +229,18 @@ void W25QXXFlash::SPI_FLASH_BlockErase(uint32_t BlockAddr) {
227 229
 * Return         : None
228 230
 *******************************************************************************/
229 231
 void W25QXXFlash::SPI_FLASH_BulkErase(void) {
230
-  /* Send write enable instruction */
232
+  // Send write enable instruction
231 233
   SPI_FLASH_WriteEnable();
232 234
 
233
-  /* Bulk Erase */
234
-  /* Select the FLASH: Chip Select low */
235
+  // Bulk Erase
236
+  // Select the FLASH: Chip Select low
235 237
   W25QXX_CS_L;
236 238
 
237
-  /* Send Bulk Erase instruction  */
239
+  // Send Bulk Erase instruction
238 240
   spi_flash_Send(W25X_ChipErase);
239
-  /* Deselect the FLASH: Chip Select high */
241
+  // Deselect the FLASH: Chip Select high
240 242
   W25QXX_CS_H;
241
-  /* Wait the end of Flash writing */
243
+  // Wait the end of Flash writing
242 244
   SPI_FLASH_WaitForWriteEnd();
243 245
 }
244 246
 
@@ -256,34 +258,34 @@ void W25QXXFlash::SPI_FLASH_BulkErase(void) {
256 258
 * Return         : None
257 259
 *******************************************************************************/
258 260
 void W25QXXFlash::SPI_FLASH_PageWrite(uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite) {
259
-  /* Enable the write access to the FLASH */
261
+  // Enable the write access to the FLASH
260 262
   SPI_FLASH_WriteEnable();
261 263
 
262
-  /* Select the FLASH: Chip Select low */
264
+  // Select the FLASH: Chip Select low
263 265
   W25QXX_CS_L;
264
-  /* Send "Write to Memory " instruction */
266
+  // Send "Write to Memory " instruction
265 267
   spi_flash_Send(W25X_PageProgram);
266
-  /* Send WriteAddr high nibble address byte to write to */
268
+  // Send WriteAddr high nibble address byte to write to
267 269
   spi_flash_Send((WriteAddr & 0xFF0000) >> 16);
268
-  /* Send WriteAddr medium nibble address byte to write to */
270
+  // Send WriteAddr medium nibble address byte to write to
269 271
   spi_flash_Send((WriteAddr & 0xFF00) >> 8);
270
-  /* Send WriteAddr low nibble address byte to write to */
272
+  // Send WriteAddr low nibble address byte to write to
271 273
   spi_flash_Send(WriteAddr & 0xFF);
272 274
 
273 275
   NOMORE(NumByteToWrite, SPI_FLASH_PerWritePageSize);
274 276
 
275
-  /* while there is data to be written on the FLASH */
277
+  // While there is data to be written on the FLASH
276 278
   while (NumByteToWrite--) {
277
-    /* Send the current byte */
279
+    // Send the current byte
278 280
     spi_flash_Send(*pBuffer);
279
-    /* Point on the next byte to be written */
281
+    // Point on the next byte to be written
280 282
     pBuffer++;
281 283
   }
282 284
 
283
-  /* Deselect the FLASH: Chip Select high */
285
+  // Deselect the FLASH: Chip Select high
284 286
   W25QXX_CS_H;
285 287
 
286
-  /* Wait the end of Flash writing */
288
+  // Wait the end of Flash writing
287 289
   SPI_FLASH_WaitForWriteEnd();
288 290
 }
289 291
 
@@ -306,11 +308,11 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
306 308
   NumOfPage = NumByteToWrite / SPI_FLASH_PageSize;
307 309
   NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize;
308 310
 
309
-  if (Addr == 0) { /* WriteAddr is SPI_FLASH_PageSize aligned  */
310
-    if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */
311
+  if (Addr == 0) { // WriteAddr is SPI_FLASH_PageSize aligned
312
+    if (NumOfPage == 0) { // NumByteToWrite < SPI_FLASH_PageSize
311 313
       SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite);
312 314
     }
313
-    else { /* NumByteToWrite > SPI_FLASH_PageSize */
315
+    else { // NumByteToWrite > SPI_FLASH_PageSize
314 316
       while (NumOfPage--) {
315 317
         SPI_FLASH_PageWrite(pBuffer, WriteAddr, SPI_FLASH_PageSize);
316 318
         WriteAddr += SPI_FLASH_PageSize;
@@ -319,9 +321,9 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
319 321
       SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumOfSingle);
320 322
     }
321 323
   }
322
-  else { /* WriteAddr is not SPI_FLASH_PageSize aligned  */
323
-    if (NumOfPage == 0) { /* NumByteToWrite < SPI_FLASH_PageSize */
324
-      if (NumOfSingle > count) { /* (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize */
324
+  else { // WriteAddr is not SPI_FLASH_PageSize aligned
325
+    if (NumOfPage == 0) { // NumByteToWrite < SPI_FLASH_PageSize
326
+      if (NumOfSingle > count) { // (NumByteToWrite + WriteAddr) > SPI_FLASH_PageSize
325 327
         temp = NumOfSingle - count;
326 328
         SPI_FLASH_PageWrite(pBuffer, WriteAddr, count);
327 329
         WriteAddr += count;
@@ -332,7 +334,7 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
332 334
         SPI_FLASH_PageWrite(pBuffer, WriteAddr, NumByteToWrite);
333 335
       }
334 336
     }
335
-    else { /* NumByteToWrite > SPI_FLASH_PageSize */
337
+    else { // NumByteToWrite > SPI_FLASH_PageSize
336 338
       NumByteToWrite -= count;
337 339
       NumOfPage = NumByteToWrite / SPI_FLASH_PageSize;
338 340
       NumOfSingle = NumByteToWrite % SPI_FLASH_PageSize;
@@ -364,24 +366,24 @@ void W25QXXFlash::SPI_FLASH_BufferWrite(uint8_t* pBuffer, uint32_t WriteAddr, ui
364 366
 * Return         : None
365 367
 *******************************************************************************/
366 368
 void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) {
367
-  /* Select the FLASH: Chip Select low */
369
+  // Select the FLASH: Chip Select low
368 370
   W25QXX_CS_L;
369 371
 
370
-  /* Send "Read from Memory " instruction */
372
+  // Send "Read from Memory " instruction
371 373
   spi_flash_Send(W25X_ReadData);
372 374
 
373
-  /* Send ReadAddr high nibble address byte to read from */
375
+  // Send ReadAddr high nibble address byte to read from
374 376
   spi_flash_Send((ReadAddr & 0xFF0000) >> 16);
375
-  /* Send ReadAddr medium nibble address byte to read from */
377
+  // Send ReadAddr medium nibble address byte to read from
376 378
   spi_flash_Send((ReadAddr & 0xFF00) >> 8);
377
-  /* Send ReadAddr low nibble address byte to read from */
379
+  // Send ReadAddr low nibble address byte to read from
378 380
   spi_flash_Send(ReadAddr & 0xFF);
379 381
 
380
-  if (NumByteToRead < 33) {
381
-    while (NumByteToRead--) { /* while there is data to be read */
382
-      /* Read a byte from the FLASH */
382
+  if (NumByteToRead <= 32 || !flash_dma_mode) {
383
+    while (NumByteToRead--) { // While there is data to be read
384
+      // Read a byte from the FLASH
383 385
       *pBuffer = spi_flash_Rec();
384
-      /* Point to the next location where the byte read will be saved */
386
+      // Point to the next location where the byte read will be saved
385 387
       pBuffer++;
386 388
     }
387 389
   }

+ 2
- 2
Marlin/src/sd/SdBaseFile.cpp Vedi File

@@ -401,8 +401,8 @@ bool SdBaseFile::make83Name(const char* str, uint8_t* name, const char** ptr) {
401 401
       // Fail for illegal characters
402 402
       PGM_P p = PSTR("|<>^+=?/[];,*\"\\");
403 403
       while (uint8_t b = pgm_read_byte(p++)) if (b == c) return false;
404
-      if (i > n || c < 0x21 || c == 0x7F) return false;           // Check size, non-printable characters
405
-      name[i++] = (c < 'a' || c > 'z') ? (c) : (c + ('A' - 'a')); // Uppercase required for 8.3 name
404
+      if (i > n || c < 0x21 || c == 0x7F) return false;       // Check size, non-printable characters
405
+      name[i++] = c + (WITHIN(c, 'a', 'z') ? 'A' - 'a' : 0);  // Uppercase required for 8.3 name
406 406
     }
407 407
   }
408 408
   *ptr = str;                         // Set passed pointer to the end

+ 1
- 0
platformio.ini Vedi File

@@ -214,6 +214,7 @@ lib_deps           =
214 214
 HAS_TFT_LVGL_UI         = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip
215 215
                           src_filter=+<src/lcd/extui/lib/mks_ui>
216 216
                           extra_scripts=download_mks_assets.py
217
+MKS_WIFI_MODULE         = QRCode=https://github.com/makerbase-mks/QRCode/archive/master.zip
217 218
 HAS_TRINAMIC_CONFIG     = TMCStepper@~0.7.1
218 219
                           src_filter=+<src/feature/tmc_util.cpp> +<src/module/stepper/trinamic.cpp> +<src/gcode/feature/trinamic/M122.cpp> +<src/gcode/feature/trinamic/M906.cpp> +<src/gcode/feature/trinamic/M911-M914.cpp>
219 220
 HAS_STEALTHCHOP         = src_filter=+<src/gcode/feature/trinamic/M569.cpp>

Loading…
Annulla
Salva