Browse Source

Add TFT_LVGL_UI support (#18438)

Victor Oliveira 4 years ago
parent
commit
e5bc9d31cc
No account linked to committer's email address
39 changed files with 1515 additions and 1388 deletions
  1. 5
    2
      Marlin/Configuration.h
  2. 1
    1
      Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp
  3. 5
    4
      Marlin/src/MarlinCore.cpp
  4. 29
    27
      Marlin/src/feature/touch/xpt2046.cpp
  5. 1
    1
      Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp
  6. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp
  7. 13
    14
      Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
  8. 6
    6
      Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
  9. 7
    5
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  10. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp
  11. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
  12. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
  13. 4
    4
      Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
  14. 6
    6
      Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp
  15. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  16. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  17. 6
    6
      Marlin/src/lcd/extui/lib/mks_ui/draw_opration.cpp
  18. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp
  19. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
  20. 54
    32
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
  21. 5
    5
      Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp
  22. 3
    3
      Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
  23. 32
    16
      Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp
  24. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp
  25. 93
    26
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  26. 8
    1
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  27. 6
    2
      Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp
  28. 4
    3
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  29. 337
    490
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
  30. 77
    48
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
  31. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/printer_opration.cpp
  32. 3
    3
      Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp
  33. 640
    654
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  34. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp
  35. 2
    2
      Marlin/src/pins/pins.h
  36. 65
    0
      Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h
  37. 65
    0
      Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h
  38. 1
    1
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
  39. 15
    4
      platformio.ini

+ 5
- 2
Marlin/Configuration.h View File

@@ -2135,9 +2135,12 @@
2135 2135
 //#define FSMC_GRAPHICAL_TFT
2136 2136
 
2137 2137
 //
2138
-// TFT Little VGL UI
2138
+// TFT LVGL UI
2139 2139
 //
2140
-//#define TFT_LITTLE_VGL_UI
2140
+// Default MKS icons and fonts: https://git.io/JJvzK
2141
+// Copy mks_pic and mks_font folders to the root of your SD
2142
+//
2143
+//#define TFT_LVGL_UI
2141 2144
 
2142 2145
 //=============================================================================
2143 2146
 //============================  Other Controllers  ============================

+ 1
- 1
Marlin/src/HAL/STM32F1/dogm/u8g_com_stm32duino_fsmc.cpp View File

@@ -291,7 +291,7 @@ uint32_t LCD_IO_ReadData(uint16_t RegValue, uint8_t ReadSize) {
291 291
   return uint32_t(data);
292 292
 }
293 293
 
294
-#if ENABLED(LCD_USE_DMA_FSMC)
294
+#ifdef LCD_USE_DMA_FSMC
295 295
 
296 296
 void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
297 297
   while (count > 0) {

+ 5
- 4
Marlin/src/MarlinCore.cpp View File

@@ -59,7 +59,7 @@
59 59
 #include "gcode/parser.h"
60 60
 #include "gcode/queue.h"
61 61
 
62
-#if ENABLED(TFT_LITTLE_VGL_UI)
62
+#if ENABLED(TFT_LVGL_UI)
63 63
   #include "lvgl.h"
64 64
   #include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
65 65
   #include "lcd/extui/lib/mks_ui/draw_ui.h"
@@ -743,7 +743,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
743 743
   // Direct Stepping
744 744
   TERN_(DIRECT_STEPPING, page_manager.write_responses());
745 745
 
746
-  #if ENABLED(TFT_LITTLE_VGL_UI)
746
+  #if ENABLED(TFT_LVGL_UI)
747 747
     LV_TASK_HANDLER();
748 748
   #endif
749 749
 }
@@ -1180,7 +1180,8 @@ void setup() {
1180 1180
     SETUP_RUN(page_manager.init());
1181 1181
   #endif
1182 1182
 
1183
-  #if ENABLED(TFT_LITTLE_VGL_UI)
1183
+  #if ENABLED(TFT_LVGL_UI)
1184
+    if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
1184 1185
     SETUP_RUN(tft_lvgl_init());
1185 1186
   #endif
1186 1187
 
@@ -1216,7 +1217,7 @@ void loop() {
1216 1217
 
1217 1218
     endstops.event_handler();
1218 1219
 
1219
-    TERN_(TFT_LITTLE_VGL_UI, printer_state_polling());
1220
+    TERN_(TFT_LVGL_UI, printer_state_polling());
1220 1221
 
1221 1222
   } while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
1222 1223
 }

+ 29
- 27
Marlin/src/feature/touch/xpt2046.cpp View File

@@ -101,39 +101,41 @@ void XPT2046::init() {
101 101
 #include "../../lcd/ultralcd.h" // For EN_C bit mask
102 102
 
103 103
 uint8_t XPT2046::read_buttons() {
104
-  int16_t tsoffsets[4] = { 0 };
105
-
106
-  if (tsoffsets[0] + tsoffsets[1] == 0) {
107
-    // Not yet set, so use defines as fallback...
108
-    tsoffsets[0] = XPT2046_X_CALIBRATION;
109
-    tsoffsets[1] = XPT2046_X_OFFSET;
110
-    tsoffsets[2] = XPT2046_Y_CALIBRATION;
111
-    tsoffsets[3] = XPT2046_Y_OFFSET;
112
-  }
104
+  #ifdef HAS_SPI_LCD
105
+    int16_t tsoffsets[4] = { 0 };
106
+
107
+    if (tsoffsets[0] + tsoffsets[1] == 0) {
108
+      // Not yet set, so use defines as fallback...
109
+      tsoffsets[0] = XPT2046_X_CALIBRATION;
110
+      tsoffsets[1] = XPT2046_X_OFFSET;
111
+      tsoffsets[2] = XPT2046_Y_CALIBRATION;
112
+      tsoffsets[3] = XPT2046_Y_OFFSET;
113
+    }
113 114
 
114
-  // We rely on XPT2046 compatible mode to ADS7843, hence no Z1 and Z2 measurements possible.
115
+    // We rely on XPT2046 compatible mode to ADS7843, hence no Z1 and Z2 measurements possible.
115 116
 
116
-  if (!isTouched()) return 0;
117
-  const uint16_t x = uint16_t(((uint32_t(getInTouch(XPT2046_X))) * tsoffsets[0]) >> 16) + tsoffsets[1],
118
-                 y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
119
-  if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
117
+    if (!isTouched()) return 0;
118
+    const uint16_t x = uint16_t(((uint32_t(getInTouch(XPT2046_X))) * tsoffsets[0]) >> 16) + tsoffsets[1],
119
+                  y = uint16_t(((uint32_t(getInTouch(XPT2046_Y))) * tsoffsets[2]) >> 16) + tsoffsets[3];
120
+    if (!isTouched()) return 0; // Fingers must still be on the TS for a valid read.
120 121
 
121
-  // Touch within the button area simulates an encoder button
122
-  if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
123
-    return WITHIN(x,  14,  77) ? EN_D
124
-         : WITHIN(x,  90, 153) ? EN_A
125
-         : WITHIN(x, 166, 229) ? EN_B
126
-         : WITHIN(x, 242, 305) ? EN_C
127
-         : 0;
122
+    // Touch within the button area simulates an encoder button
123
+    if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
124
+      return WITHIN(x,  14,  77) ? EN_D
125
+          : WITHIN(x,  90, 153) ? EN_A
126
+          : WITHIN(x, 166, 229) ? EN_B
127
+          : WITHIN(x, 242, 305) ? EN_C
128
+          : 0;
128 129
 
129
-  if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
130
+    if (x > TOUCH_SCREEN_WIDTH || !WITHIN(y, SCREEN_START_TOP, SCREEN_START_TOP + SCREEN_HEIGHT)) return 0;
130 131
 
131
-  // Column and row above BUTTON_AREA_TOP
132
-  int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
133
-         row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
132
+    // Column and row above BUTTON_AREA_TOP
133
+    int8_t col = (x - (SCREEN_START_LEFT)) * (LCD_WIDTH) / (TOUCHABLE_X_WIDTH),
134
+          row = (y - (SCREEN_START_TOP)) * (LCD_HEIGHT) / (TOUCHABLE_Y_HEIGHT);
134 135
 
135
-  // Send the touch to the UI (which will simulate the encoder wheel)
136
-  MarlinUI::screen_click(row, col, x, y);
136
+    // Send the touch to the UI (which will simulate the encoder wheel)
137
+    MarlinUI::screen_click(row, col, x, y);
138
+  #endif
137 139
   return 0;
138 140
 }
139 141
 

+ 1
- 1
Marlin/src/lcd/dogm/u8g_dev_tft_320x240_upscale_from_128x64.cpp View File

@@ -64,7 +64,7 @@
64 64
 
65 65
 #include <string.h>
66 66
 
67
-#if ENABLED(LCD_USE_DMA_FSMC)
67
+#ifdef LCD_USE_DMA_FSMC
68 68
   extern void LCD_IO_WriteReg(uint16_t Reg);
69 69
   extern void LCD_IO_WriteData(uint16_t RegValue);
70 70
   extern void LCD_IO_WriteSequence(uint16_t *data, uint16_t length);

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/W25Qxx.cpp View File

@@ -22,7 +22,7 @@
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24 24
 #if 1 // ENABLED(SPI_FLASH)
25
-#if ENABLED(TFT_LITTLE_VGL_UI)
25
+#if ENABLED(TFT_LVGL_UI)
26 26
 
27 27
 #include <SPI.h>
28 28
 #include "../../../../inc/MarlinConfig.h"
@@ -391,5 +391,5 @@ void ext_FLASH::SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16
391 391
 
392 392
 void ext_FLASH::lv_pic_read(uint8_t *P_Rbuff, uint32_t addr, uint32_t size) {SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, addr, size);}
393 393
 
394
-#endif // TFT_LITTLE_VGL_UI
394
+#endif // TFT_LVGL_UI
395 395
 #endif // 1 ... SPI_FLASH

+ 13
- 14
Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -99,29 +99,28 @@ void lv_draw_about(void) {
99 99
 
100 100
   fw_version = lv_label_create(scr, NULL);
101 101
   lv_obj_set_style(fw_version, &tft_style_lable_rel);
102
-  lv_label_set_text(fw_version, "Version: V_2.0.5.3");
102
+  lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
103 103
   lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
104 104
 
105 105
   fw_type = lv_label_create(scr, NULL);
106 106
   lv_obj_set_style(fw_type, &tft_style_lable_rel);
107
-  #if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO)
108
-    lv_label_set_text(fw_type, "Firmware: Robin_Pro35");
109
-  #elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO)
110
-    lv_label_set_text(fw_type, "Firmware: Robin_Nano35");
111
-  #endif
107
+  lv_label_set_text(fw_type,
108
+    #if MB(MKS_ROBIN_PRO)
109
+      "Firmware: Robin_Pro35"
110
+    #elif MB(MKS_ROBIN_NANO)
111
+      "Firmware: Robin_Nano35"
112
+    #else
113
+      CUSTOM_MACHINE_NAME
114
+    #endif
115
+  );
112 116
   lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20);
113 117
 
114 118
   board = lv_label_create(scr, NULL);
115 119
   lv_obj_set_style(board, &tft_style_lable_rel);
116
-  #if (MOTHERBOARD == BOARD_MKS_ROBIN_PRO)
117
-    lv_label_set_text(board, "Board: MKS Robin pro");
118
-  #elif (MOTHERBOARD == BOARD_MKS_ROBIN_NANO)
119
-    lv_label_set_text(board, "Board: MKS Robin nano");
120
-  #endif
121
-
120
+  lv_label_set_text(board, "Board: " BOARD_INFO_NAME);
122 121
   lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20);
123 122
 }
124 123
 
125 124
 void lv_clear_about() { lv_obj_del(scr); }
126 125
 
127
-#endif // TFT_LITTLE_VGL_UI
126
+#endif // TFT_LVGL_UI

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -310,13 +310,13 @@ void disp_print_speed() {
310 310
 void disp_speed_type() {
311 311
   switch (speedType) {
312 312
     case 1:
313
-      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed_sel.bin", 0);
314
-      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed.bin", 0);
313
+      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_extruct_sel.bin", 0);
314
+      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_changespeed.bin", 0);
315 315
       break;
316 316
 
317 317
     default:
318
-      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct_speed.bin", 0);
319
-      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_Mov_speed_sel.bin", 0);
318
+      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_Extruct.bin", 0);
319
+      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_sel.bin", 0);
320 320
       break;
321 321
   }
322 322
   lv_obj_refresh_ext_draw_pad(buttonExt);
@@ -333,4 +333,4 @@ void disp_speed_type() {
333 333
 
334 334
 void lv_clear_change_speed() { lv_obj_del(scr); }
335 335
 
336
-#endif // TFT_LITTLE_VGL_UI
336
+#endif // TFT_LVGL_UI

+ 7
- 5
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp View File

@@ -26,7 +26,7 @@
26 26
 
27 27
 #include "../../../../inc/MarlinConfigPre.h"
28 28
 
29
-#if ENABLED(TFT_LITTLE_VGL_UI)
29
+#if ENABLED(TFT_LVGL_UI)
30 30
 
31 31
 #include "lv_conf.h"
32 32
 #include "draw_ui.h"
@@ -61,7 +61,9 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
61 61
   }
62 62
   else if (event == LV_EVENT_RELEASED) {
63 63
     if (DialogType == DIALOG_TYPE_PRINT_FILE) {
64
-      preview_gcode_prehandle(list_file.file_name[sel_id]);
64
+      #if HAS_GCODE_PREVIEW
65
+        preview_gcode_prehandle(list_file.file_name[sel_id]);
66
+      #endif
65 67
       reset_print_time();
66 68
       start_print_time();
67 69
 
@@ -202,7 +204,7 @@ void lv_draw_dialog(uint8_t type) {
202 204
   style_btn_rel.body.shadow.type = LV_SHADOW_BOTTOM;
203 205
   style_btn_rel.body.radius = LV_RADIUS_CIRCLE;
204 206
   style_btn_rel.text.color = lv_color_hex3(0xDEF);
205
-  style_btn_rel.text.font = &gb2312_puhui32;
207
+  style_btn_rel.text.font = &lv_font_roboto_22;
206 208
 
207 209
   static lv_style_t style_btn_pr;                                    // A variable to store the pressed style
208 210
   lv_style_copy(&style_btn_pr, &style_btn_rel);                      // Initialize from the released style
@@ -211,7 +213,7 @@ void lv_draw_dialog(uint8_t type) {
211 213
   style_btn_pr.body.grad_color = lv_color_hex3(0x24A);
212 214
   style_btn_pr.body.shadow.width = 2;
213 215
   style_btn_pr.text.color = lv_color_hex3(0xBCD);
214
-  style_btn_pr.text.font = &gb2312_puhui32;
216
+  style_btn_pr.text.font = &lv_font_roboto_22;
215 217
 
216 218
   lv_obj_t * labelDialog = lv_label_create(scr, NULL);
217 219
   lv_obj_set_style(labelDialog, &tft_style_lable_rel);
@@ -340,4 +342,4 @@ void lv_draw_dialog(uint8_t type) {
340 342
 
341 343
 void lv_clear_dialog() { lv_obj_del(scr); }
342 344
 
343
-#endif // TFT_LITTLE_VGL_UI
345
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -81,4 +81,4 @@ void lv_draw_error_message(PGM_P const msg) {
81 81
 
82 82
 void lv_clear_error_message() { lv_obj_del(scr); }
83 83
 
84
-#endif // TFT_LITTLE_VGL_UI
84
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -375,4 +375,4 @@ void disp_ext_step() {
375 375
 
376 376
 void lv_clear_extrusion() { lv_obj_del(scr); }
377 377
 
378
-#endif // TFT_LITTLE_VGL_UI
378
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "lv_conf.h"
@@ -244,4 +244,4 @@ void disp_fan_value() {
244 244
 
245 245
 void lv_clear_fan() { lv_obj_del(scr); }
246 246
 
247
-#endif // TFT_LITTLE_VGL_UI
247
+#endif // TFT_LVGL_UI

+ 4
- 4
Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "draw_ready_print.h"
@@ -190,13 +190,13 @@ void lv_draw_home(void) {
190 190
     lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_lable_pre);
191 191
     lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_lable_rel);
192 192
 
193
-    lv_obj_set_event_cb_mks(buttonOffAll, event_handler, ID_H_OFF_ALL, "bmp_Motor_off.bin", 0);
193
+    lv_obj_set_event_cb_mks(buttonOffAll, event_handler, ID_H_OFF_ALL, "bmp_manual_off.bin", 0);
194 194
     lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic);
195 195
     lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic);
196 196
     lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_lable_pre);
197 197
     lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_lable_rel);
198 198
 
199
-    lv_obj_set_event_cb_mks(buttonOffXY, event_handler, ID_H_OFF_XY, "bmp_Motor_off.bin", 0);
199
+    lv_obj_set_event_cb_mks(buttonOffXY, event_handler, ID_H_OFF_XY, "bmp_manual_off.bin", 0);
200 200
     lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic);
201 201
     lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic);
202 202
     lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_lable_pre);
@@ -280,4 +280,4 @@ void lv_draw_home(void) {
280 280
 
281 281
 void lv_clear_home() { lv_obj_del(scr); }
282 282
 
283
-#endif // TFT_LITTLE_VGL_UI
283
+#endif // TFT_LVGL_UI

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -61,7 +61,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
61 61
       }
62 62
       else if (event == LV_EVENT_RELEASED) {
63 63
         disp_language(gCfgItems.language, UNSELECTED);
64
-        lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_Simple_cn_sel.bin", 0);
64
+        lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn_sel.bin", 0);
65 65
         gCfgItems.language = LANG_SIMPLE_CHINESE;
66 66
         gCfg_to_spiFlah();
67 67
         disp_language_init();
@@ -73,7 +73,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
73 73
       }
74 74
       else if (event == LV_EVENT_RELEASED) {
75 75
         disp_language(gCfgItems.language, UNSELECTED);
76
-        lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_Tradition_cn_sel.bin", 0);
76
+        lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn_sel.bin", 0);
77 77
         gCfgItems.language = LANG_COMPLEX_CHINESE;
78 78
         gCfg_to_spiFlah();
79 79
         disp_language_init();
@@ -258,14 +258,14 @@ void lv_draw_language(void) {
258 258
   buttonBack = lv_imgbtn_create(scr, NULL);
259 259
 
260 260
 
261
-  lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_Simple_cn.bin", 0);
261
+  lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn.bin", 0);
262 262
   lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, &bmp_pic);
263 263
   lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, &bmp_pic);
264 264
   lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_PR, &tft_style_lable_pre);
265 265
   lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_REL, &tft_style_lable_rel);
266 266
   lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
267 267
   #if 1
268
-    lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_Tradition_cn.bin", 0);
268
+    lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn.bin", 0);
269 269
     lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, &bmp_pic);
270 270
     lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, &bmp_pic);
271 271
     lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_PR, &tft_style_lable_pre);
@@ -367,4 +367,4 @@ void lv_draw_language(void) {
367 367
 
368 368
 void lv_clear_language() { lv_obj_del(scr); }
369 369
 
370
-#endif // TFT_LITTLE_VGL_UI
370
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "lv_conf.h"
@@ -281,4 +281,4 @@ void lv_draw_manualLevel(void) {
281 281
 
282 282
 void lv_clear_manualLevel() { lv_obj_del(scr); }
283 283
 
284
-#endif // TFT_LITTLE_VGL_UI
284
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "lv_conf.h"
@@ -326,4 +326,4 @@ void disp_move_dist() {
326 326
 
327 327
 void lv_clear_move_motor() { lv_obj_del(scr); }
328 328
 
329
-#endif // TFT_LITTLE_VGL_UI
329
+#endif // TFT_LVGL_UI

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/draw_opration.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -116,7 +116,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
116 116
       else if (event == LV_EVENT_RELEASED) {
117 117
         if (gCfgItems.finish_power_off == 1) {
118 118
           gCfgItems.finish_power_off = 0;
119
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_Mamual.bin", 0);
119
+          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0); //dindt find bmp_Mamual...
120 120
           lv_label_set_text(label_PowerOff, printing_more_menu.manual);
121 121
           lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
122 122
           lv_obj_refresh_ext_draw_pad(label_PowerOff);
@@ -124,7 +124,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
124 124
         }
125 125
         else {
126 126
           gCfgItems.finish_power_off = 1;
127
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_Auto.bin", 0);
127
+          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
128 128
           lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
129 129
           lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
130 130
           lv_obj_refresh_ext_draw_pad(label_PowerOff);
@@ -218,9 +218,9 @@ void lv_draw_opration(void) {
218 218
       lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_lable_rel);
219 219
     }
220 220
     if (gCfgItems.finish_power_off == 1)
221
-      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_Auto.bin", 0);
221
+      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
222 222
     else
223
-      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_Mamual.bin", 0);
223
+      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0);
224 224
     lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, &bmp_pic);
225 225
     lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, &bmp_pic);
226 226
     lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_lable_pre);
@@ -319,4 +319,4 @@ void lv_draw_opration(void) {
319 319
 
320 320
 void lv_clear_opration() { lv_obj_del(scr); }
321 321
 
322
-#endif // TFT_LITTLE_VGL_UI
322
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_pause_message.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if BOTH(TFT_LITTLE_VGL_UI, ADVANCED_PAUSE_FEATURE)
24
+#if BOTH(TFT_LVGL_UI, ADVANCED_PAUSE_FEATURE)
25 25
 
26 26
 #include "draw_ui.h"
27 27
 #include "lv_conf.h"
@@ -52,4 +52,4 @@ void lv_draw_pause_message(const PauseMessage msg) {
52 52
   }
53 53
 }
54 54
 
55
-#endif // TFT_LITTLE_VGL_UI && ADVANCED_PAUSE_FEATURE
55
+#endif // TFT_LVGL_UI && ADVANCED_PAUSE_FEATURE

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -389,4 +389,4 @@ void disp_step_heat() {
389 389
 
390 390
 void lv_clear_preHeat() { lv_obj_del(scr); }
391 391
 
392
-#endif // TFT_LITTLE_VGL_UI
392
+#endif // TFT_LVGL_UI

+ 54
- 32
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "lv_conf.h"
@@ -324,7 +324,7 @@ void disp_gcode_icon(uint8_t file_num) {
324 324
     lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_PR, &tft_style_lable_pre);
325 325
     lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_REL, &tft_style_lable_rel);
326 326
 
327
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_Back.bin", 0);
327
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_Return.bin", 0);
328 328
     lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic_117x92);
329 329
     lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic_117x92);
330 330
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_lable_pre);
@@ -445,21 +445,9 @@ void disp_gcode_icon(uint8_t file_num) {
445 445
 
446 446
 void lv_open_gcode_file(char *path) {
447 447
   #if ENABLED(SDSUPPORT)
448
-    //uint32_t read;
449
-    uint32_t *ps4;
450
-    int pre_sread_cnt;
451 448
     char *cur_name;
452
-
453 449
     cur_name = strrchr(path, '/');
454
-
455 450
     card.openFileRead(cur_name);
456
-    card.read(public_buf, 512);
457
-    ps4 = (uint32_t *)strstr((char *)public_buf, ";simage:");
458
-
459
-    if (ps4) {
460
-      pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0]));
461
-      card.setIndex(pre_sread_cnt + 8);
462
-    }
463 451
   #endif
464 452
 }
465 453
 
@@ -480,30 +468,64 @@ int ascii2dec_test(char *ascii) {
480 468
   return result;
481 469
 }
482 470
 
483
-void lv_gcode_file_read(uint8_t *data_buf) {
484
-  #if ENABLED(SDSUPPORT)
485
-    uint16_t i = 0, j = 0, k = 0;
486
-    //uint32_t read;
487
-    uint16_t row_1 = 0;
471
+void lv_gcode_file_read(uint8_t *data_buf)
472
+{
473
+	#if ENABLED (SDSUPPORT)
474
+    uint16_t i=0,j=0,k=0;
475
+    uint16_t row_1=0;
476
+    bool ignore_start = true;
488 477
     char temp_test[200];
478
+    volatile uint16_t *p_index;
479
+
480
+    memset(public_buf, 0, 200);
489 481
 
490
-    while (1) {
491
-      card.read(temp_test, 200);
492
-      for (i = 0; i < 200;) {
493
-        public_buf[row_1 * 200 + 100 * k + j] = (char)(ascii2dec_test(&temp_test[i]) << 4 | ascii2dec_test(&temp_test[i + 1]));
482
+    while(card.isFileOpen())
483
+    {
484
+      if (ignore_start) card.read(temp_test, 8); //line start -> ignore
485
+      card.read(temp_test, 200); //data
486
+      //\r;;gimage: we got the bit img, so stop here
487
+      if (temp_test[1] == ';') {
488
+        card.closefile();
489
+        break;
490
+      }
491
+      for(i=0;i<200;) {
492
+        public_buf[row_1*200+100*k+j] = (char)(ascii2dec_test(&temp_test[i])<<4|ascii2dec_test(&temp_test[i+1]));
494 493
         j++;
495
-        i += 2;
494
+        i+=2;
496 495
       }
497
-      k++;
498
-      j = 0;
499
-      if (k >= 2) {
500
-        k = 0;
501
-        card.read(temp_test, 9);
496
+
497
+      uint16_t c = card.get();
498
+      //check if we have more data or finished the line (CR)
499
+      if (c == '\r') {
502 500
         break;
503 501
       }
502
+      card.setIndex(card.getIndex());
503
+      k++;
504
+      j=0;
505
+      ignore_start = false;
504 506
     }
505
-    memcpy(data_buf, public_buf, 200);
506
-  #endif
507
+    #if ENABLED(SPI_GRAPHICAL_TFT)
508
+      for(i=0;i<200;)
509
+      {
510
+        p_index = (uint16_t *)(&public_buf[i]);
511
+
512
+            //Color = (*p_index >> 8);
513
+        //*p_index = Color | ((*p_index & 0xff) << 8);
514
+        i+=2;
515
+        if(*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full;
516
+      }
517
+    #else
518
+      for(i=0;i<200;)
519
+      {
520
+        p_index = (uint16_t *)(&public_buf[i]);
521
+        //Color = (*p_index >> 8);
522
+        //*p_index = Color | ((*p_index & 0xff) << 8);
523
+        i+=2;
524
+        if(*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full; // 0x18C3; //
525
+      }
526
+    #endif
527
+    memcpy(data_buf,public_buf,200);
528
+	#endif
507 529
 }
508 530
 
509 531
 void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());}
@@ -592,4 +614,4 @@ void cutFileName(char *path, int len, int bytePerLine,  char *outStr) {
592 614
 
593 615
 void lv_clear_print_file() { lv_obj_del(scr); }
594 616
 
595
-#endif // TFT_LITTLE_VGL_UI
617
+#endif // TFT_LVGL_UI

+ 5
- 5
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -308,13 +308,13 @@ void lv_draw_printing(void) {
308 308
       lv_label_set_text(labelPause, printing_menu.pause);
309 309
     else
310 310
       lv_label_set_text(labelPause, printing_menu.resume);
311
-    lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
311
+    lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0);
312 312
 
313 313
     lv_label_set_text(labelStop, printing_menu.stop);
314
-    lv_obj_align(labelStop, buttonStop, LV_ALIGN_CENTER, 30, 0);
314
+    lv_obj_align(labelStop, buttonStop, LV_ALIGN_CENTER, 20, 0);
315 315
 
316 316
     lv_label_set_text(labelOperat, printing_menu.option);
317
-    lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 30, 0);
317
+    lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
318 318
   }
319 319
 
320 320
   lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
@@ -440,4 +440,4 @@ void setProBarRate() {
440 440
 
441 441
 void lv_clear_printing() { lv_obj_del(scr); }
442 442
 
443
-#endif // TFT_LITTLE_VGL_UI
443
+#endif // TFT_LVGL_UI

+ 3
- 3
Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "draw_ready_print.h"
27 27
 #include "draw_tool.h"
@@ -260,7 +260,7 @@ void lv_draw_ready_print(void) {
260 260
     buttonTool = lv_imgbtn_create(scr, NULL);
261 261
     buttonSet = lv_imgbtn_create(scr, NULL);
262 262
 
263
-    lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_Print.bin", 0);
263
+    lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_printing.bin", 0);
264 264
     //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin");
265 265
     lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic);
266 266
     lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic);
@@ -316,4 +316,4 @@ void lv_draw_ready_print(void) {
316 316
 
317 317
 void lv_clear_ready_print() { lv_obj_del(scr); }
318 318
 
319
-#endif // TFT_LITTLE_VGL_UI
319
+#endif // TFT_LVGL_UI

+ 32
- 16
Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "draw_ready_print.h"
@@ -33,6 +33,7 @@
33 33
 //#include "../lvgl/src/lv_core/lv_refr.h"
34 34
 #include "draw_ui.h"
35 35
 #include "../../../../gcode/queue.h"
36
+#include "pic_manager.h"
36 37
 
37 38
 static lv_obj_t * scr;
38 39
 
@@ -110,7 +111,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
110 111
 
111 112
 void lv_draw_set(void) {
112 113
   lv_obj_t *buttonFan, *buttonAbout;
113
-  lv_obj_t *buMotorOff, *buttonLanguage, *buttonBack;
114
+  lv_obj_t *buMotorOff, *buttonBack;
115
+  #if HAS_LANG_SELECT_SCREEN
116
+    lv_obj_t *buttonLanguage;
117
+  #endif
114 118
 
115 119
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) {
116 120
     disp_state_stack._disp_index++;
@@ -141,7 +145,9 @@ void lv_draw_set(void) {
141 145
   buttonAbout = lv_imgbtn_create(scr, NULL);
142 146
   //buttonContinue = lv_imgbtn_create(scr, NULL);
143 147
   buMotorOff = lv_imgbtn_create(scr, NULL);
144
-  buttonLanguage = lv_imgbtn_create(scr, NULL);
148
+  #if HAS_LANG_SELECT_SCREEN
149
+    buttonLanguage = lv_imgbtn_create(scr, NULL);
150
+  #endif
145 151
   buttonBack = lv_imgbtn_create(scr, NULL);
146 152
 
147 153
 
@@ -170,20 +176,22 @@ void lv_draw_set(void) {
170 176
     //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_lable_pre);
171 177
     //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_lable_rel);
172 178
     #if HAS_SUICIDE
173
-      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Mamual.bin", 0);
179
+      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_manual_off.bin", 0);
174 180
     #else
175
-      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Motor_off.bin", 0);
181
+      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_manual_off.bin", 0);
176 182
     #endif
177 183
     lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, &bmp_pic);
178 184
     lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, &bmp_pic);
179 185
     lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_PR, &tft_style_lable_pre);
180 186
     lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_REL, &tft_style_lable_rel);
181 187
 
182
-    lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_Language.bin", 0);
183
-    lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic);
184
-    lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic);
185
-    lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_lable_pre);
186
-    lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_lable_rel);
188
+    #if HAS_LANG_SELECT_SCREEN
189
+      lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_Language.bin", 0);
190
+      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic);
191
+      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic);
192
+      lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_lable_pre);
193
+      lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_lable_rel);
194
+    #endif
187 195
 
188 196
     lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN, "bmp_Return.bin", 0);
189 197
     lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
@@ -205,7 +213,9 @@ void lv_draw_set(void) {
205 213
   lv_obj_set_pos(buttonAbout, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
206 214
   //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
207 215
   lv_obj_set_pos(buMotorOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
208
-  lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight);
216
+  #if HAS_LANG_SELECT_SCREEN
217
+    lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight);
218
+  #endif
209 219
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4,  BTN_Y_PIXEL + INTERVAL_H + titleHeight);
210 220
 
211 221
   /*Create a label on the Image button*/
@@ -214,7 +224,9 @@ void lv_draw_set(void) {
214 224
   lv_btn_set_layout(buttonAbout, LV_LAYOUT_OFF);
215 225
   //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF);
216 226
   lv_btn_set_layout(buMotorOff, LV_LAYOUT_OFF);
217
-  lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF);
227
+  #if HAS_LANG_SELECT_SCREEN
228
+    lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF);
229
+  #endif
218 230
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
219 231
 
220 232
   //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL);
@@ -222,7 +234,9 @@ void lv_draw_set(void) {
222 234
   lv_obj_t * label_About = lv_label_create(buttonAbout, NULL);
223 235
   //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL);
224 236
   lv_obj_t * label_MotorOff = lv_label_create(buMotorOff, NULL);
225
-  lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL);
237
+  #if HAS_LANG_SELECT_SCREEN
238
+    lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL);
239
+  #endif
226 240
   lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
227 241
 
228 242
 
@@ -245,8 +259,10 @@ void lv_draw_set(void) {
245 259
     #endif
246 260
     lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
247 261
 
248
-    lv_label_set_text(label_Language, set_menu.language);
249
-    lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
262
+    #if HAS_LANG_SELECT_SCREEN
263
+      lv_label_set_text(label_Language, set_menu.language);
264
+      lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
265
+    #endif
250 266
 
251 267
     lv_label_set_text(label_Back, common_menu.text_back);
252 268
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -255,4 +271,4 @@ void lv_draw_set(void) {
255 271
 
256 272
 void lv_clear_set() { lv_obj_del(scr); }
257 273
 
258
-#endif // TFT_LITTLE_VGL_UI
274
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "lv_conf.h"
27 27
 #include "draw_ui.h"
@@ -267,4 +267,4 @@ void lv_draw_tool(void) {
267 267
 
268 268
 void lv_clear_tool() { lv_obj_del(scr); }
269 269
 
270
-#endif // TFT_LITTLE_VGL_UI
270
+#endif // TFT_LVGL_UI

+ 93
- 26
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp View File

@@ -21,11 +21,10 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "W25Qxx.h"
27 27
 #include "tft_lvgl_configuration.h"
28
-#include "pic_manager.h"
29 28
 
30 29
 #include <SPI.h>
31 30
 
@@ -38,6 +37,8 @@
38 37
 #include "../../../../module/motion.h"
39 38
 #include "../../../../module/planner.h"
40 39
 
40
+#include "pic_manager.h"
41
+
41 42
 #if ENABLED(POWER_LOSS_RECOVERY)
42 43
   #include "../../../../feature/powerloss.h"
43 44
 #endif
@@ -73,7 +74,33 @@ extern void LCD_IO_WriteData(uint16_t RegValue);
73 74
 
74 75
 void gCfgItems_init() {
75 76
   gCfgItems.multiple_language = MULTI_LANGUAGE_ENABLE;
76
-  gCfgItems.language = LANG_ENGLISH;
77
+  #if 1 //LCD_LANGUAGE == en
78
+    gCfgItems.language = LANG_ENGLISH;
79
+  #elif LCD_LANGUAGE == zh_CN
80
+    gCfgItems.language = LANG_SIMPLE_CHINESE;
81
+  #elif LCD_LANGUAGE == zh_TW
82
+    gCfgItems.language = LANG_COMPLEX_CHINESE;
83
+  #elif LCD_LANGUAGE == jp_kana
84
+    gCfgItems.language = LANG_JAPAN;
85
+  #elif LCD_LANGUAGE == de
86
+    gCfgItems.language = LANG_GERMAN;
87
+  #elif LCD_LANGUAGE == fr
88
+    gCfgItems.language = LANG_FRENCH;
89
+  #elif LCD_LANGUAGE == ru
90
+    gCfgItems.language = LANG_RUSSIAN;
91
+  #elif LCD_LANGUAGE == ko_KR
92
+    gCfgItems.language = LANG_KOREAN;
93
+  #elif LCD_LANGUAGE == tr
94
+    gCfgItems.language = LANG_TURKISH;
95
+  #elif LCD_LANGUAGE == es
96
+    gCfgItems.language = LANG_SPANISH;
97
+  #elif LCD_LANGUAGE == el
98
+    gCfgItems.language = LANG_GREEK;
99
+  #elif LCD_LANGUAGE == it
100
+    gCfgItems.language = LANG_ITALY;
101
+  #elif LCD_LANGUAGE == pt
102
+    gCfgItems.language = LANG_PORTUGUESE;
103
+  #endif
77 104
   gCfgItems.leveling_mode = 0;
78 105
   gCfgItems.from_flash_pic = 0;
79 106
   gCfgItems.curFilesize = 0;
@@ -139,8 +166,13 @@ void tft_style_init() {
139 166
   tft_style_lable_rel.body.grad_color = LV_COLOR_BACKGROUND;
140 167
   tft_style_lable_rel.text.color = LV_COLOR_TEXT;
141 168
   tft_style_lable_rel.text.sel_color = LV_COLOR_TEXT;
142
-  tft_style_lable_pre.text.font = &gb2312_puhui32;
143
-  tft_style_lable_rel.text.font = &gb2312_puhui32;
169
+  #if HAS_SPI_FLASH_FONT
170
+    tft_style_lable_pre.text.font = &gb2312_puhui32;
171
+    tft_style_lable_rel.text.font = &gb2312_puhui32;
172
+  #else
173
+    tft_style_lable_pre.text.font = LV_FONT_DEFAULT;
174
+    tft_style_lable_rel.text.font = LV_FONT_DEFAULT;
175
+  #endif
144 176
   tft_style_lable_pre.line.width = 0;
145 177
   tft_style_lable_rel.line.width = 0;
146 178
   tft_style_lable_pre.text.letter_space = 0;
@@ -325,6 +357,9 @@ char *creat_title_text() {
325 357
   return public_buf_m;
326 358
 }
327 359
 
360
+#if HAS_GCODE_PREVIEW
361
+uint32_t gPicturePreviewStart = 0;
362
+
328 363
 void preview_gcode_prehandle(char *path) {
329 364
   #if ENABLED(SDSUPPORT)
330 365
     //uint8_t re;
@@ -333,6 +368,7 @@ void preview_gcode_prehandle(char *path) {
333 368
     uint32_t *p1;
334 369
     char *cur_name;
335 370
 
371
+    gPicturePreviewStart = 0;
336 372
     cur_name = strrchr(path, '/');
337 373
     card.openFileRead(cur_name);
338 374
     card.read(public_buf, 512);
@@ -369,7 +405,24 @@ void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
369 405
     cur_name = strrchr(path, '/');
370 406
     card.openFileRead(cur_name);
371 407
 
372
-    card.setIndex((PREVIEW_LITTLE_PIC_SIZE + To_pre_view) + size * row + 8);
408
+    if (gPicturePreviewStart <= 0) {
409
+      while (1) {
410
+        uint32_t br = card.read(public_buf, 400);
411
+        uint32_t* p1 = (uint32_t *)strstr((char *)public_buf, ";gimage:");
412
+        if (p1) {
413
+          gPicturePreviewStart += (uint32_t)p1 - (uint32_t)((uint32_t *)(&public_buf[0]));
414
+          break;
415
+        }
416
+        else {
417
+          gPicturePreviewStart += br;
418
+        }
419
+        if (br < 400) break;
420
+      }
421
+    }
422
+
423
+    // SERIAL_ECHOLNPAIR("gPicturePreviewStart: ", gPicturePreviewStart, " PREVIEW_LITTLE_PIC_SIZE: ", PREVIEW_LITTLE_PIC_SIZE);
424
+
425
+    card.setIndex((gPicturePreviewStart + To_pre_view) + size * row + 8);
373 426
     #if ENABLED(SPI_GRAPHICAL_TFT)
374 427
       SPI_TFT.spi_init(SPI_FULL_SPEED);
375 428
       //SPI_TFT.SetCursor(0,0);
@@ -417,14 +470,16 @@ void gcode_preview(char *path, int xpos_pixel, int ypos_pixel) {
417 470
     #else
418 471
       for (i = 0; i < 400;) {
419 472
         p_index = (uint16_t *)(&bmp_public_buf[i]);
420
-        //if (*p_index == 0x0000)*p_index=gCfgItems.preview_bk_color;
473
+        if (*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
421 474
         LCD_IO_WriteData(*p_index);
422 475
         i += 2;
423 476
       }
424 477
     #endif
425
-    W25QXX.init(SPI_QUARTER_SPEED);
426
-    if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
427
-    W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
478
+    #if HAS_BAK_VIEW_IN_FLASH
479
+      W25QXX.init(SPI_QUARTER_SPEED);
480
+      if (row < 20) W25QXX.SPI_FLASH_SectorErase(BAK_VIEW_ADDR_TFT35 + row * 4096);
481
+      W25QXX.SPI_FLASH_BufferWrite(bmp_public_buf, BAK_VIEW_ADDR_TFT35 + row * 400, 400);
482
+    #endif
428 483
     row++;
429 484
     if (row >= 200) {
430 485
       size = 809;
@@ -489,15 +544,19 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
489 544
   int x_off = 0, y_off = 0;
490 545
   int _y;
491 546
   uint16_t *p_index;
492
-  int i, j;
493
-  uint16_t temp_p, Color;
547
+  int i;
548
+  uint16_t temp_p;
494 549
 
495 550
   for (index = 0; index < 10; index++) { // 200*200
496
-    if (sel == 1) flash_view_Read(bmp_public_buf, 8000); //20k
497
-    //memset(bmp_public_buf,0x1f,8000);
498
-    else
551
+    #if HAS_BAK_VIEW_IN_FLASH
552
+      if (sel == 1) flash_view_Read(bmp_public_buf, 8000); //20k
499 553
       //memset(bmp_public_buf,0x1f,8000);
500
-      default_view_Read(bmp_public_buf, 8000); //20k
554
+      else
555
+        //memset(bmp_public_buf,0x1f,8000);
556
+        default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); //20k
557
+    #else
558
+      default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); //20k
559
+    #endif
501 560
 
502 561
     i = 0;
503 562
     #if ENABLED(SPI_GRAPHICAL_TFT)
@@ -534,6 +593,7 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
534 593
           else {
535 594
             p_index = (uint16_t *)(&bmp_public_buf[i]);
536 595
           }
596
+          if (*p_index == 0x0000)*p_index=LV_COLOR_BACKGROUND.full; //gCfgItems.preview_bk_color;
537 597
           LCD_IO_WriteData(*p_index);
538 598
           i += 2;
539 599
         }
@@ -547,15 +607,20 @@ void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
547 607
 
548 608
 void disp_pre_gcode(int xpos_pixel, int ypos_pixel) {
549 609
   if (gcode_preview_over == 1) gcode_preview(list_file.file_name[sel_id], xpos_pixel, ypos_pixel);
550
-  if (flash_preview_begin == 1) {
551
-    flash_preview_begin = 0;
552
-    Draw_default_preview(xpos_pixel, ypos_pixel, 1);
553
-  }
554
-  if (default_preview_flg == 1) {
555
-    Draw_default_preview(xpos_pixel, ypos_pixel, 0);
556
-    default_preview_flg = 0;
557
-  }
610
+  #if HAS_BAK_VIEW_IN_FLASH
611
+    if (flash_preview_begin == 1) {
612
+      flash_preview_begin = 0;
613
+      Draw_default_preview(xpos_pixel, ypos_pixel, 1);
614
+    }
615
+  #endif
616
+  #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
617
+    if (default_preview_flg == 1) {
618
+      Draw_default_preview(xpos_pixel, ypos_pixel, 0);
619
+      default_preview_flg = 0;
620
+    }
621
+  #endif
558 622
 }
623
+#endif
559 624
 
560 625
 void print_time_run() {
561 626
   static uint8_t lastSec = 0;
@@ -1175,9 +1240,11 @@ void LV_TASK_HANDLER() {
1175 1240
   //lv_tick_inc(1);
1176 1241
   lv_task_handler();
1177 1242
   TERN_(MKS_TEST, mks_test());
1178
-  disp_pre_gcode(2, 36);
1243
+  #if HAS_GCODE_PREVIEW
1244
+    disp_pre_gcode(2, 36);
1245
+  #endif
1179 1246
   GUI_RefreshPage();
1180 1247
   //sd_detection();
1181 1248
 }
1182 1249
 
1183
-#endif // TFT_LITTLE_VGL_UI
1250
+#endif // TFT_LVGL_UI

+ 8
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h View File

@@ -28,6 +28,11 @@ extern "C" { /* C-declarations for C++ */
28 28
 #include <stdint.h>
29 29
 #include <string.h>
30 30
 #include "lvgl.h"
31
+
32
+//the colors of the last MKS Ui
33
+#undef LV_COLOR_BACKGROUND
34
+#define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) //LV_COLOR_MAKE(0x00, 0x00, 0x00)
35
+
31 36
 #include "tft_multi_language.h"
32 37
 #include "draw_ready_print.h"
33 38
 #include "draw_language.h"
@@ -214,7 +219,9 @@ extern void tft_style_init();
214 219
 extern char *creat_title_text(void);
215 220
 extern void preview_gcode_prehandle(char *path);
216 221
 extern void update_spi_flash();
217
-extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
222
+#if HAS_GCODE_PREVIEW
223
+  extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
224
+#endif
218 225
 extern void GUI_RefreshPage();
219 226
 extern void clear_cur_ui();
220 227
 extern void draw_return_ui();

+ 6
- 2
Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp View File

@@ -21,12 +21,14 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 #include "lvgl.h"
28 28
 #include "pic_manager.h"
29 29
 
30
+#if HAS_SPI_FLASH_FONT
31
+
30 32
 typedef struct {
31 33
   uint16_t min;
32 34
   uint16_t max;
@@ -108,4 +110,6 @@ void init_gb2312_font() {
108 110
   gb2312_puhui32.base_line = 0;
109 111
 }
110 112
 
111
-#endif // TFT_LITTLE_VGL_UI
113
+#endif // HAS_SPI_FLASH_FONT
114
+
115
+#endif // TFT_LVGL_UI

+ 4
- 3
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp View File

@@ -21,19 +21,20 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "tft_lvgl_configuration.h"
27 27
 #include "lvgl.h"
28 28
 #include "draw_ready_print.h"
29 29
 #include "W25Qxx.h"
30
-#include "pic_manager.h"
31 30
 #include "mks_hardware_test.h"
32 31
 
33 32
 #include "../../../../MarlinCore.h"
34 33
 #include "../../../../module/temperature.h"
35 34
 #include "../../../../feature/touch/xpt2046.h"
36 35
 
36
+#include "pic_manager.h"
37
+
37 38
 #if ENABLED(MKS_TEST)
38 39
 
39 40
   extern uint8_t curent_disp_ui;
@@ -591,4 +592,4 @@ void disp_font_update() {
591 592
   disp_string(120, 150, "FONT Updating...", 0xFFFF, 0x0000);
592 593
 }
593 594
 
594
-#endif // TFT_LITTLE_VGL_UI
595
+#endif // TFT_LVGL_UI

+ 337
- 490
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp View File

@@ -21,11 +21,10 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 
28
-//#include "type_define.h"
29 28
 #include "string.h"
30 29
 
31 30
 #include "pic_manager.h"
@@ -34,10 +33,6 @@
34 33
 #include "draw_ready_print.h"
35 34
 #include "mks_hardware_test.h"
36 35
 
37
-//#include "gui.h"
38
-//#include "spi_flash.h"
39
-
40
-//uint8_t DMA_ERRO_FLAG;
41 36
 extern uint16_t DeviceCode;
42 37
 extern unsigned char bmp_public_buf[17 * 1024];
43 38
 
@@ -45,7 +40,158 @@ extern unsigned char bmp_public_buf[17 * 1024];
45 40
   extern char *createFilename(char * const buffer, const dir_t &p);
46 41
 #endif
47 42
 
48
-/*void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead) {}*/
43
+static char assets[][30] = {
44
+  //homing screen
45
+  "bmp_Zero.bin",
46
+  "bmp_zeroX.bin",
47
+  "bmp_zeroY.bin",
48
+  "bmp_zeroZ.bin",
49
+  "bmp_manual_off.bin",
50
+
51
+  //tool screen
52
+  "bmp_PreHeat.bin",
53
+  "bmp_Extruct.bin",
54
+  "bmp_Mov.bin",
55
+  // "bmp_Zero.bin",
56
+  "bmp_Leveling.bin",
57
+
58
+  //fan screen
59
+  "bmp_Add.bin",
60
+  "bmp_Dec.bin",
61
+  "bmp_Speed255.bin",
62
+  "bmp_Speed127.bin",
63
+  "bmp_Speed0.bin",
64
+
65
+  //preheat screen
66
+  // "bmp_Add.bin",
67
+  // "bmp_Dec.bin",
68
+  "bmp_Speed0.bin",
69
+  // "bmp_Extru2.bin",
70
+  // "bmp_Extru1.bin",
71
+  "bmp_Bed.bin",
72
+  "bmp_Step1_degree.bin",
73
+  "bmp_Step5_degree.bin",
74
+  "bmp_Step10_degree.bin",
75
+
76
+  //extrusion screen
77
+  "bmp_In.bin",
78
+  "bmp_Out.bin",
79
+  "bmp_Extru1.bin",
80
+  #if EXTRUDERS > 1
81
+    "bmp_Extru2.bin",
82
+  #endif
83
+  "bmp_Speed_high.bin",
84
+  "bmp_Speed_slow.bin",
85
+  "bmp_Speed_normal.bin",
86
+  "bmp_Step1_mm.bin",
87
+  "bmp_Step5_mm.bin",
88
+  "bmp_Step10_mm.bin",
89
+
90
+  //select file screen
91
+  "bmp_pageUp.bin",
92
+  "bmp_pageDown.bin",
93
+  //"bmp_Back.bin", //TODO: why two back buttons? Why not just one? (return / back)
94
+  "bmp_Dir.bin",
95
+  "bmp_File.bin",
96
+
97
+  //move motor screen
98
+  //TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
99
+  "bmp_xAdd.bin",
100
+  "bmp_xDec.bin",
101
+  "bmp_yAdd.bin",
102
+  "bmp_yDec.bin",
103
+  "bmp_zAdd.bin",
104
+  "bmp_zDec.bin",
105
+  "bmp_Step_move0_1.bin",
106
+  "bmp_Step_move1.bin",
107
+  "bmp_Step_move10.bin",
108
+
109
+  //operation screen
110
+  "bmp_auto_off.bin",
111
+  "bmp_Speed.bin",
112
+  //"bmp_Mamual.bin", //TODO: didn't find it.. changed to bmp_manual_off.bin
113
+  "bmp_Fan.bin",
114
+  //"bmp_PreHeat.bin",
115
+  //"bmp_Extruct.bin",
116
+  // "bmp_Mov.bin",
117
+
118
+  //change speed screen
119
+  "bmp_Step1_percent.bin",
120
+  "bmp_Step5_percent.bin",
121
+  "bmp_Step10_percent.bin",
122
+  "bmp_extruct_sel.bin",
123
+  "bmp_mov_changespeed.bin",
124
+  // "bmp_extrude_opr.bin", equal to "bmp_Extruct.bin"
125
+  "bmp_mov_sel.bin",
126
+
127
+  //printing screen
128
+  "bmp_Pause.bin",
129
+  "bmp_Resume.bin",
130
+  "bmp_Stop.bin",
131
+  "bmp_Ext1_state.bin",
132
+  #if EXTRUDERS > 1
133
+    "bmp_Ext2_state.bin",
134
+  #endif
135
+  "bmp_Bed_state.bin",
136
+  "bmp_Fan_state.bin",
137
+  "bmp_Time_state.bin",
138
+  "bmp_Zpos_state.bin",
139
+  "bmp_Operate.bin",
140
+
141
+  //manual leval screen (only if disabled auto level)
142
+  #if DISABLED(AUTO_BED_LEVELING_BILINEAR)
143
+    "bmp_Leveling1.bin",
144
+    "bmp_Leveling2.bin",
145
+    "bmp_Leveling3.bin",
146
+    "bmp_Leveling4.bin",
147
+    "bmp_Leveling5.bin",
148
+  #endif
149
+
150
+  //lang select screen
151
+  #if HAS_LANG_SELECT_SCREEN
152
+    "bmp_Language.bin",
153
+    "bmp_simplified_cn.bin",
154
+    "bmp_simplified_cn_sel.bin",
155
+    "bmp_traditional_cn.bin",
156
+    "bmp_traditional_cn_sel.bin",
157
+    "bmp_English.bin",
158
+    "bmp_English_sel.bin",
159
+    "bmp_Russian.bin",
160
+    "bmp_Russian_sel.bin",
161
+    "bmp_Spanish.bin",
162
+    "bmp_Spanish_sel.bin",
163
+    "bmp_French.bin",
164
+    "bmp_French_sel.bin",
165
+    "bmp_Italy.bin",
166
+    "bmp_Italy_sel.bin",
167
+  #endif //HAS_LANG_SELECT_SCREEN
168
+
169
+  //gcode preview
170
+  #if HAS_GCODE_DEFAULT_VIEW_IN_FLASH
171
+    "bmp_preview.bin",
172
+  #endif
173
+
174
+  //settings screen
175
+  "bmp_About.bin",
176
+  //"bmp_Language.bin",
177
+  //"bmp_Fan.bin",
178
+  //"bmp_manual_off.bin",
179
+
180
+  //start screen
181
+  "bmp_printing.bin",
182
+  "bmp_Set.bin",
183
+  "bmp_Tool.bin",
184
+
185
+  //base icons
186
+  "bmp_Return.bin"
187
+};
188
+
189
+#if HAS_SPI_FLASH_FONT
190
+  static char fonts[][50] = {
191
+    "GBK16.bin",
192
+    "UNIGBK.bin",
193
+  };
194
+#endif
49 195
 
50 196
 uint32_t lv_get_pic_addr(uint8_t *Pname) {
51 197
   uint8_t Pic_cnt;
@@ -54,21 +200,22 @@ uint32_t lv_get_pic_addr(uint8_t *Pname) {
54 200
   uint32_t tmp_cnt = 0;
55 201
   uint32_t addr = 0;
56 202
 
203
+  #if ENABLED(MARLIN_DEV_MODE)
204
+    SERIAL_ECHOLNPAIR("Getting picture SPI Flash Address: ", (const char*)Pname);
205
+  #endif
206
+
57 207
   W25QXX.init(SPI_QUARTER_SPEED);
58 208
 
59 209
   W25QXX.SPI_FLASH_BufferRead(&Pic_cnt, PIC_COUNTER_ADDR, 1);
60
-  if (Pic_cnt == 0xff)
61
-    Pic_cnt = 0;
210
+  if (Pic_cnt == 0xFF) Pic_cnt = 0;
62 211
   for (i = 0; i < Pic_cnt; i++) {
63 212
     j = 0;
64
-    do
65
-    {
213
+    do {
66 214
       W25QXX.SPI_FLASH_BufferRead(&PIC.name[j], PIC_NAME_ADDR + tmp_cnt, 1);
67 215
       tmp_cnt++;
68
-    }while (PIC.name[j++] != '\0');
69
-
70
-    if ((strcmp((char*)Pname, (char*)PIC.name)) == 0) {
216
+    } while (PIC.name[j++] != '\0');
71 217
 
218
+    if ((strcasecmp((char*)Pname, (char*)PIC.name)) == 0) {
72 219
       if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761))
73 220
         addr = PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35;
74 221
       else
@@ -86,111 +233,40 @@ const char *bakPath = "bak_pic";
86 233
 const char *fontPath = "mks_font";
87 234
 const char *bakFont = "bak_font";
88 235
 
89
-#if 1
90
-
91 236
 void spiFlashErase_PIC() {
92
-  #if 1
93
-    volatile uint32_t pic_sectorcnt = 0;
94
-
95
-    //LCD_Clear(BACK_COLOR);
96
-    //LCD_DisplayString(90,80,"SPI Flash");
97
-    //LCD_DisplayString(120,90,"PIC Erasing...");
98
-    if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) {
99
-      //LCD_ShowString(180,100,200,24,24,"SPI Flash");
100
-      //LCD_ShowString(170,130,200,24,24,"PIC Erasing...");
101
-    }
102
-    else {
103
-      //LCD_ShowString(100,90,200,24,24,"SPI Flash");
104
-      //LCD_ShowString(100,120,200,24,24,"PIC Erasing...");
105
-    }
106
-    #if ENABLED(MKS_TEST)
107
-      for (pic_sectorcnt = 0; pic_sectorcnt < 2; pic_sectorcnt++)
108
-        W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024);
109
-
110
-    #else
111
-      for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++)
112
-        W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024);
113
-
114
-    #endif
115
-    /*
116
-    FLASH_Unlock();
117
-    spiFlashEraseFlag = SPI_FLASH_ERASE_FLAG_DATA;
118
-    FLASH_ProgramHalfWord(SPI_FLASH_ERASE_FLAG_ADDR,spiFlashEraseFlag);
119
-    FLASH_Lock();
120
-    */
121
-    #if 0
122
-      if (DeviceCode == 0x9488)
123
-        LCD_ShowString(170, 130, 200, 24, 24, "PIC Erase Done");
124
-      else
125
-        LCD_ShowString(100, 120, 200, 24, 24, "PIC Erase Done");
126
-
127
-    #endif
128
-    //spiFlashEraseFlag = 1;
129
-  #endif
237
+  volatile uint32_t pic_sectorcnt = 0;
238
+  for (pic_sectorcnt = 0; pic_sectorcnt < TERN(MKS_TEST, 2, PIC_SIZE_xM * 1024 / 64); pic_sectorcnt++)
239
+    W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024);
130 240
 }
131 241
 
132
-void spiFlashErase_FONT() {
133
-  volatile uint32_t Font_sectorcnt = 0;
134
-
135
-  //LCD_Clear(BACK_COLOR);
136
-  if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) {
137
-    //LCD_ShowString(180,100,200,24,24,"SPI Flash");
138
-    //LCD_ShowString(170,130,200,24,24,"FONT Erasing...");
242
+#if HAS_SPI_FLASH_FONT
243
+  void spiFlashErase_FONT() {
244
+    volatile uint32_t Font_sectorcnt = 0;
245
+    for (Font_sectorcnt = 0; Font_sectorcnt < FONT_SIZE_xM * 1024 / 64; Font_sectorcnt++)
246
+      W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024);
139 247
   }
140
-  else {
141
-    //LCD_ShowString(100,90,200,24,24,"SPI Flash");
142
-    //LCD_ShowString(90,120,200,24,24,"FONT Erasing...");
143
-  }
144
-
145
-  for (Font_sectorcnt = 0; Font_sectorcnt < FONT_SIZE_xM * 1024 / 64; Font_sectorcnt++)
146
-    W25QXX.SPI_FLASH_BlockErase(FONTINFOADDR + Font_sectorcnt * 64 * 1024);
147
-
148
-  /*
149
-  FLASH_Unlock();
150
-  spiFlashEraseFlag = SPI_FLASH_ERASE_FLAG_DATA;
151
-  FLASH_ProgramHalfWord(SPI_FLASH_ERASE_FLAG_ADDR,spiFlashEraseFlag);
152
-  FLASH_Lock();
153
-  */
154
-  #if 0
155
-    if (DeviceCode == 0x9488)
156
-      LCD_ShowString(170, 130, 200, 24, 24, "FONT Erase Done");
157
-    else
158
-      LCD_ShowString(90, 120, 200, 24, 24, "FONT Erase Done");
159
-    //LCD_DisplayString(120,90,"FONT Erase Done");
160
-  #endif
161
-  //spiFlashEraseFlag = 1;
162
-}
248
+#endif
163 249
 
164 250
 uint32_t LogoWrite_Addroffset = 0;
165 251
 
166 252
 uint8_t Pic_Logo_Write(uint8_t *LogoName, uint8_t *Logo_Wbuff, uint32_t LogoWriteSize) {
167
-  //uint16_t n;
168
-  uint32_t i;
169
-  uint8_t temp1;
170
-  static uint32_t logo_maxsize;
171
-
172 253
   if (LogoWriteSize <= 0) return 0;
173 254
 
174 255
   W25QXX.SPI_FLASH_BufferWrite(Logo_Wbuff, PIC_LOGO_ADDR + LogoWrite_Addroffset, LogoWriteSize);
175 256
 
176
-  for (i = 0; i < LogoWriteSize; i++) {
257
+  for (uint32_t i = 0; i < LogoWriteSize; i++) {
258
+    uint8_t temp1;
177 259
     W25QXX.SPI_FLASH_BufferRead(&temp1, PIC_LOGO_ADDR + LogoWrite_Addroffset + i, 1);
178 260
     if (*(Logo_Wbuff + i) != temp1) return 0;
179 261
   }
180 262
   LogoWrite_Addroffset += LogoWriteSize;
181
-  if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761))
182
-    logo_maxsize = LOGO_MAX_SIZE_TFT35;
183
-  else
184
-    logo_maxsize = LOGO_MAX_SIZE_TFT32;
185
-  if (LogoWrite_Addroffset >= logo_maxsize)
186
-    LogoWrite_Addroffset = 0;
263
+  const uint32_t logo_maxsize = DeviceCode == 0x9488 || DeviceCode == 0x5761 ? LOGO_MAX_SIZE_TFT35 : LOGO_MAX_SIZE_TFT32;
264
+  if (LogoWrite_Addroffset >= logo_maxsize) LogoWrite_Addroffset = 0;
187 265
   return 1;
188 266
 }
189 267
 
190 268
 uint32_t TitleLogoWrite_Addroffset = 0;
191 269
 uint8_t Pic_TitleLogo_Write(uint8_t *TitleLogoName, uint8_t *TitleLogo_Wbuff, uint32_t TitleLogoWriteSize) {
192
-  //uint32_t i;
193
-  //uint8_t temp1;
194 270
   if (TitleLogoWriteSize <= 0)
195 271
     return 0;
196 272
   if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761))
@@ -216,18 +292,11 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
216 292
   uint32_t Pic_SaveAddr;
217 293
   uint32_t Pic_SizeSaveAddr;
218 294
   uint32_t Pic_NameSaveAddr;
219
-  //uint8_t temp;
220 295
   uint8_t Pname_temp;
221 296
   uint32_t i, j;
222 297
   uint32_t name_len = 0;
223 298
   uint32_t SaveName_len = 0;
224 299
   union union32 size_tmp;
225
-  //union union32 size1;
226
-  //uint8_t Pn[PIC_NAME_MAX_LEN];
227
-  //uint8_t cnt_temp;
228
-  //uint16_t n0;
229
-  //uint32_t Name_saveAddr = 0;
230
-  //uint8_t pic_position;
231 300
 
232 301
   W25QXX.SPI_FLASH_BufferRead(&pic_counter, PIC_COUNTER_ADDR, 1);
233 302
 
@@ -266,386 +335,182 @@ uint32_t Pic_Info_Write(uint8_t *P_name, uint32_t P_size) {
266 335
 
267 336
 uint8_t public_buf[512];
268 337
 
269
-//uint8_t public_buf_test[512];
270
-  #if ENABLED(SDSUPPORT)
271
-void UpdatePic() {
272
-  //int r;
273
-  //unsigned char *p;
274
-  //char rootPath[10]={0};
275
-  char *fn;
276
-  unsigned char logoFlag;
277
-  uint16_t pbr;
278
-  uint32_t pfileSize;
279
-  uint32_t Pic_Write_Addr;
280
-  /*----------------------------------*/
281
-
282
-  // FILINFO fno;
283
-  //DIR dir;
284
-  //char tmp[30];
285
-  #if 0//_USE_LFN
286
-    static char lfn[_MAX_LFN + 1];
287
-    finfo.lfname = lfn;
288
-    finfo.lfsize = sizeof(lfn);
289
-  #endif
290
-  //SdFile curDir;
291
-  //if (f_opendir(&dirs, picPath) == FR_OK)
292
-  //card.cd(picPath);
293
-
294
-  //const uint16_t fileCnt = card.get_num_Files();
295
-
296
-  //SdFile *curDir;
297
-  //SdFile dir;
298
-  //dir.open(picPath, O_READ);
299
-  //const char * const fname = card.diveToFile(true, curDir, picPath);
300
-  //if (!fname) return;
301
-
302
-  SdFile dir, root = card.getroot();
303
-  if (dir.open(&root, picPath, O_RDONLY)) {
304
-
305
-    disp_pic_update();
306
-    spiFlashErase_PIC();
307
-
308
-    dir_t d;
309
-    while (dir.readDir(&d, card.longFilename) > 0) {
310
-      #if 1
311
-        /*
312
-        if (power_det == 0) {
313
-          PW_DET_ON;
314
-          power_det=0;
315
-        }
316
-        SPI_FLASH_Init();
317
-        */
338
+#if ENABLED(SDSUPPORT)
318 339
 
319
-        //for (uint16_t i = 0; i < fileCnt; i++) {
320
-        //res = f_readdir(&dirs, &finfo);
321
-        //card.getfilename_sorted(i);
340
+  static void dosName2LongName(const char dosName[11], char* longName) {
341
+    uint8_t j = 0;
342
+    LOOP_L_N(i, 11) {
343
+      if (i == 8) longName[j++] = '.';
344
+      if (dosName[i] == '\0' || dosName[i] == ' ') continue;
345
+      longName[j++] = dosName[i];
346
+    }
347
+    longName[j] = '\0';
348
+  }
349
+
350
+  void UpdatePic() {
351
+    char *fn;
352
+    unsigned char logoFlag;
353
+    uint16_t pbr;
354
+    uint32_t pfileSize;
355
+    uint32_t totalSizeLoaded = 0;
356
+    uint32_t Pic_Write_Addr;
357
+
358
+    SdFile dir, root = card.getroot();
359
+    if (dir.open(&root, picPath, O_RDONLY)) {
360
+
361
+      disp_pic_update();
362
+      spiFlashErase_PIC();
363
+
364
+      dir_t d;
365
+      while (dir.readDir(&d, card.longFilename) > 0) {
366
+        // if we dont get a long name, but gets a short one, try it
367
+        if (card.longFilename[0] == 0 && d.name[0] != 0) {
368
+          dosName2LongName((const char*)d.name, card.longFilename);
369
+        }
322 370
 
323 371
         if (card.longFilename[0] == 0)
324
-          break;
325
-        /*if ( card.filename[0] == '.')
326
-        continue;
327
-      */
372
+          continue;
328 373
         if (card.longFilename[0] == '.')
329 374
           continue;
330 375
 
331
-        fn = card.longFilename;
376
+        uint8_t a = -1;
377
+        for(a = 0; a < COUNT(assets); a++) {
378
+          if (strcasecmp(assets[a], card.longFilename) == 0) {
379
+            break;
380
+          }
381
+        }
382
+        if (a < 0 || a >= COUNT(assets)) continue;
332 383
 
333
-        /*if ((finfo.lfname[0] == 0) || (finfo.lfname == 0))
334
-          fn = finfo.fname;
335
-        else
336
-          fn = finfo.lfname;*/
384
+        fn = assets[a];
385
+        char dosFilename[FILENAME_LENGTH];
386
+        createFilename(dosFilename, d);
337 387
 
338
-        /*   if (fno.fattrib & AM_DIR)
339
-        {
388
+        SdFile file;
389
+        if (!file.open(&dir, dosFilename, O_READ)) {
390
+          #if ENABLED(MARLIN_DEV_MODE)
391
+            SERIAL_ECHOLNPAIR("Error opening Asset: ", fn);
392
+          #endif
340 393
           continue;
341 394
         }
342
-        else */
343
-        //{
344
-        //if ((strstr(fn, ".gco")) || (strstr(fn, ".GCO")) || (fno.fattrib & AM_DIR))
345
-        if (strstr(fn, ".bin")) {
346
-          if (strstr(fn, "_logo"))
347
-            logoFlag = 1;
348
-          else if (strstr(fn, "_titlelogo"))
349
-            logoFlag = 2;
350
-          else if (strstr(fn, "_preview"))
351
-            logoFlag = 3;
352
-          else
353
-            logoFlag = 0;
354
-
355
-          //public_buf[0] = '\0';
356
-          //strcat(public_buf, picPath);
357
-          //strcat(public_buf, "/");
358
-          char dosFilename[FILENAME_LENGTH];
359
-          createFilename(dosFilename, d);
360
-          //strcat(public_buf, dosFilename);
361
-
362
-          SdFile file;
363
-          if (file.open(&dir, dosFilename, O_READ)) {
364
-            #if 1
365
-            /*LCD_Clear(BACK_COLOR);
366
-
367
-            if ((DeviceCode==0x9488)||(DeviceCode==0x5761)) {
368
-              LCD_ShowString(170,100,200,24,24,(u8 *)fn);
369
-              LCD_ShowString(180,130,200,24,24,"Updating...");
370
-            }
371
-            else {
372
-              LCD_ShowString(90,90,200,24,24,(u8 *)fn);
373
-              LCD_ShowString(90,120,200,24,24,"Updating...");
374
-            }
375
-            */
376
-            if (logoFlag == 1) {
377
-              while (1) {
378
-                pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
379
-                Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); //
380
-                if (pbr < BMP_WRITE_BUF_LEN) break;
381
-              }
382
-            }
383
-            else if (logoFlag == 2) {
384
-              while (1) {
385
-                pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
386
-                Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); //
387
-                if (pbr < BMP_WRITE_BUF_LEN) break;
388
-              }
389
-            }
390
-            else if (logoFlag == 3) {
391
-              while (1)
392
-              {
393
-                pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
394
-                default_view_Write(public_buf, pbr); //
395
-                if (pbr < BMP_WRITE_BUF_LEN) break;
396
-              }
397
-            }
398
-            else {
399
-              pfileSize = file.fileSize();
400
-              Pic_Write_Addr = Pic_Info_Write((uint8_t *)fn, pfileSize);
401
-              //uint32_t addr_test = Pic_Write_Addr;
402
-              //memset(bmp_public_buf, 0xff, BMP_WRITE_BUF_LEN);
403
-              while (1)
404
-              {
405
-                pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
406
-                W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr);
407
-                Pic_Write_Addr += pbr;
408
-                if (pbr < BMP_WRITE_BUF_LEN) break;
409
-              }
410
-              //W25QXX.SPI_FLASH_BufferRead(public_buf_test,addr_test,BMP_WRITE_BUF_LEN);
411
-            }
412 395
 
413
-            /*--------------read test--------------------*/
414
-            /*
415
-            BufferSet(picBuffer, 0xff, PICTURE_MAX_SIZE);
416
-            if (logoFlag == 0)
417
-            {
418
-              PicMsg_Init();
419
-              Pic_Read(fn,picBuffer);
420
-            }
421
-            else
422
-              Pic_Logo_Read(fn,picBuffer,PICTURE_MAX_SIZE);
423
-            */
424
-            /*--------------read test--------------------*/
425
-
426
-            file.close();
427
-            #endif
396
+        if (strstr(fn, "_logo"))
397
+          logoFlag = 1;
398
+        else if (strstr(fn, "_titlelogo"))
399
+          logoFlag = 2;
400
+        else if (strstr(fn, "_preview"))
401
+          logoFlag = 3;
402
+        else
403
+          logoFlag = 0;
404
+
405
+        pfileSize = file.fileSize();
406
+        totalSizeLoaded += pfileSize;
407
+        if (logoFlag == 1) {
408
+          while (1) {
409
+            pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
410
+            Pic_Logo_Write((uint8_t *)fn, public_buf, pbr); //
411
+            if (pbr < BMP_WRITE_BUF_LEN)
412
+              break;
428 413
           }
429
-
430 414
         }
431
-        //}
432
-        //}
433
-        /*
434
-            LCD_Clear(LCD_COLOR_BLACK);
435
-            //LCD_ShowString(110,100,200,24,24,"Complete");
436
-            LCD_DisplayString(110,80,"Complete");
437
-            delay(0xfffff);
438
-        */
439
-        //r = f_chdir("/");
440
-        #if 1
441
-          //SdFile dir, root = card.getroot();
442
-          /*if (dir.open(&root, bakPath, O_RDONLY))
443
-      {
444
-        dir.remove();
445
-      }*/
446
-
447
-          //r = f_rename(picPath, bakPath);
448
-
449
-
450
-          //update_flag_ok = 1;
415
+        else if (logoFlag == 2) {
416
+          while (1) {
417
+            pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
418
+            Pic_TitleLogo_Write((uint8_t *)fn, public_buf, pbr); //
419
+            if (pbr < BMP_WRITE_BUF_LEN)
420
+              break;
421
+          }
422
+        }
423
+        else if (logoFlag == 3) {
424
+          while (1) {
425
+            pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
426
+            default_view_Write(public_buf, pbr); //
427
+            if (pbr < BMP_WRITE_BUF_LEN)
428
+              break;
429
+          }
430
+        }
431
+        else {
432
+          Pic_Write_Addr = Pic_Info_Write((uint8_t *)fn, pfileSize);
433
+          while (1) {
434
+            pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
435
+            W25QXX.SPI_FLASH_BufferWrite(public_buf, Pic_Write_Addr, pbr);
436
+            Pic_Write_Addr += pbr;
437
+            if (pbr < BMP_WRITE_BUF_LEN)
438
+              break;
439
+          }
440
+        }
441
+
442
+        #if ENABLED(MARLIN_DEV_MODE)
443
+          SERIAL_ECHOLNPAIR("Asset added: ", fn);
451 444
         #endif
452
-      #endif
445
+
446
+        file.close();
447
+      }
448
+      dir.rename(&root, bakPath);
453 449
     }
454
-    dir.rename(&root, bakPath);
450
+    dir.close();
451
+
452
+    #if ENABLED(MARLIN_DEV_MODE)
453
+      uint8_t pic_counter = 0;
454
+      W25QXX.SPI_FLASH_BufferRead(&pic_counter, PIC_COUNTER_ADDR, 1);
455
+      SERIAL_ECHOLNPAIR("Total assets loaded: ", pic_counter, ", Total size: ", totalSizeLoaded);
456
+    #endif
455 457
   }
456
-}
457 458
 
459
+  #if HAS_SPI_FLASH_FONT
458 460
 
459
-void spi_flash_read_test() {W25QXX.SPI_FLASH_BufferRead(public_buf, UNIGBK_FLASH_ADDR, BMP_WRITE_BUF_LEN);}
460
-
461
-void UpdateFont() {
462
-  //int r;
463
-  //unsigned char *p;
464
-  //char rootPath[10]={0};
465
-  char *fn;
466
-  //unsigned char logoFlag;
467
-  uint16_t pbr;
468
-  uint32_t flashaddr = 0;
469
-  //uint32_t pfileSize;
470
-  //uint32_t Pic_Write_Addr;
471
-  /*----------------------------------*/
472
-
473
-  // FILINFO fno;
474
-  //DIR dir;
475
-  //char tmp[30];
476
-  #if 0//_USE_LFN
477
-    static char lfn[_MAX_LFN + 1];
478
-    finfo.lfname = lfn;
479
-    finfo.lfsize = sizeof(lfn);
480
-  #endif
481
-  //SdFile curDir;
482
-  //if (f_opendir(&dirs, picPath) == FR_OK)
483
-  //card.cd(picPath);
484
-
485
-  //const uint16_t fileCnt = card.get_num_Files();
486
-
487
-  //SdFile *curDir;
488
-  //SdFile dir;
489
-  //dir.open(picPath, O_READ);
490
-  //const char * const fname = card.diveToFile(true, curDir, picPath);
491
-  //if (!fname) return;
492
-
493
-  SdFile dir, root = card.getroot();
494
-  if (dir.open(&root, fontPath, O_RDONLY)) {
495
-
496
-    disp_font_update();
497
-    spiFlashErase_FONT();
498
-
499
-    dir_t d;
500
-    while (dir.readDir(&d, card.longFilename) > 0)
501
-    {
502
-      #if 1
503
-        /*if (power_det == 0)
504
-        {
505
-          PW_DET_ON;
506
-          power_det=0;
507
-        }
508
-        SPI_FLASH_Init();*/
461
+    void spi_flash_read_test() { W25QXX.SPI_FLASH_BufferRead(public_buf, UNIGBK_FLASH_ADDR, BMP_WRITE_BUF_LEN); }
509 462
 
463
+    void UpdateFont() {
464
+      char *fn;
465
+      uint16_t pbr;
466
+      uint32_t flashaddr = 0;
510 467
 
511
-        //for (uint16_t i = 0; i < fileCnt; i++)
512
-        //{
513
-        //res = f_readdir(&dirs, &finfo);
514
-        //card.getfilename_sorted(i);
468
+      SdFile dir, root = card.getroot();
469
+      if (dir.open(&root, fontPath, O_RDONLY)) {
515 470
 
516
-        if (card.longFilename[0] == 0)
517
-          break;
518
-        /*if ( card.filename[0] == '.')
519
-        continue;
520
-      */
521
-        if (card.longFilename[0] == '.')
522
-          continue;
471
+        disp_font_update();
472
+        spiFlashErase_FONT();
523 473
 
524
-        fn = card.longFilename;
474
+        dir_t d;
475
+        while (dir.readDir(&d, card.longFilename) > 0) {
476
+          if (card.longFilename[0] == 0)
477
+            break;
525 478
 
526
-        /*if ((finfo.lfname[0] == 0) || (finfo.lfname == 0))
527
-          fn = finfo.fname;
528
-        else
529
-          fn = finfo.lfname;*/
479
+          if (card.longFilename[0] == '.')
480
+            continue;
481
+
482
+          fn = card.longFilename;
483
+
484
+          if (strstr(fn, ".bin")) {
485
+            char dosFilename[FILENAME_LENGTH];
486
+            createFilename(dosFilename, d);
487
+            //strcat(public_buf, dosFilename);
488
+
489
+            SdFile file;
490
+            if (file.open(&dir, dosFilename, O_READ)) {
530 491
 
531
-        /*   if (fno.fattrib & AM_DIR)
532
-        {
533
-        continue;
534
-        }
535
-        else */
536
-        //{
537
-        //if ((strstr(fn, ".gco")) || (strstr(fn, ".GCO")) || (fno.fattrib & AM_DIR))
538
-        if (strstr(fn, ".bin")) {
539
-          char dosFilename[FILENAME_LENGTH];
540
-          createFilename(dosFilename, d);
541
-          //strcat(public_buf, dosFilename);
542
-
543
-          SdFile file;
544
-          if (file.open(&dir, dosFilename, O_READ)) {
545
-
546
-            #if 1
547
-              /*LCD_Clear(BACK_COLOR);
548
-
549
-              if ((DeviceCode==0x9488)||(DeviceCode==0x5761))
550
-              {
551
-                LCD_ShowString(170,100,200,24,24,(u8 *)fn);
552
-                LCD_ShowString(180,130,200,24,24,"Updating...");
553
-              }
554
-              else
555
-              {
556
-                LCD_ShowString(90,90,200,24,24,(u8 *)fn);
557
-                LCD_ShowString(90,120,200,24,24,"Updating...");
558
-              }
559
-              */
560 492
               flashaddr = UNIGBK_FLASH_ADDR;
561 493
               pbr = 0;
562
-              while (1)
563
-              {
494
+              while (1) {
564 495
                 flashaddr += pbr;
565 496
                 pbr = file.read(public_buf, BMP_WRITE_BUF_LEN);
566 497
                 W25QXX.SPI_FLASH_BufferWrite(public_buf, flashaddr, pbr);
567
-                //W25QXX.SPI_FLASH_BufferRead(public_buf_test,flashaddr,pbr);
568
-                /*if (UNIGBKFlag == 1)
569
-                {
570
-                  fontrate = (uint16_t)(((float)(flashaddr - UNIGBK_FLASH_ADDR)/(float)(psrc.fsize))*100);
571
-                }
572
-                else
573
-                {
574
-                  fontrate = (uint16_t)(((float)(flashaddr - GBK_FLASH_ADDR)/(float)(psrc.fsize))*100);
575
-                }
576
-
577
-                if (fontrate > 99) fontrate=99;
578
-
579
-                if (fontrate < 10)
580
-                {
581
-                  fontString[0] = fontrate%10 + 0x30;
582
-                  fontString[1] = '%';
583
-                  fontString[2] = '\0';
584
-                }
585
-                else
586
-                {
587
-                  fontString[0] = fontrate/10 + 0x30;
588
-                  fontString[1] = fontrate%10 + 0x30;
589
-                  fontString[2] = '%';
590
-                  fontString[3] = '\0';
591
-                }*/
592
-                //LCD_DisplayString(140,130,fontString);
593
-                if ((DeviceCode == 0x9488) || (DeviceCode == 0x5761)) {
594
-                  //LCD_ShowString(200,160,200,24,24,fontString);
595
-                }
596
-                else {
597
-                  //LCD_ShowString(140,150,200,24,24,fontString);
598
-                }
599 498
                 if (pbr < BMP_WRITE_BUF_LEN) break;
600 499
               }
601
-              /*--------------read test--------------------*/
602
-              /*
603
-              BufferSet(picBuffer, 0xff, PICTURE_MAX_SIZE);
604
-              if (logoFlag == 0)
605
-              {
606
-                PicMsg_Init();
607
-                Pic_Read(fn,picBuffer);
608
-              }
609
-              else
610
-                Pic_Logo_Read(fn,picBuffer,PICTURE_MAX_SIZE);
611
-              */
612
-              /*--------------read test--------------------*/
613
-
614 500
               file.close();
615
-            #endif
616
-          }
501
+            }
617 502
 
503
+          }
618 504
         }
619
-        //}
620
-        //}
621
-        /*
622
-            LCD_Clear(LCD_COLOR_BLACK);
623
-            //LCD_ShowString(110,100,200,24,24,"Complete");
624
-            LCD_DisplayString(110,80,"Complete");
625
-            delay(0xfffff);
626
-        */
627
-        //r = f_chdir("/");
628
-        #if 1
629
-          //SdFile dir, root = card.getroot();
630
-          /*if (dir.open(&root, bakPath, O_RDONLY))
631
-      {
632
-        dir.remove();
633
-      }*/
634
-          dir.rename(&root, bakFont);
635
-          //r = f_rename(picPath, bakPath);
636
-
637
-
638
-          //update_flag_ok = 1;
639
-        #endif
640
-      #endif
505
+
506
+        dir.rename(&root, bakFont);
507
+        dir.close();
508
+      }
641 509
     }
642
-  }
643
-}
644
-  #endif // SDSUPPORT
645 510
 
646
-#endif
511
+  #endif // HAS_SPI_FLASH_FONT
647 512
 
648
-#if 1
513
+#endif // SDSUPPORT
649 514
 
650 515
 void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff) {
651 516
   uint8_t i, j;
@@ -653,30 +518,21 @@ void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff) {
653 518
   uint32_t tmp_cnt = 0;
654 519
   PIC_MSG PIC;
655 520
 
656
-  //void SPI_FLASH_BufferRead(u8* pBuffer, u32 ReadAddr, u16 NumByteToRead);
657
-
658 521
   W25QXX.SPI_FLASH_BufferRead(&Pic_cnt, PIC_COUNTER_ADDR, 1);
659 522
   if (Pic_cnt == 0xff)
660 523
     Pic_cnt = 0;
661 524
 
662 525
   for (i = 0; i < Pic_cnt; i++) {
663
-    //pic name
664 526
     j = 0;
665
-    do
666
-    {
527
+    do {
667 528
       W25QXX.SPI_FLASH_BufferRead(&PIC.name[j], PIC_NAME_ADDR + tmp_cnt, 1);
668 529
       tmp_cnt++;
669
-    }while (PIC.name[j++] != '\0');
530
+    } while (PIC.name[j++] != '\0');
670 531
     //pic size
671 532
     W25QXX.SPI_FLASH_BufferRead(PIC.size.bytes, PIC_SIZE_ADDR + i * 4, 4);
672 533
 
673 534
     if ((strcmp((char*)Pname, (char*)PIC.name)) == 0) {
674 535
       W25QXX.SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, PIC_DATA_ADDR_TFT35 + i * PER_PIC_MAX_SPACE_TFT35, PIC.size.dwords);
675
-      /*if (DMA_ERRO_FLAG)
676
-      {
677
-        DMA_ERRO_FLAG = 0;
678
-        SPI_FLASH_BufferRead((uint8_t *)P_Rbuff,PIC_DATA_ADDR+i*PER_PIC_MAX_SPACE,PIC.size.dwords);
679
-      }*/
680 536
       break;
681 537
     }
682 538
   }
@@ -685,41 +541,34 @@ void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff) {
685 541
 void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size) {
686 542
   W25QXX.init(SPI_QUARTER_SPEED);
687 543
   W25QXX.SPI_FLASH_BufferRead((uint8_t *)P_Rbuff, addr, size);
688
-  /*if (DMA_ERRO_FLAG) {
689
-    DMA_ERRO_FLAG = 0;
690
-    SPI_FLASH_BufferRead((uint8_t *)P_Rbuff,addr,size);
691
-  }*/
692
-
693 544
 }
694 545
 
695
-void get_spi_flash_data(const char *rec_buf, int addr, int size) {
696
-  W25QXX.init(SPI_QUARTER_SPEED);
697
-  W25QXX.SPI_FLASH_BufferRead((uint8_t *)rec_buf, UNIGBK_FLASH_ADDR + addr, size);
698
-}
699
-
700
-#endif
701
-
702
-#if 1
703
-
704
-  uint32_t logo_addroffset = 0;
705
-  void Pic_Logo_Read(uint8_t *LogoName, uint8_t *Logo_Rbuff, uint32_t LogoReadsize) {
706
-    W25QXX.SPI_FLASH_BufferRead(Logo_Rbuff, PIC_LOGO_ADDR + logo_addroffset, LogoReadsize);
707
-    logo_addroffset += LogoReadsize;
708
-    if (logo_addroffset >= LOGO_MAX_SIZE_TFT35)
709
-      logo_addroffset = 0;
546
+#if HAS_SPI_FLASH_FONT
547
+  void get_spi_flash_data(const char *rec_buf, int addr, int size) {
548
+    W25QXX.init(SPI_QUARTER_SPEED);
549
+    W25QXX.SPI_FLASH_BufferRead((uint8_t *)rec_buf, UNIGBK_FLASH_ADDR + addr, size);
710 550
   }
551
+#endif
711 552
 
712
-  uint32_t default_view_addroffset = 0;
713
-  void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize) {
714
-    W25QXX.init(SPI_QUARTER_SPEED);
553
+uint32_t logo_addroffset = 0;
554
+void Pic_Logo_Read(uint8_t *LogoName, uint8_t *Logo_Rbuff, uint32_t LogoReadsize) {
555
+  W25QXX.SPI_FLASH_BufferRead(Logo_Rbuff, PIC_LOGO_ADDR + logo_addroffset, LogoReadsize);
556
+  logo_addroffset += LogoReadsize;
557
+  if (logo_addroffset >= LOGO_MAX_SIZE_TFT35)
558
+    logo_addroffset = 0;
559
+}
715 560
 
716
-    W25QXX.SPI_FLASH_BufferRead(default_view_Rbuff, DEFAULT_VIEW_ADDR_TFT35 + default_view_addroffset + 4, default_view_Readsize);
717
-    default_view_addroffset += default_view_Readsize;
718
-    if (default_view_addroffset >= DEFAULT_VIEW_MAX_SIZE)
719
-      default_view_addroffset = 0;
561
+uint32_t default_view_addroffset = 0;
562
+void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize) {
563
+  W25QXX.init(SPI_QUARTER_SPEED);
720 564
 
721
-  }
565
+  W25QXX.SPI_FLASH_BufferRead(default_view_Rbuff, DEFAULT_VIEW_ADDR_TFT35 + default_view_addroffset, default_view_Readsize);
566
+  default_view_addroffset += default_view_Readsize;
567
+  if (default_view_addroffset >= DEFAULT_VIEW_MAX_SIZE)
568
+    default_view_addroffset = 0;
569
+}
722 570
 
571
+#if HAS_BAK_VIEW_IN_FLASH
723 572
   uint32_t flash_view_addroffset = 0;
724 573
   void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize) {
725 574
     W25QXX.init(SPI_QUARTER_SPEED);
@@ -728,9 +577,7 @@ void get_spi_flash_data(const char *rec_buf, int addr, int size) {
728 577
     flash_view_addroffset += flash_view_Readsize;
729 578
     if (flash_view_addroffset >= FLASH_VIEW_MAX_SIZE)
730 579
       flash_view_addroffset = 0;
731
-
732 580
   }
733
-
734 581
 #endif
735 582
 
736
-#endif // TFT_LITTLE_VGL_UI
583
+#endif // TFT_LVGL_UI

+ 77
- 48
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h View File

@@ -29,21 +29,61 @@ extern "C" { /* C-declarations for C++ */
29 29
 #include <string.h>
30 30
 #include "lvgl.h"
31 31
 
32
-#if 1
32
+#include "../../inc/MarlinConfigPre.h"
33 33
 
34
-  #define PIC_MAX_CN           100    // Maximum number of pictures
35
-  #define PIC_NAME_MAX_LEN      50    // Picture name maximum length
34
+#ifndef HAS_SPI_FLASH_FONT
35
+  #define HAS_SPI_FLASH_FONT              0 //disabled until fix the font load code
36
+#endif
37
+#ifndef HAS_GCODE_PREVIEW
38
+  #define HAS_GCODE_PREVIEW               1
39
+#endif
40
+#ifndef HAS_LANG_SELECT_SCREEN
41
+  #define HAS_LANG_SELECT_SCREEN               0
42
+#endif
43
+#ifndef HAS_BAK_VIEW_IN_FLASH
44
+  #define HAS_BAK_VIEW_IN_FLASH               1
45
+#endif
46
+#ifndef HAS_GCODE_DEFAULT_VIEW_IN_FLASH
47
+  #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH               1
48
+#endif
49
+#ifndef SPI_FLASH_SIZE
50
+  #define SPI_FLASH_SIZE                  0x1000000 // 16MB
51
+#endif
36 52
 
37
-  #define LOGO_MAX_SIZE_TFT35             (300*1024)
38
-  #define LOGO_MAX_SIZE_TFT32             (150*1024)
39
-  #define TITLELOGO_MAX_SIZE              (150*1024) // Little logo maximum
40
-  #define DEFAULT_VIEW_MAX_SIZE           (200*200*2)
41
-  #define FLASH_VIEW_MAX_SIZE             (200*200*2)
53
+#define PIC_MAX_CN           100    // Maximum number of pictures
54
+#define PIC_NAME_MAX_LEN      50    // Picture name maximum length
42 55
 
43
-  #define PER_PIC_MAX_SPACE_TFT35         (32*1024)
44
-  #define PER_PIC_MAX_SPACE_TFT32         (16*1024)
45
-  #define PER_FONT_MAX_SPACE              (16*1024)
56
+#define LOGO_MAX_SIZE_TFT35             (300*1024)
57
+#define LOGO_MAX_SIZE_TFT32             (150*1024)
58
+#define TITLELOGO_MAX_SIZE              (150*1024) // Little logo maximum
59
+#define DEFAULT_VIEW_MAX_SIZE           (200*200*2)
60
+#define FLASH_VIEW_MAX_SIZE             (200*200*2)
46 61
 
62
+#define PER_PIC_MAX_SPACE_TFT35         (32*1024)
63
+#define PER_PIC_MAX_SPACE_TFT32         (16*1024)
64
+#define PER_FONT_MAX_SPACE              (16*1024)
65
+
66
+#if SPI_FLASH_SIZE == 0x200000
67
+  //pic
68
+  //Robin_pro pic addr
69
+  #define PIC_NAME_ADDR                   0x001000      // Pic information addr
70
+  #define PIC_SIZE_ADDR                   0x001800      // Pic size information addr
71
+  #define PIC_COUNTER_ADDR                0x002000      // Pic total number
72
+  #define PER_PIC_SAVE_ADDR               0x000000      // Storage address of each picture
73
+  #define PIC_LOGO_ADDR                   0x000000      // Logo addr
74
+  #define PIC_DATA_ADDR                   0x003000    //
75
+
76
+  // TFT35
77
+  #define DEFAULT_VIEW_ADDR_TFT35         0x1ea070
78
+  #define BAK_VIEW_ADDR_TFT35             (DEFAULT_VIEW_ADDR_TFT35+90*1024)
79
+  #define PIC_ICON_LOGO_ADDR_TFT35        (BAK_VIEW_ADDR_TFT35+80*1024)
80
+  #define PIC_DATA_ADDR_TFT35             0x003000 // (PIC_ICON_LOGO_ADDR_TFT35+350*1024) //0xC5800
81
+
82
+  #define PIC_DATA_ADDR_TFT32             0x00F000
83
+  #define PIC_ICON_LOGO_ADDR_TFT32        0x5D8000
84
+  #define PIC_OTHER_SIZE_ADDR_TFT32       0x5EE000
85
+
86
+#else
47 87
   //pic
48 88
   //Robin_pro pic addr
49 89
   #define PIC_NAME_ADDR                   0x003000      // Pic information addr
@@ -51,13 +91,13 @@ extern "C" { /* C-declarations for C++ */
51 91
   #define PIC_COUNTER_ADDR                0x008000      // Pic total number
52 92
   #define PER_PIC_SAVE_ADDR               0x009000      // Storage address of each picture
53 93
   #define PIC_LOGO_ADDR                   0x00A000      // Logo addr
54
-  //#define PIC_DATA_ADDR                   0x02F000    //
94
+  //#define PIC_DATA_ADDR                 0x02F000      //
55 95
 
56 96
   // TFT35
57
-  #define DEFAULT_VIEW_ADDR_TFT35                         0XC5800
58
-  #define BAK_VIEW_ADDR_TFT35                                             (DEFAULT_VIEW_ADDR_TFT35+90*1024)
59
-  #define PIC_ICON_LOGO_ADDR_TFT35            (BAK_VIEW_ADDR_TFT35+80*1024)
60
-  #define PIC_DATA_ADDR_TFT35                                             (PIC_ICON_LOGO_ADDR_TFT35+350*1024)//0XC5800
97
+  #define DEFAULT_VIEW_ADDR_TFT35         0xC5800
98
+  #define BAK_VIEW_ADDR_TFT35             (DEFAULT_VIEW_ADDR_TFT35+90*1024)
99
+  #define PIC_ICON_LOGO_ADDR_TFT35        (BAK_VIEW_ADDR_TFT35+80*1024)
100
+  #define PIC_DATA_ADDR_TFT35             (PIC_ICON_LOGO_ADDR_TFT35+350*1024) //0xC5800
61 101
 
62 102
   // TFT32
63 103
   #define PIC_DATA_ADDR_TFT32             0x02F000
@@ -69,48 +109,37 @@ extern "C" { /* C-declarations for C++ */
69 109
   #define UNIGBK_FLASH_ADDR              (FONTINFOADDR+4096) // 4*1024
70 110
   #define GBK_FLASH_ADDR                 (UNIGBK_FLASH_ADDR+180224) // 176*1024
71 111
 
72
-  // Flash flag
73
-  #define FLASH_INF_VALID_FLAG            0xAA558761
74
-  // SD card information first addr
75
-  #define VAR_INF_ADDR                    0x000000
76
-
77
-  union union32 {
78
-    uint8_t bytes[4];
79
-    uint32_t dwords;
80
-  };
81
-
82
-  // pic information
83
-  struct pic_msg {
84
-    uint8_t name[PIC_NAME_MAX_LEN];
85
-    union union32 size;
86
-  };
112
+#endif
87 113
 
88
-  typedef struct pic_msg PIC_MSG;
114
+// Flash flag
115
+#define FLASH_INF_VALID_FLAG            0xAA558761
116
+// SD card information first addr
117
+#define VAR_INF_ADDR                    0x000000
89 118
 
90
-  #define BMP_WRITE_BUF_LEN 512
119
+union union32 {
120
+  uint8_t bytes[4];
121
+  uint32_t dwords;
122
+};
91 123
 
92
-  #define PICINFOADDR   0
124
+// pic information
125
+struct pic_msg {
126
+  uint8_t name[PIC_NAME_MAX_LEN];
127
+  union union32 size;
128
+};
93 129
 
94
-  #define PIC_SIZE_xM   6
95
-  #define FONT_SIZE_xM  2
130
+typedef struct pic_msg PIC_MSG;
96 131
 
97
-  //extern void PicMsg_Init(void);
98
-  extern void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff);
99
-  //extern void bindBmpFileData(const uint8_t **pBuf, uint8_t *pName);
100
-  //extern void Pic_Logo_Read(uint8_t *LogoName,uint8_t *Logo_Rbuff,uint32_t LogoReadsize);
101
-  //extern void default_view_Read(uint8_t *default_view_Rbuff,uint32_t default_view_Readsize);
102
-  //extern void flash_view_Read(uint8_t *flash_view_Rbuff,uint32_t flash_view_Readsize);
132
+#define BMP_WRITE_BUF_LEN 512
103 133
 
104
-  //extern void lv_Pic_Read(uint8_t *Pname,uint8_t *P_Rbuff,uint32_t addr,uint32_t size);
105
-  extern void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size);
134
+#define PICINFOADDR   0
106 135
 
107
-#endif
136
+#define PIC_SIZE_xM   6
137
+#define FONT_SIZE_xM  2
108 138
 
139
+extern void Pic_Read(uint8_t *Pname, uint8_t *P_Rbuff);
140
+extern void lv_pic_test(uint8_t *P_Rbuff, uint32_t addr, uint32_t size);
109 141
 extern uint32_t lv_get_pic_addr(uint8_t *Pname);
110
-
111 142
 extern void get_spi_flash_data(const char *rec_buf, int offset, int size);
112
-//extern void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead);
113
-
114 143
 extern void spi_flash_read_test();
115 144
 extern void default_view_Read(uint8_t *default_view_Rbuff, uint32_t default_view_Readsize);
116 145
 extern void flash_view_Read(uint8_t *flash_view_Rbuff, uint32_t flash_view_Readsize);

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/printer_opration.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
   #include "../../../../MarlinCore.h"
27 27
 
@@ -215,4 +215,4 @@
215 215
     }
216 216
   }
217 217
 
218
-#endif // TFT_LITTLE_VGL_UI
218
+#endif // TFT_LVGL_UI

+ 3
- 3
Marlin/src/lcd/extui/lib/mks_ui/tft_fsmc.cpp View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 #include "../../../../inc/MarlinConfig.h"
24 24
 
25
-#if ENABLED(TFT_LITTLE_VGL_UI)
25
+#if ENABLED(TFT_LVGL_UI)
26 26
 
27 27
   #if defined(ARDUINO_ARCH_STM32F1) && PIN_EXISTS(FSMC_CS) // FSMC on 100/144 pins SoCs
28 28
 
@@ -230,7 +230,7 @@
230 230
       return uint32_t(data);
231 231
     }
232 232
 
233
-    #if ENABLED(LCD_USE_DMA_FSMC)
233
+    #ifdef LCD_USE_DMA_FSMC
234 234
 
235 235
     void LCD_IO_WriteMultiple(uint16_t color, uint32_t count) {
236 236
       while (count > 0) {
@@ -270,4 +270,4 @@
270 270
 
271 271
     #endif // LCD_USE_DMA_FSMC
272 272
   #endif // ARDUINO_ARCH_STM32F1 && FSMC_CS_PIN
273
-#endif // TFT_LITTLE_VGL_UI
273
+#endif // TFT_LVGL_UI

+ 640
- 654
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
File diff suppressed because it is too large
View File


+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #include "../../../../inc/MarlinConfigPre.h"
23 23
 
24
-#if ENABLED(TFT_LITTLE_VGL_UI)
24
+#if ENABLED(TFT_LVGL_UI)
25 25
 
26 26
 #include "../../../../MarlinCore.h"
27 27
 
@@ -1900,4 +1900,4 @@ void disp_language_init() {
1900 1900
   }
1901 1901
 }
1902 1902
 
1903
-#endif // TFT_LITTLE_VGL_UI
1903
+#endif // TFT_LVGL_UI

+ 2
- 2
Marlin/src/pins/pins.h View File

@@ -541,9 +541,9 @@
541 541
 #elif MB(CCROBOT_MEEB_3DP)
542 542
   #include "stm32f1/pins_CCROBOT_MEEB_3DP.h"    // STM32F1                                env:STM32F103RC_meeb
543 543
 #elif MB(CHITU3D_V5)
544
-  #include "stm32f1/pins_CHITU3D_V5.h"          // STM32F1                                env:chitu_f103 env:chitu_v5_gpio_init
544
+  #include "stm32f1/pins_CHITU3D_V5.h"          // STM32F1                                env:chitu_f103 env:chitu_v5_gpio_init env:chitu_f103_lvgl
545 545
 #elif MB(CHITU3D_V6)
546
-  #include "stm32f1/pins_CHITU3D_V6.h"          // STM32F1                                env:chitu_f103
546
+  #include "stm32f1/pins_CHITU3D_V6.h"          // STM32F1                                env:chitu_f103 env:chitu_f103_lvgl
547 547
 #elif MB(CREALITY_V4)
548 548
   #include "stm32f1/pins_CREALITY_V4.h"         // STM32F1                                env:STM32F103RET6_creality
549 549
 

+ 65
- 0
Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h View File

@@ -142,6 +142,71 @@
142 142
   #endif
143 143
 #endif
144 144
 
145
+#define SPI_FLASH_SIZE 0x200000                   // 2MB
146
+
147
+#if ENABLED(TFT_LVGL_UI)
148
+  #define HAS_SPI_FLASH_FONT 0
149
+  #define HAS_GCODE_PREVIEW 1
150
+  #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0
151
+  #define HAS_LANG_SELECT_SCREEN 0
152
+  #define HAS_BAK_VIEW_IN_FLASH 0
153
+
154
+  //SPI 2
155
+  #define W25QXX_CS_PIN                     PB12
156
+  #define W25QXX_MOSI_PIN                   PB15
157
+  #define W25QXX_MISO_PIN                   PB14
158
+  #define W25QXX_SCK_PIN                    PB13
159
+
160
+  #define TOUCH_CS_PIN                      PB7   // SPI1_NSS
161
+  #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
162
+  #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
163
+  #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
164
+  // #define TOUCH_INT_PIN                   PB6
165
+
166
+  #define SPI_TFT_CS_PIN            TOUCH_CS_PIN
167
+  #define SPI_TFT_SCK_PIN          TOUCH_SCK_PIN
168
+  #define SPI_TFT_MISO_PIN        TOUCH_MISO_PIN
169
+  #define SPI_TFT_MOSI_PIN        TOUCH_MOSI_PIN
170
+  #define SPI_TFT_DC_PIN                    PB6
171
+  #define SPI_TFT_RST_PIN                   PF11
172
+
173
+  #define LCD_RESET_PIN                     PF11
174
+  #define LCD_BACKLIGHT_PIN                 PD13
175
+  #define FSMC_CS_PIN                       PD7
176
+  #define FSMC_RS_PIN                       PD11
177
+
178
+  #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
179
+  #define FSMC_DMA_DEV                      DMA2
180
+  #define FSMC_DMA_CHANNEL               DMA_CH5
181
+
182
+  #define LCD_FULL_PIXEL_WIDTH 480
183
+  #define LCD_PIXEL_OFFSET_X 48
184
+  #define LCD_FULL_PIXEL_HEIGHT 320
185
+  #define LCD_PIXEL_OFFSET_Y 48
186
+
187
+  #define LCD_PIXEL_HEIGHT 320
188
+  #define LCD_PIXEL_WIDTH 480
189
+
190
+  #define XPT2046_X_CALIBRATION  -12316
191
+  #define XPT2046_Y_CALIBRATION   8981
192
+  #define XPT2046_X_OFFSET        340
193
+  #define XPT2046_Y_OFFSET        -20
194
+
195
+  #define USE_XPT2046       1
196
+  #define XPT2046_XY_SWAP   0
197
+  #define XPT2046_X_INV     1
198
+  #define XPT2046_Y_INV     0
199
+
200
+  #define XPT2046_HOR_RES   480
201
+  #define XPT2046_VER_RES   320
202
+  #define XPT2046_X_MIN     140
203
+  #define XPT2046_Y_MIN     200
204
+  #define XPT2046_X_MAX     1900
205
+  #define XPT2046_Y_MAX     1900
206
+  #define XPT2046_AVG       4
207
+  #define XPT2046_INV       0
208
+#endif
209
+
145 210
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
146 211
 // We nee to use the SPI2
147 212
 #define ENABLE_SPI2

+ 65
- 0
Marlin/src/pins/stm32f1/pins_CHITU3D_V6.h View File

@@ -147,6 +147,71 @@
147 147
   #endif
148 148
 #endif
149 149
 
150
+#define SPI_FLASH_SIZE 0x200000                   // 2MB
151
+
152
+#if ENABLED(TFT_LVGL_UI)
153
+  #define HAS_SPI_FLASH_FONT 0
154
+  #define HAS_GCODE_PREVIEW 1
155
+  #define HAS_GCODE_DEFAULT_VIEW_IN_FLASH 0
156
+  #define HAS_LANG_SELECT_SCREEN 0
157
+  #define HAS_BAK_VIEW_IN_FLASH 0
158
+
159
+  //SPI 2
160
+  #define W25QXX_CS_PIN                     PB12
161
+  #define W25QXX_MOSI_PIN                   PB15
162
+  #define W25QXX_MISO_PIN                   PB14
163
+  #define W25QXX_SCK_PIN                    PB13
164
+
165
+  #define TOUCH_CS_PIN                      PB7   // SPI1_NSS
166
+  #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
167
+  #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
168
+  #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
169
+  // #define TOUCH_INT_PIN                   PB6
170
+
171
+  #define SPI_TFT_CS_PIN            TOUCH_CS_PIN
172
+  #define SPI_TFT_SCK_PIN          TOUCH_SCK_PIN
173
+  #define SPI_TFT_MISO_PIN        TOUCH_MISO_PIN
174
+  #define SPI_TFT_MOSI_PIN        TOUCH_MOSI_PIN
175
+  #define SPI_TFT_DC_PIN                    PB6
176
+  #define SPI_TFT_RST_PIN                   PF11
177
+
178
+  #define LCD_RESET_PIN                     PF11
179
+  #define LCD_BACKLIGHT_PIN                 PD13
180
+  #define FSMC_CS_PIN                       PD7
181
+  #define FSMC_RS_PIN                       PD11
182
+
183
+  #define LCD_USE_DMA_FSMC                        // Use DMA transfers to send data to the TFT
184
+  #define FSMC_DMA_DEV                      DMA2
185
+  #define FSMC_DMA_CHANNEL               DMA_CH5
186
+
187
+  #define LCD_FULL_PIXEL_WIDTH 480
188
+  #define LCD_PIXEL_OFFSET_X 48
189
+  #define LCD_FULL_PIXEL_HEIGHT 320
190
+  #define LCD_PIXEL_OFFSET_Y 48
191
+
192
+  #define LCD_PIXEL_HEIGHT 320
193
+  #define LCD_PIXEL_WIDTH 480
194
+
195
+  #define XPT2046_X_CALIBRATION  -12316
196
+  #define XPT2046_Y_CALIBRATION   8981
197
+  #define XPT2046_X_OFFSET        340
198
+  #define XPT2046_Y_OFFSET        -20
199
+
200
+  #define USE_XPT2046       1
201
+  #define XPT2046_XY_SWAP   0
202
+  #define XPT2046_X_INV     1
203
+  #define XPT2046_Y_INV     0
204
+
205
+  #define XPT2046_HOR_RES   480
206
+  #define XPT2046_VER_RES   320
207
+  #define XPT2046_X_MIN     140
208
+  #define XPT2046_Y_MIN     200
209
+  #define XPT2046_X_MAX     1900
210
+  #define XPT2046_Y_MAX     1900
211
+  #define XPT2046_AVG       4
212
+  #define XPT2046_INV       0
213
+#endif
214
+
150 215
 // SPI1(PA7)=LCD & SPI3(PB5)=STUFF, are not available
151 216
 // so SPI2 is required.
152 217
 #define ENABLE_SPI2

+ 1
- 1
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h View File

@@ -231,7 +231,7 @@
231 231
 
232 232
   #endif // HAS_SPI_LCD
233 233
 
234
-#elif ENABLED(TFT_LITTLE_VGL_UI)
234
+#elif ENABLED(TFT_LVGL_UI)
235 235
 
236 236
   #define FSMC_CS_PIN                       PD7   // NE4
237 237
   #define FSMC_RS_PIN                       PD11  // A0

+ 15
- 4
platformio.ini View File

@@ -267,7 +267,7 @@ build_flags    = ${common.build_flags} -std=gnu++17 -Wno-register
267 267
 build_unflags  = -std=gnu++11
268 268
 src_filter     = ${common.default_src_filter} +<src/HAL/SAMD51>
269 269
 lib_deps       = ${common.lib_deps}
270
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
270
+  SoftwareSerialM
271 271
   Adafruit_SPIFlash=https://github.com/adafruit/Adafruit_SPIFlash/archive/master.zip
272 272
 debug_tool     = jlink
273 273
 
@@ -346,7 +346,7 @@ lib_ignore    =
346 346
   Adafruit NeoPixel
347 347
   SPI
348 348
 lib_deps      = ${common.lib_deps}
349
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
349
+  SoftwareSerialM
350 350
 
351 351
 #
352 352
 # STM32F103RC
@@ -385,7 +385,7 @@ lib_deps          =
385 385
   LiquidTWI2@1.2.7
386 386
   Adafruit NeoPixel=https://github.com/ccccmagicboy/Adafruit_NeoPixel#meeb_3dp_use
387 387
   SailfishLCD=https://github.com/mikeshub/SailfishLCD/archive/master.zip
388
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
388
+  SoftwareSerialM
389 389
   USBComposite for STM32F1@0.91
390 390
 lib_ignore        = SPI
391 391
 debug_tool        = stlink
@@ -640,7 +640,7 @@ build_unflags = -std=gnu++11
640 640
 extra_scripts = buildroot/share/PlatformIO/scripts/mks_robin_nano35.py
641 641
 src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
642 642
 lib_deps      = ${common.lib_deps}
643
-  SoftwareSerialM=https://github.com/FYSETC/SoftwareSerialM/archive/master.zip
643
+  SoftwareSerialM
644 644
   MKS-LittlevGL=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
645 645
 lib_ignore    = Adafruit NeoPixel, SPI
646 646
 
@@ -692,6 +692,17 @@ extends       = env:chitu_f103
692 692
 build_flags   = ${env:chitu_f103.build_flags} -DCHITU_V5_Z_MIN_BUGFIX
693 693
 
694 694
 #
695
+# Chitu boards like Tronxy X5SA (STM32F103ZET6) using TFT LVGL UI
696
+#
697
+[env:chitu_f103_lvgl]
698
+platform      = ${common_stm32f1.platform}
699
+extends       = env:chitu_f103
700
+src_filter    = ${common.default_src_filter} +<src/HAL/STM32F1>
701
+lib_deps      = ${common.lib_deps}
702
+   SoftwareSerialM
703
+   MKS-LittlevGL=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
704
+
705
+#
695 706
 # Creality (STM32F103RET6)
696 707
 #
697 708
 [env:STM32F103RET6_creality]

Loading…
Cancel
Save