Browse Source

Add MKS Robin E3P, improve LVGL UI (#19442)

makerbase 3 years ago
parent
commit
d8ed749045
No account linked to committer's email address
94 changed files with 12673 additions and 2970 deletions
  1. 2
    0
      Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp
  2. 11
    0
      Marlin/src/MarlinCore.cpp
  3. 37
    36
      Marlin/src/core/boards.h
  4. 2
    0
      Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp
  5. 3
    2
      Marlin/src/lcd/extui/lib/mks_ui/SPI_TFT.cpp
  6. 20
    21
      Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
  7. 144
    178
      Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp
  8. 214
    20
      Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp
  9. 203
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp
  10. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h
  11. 352
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp
  12. 36
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h
  13. 52
    31
      Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
  14. 392
    63
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  15. 5
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h
  16. 63
    76
      Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp
  17. 172
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp
  18. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h
  19. 62
    35
      Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
  20. 35
    21
      Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
  21. 270
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp
  22. 36
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h
  23. 329
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp
  24. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h
  25. 60
    77
      Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
  26. 262
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp
  27. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h
  28. 62
    88
      Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp
  29. 286
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp
  30. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h
  31. 84
    52
      Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp
  32. 261
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp
  33. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h
  34. 86
    28
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp
  35. 47
    34
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp
  36. 41
    28
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  37. 459
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp
  38. 33
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h
  39. 94
    118
      Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp
  40. 128
    32
      Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp
  41. 55
    32
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  42. 242
    49
      Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp
  43. 174
    87
      Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp
  44. 50
    70
      Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp
  45. 57
    40
      Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
  46. 61
    42
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
  47. 2
    1
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h
  48. 93
    102
      Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp
  49. 48
    74
      Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
  50. 160
    89
      Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp
  51. 93
    123
      Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp
  52. 195
    194
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp
  53. 282
    174
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp
  54. 94
    77
      Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp
  55. 350
    145
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  56. 145
    23
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  57. 222
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp
  58. 38
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h
  59. 235
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp
  60. 76
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h
  61. 299
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp
  62. 36
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h
  63. 85
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp
  64. 51
    0
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h
  65. 69
    0
      Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp
  66. 73
    27
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  67. 95
    79
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp
  68. 11
    2
      Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h
  69. 39
    5
      Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp
  70. 36
    18
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h
  71. 0
    5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h
  72. 0
    5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h
  73. 0
    5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h
  74. 36
    16
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h
  75. 0
    5
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h
  76. 35
    16
      Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h
  77. 597
    283
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  78. 35
    16
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
  79. 154
    137
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.cpp
  80. 32
    43
      Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h
  81. 120
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp
  82. 102
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h
  83. 1927
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
  84. 202
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h
  85. 847
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp
  86. 74
    0
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h
  87. 7
    7
      Marlin/src/module/stepper.h
  88. 2
    0
      Marlin/src/pins/pins.h
  89. 377
    0
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h
  90. 21
    17
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h
  91. 27
    21
      Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h
  92. 14
    0
      buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld
  93. 40
    0
      buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
  94. 17
    1
      platformio.ini

+ 2
- 0
Marlin/src/HAL/STM32F1/tft/tft_fsmc.cpp View File

@@ -201,6 +201,8 @@ uint32_t TFT_FSMC::GetID() {
201 201
     id = ReadID(LCD_READ_ID);
202 202
   if ((id & 0xFFFF) == 0 || (id & 0xFFFF) == 0xFFFF)
203 203
     id = ReadID(LCD_READ_ID4);
204
+  if ((id & 0xFF00) == 0 && (id & 0xFF) != 0)
205
+    id = ReadID(LCD_READ_ID4);
204 206
   return id;
205 207
 }
206 208
 

+ 11
- 0
Marlin/src/MarlinCore.cpp View File

@@ -796,6 +796,10 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
796 796
     UNUSED(lcd_component);
797 797
   #endif
798 798
 
799
+  #if HAS_TFT_LVGL_UI
800
+    lv_draw_error_message(lcd_error);
801
+  #endif
802
+
799 803
   #ifdef ACTION_ON_KILL
800 804
     host_action_kill();
801 805
   #endif
@@ -920,6 +924,13 @@ void setup() {
920 924
     SERIAL_ECHO_MSG("start");
921 925
   #endif
922 926
 
927
+  #if BOTH(HAS_TFT_LVGL_UI, USE_WIFI_FUNCTION)
928
+    mks_esp_wifi_init();
929
+    WIFISERIAL.begin(WIFI_BAUDRATE);
930
+    serial_connect_timeout = millis() + 1000UL;
931
+    while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
932
+  #endif
933
+
923 934
   SETUP_RUN(HAL_init());
924 935
 
925 936
   #if HAS_L64XX

+ 37
- 36
Marlin/src/core/boards.h View File

@@ -282,42 +282,43 @@
282 282
 // STM32 ARM Cortex-M3
283 283
 //
284 284
 
285
-#define BOARD_STM32F103RE             4000  // STM32F103RE Libmaple-based STM32F1 controller
286
-#define BOARD_MALYAN_M200             4001  // STM32C8T6  Libmaple-based STM32F1 controller
287
-#define BOARD_MALYAN_M200_V2          4002  // STM32F070CB  STM32F0 controller
288
-#define BOARD_STM3R_MINI              4003  // STM32F103RE  Libmaple-based STM32F1 controller
289
-#define BOARD_GTM32_PRO_VB            4004  // STM32F103VET6 controller
290
-#define BOARD_MORPHEUS                4005  // STM32F103C8 / STM32F103CB  Libmaple-based STM32F1 controller
291
-#define BOARD_CHITU3D                 4006  // Chitu3D (STM32F103RET6)
292
-#define BOARD_MKS_ROBIN               4007  // MKS Robin (STM32F103ZET6)
293
-#define BOARD_MKS_ROBIN_MINI          4008  // MKS Robin Mini (STM32F103VET6)
294
-#define BOARD_MKS_ROBIN_NANO          4009  // MKS Robin Nano (STM32F103VET6)
295
-#define BOARD_MKS_ROBIN_NANO_V2       4010  // MKS Robin Nano V2 (STM32F103VET6)
296
-#define BOARD_MKS_ROBIN_LITE          4011  // MKS Robin Lite/Lite2 (STM32F103RCT6)
297
-#define BOARD_MKS_ROBIN_LITE3         4012  // MKS Robin Lite3 (STM32F103RCT6)
298
-#define BOARD_MKS_ROBIN_PRO           4013  // MKS Robin Pro (STM32F103ZET6)
299
-#define BOARD_BTT_SKR_MINI_V1_1       4014  // BigTreeTech SKR Mini v1.1 (STM32F103RC)
300
-#define BOARD_BTT_SKR_MINI_E3_V1_0    4015  // BigTreeTech SKR Mini E3 (STM32F103RC)
301
-#define BOARD_BTT_SKR_MINI_E3_V1_2    4016  // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
302
-#define BOARD_BTT_SKR_MINI_E3_V2_0    4017  // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
303
-#define BOARD_BTT_SKR_E3_DIP          4018  // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
304
-#define BOARD_JGAURORA_A5S_A1         4019  // JGAurora A5S A1 (STM32F103ZET6)
305
-#define BOARD_FYSETC_AIO_II           4020  // FYSETC AIO_II
306
-#define BOARD_FYSETC_CHEETAH          4021  // FYSETC Cheetah
307
-#define BOARD_FYSETC_CHEETAH_V12      4022  // FYSETC Cheetah V1.2
308
-#define BOARD_LONGER3D_LK             4023  // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
309
-#define BOARD_GTM32_MINI              4024  // STM32F103VET6 controller
310
-#define BOARD_GTM32_MINI_A30          4025  // STM32F103VET6 controller
311
-#define BOARD_GTM32_REV_B             4026  // STM32F103VET6 controller
312
-#define BOARD_MKS_ROBIN_E3D           4027  // MKS Robin E3D (STM32F103RCT6)
313
-#define BOARD_MKS_ROBIN_E3            4028  // MKS Robin E3 (STM32F103RCT6)
314
-#define BOARD_MALYAN_M300             4029  // STM32F070-based delta
315
-#define BOARD_CCROBOT_MEEB_3DP        4030  // ccrobot-online.com MEEB_3DP (STM32F103RC)
316
-#define BOARD_CHITU3D_V5              4031  // Chitu3D TronXY X5SA V5 Board
317
-#define BOARD_CHITU3D_V6              4032  // Chitu3D TronXY X5SA V5 Board
318
-#define BOARD_CREALITY_V4             4033  // Creality v4.x (STM32F103RE)
319
-#define BOARD_CREALITY_V427           4034  // Creality v4.2.7 (STM32F103RE)
320
-#define BOARD_TRIGORILLA_PRO          4035  // Trigorilla Pro (STM32F103ZET6)
285
+#define BOARD_MALYAN_M200_V2          4000  // STM32F070CB  STM32F0 controller
286
+#define BOARD_MALYAN_M300             4001  // STM32F070-based delta
287
+#define BOARD_STM32F103RE             4002  // STM32F103RE Libmaple-based STM32F1 controller
288
+#define BOARD_MALYAN_M200             4003  // STM32C8T6  Libmaple-based STM32F1 controller
289
+#define BOARD_STM3R_MINI              4004  // STM32F103RE  Libmaple-based STM32F1 controller
290
+#define BOARD_GTM32_PRO_VB            4005  // STM32F103VET6 controller
291
+#define BOARD_GTM32_MINI              4006  // STM32F103VET6 controller
292
+#define BOARD_GTM32_MINI_A30          4007  // STM32F103VET6 controller
293
+#define BOARD_GTM32_REV_B             4008  // STM32F103VET6 controller
294
+#define BOARD_MORPHEUS                4009  // STM32F103C8 / STM32F103CB  Libmaple-based STM32F1 controller
295
+#define BOARD_CHITU3D                 4010  // Chitu3D (STM32F103RET6)
296
+#define BOARD_MKS_ROBIN               4011  // MKS Robin (STM32F103ZET6)
297
+#define BOARD_MKS_ROBIN_MINI          4012  // MKS Robin Mini (STM32F103VET6)
298
+#define BOARD_MKS_ROBIN_NANO          4013  // MKS Robin Nano (STM32F103VET6)
299
+#define BOARD_MKS_ROBIN_NANO_V2       4014  // MKS Robin Nano V2 (STM32F103VET6)
300
+#define BOARD_MKS_ROBIN_LITE          4015  // MKS Robin Lite/Lite2 (STM32F103RCT6)
301
+#define BOARD_MKS_ROBIN_LITE3         4016  // MKS Robin Lite3 (STM32F103RCT6)
302
+#define BOARD_MKS_ROBIN_PRO           4017  // MKS Robin Pro (STM32F103ZET6)
303
+#define BOARD_MKS_ROBIN_E3            4018  // MKS Robin E3  (STM32F103RCT6)
304
+#define BOARD_MKS_ROBIN_E3D           4019  // MKS Robin E3D (STM32F103RCT6)
305
+#define BOARD_MKS_ROBIN_E3P           4020  // MKS Robin E3p (STM32F103VET6)
306
+#define BOARD_BTT_SKR_MINI_V1_1       4021  // BigTreeTech SKR Mini v1.1 (STM32F103RC)
307
+#define BOARD_BTT_SKR_MINI_E3_V1_0    4022  // BigTreeTech SKR Mini E3 (STM32F103RC)
308
+#define BOARD_BTT_SKR_MINI_E3_V1_2    4023  // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC)
309
+#define BOARD_BTT_SKR_MINI_E3_V2_0    4024  // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC)
310
+#define BOARD_BTT_SKR_E3_DIP          4025  // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE)
311
+#define BOARD_JGAURORA_A5S_A1         4026  // JGAurora A5S A1 (STM32F103ZET6)
312
+#define BOARD_FYSETC_AIO_II           4027  // FYSETC AIO_II
313
+#define BOARD_FYSETC_CHEETAH          4028  // FYSETC Cheetah
314
+#define BOARD_FYSETC_CHEETAH_V12      4029  // FYSETC Cheetah V1.2
315
+#define BOARD_LONGER3D_LK             4030  // Alfawise U20/U20+/U30 (Longer3D LK1/2) / STM32F103VET6
316
+#define BOARD_CCROBOT_MEEB_3DP        4031  // ccrobot-online.com MEEB_3DP (STM32F103RC)
317
+#define BOARD_CHITU3D_V5              4032  // Chitu3D TronXY X5SA V5 Board
318
+#define BOARD_CHITU3D_V6              4033  // Chitu3D TronXY X5SA V5 Board
319
+#define BOARD_CREALITY_V4             4034  // Creality v4.x (STM32F103RE)
320
+#define BOARD_CREALITY_V427           4035  // Creality v4.2.7 (STM32F103RE)
321
+#define BOARD_TRIGORILLA_PRO          4036  // Trigorilla Pro (STM32F103ZET6)
321 322
 
322 323
 //
323 324
 // ARM Cortex-M4F

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

@@ -27,6 +27,8 @@
27 27
 #include "../../../../inc/MarlinConfig.h"
28 28
 #include "SPIFlashStorage.h"
29 29
 
30
+extern W25QXXFlash W25QXX;
31
+
30 32
 uint8_t SPIFlashStorage::m_pageData[SPI_FLASH_PageSize];
31 33
 uint32_t SPIFlashStorage::m_currentPage;
32 34
 uint16_t SPIFlashStorage::m_pageDataUsed;

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

@@ -26,6 +26,7 @@
26 26
 
27 27
 #include "SPI_TFT.h"
28 28
 #include "pic_manager.h"
29
+#include "tft_lvgl_configuration.h"
29 30
 
30 31
 #include "../../../../inc/MarlinConfig.h"
31 32
 
@@ -74,6 +75,7 @@ void TFT::SetWindows(uint16_t x, uint16_t y, uint16_t with, uint16_t height) {
74 75
 }
75 76
 
76 77
 void TFT::LCD_init() {
78
+  TFT_BLK_L;
77 79
   TFT_RST_H;
78 80
   delay(150);
79 81
   TFT_RST_L;
@@ -92,8 +94,7 @@ void TFT::LCD_init() {
92 94
   LCD_WR_DATA(0x96);
93 95
 
94 96
   LCD_WR_REG(0x36);
95
-  LCD_WR_DATA(0x28);
96
-
97
+  LCD_WR_DATA(0x28 + TERN0(GRAPHICAL_TFT_ROTATE_180, 0x80));
97 98
   LCD_WR_REG(0x3A);
98 99
   LCD_WR_DATA(0x55);
99 100
 

+ 20
- 21
Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp View File

@@ -33,8 +33,9 @@
33 33
 #include "../../../../MarlinCore.h"
34 34
 #include "../../../../module/temperature.h"
35 35
 
36
+extern lv_group_t * g;
36 37
 static lv_obj_t * scr;
37
-static lv_obj_t * fw_type, *board, *fw_version;
38
+static lv_obj_t * fw_type, *board; //*fw_version;
38 39
 
39 40
 #define ID_A_RETURN   1
40 41
 
@@ -73,17 +74,18 @@ void lv_draw_about(void) {
73 74
 
74 75
   lv_refr_now(lv_refr_get_disp_refreshing());
75 76
 
76
-  LV_IMG_DECLARE(bmp_pic);
77
-
78 77
   // Create an Image button
79 78
   buttonBack = lv_imgbtn_create(scr, NULL);
80 79
 
81 80
   #if 1
82
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, "bmp_return.bin", 0);
83
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
84
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
81
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_A_RETURN, NULL, 0);
82
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
83
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
85 84
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
86 85
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
86
+    #if HAS_ROTARY_ENCODER
87
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
88
+    #endif
87 89
   #endif
88 90
 
89 91
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
@@ -97,30 +99,27 @@ void lv_draw_about(void) {
97 99
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
98 100
   }
99 101
 
100
-  fw_version = lv_label_create(scr, NULL);
101
-  lv_obj_set_style(fw_version, &tft_style_label_rel);
102
-  lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
103
-  lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
102
+  //fw_version = lv_label_create(scr, NULL);
103
+  //lv_obj_set_style(fw_version, &tft_style_label_rel);
104
+  //lv_label_set_text(fw_version, SHORT_BUILD_VERSION);
105
+  //lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
104 106
 
105 107
   fw_type = lv_label_create(scr, NULL);
106 108
   lv_obj_set_style(fw_type, &tft_style_label_rel);
107
-  lv_label_set_text(fw_type,
108
-    #if MB(MKS_ROBIN_PRO)
109
-      "Firmware: Robin_Pro35"
110
-    #elif MB(MKS_ROBIN_NANO, MKS_ROBIN_NANO_V2)
111
-      "Firmware: Robin_Nano35"
112
-    #else
113
-      CUSTOM_MACHINE_NAME
114
-    #endif
115
-  );
109
+  lv_label_set_text(fw_type, "Firmware: Marlin " SHORT_BUILD_VERSION);
116 110
   lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20);
117 111
 
118 112
   board = lv_label_create(scr, NULL);
119 113
   lv_obj_set_style(board, &tft_style_label_rel);
120 114
   lv_label_set_text(board, "Board: " BOARD_INFO_NAME);
121
-  lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, 20);
115
+  lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, -60);
122 116
 }
123 117
 
124
-void lv_clear_about() { lv_obj_del(scr); }
118
+void lv_clear_about() {
119
+  #if HAS_ROTARY_ENCODER
120
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
121
+  #endif
122
+  lv_obj_del(scr);
123
+}
125 124
 
126 125
 #endif // HAS_TFT_LVGL_UI

+ 144
- 178
Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp View File

@@ -29,6 +29,7 @@
29 29
 #include "../../../../MarlinCore.h"
30 30
 #include "../../../../module/planner.h"
31 31
 
32
+extern lv_group_t * g;
32 33
 static lv_obj_t * scr;
33 34
 
34 35
 #define ID_ACCE_RETURN  1
@@ -160,14 +161,14 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
160 161
 
161 162
 void lv_draw_acceleration_settings(void) {
162 163
   lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
163
-  lv_obj_t *buttonPrintText = NULL, *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL;
164
-  lv_obj_t *buttonRetraText = NULL, *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL;
165
-  lv_obj_t *buttonTravelText = NULL, *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL;
166
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
167
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
168
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
169
-  lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
170
-  lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
164
+  lv_obj_t *labelPrintText = NULL, *buttonPrintValue = NULL, *labelPrintValue = NULL;
165
+  lv_obj_t *labelRetraText = NULL, *buttonRetraValue = NULL, *labelRetraValue = NULL;
166
+  lv_obj_t *labelTravelText = NULL, *buttonTravelValue = NULL, *labelTravelValue = NULL;
167
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
168
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
169
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
170
+  lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
171
+  lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
171 172
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
172 173
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) {
173 174
     disp_state_stack._disp_index++;
@@ -188,231 +189,202 @@ void lv_draw_acceleration_settings(void) {
188 189
 
189 190
   lv_refr_now(lv_refr_get_disp_refreshing());
190 191
 
191
-  LV_IMG_DECLARE(bmp_para_back);
192
-  // LV_IMG_DECLARE(bmp_para_arrow);
193
-  LV_IMG_DECLARE(bmp_para_bank);
194
-
195 192
   if (uiCfg.para_ui_page != 1) {
196
-    buttonPrintText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
197
-    lv_obj_set_pos(buttonPrintText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
198
-    lv_obj_set_size(buttonPrintText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
199
-    lv_obj_set_event_cb(buttonPrintText, event_handler);
200
-    lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
201
-    lv_btn_set_style(buttonPrintText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
202
-    lv_btn_set_layout(buttonPrintText, LV_LAYOUT_OFF);
203
-    labelPrintText = lv_label_create(buttonPrintText, NULL);                    /*Add a label to the button*/
204
-
205
-    buttonPrintValue = lv_imgbtn_create(scr, NULL);
193
+
194
+    labelPrintText = lv_label_create(scr, NULL);
195
+    lv_obj_set_style(labelPrintText, &tft_style_label_rel);
196
+    lv_obj_set_pos(labelPrintText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
197
+    lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration);
198
+
199
+    buttonPrintValue = lv_btn_create(scr, NULL);
206 200
     lv_obj_set_pos(buttonPrintValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
207
-    lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, "bmp_value_blank.bin", 0);
208
-    lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_REL, &bmp_para_bank);
209
-    lv_imgbtn_set_src(buttonPrintValue, LV_BTN_STATE_PR, &bmp_para_bank);
210
-    lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_PR, &style_para_value_pre);
211
-    lv_imgbtn_set_style(buttonPrintValue, LV_BTN_STATE_REL, &style_para_value_rel);
212
-    lv_btn_set_layout(buttonPrintValue, LV_LAYOUT_OFF);
201
+    lv_obj_set_size(buttonPrintValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
202
+    lv_obj_set_event_cb_mks(buttonPrintValue, event_handler, ID_ACCE_PRINT, NULL, 0);
203
+    lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_REL, &style_para_value);
204
+    lv_btn_set_style(buttonPrintValue, LV_BTN_STYLE_PR, &style_para_value);
213 205
     labelPrintValue = lv_label_create(buttonPrintValue, NULL);
214 206
 
215 207
     line1 = lv_line_create(scr, NULL);
216 208
     lv_ex_line(line1, line_points[0]);
217 209
 
218
-    buttonRetraText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
219
-    lv_obj_set_pos(buttonRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
220
-    lv_obj_set_size(buttonRetraText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
221
-    lv_obj_set_event_cb(buttonRetraText, event_handler);
222
-    lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
223
-    lv_btn_set_style(buttonRetraText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
224
-    lv_btn_set_layout(buttonRetraText, LV_LAYOUT_OFF);
225
-    labelRetraText = lv_label_create(buttonRetraText, NULL);                    /*Add a label to the button*/
210
+    labelRetraText = lv_label_create(scr, NULL);
211
+    lv_obj_set_style(labelRetraText, &tft_style_label_rel);
212
+    lv_obj_set_pos(labelRetraText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
213
+    lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration);
226 214
 
227
-    buttonRetraValue = lv_imgbtn_create(scr, NULL);
215
+    buttonRetraValue = lv_btn_create(scr, NULL);
228 216
     lv_obj_set_pos(buttonRetraValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
229
-    lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, "bmp_value_blank.bin", 0);
230
-    lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_REL, &bmp_para_bank);
231
-    lv_imgbtn_set_src(buttonRetraValue, LV_BTN_STATE_PR, &bmp_para_bank);
232
-    lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_PR, &style_para_value_pre);
233
-    lv_imgbtn_set_style(buttonRetraValue, LV_BTN_STATE_REL, &style_para_value_rel);
234
-    lv_btn_set_layout(buttonRetraValue, LV_LAYOUT_OFF);
217
+    lv_obj_set_size(buttonRetraValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
218
+    lv_obj_set_event_cb_mks(buttonRetraValue, event_handler, ID_ACCE_RETRA, NULL, 0);
219
+    lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_REL, &style_para_value);
220
+    lv_btn_set_style(buttonRetraValue, LV_BTN_STYLE_PR, &style_para_value);
235 221
     labelRetraValue = lv_label_create(buttonRetraValue, NULL);
236 222
 
237 223
     line2 = lv_line_create(scr, NULL);
238 224
     lv_ex_line(line2, line_points[1]);
239 225
 
240
-    buttonTravelText = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
241
-    lv_obj_set_pos(buttonTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);         /*Set its position*/
242
-    lv_obj_set_size(buttonTravelText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
243
-    lv_obj_set_event_cb(buttonTravelText, event_handler);
244
-    lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
245
-    lv_btn_set_style(buttonTravelText, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
246
-    lv_btn_set_layout(buttonTravelText, LV_LAYOUT_OFF);
247
-    labelTravelText = lv_label_create(buttonTravelText, NULL);                  /*Add a label to the button*/
226
+    labelTravelText = lv_label_create(scr, NULL);
227
+    lv_obj_set_style(labelTravelText, &tft_style_label_rel);
228
+    lv_obj_set_pos(labelTravelText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
229
+    lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration);
248 230
 
249
-    buttonTravelValue = lv_imgbtn_create(scr, NULL);
231
+    buttonTravelValue = lv_btn_create(scr, NULL);
250 232
     lv_obj_set_pos(buttonTravelValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
251
-    lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, "bmp_value_blank.bin", 0);
252
-    lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_REL, &bmp_para_bank);
253
-    lv_imgbtn_set_src(buttonTravelValue, LV_BTN_STATE_PR, &bmp_para_bank);
254
-    lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_PR, &style_para_value_pre);
255
-    lv_imgbtn_set_style(buttonTravelValue, LV_BTN_STATE_REL, &style_para_value_rel);
256
-    lv_btn_set_layout(buttonTravelValue, LV_LAYOUT_OFF);
233
+    lv_obj_set_size(buttonTravelValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
234
+    lv_obj_set_event_cb_mks(buttonTravelValue, event_handler, ID_ACCE_TRAVEL, NULL, 0);
235
+    lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_REL, &style_para_value);
236
+    lv_btn_set_style(buttonTravelValue, LV_BTN_STYLE_PR, &style_para_value);
257 237
     labelTravelValue = lv_label_create(buttonTravelValue, NULL);
258 238
 
259 239
     line3 = lv_line_create(scr, NULL);
260 240
     lv_ex_line(line3, line_points[2]);
261 241
 
262
-    buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
263
-    lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4);          /*Set its position*/
264
-    lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
265
-    lv_obj_set_event_cb(buttonXText, event_handler);
266
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
267
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
268
-    lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
269
-    labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
242
+    labelXText = lv_label_create(scr, NULL);
243
+    lv_obj_set_style(labelXText, &tft_style_label_rel);
244
+    lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
245
+    lv_label_set_text(labelXText, machine_menu.X_Acceleration);
270 246
 
271
-    buttonXValue = lv_imgbtn_create(scr, NULL);
247
+    buttonXValue = lv_btn_create(scr, NULL);
272 248
     lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
273
-    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, "bmp_value_blank.bin", 0);
274
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
275
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
276
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
277
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
278
-    lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
249
+    lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
250
+    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_ACCE_X, NULL, 0);
251
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
252
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
279 253
     labelXValue = lv_label_create(buttonXValue, NULL);
280 254
 
281 255
     line4 = lv_line_create(scr, NULL);
282 256
     lv_ex_line(line4, line_points[3]);
283 257
 
284
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
285
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, "bmp_back70x40.bin", 0);
286
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
287
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
288
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
289
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
258
+    buttonTurnPage = lv_btn_create(scr, NULL);
259
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_DOWN, NULL, 0);
260
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
261
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
262
+
263
+    #if HAS_ROTARY_ENCODER
264
+      if (gCfgItems.encoder_enable) {
265
+        lv_group_add_obj(g, buttonPrintValue);
266
+        lv_group_add_obj(g, buttonRetraValue);
267
+        lv_group_add_obj(g, buttonTravelValue);
268
+        lv_group_add_obj(g, buttonXValue);
269
+        lv_group_add_obj(g, buttonTurnPage);
270
+      }
271
+    #endif
290 272
   }
291 273
   else {
292
-    buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
293
-    lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
294
-    lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
295
-    lv_obj_set_event_cb(buttonYText, event_handler);
296
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
297
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
298
-    lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
299
-    labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
300
-
301
-    buttonYValue = lv_imgbtn_create(scr, NULL);
274
+    labelYText = lv_label_create(scr, NULL);
275
+    lv_obj_set_style(labelYText, &tft_style_label_rel);
276
+    lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
277
+    lv_label_set_text(labelYText, machine_menu.Y_Acceleration);
278
+
279
+    buttonYValue = lv_btn_create(scr, NULL);
302 280
     lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
303
-    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, "bmp_value_blank.bin", 0);
304
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
305
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
306
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
307
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
308
-    lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
281
+    lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
282
+    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
283
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
284
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
309 285
     labelYValue = lv_label_create(buttonYValue, NULL);
310 286
 
311 287
     line1 = lv_line_create(scr, NULL);
312 288
     lv_ex_line(line1, line_points[0]);
313 289
 
314
-    buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
315
-    lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
316
-    lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
317
-    lv_obj_set_event_cb(buttonZText, event_handler);
318
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
319
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
320
-    lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
321
-    labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
290
+    labelZText = lv_label_create(scr, NULL);
291
+    lv_obj_set_style(labelZText, &tft_style_label_rel);
292
+    lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
293
+    lv_label_set_text(labelZText, machine_menu.Z_Acceleration);
322 294
 
323
-    buttonZValue = lv_imgbtn_create(scr, NULL);
295
+    buttonZValue = lv_btn_create(scr, NULL);
324 296
     lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
325
-    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, "bmp_value_blank.bin", 0);
326
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
327
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
328
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
329
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
330
-    lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
297
+    lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
298
+    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_ACCE_Z, NULL, 0);
299
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
300
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
331 301
     labelZValue = lv_label_create(buttonZValue, NULL);
332 302
 
303
+
333 304
     line2 = lv_line_create(scr, NULL);
334 305
     lv_ex_line(line2, line_points[1]);
335 306
 
336
-    buttonE0Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
337
-    lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3);         /*Set its position*/
338
-    lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
339
-    lv_obj_set_event_cb(buttonE0Text, event_handler);
340
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
341
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
342
-    lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
343
-    labelE0Text = lv_label_create(buttonE0Text, NULL);                      /*Add a label to the button*/
307
+    labelE0Text = lv_label_create(scr, NULL);
308
+    lv_obj_set_style(labelE0Text, &tft_style_label_rel);
309
+    lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
310
+    lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration);
344 311
 
345
-    buttonE0Value = lv_imgbtn_create(scr, NULL);
312
+    buttonE0Value = lv_btn_create(scr, NULL);
346 313
     lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
347
-    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, "bmp_value_blank.bin", 0);
348
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
349
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
350
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
351
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
352
-    lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
314
+    lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
315
+    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_ACCE_E0, NULL, 0);
316
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
317
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
353 318
     labelE0Value = lv_label_create(buttonE0Value, NULL);
354 319
 
320
+
355 321
     line3 = lv_line_create(scr, NULL);
356 322
     lv_ex_line(line3, line_points[2]);
357 323
 
358
-    buttonE1Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
359
-    lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4);         /*Set its position*/
360
-    lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
361
-    lv_obj_set_event_cb(buttonE1Text, event_handler);
362
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
363
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
364
-    lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
365
-    labelE1Text = lv_label_create(buttonE1Text, NULL);                      /*Add a label to the button*/
324
+    labelE1Text = lv_label_create(scr, NULL);
325
+    lv_obj_set_style(labelE1Text, &tft_style_label_rel);
326
+    lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
327
+    lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration);
366 328
 
367
-    buttonE1Value = lv_imgbtn_create(scr, NULL);
329
+    buttonE1Value = lv_btn_create(scr, NULL);
368 330
     lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
369
-    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, "bmp_value_blank.bin", 0);
370
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
371
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
372
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
373
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
374
-    lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
331
+    lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_ACCE_Y, NULL, 0);
332
+    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_ACCE_E1, NULL, 0);
333
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
334
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
375 335
     labelE1Value = lv_label_create(buttonE1Value, NULL);
376 336
 
337
+
377 338
     line4 = lv_line_create(scr, NULL);
378 339
     lv_ex_line(line4, line_points[3]);
379 340
 
380
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
381
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, "bmp_back70x40.bin", 0);
382
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
383
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
384
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
385
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
341
+    buttonTurnPage = lv_btn_create(scr, NULL);
342
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_ACCE_UP, NULL, 0);
343
+    //lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
344
+    //lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
345
+    //lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
346
+    //lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
347
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
348
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
349
+
350
+    #if HAS_ROTARY_ENCODER
351
+      if (gCfgItems.encoder_enable) {
352
+        lv_group_add_obj(g, buttonYValue);
353
+        lv_group_add_obj(g, buttonZValue);
354
+        lv_group_add_obj(g, buttonE0Value);
355
+        lv_group_add_obj(g, buttonE1Value);
356
+        lv_group_add_obj(g, buttonTurnPage);
357
+      }
358
+    #endif
386 359
   }
387 360
 
361
+  //lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
362
+  //lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
363
+  //labelTurnPage = lv_label_create(buttonTurnPage, NULL);
388 364
   lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
389
-  lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
365
+  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
390 366
   labelTurnPage = lv_label_create(buttonTurnPage, NULL);
391 367
 
392
-  buttonBack = lv_imgbtn_create(scr, NULL);
393
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, "bmp_back70x40.bin", 0);
394
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
395
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
396
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
397
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
398
-
368
+  buttonBack = lv_btn_create(scr, NULL);
369
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ACCE_RETURN, NULL, 0);
370
+  //lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
371
+  //lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
372
+  //lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
373
+  //lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
374
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
375
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
399 376
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
400
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
377
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
401 378
   label_Back = lv_label_create(buttonBack, NULL);
379
+  #if HAS_ROTARY_ENCODER
380
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
381
+  #endif
382
+
383
+  //lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
384
+  //lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
402 385
 
403 386
   if (gCfgItems.multiple_language != 0) {
404 387
     if (uiCfg.para_ui_page != 1) {
405
-      lv_label_set_text(labelPrintText, machine_menu.PrintAcceleration);
406
-      lv_obj_align(labelPrintText, buttonPrintText, LV_ALIGN_IN_LEFT_MID, 0, 0);
407
-
408
-      lv_label_set_text(labelRetraText, machine_menu.RetractAcceleration);
409
-      lv_obj_align(labelRetraText, buttonRetraText, LV_ALIGN_IN_LEFT_MID, 0, 0);
410
-
411
-      lv_label_set_text(labelTravelText, machine_menu.TravelAcceleration);
412
-      lv_obj_align(labelTravelText, buttonTravelText, LV_ALIGN_IN_LEFT_MID, 0, 0);
413
-
414
-      lv_label_set_text(labelXText, machine_menu.X_Acceleration);
415
-      lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
416 388
 
417 389
       lv_label_set_text(labelTurnPage, machine_menu.next);
418 390
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@@ -438,17 +410,6 @@ void lv_draw_acceleration_settings(void) {
438 410
       lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
439 411
     }
440 412
     else {
441
-      lv_label_set_text(labelYText, machine_menu.Y_Acceleration);
442
-      lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
443
-
444
-      lv_label_set_text(labelZText, machine_menu.Z_Acceleration);
445
-      lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
446
-
447
-      lv_label_set_text(labelE0Text, machine_menu.E0_Acceleration);
448
-      lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
449
-
450
-      lv_label_set_text(labelE1Text, machine_menu.E1_Acceleration);
451
-      lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
452 413
 
453 414
       lv_label_set_text(labelTurnPage, machine_menu.previous);
454 415
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@@ -478,6 +439,11 @@ void lv_draw_acceleration_settings(void) {
478 439
   }
479 440
 }
480 441
 
481
-void lv_clear_acceleration_settings() { lv_obj_del(scr); }
442
+void lv_clear_acceleration_settings() {
443
+  #if HAS_ROTARY_ENCODER
444
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
445
+  #endif
446
+  lv_obj_del(scr);
447
+}
482 448
 
483 449
 #endif // HAS_TFT_LVGL_UI

+ 214
- 20
Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp View File

@@ -28,11 +28,18 @@
28 28
 
29 29
 #include "../../../../MarlinCore.h"
30 30
 
31
+extern lv_group_t * g;
31 32
 static lv_obj_t * scr;
32 33
 
33
-#define ID_ADVANCE_RETURN   1
34
-#define ID_PAUSE_POS        2
35
-#define ID_PAUSE_POS_ARROW  3
34
+#define ID_ADVANCE_RETURN           1
35
+#define ID_PAUSE_POS                2
36
+#define ID_PAUSE_POS_ARROW          3
37
+#define ID_WIFI_PARA                4
38
+#define ID_WIFI_PARA_ARROW          5
39
+#define ID_FILAMENT_SETTINGS        6
40
+#define ID_FILAMENT_SETTINGS_ARROW  7
41
+#define ID_ENCODER_SETTINGS         8
42
+#define ID_ENCODER_SETTINGS_ARROW   9
36 43
 
37 44
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
38 45
   switch (obj->mks_obj_id) {
@@ -63,13 +70,79 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
63 70
         lv_draw_pause_position();
64 71
       }
65 72
       break;
73
+    case ID_FILAMENT_SETTINGS:
74
+      if (event == LV_EVENT_CLICKED) {
75
+
76
+      }
77
+      else if (event == LV_EVENT_RELEASED) {
78
+        lv_clear_advance_settings();
79
+        lv_draw_filament_settings();
80
+      }
81
+      break;
82
+    case ID_FILAMENT_SETTINGS_ARROW:
83
+      if (event == LV_EVENT_CLICKED) {
84
+
85
+      }
86
+      else if (event == LV_EVENT_RELEASED) {
87
+        lv_clear_advance_settings();
88
+        lv_draw_filament_settings();
89
+      }
90
+      break;
91
+    #if ENABLED(USE_WIFI_FUNCTION)
92
+      case ID_WIFI_PARA:
93
+      if (event == LV_EVENT_CLICKED) {
94
+
95
+      }
96
+      else if (event == LV_EVENT_RELEASED) {
97
+        lv_clear_advance_settings();
98
+        lv_draw_wifi_settings();
99
+      }
100
+      break;
101
+      case ID_WIFI_PARA_ARROW:
102
+      if (event == LV_EVENT_CLICKED) {
103
+
104
+      }
105
+      else if (event == LV_EVENT_RELEASED) {
106
+        lv_clear_advance_settings();
107
+        lv_draw_wifi_settings();
108
+      }
109
+      break;
110
+    #endif
111
+    #if HAS_ROTARY_ENCODER
112
+      case ID_ENCODER_SETTINGS:
113
+        if (event == LV_EVENT_CLICKED) {
114
+
115
+        }
116
+        else if (event == LV_EVENT_RELEASED) {
117
+          lv_clear_advance_settings();
118
+          lv_draw_encoder_settings();
119
+        }
120
+        break;
121
+      case ID_ENCODER_SETTINGS_ARROW:
122
+        if (event == LV_EVENT_CLICKED) {
123
+
124
+        }
125
+        else if (event == LV_EVENT_RELEASED) {
126
+          lv_clear_advance_settings();
127
+          lv_draw_encoder_settings();
128
+        }
129
+        break;
130
+    #endif
66 131
   }
67 132
 }
68 133
 
69 134
 void lv_draw_advance_settings(void) {
70 135
   lv_obj_t *buttonBack, *label_Back;
71 136
   lv_obj_t *buttonPausePos, *labelPausePos, *buttonPausePosNarrow;
72
-  lv_obj_t * line1;
137
+  lv_obj_t *buttonFilamentSettings, *labelFilamentSettings, *buttonFilamentSettingsNarrow;
138
+  lv_obj_t * line1,* line2;
139
+  #if ENABLED(USE_WIFI_FUNCTION)
140
+    lv_obj_t *buttonWifiSet,*labelWifiSet,*buttonWifiSetNarrow;
141
+  #endif
142
+  #if HAS_ROTARY_ENCODER
143
+    lv_obj_t *buttonEcoder,*labelEcoder,*buttonEcoderNarrow;
144
+  #endif
145
+
73 146
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
74 147
     disp_state_stack._disp_index++;
75 148
     disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
@@ -89,24 +162,24 @@ void lv_draw_advance_settings(void) {
89 162
 
90 163
   lv_refr_now(lv_refr_get_disp_refreshing());
91 164
 
92
-  LV_IMG_DECLARE(bmp_para_back);
93
-  LV_IMG_DECLARE(bmp_para_arrow);
94
-
95
-  buttonPausePos = lv_btn_create(scr, NULL);   /*Add a button the current screen*/
96
-  lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y);                         /*Set its position*/
97
-  lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
165
+  buttonPausePos = lv_btn_create(scr, NULL);
166
+  lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y);
167
+  lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
98 168
   //lv_obj_set_event_cb(buttonMachine, event_handler);
99 169
   lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
100
-  lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
101
-  lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre);    /*Set the button's pressed style*/
170
+  lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_REL, &tft_style_label_rel);
171
+  lv_btn_set_style(buttonPausePos, LV_BTN_STYLE_PR, &tft_style_label_pre);
102 172
   lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
103
-  labelPausePos = lv_label_create(buttonPausePos, NULL);        /*Add a label to the button*/
173
+  labelPausePos = lv_label_create(buttonPausePos, NULL);
174
+  #if HAS_ROTARY_ENCODER
175
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos);
176
+  #endif
104 177
 
105 178
   buttonPausePosNarrow = lv_imgbtn_create(scr, NULL);
106 179
   lv_obj_set_pos(buttonPausePosNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
107
-  lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, "bmp_arrow.bin", 0);
108
-  lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
109
-  lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
180
+  lv_obj_set_event_cb_mks(buttonPausePosNarrow, event_handler, ID_PAUSE_POS_ARROW, NULL, 0);
181
+  lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
182
+  lv_imgbtn_set_src(buttonPausePosNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
110 183
   lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
111 184
   lv_imgbtn_set_style(buttonPausePosNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
112 185
   lv_btn_set_layout(buttonPausePosNarrow, LV_LAYOUT_OFF);
@@ -114,13 +187,117 @@ void lv_draw_advance_settings(void) {
114 187
   line1 = lv_line_create(lv_scr_act(), NULL);
115 188
   lv_ex_line(line1, line_points[0]);
116 189
 
190
+  buttonFilamentSettings = lv_btn_create(scr, NULL);
191
+  lv_obj_set_pos(buttonFilamentSettings, PARA_UI_POS_X, PARA_UI_POS_Y*2);
192
+  lv_obj_set_size(buttonFilamentSettings, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
193
+  lv_obj_set_event_cb_mks(buttonFilamentSettings, event_handler, ID_FILAMENT_SETTINGS, NULL, 0);
194
+  lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_REL, &tft_style_label_rel);
195
+  lv_btn_set_style(buttonFilamentSettings, LV_BTN_STYLE_PR, &tft_style_label_pre);
196
+  lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF);
197
+  labelFilamentSettings = lv_label_create(buttonFilamentSettings, NULL);
198
+  #if HAS_ROTARY_ENCODER
199
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings);
200
+  #endif
201
+
202
+  buttonFilamentSettingsNarrow = lv_imgbtn_create(scr, NULL);
203
+  lv_obj_set_pos(buttonFilamentSettingsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V);
204
+  lv_obj_set_event_cb_mks(buttonFilamentSettingsNarrow, event_handler, ID_FILAMENT_SETTINGS_ARROW, NULL, 0);
205
+  lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
206
+  lv_imgbtn_set_src(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
207
+  lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
208
+  lv_imgbtn_set_style(buttonFilamentSettingsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
209
+  lv_btn_set_layout(buttonFilamentSettingsNarrow, LV_LAYOUT_OFF);
210
+
211
+  line2 = lv_line_create(lv_scr_act(), NULL);
212
+  lv_ex_line(line2, line_points[1]);
213
+
214
+  #if ENABLED(USE_WIFI_FUNCTION)
215
+
216
+    buttonWifiSet = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
217
+    lv_obj_set_pos(buttonWifiSet, PARA_UI_POS_X,PARA_UI_POS_Y*3);
218
+    lv_obj_set_size(buttonWifiSet, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
219
+    lv_obj_set_event_cb_mks(buttonWifiSet, event_handler,ID_WIFI_PARA,NULL,0);
220
+    lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_REL, &tft_style_label_rel);
221
+    lv_btn_set_style(buttonWifiSet, LV_BTN_STYLE_PR, &tft_style_label_pre);
222
+    lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF);
223
+    labelWifiSet = lv_label_create(buttonWifiSet, NULL);
224
+    #if HAS_ROTARY_ENCODER
225
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet);
226
+    #endif
227
+
228
+    buttonWifiSetNarrow = lv_imgbtn_create(scr, NULL);
229
+    lv_obj_set_pos(buttonWifiSetNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
230
+    lv_obj_set_event_cb_mks(buttonWifiSetNarrow, event_handler,ID_WIFI_PARA_ARROW, NULL,0);
231
+    lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
232
+    lv_imgbtn_set_src(buttonWifiSetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
233
+    lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
234
+    lv_imgbtn_set_style(buttonWifiSetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
235
+    lv_btn_set_layout(buttonWifiSetNarrow, LV_LAYOUT_OFF);
236
+
237
+    lv_obj_t * line3 = lv_line_create(scr, NULL);
238
+    lv_ex_line(line3,line_points[2]);
239
+
240
+    #if HAS_ROTARY_ENCODER
241
+      buttonEcoder = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
242
+      lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*4);
243
+      lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
244
+      lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
245
+      lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
246
+      lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
247
+      lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
248
+      labelEcoder = lv_label_create(buttonEcoder, NULL);
249
+
250
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
251
+
252
+      buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
253
+      lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*4+PARA_UI_ARROW_V);
254
+      lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
255
+      lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
256
+      lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
257
+      lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
258
+      lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
259
+      lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
260
+
261
+      lv_obj_t * line4 = lv_line_create(scr, NULL);
262
+      lv_ex_line(line4,line_points[3]);
263
+    #endif
264
+
265
+  #elif HAS_ROTARY_ENCODER
266
+    buttonEcoder = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
267
+    lv_obj_set_pos(buttonEcoder, PARA_UI_POS_X,PARA_UI_POS_Y*3);
268
+    lv_obj_set_size(buttonEcoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
269
+    lv_obj_set_event_cb_mks(buttonEcoder, event_handler,ID_ENCODER_SETTINGS,NULL,0);
270
+    lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_REL, &tft_style_label_rel);
271
+    lv_btn_set_style(buttonEcoder, LV_BTN_STYLE_PR, &tft_style_label_pre);
272
+    lv_btn_set_layout(buttonEcoder, LV_LAYOUT_OFF);
273
+    labelEcoder = lv_label_create(buttonEcoder, NULL);
274
+
275
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEcoder);
276
+
277
+    buttonEcoderNarrow = lv_imgbtn_create(scr, NULL);
278
+    lv_obj_set_pos(buttonEcoderNarrow,PARA_UI_POS_X+PARA_UI_SIZE_X,PARA_UI_POS_Y*3+PARA_UI_ARROW_V);
279
+    lv_obj_set_event_cb_mks(buttonEcoderNarrow, event_handler,ID_ENCODER_SETTINGS_ARROW, NULL,0);
280
+    lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
281
+    lv_imgbtn_set_src(buttonEcoderNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
282
+    lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
283
+    lv_imgbtn_set_style(buttonEcoderNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
284
+    lv_btn_set_layout(buttonEcoderNarrow, LV_LAYOUT_OFF);
285
+
286
+    lv_obj_t * line3 = lv_line_create(scr, NULL);
287
+    lv_ex_line(line3,line_points[2]);
288
+  #endif
289
+
117 290
   buttonBack = lv_imgbtn_create(scr, NULL);
118
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, "bmp_back70x40.bin", 0);
119
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
120
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
291
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ADVANCE_RETURN, NULL, 0);
292
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
293
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
121 294
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
122 295
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
123 296
 
297
+  #if HAS_ROTARY_ENCODER
298
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
299
+  #endif
300
+
124 301
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
125 302
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
126 303
   label_Back = lv_label_create(buttonBack, NULL);
@@ -131,10 +308,27 @@ void lv_draw_advance_settings(void) {
131 308
 
132 309
     lv_label_set_text(labelPausePos, machine_menu.PausePosition);
133 310
     lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0);
311
+
312
+    lv_label_set_text(labelFilamentSettings, machine_menu.FilamentConf);
313
+    lv_obj_align(labelFilamentSettings, buttonFilamentSettings, LV_ALIGN_IN_LEFT_MID, 0, 0);
314
+
315
+    #if ENABLED(USE_WIFI_FUNCTION)
316
+      lv_label_set_text(labelWifiSet, machine_menu.WifiSettings);
317
+      lv_obj_align(labelWifiSet, buttonWifiSet, LV_ALIGN_IN_LEFT_MID,0, 0);
318
+    #endif
319
+    #if HAS_ROTARY_ENCODER
320
+      lv_label_set_text(labelEcoder, machine_menu.EncoderSettings);
321
+      lv_obj_align(labelEcoder, buttonEcoder, LV_ALIGN_IN_LEFT_MID,0, 0);
322
+    #endif
134 323
   }
135 324
 
136 325
 }
137 326
 
138
-void lv_clear_advance_settings() { lv_obj_del(scr); }
327
+void lv_clear_advance_settings() {
328
+  #if HAS_ROTARY_ENCODER
329
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
330
+  #endif
331
+  lv_obj_del(scr);
332
+}
139 333
 
140 334
 #endif // HAS_TFT_LVGL_UI

+ 203
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp View File

@@ -0,0 +1,203 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if BOTH(HAS_TFT_LVGL_UI, HAS_BED_PROBE)
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/planner.h"
31
+#include "../../../../module/probe.h"
32
+
33
+extern lv_group_t * g;
34
+static lv_obj_t * scr;
35
+
36
+#define ID_OFFSET_RETURN   1
37
+#define ID_OFFSET_X        2
38
+#define ID_OFFSET_Y        3
39
+#define ID_OFFSET_Z        4
40
+
41
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
42
+  switch (obj->mks_obj_id) {
43
+    case ID_OFFSET_RETURN:
44
+      if (event == LV_EVENT_CLICKED) {
45
+
46
+      }
47
+      else if (event == LV_EVENT_RELEASED) {
48
+        lv_clear_auto_level_offset_settings();
49
+        draw_return_ui();
50
+      }
51
+      break;
52
+    case ID_OFFSET_X:
53
+      if (event == LV_EVENT_CLICKED) {
54
+
55
+      }
56
+      else if (event == LV_EVENT_RELEASED) {
57
+        value = x_offset;
58
+        lv_clear_auto_level_offset_settings();
59
+        lv_draw_number_key();
60
+      }
61
+      break;
62
+    case ID_OFFSET_Y:
63
+      if (event == LV_EVENT_CLICKED) {
64
+
65
+      }
66
+      else if (event == LV_EVENT_RELEASED) {
67
+        value = y_offset;
68
+        lv_clear_auto_level_offset_settings();
69
+        lv_draw_number_key();
70
+      }
71
+      break;
72
+    case ID_OFFSET_Z:
73
+      if (event == LV_EVENT_CLICKED) {
74
+
75
+      }
76
+      else if (event == LV_EVENT_RELEASED) {
77
+        value = z_offset;
78
+        lv_clear_auto_level_offset_settings();
79
+        lv_draw_number_key();
80
+      }
81
+      break;
82
+  }
83
+}
84
+
85
+void lv_draw_auto_level_offset_settings(void) {
86
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
87
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
88
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
89
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
90
+  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
91
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) {
92
+    disp_state_stack._disp_index++;
93
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI;
94
+  }
95
+  disp_state = NOZZLE_PROBE_OFFSET_UI;
96
+
97
+  scr = lv_obj_create(NULL, NULL);
98
+
99
+  lv_obj_set_style(scr, &tft_style_scr);
100
+  lv_scr_load(scr);
101
+  lv_obj_clean(scr);
102
+
103
+  lv_obj_t * title = lv_label_create(scr, NULL);
104
+  lv_obj_set_style(title, &tft_style_label_rel);
105
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
106
+  lv_label_set_text(title, machine_menu.OffsetConfTitle);
107
+
108
+  lv_refr_now(lv_refr_get_disp_refreshing());
109
+
110
+  labelXText = lv_label_create(scr, NULL);
111
+  lv_obj_set_style(labelXText, &tft_style_label_rel);
112
+  lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
113
+  lv_label_set_text(labelXText, machine_menu.Xoffset);
114
+
115
+  buttonXValue = lv_btn_create(scr, NULL);
116
+  lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
117
+  lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
118
+  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_OFFSET_X, NULL, 0);
119
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
120
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
121
+  labelXValue = lv_label_create(buttonXValue, NULL);
122
+
123
+  line1 = lv_line_create(scr, NULL);
124
+  lv_ex_line(line1, line_points[0]);
125
+
126
+  labelYText = lv_label_create(scr, NULL);
127
+  lv_obj_set_style(labelYText, &tft_style_label_rel);
128
+  lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
129
+  lv_label_set_text(labelYText, machine_menu.Yoffset);
130
+
131
+  buttonYValue = lv_btn_create(scr, NULL);
132
+  lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
133
+  lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
134
+  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_OFFSET_Y, NULL, 0);
135
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
136
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
137
+  labelYValue = lv_label_create(buttonYValue, NULL);
138
+
139
+  line2 = lv_line_create(scr, NULL);
140
+  lv_ex_line(line2, line_points[1]);
141
+
142
+  labelZText = lv_label_create(scr, NULL);
143
+  lv_obj_set_style(labelZText, &tft_style_label_rel);
144
+  lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
145
+  lv_label_set_text(labelZText, machine_menu.Zoffset);
146
+
147
+  buttonZValue = lv_btn_create(scr, NULL);
148
+  lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
149
+  lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
150
+  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_OFFSET_Z, NULL, 0);
151
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
152
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
153
+  labelZValue = lv_label_create(buttonZValue, NULL);
154
+
155
+  line3 = lv_line_create(scr, NULL);
156
+  lv_ex_line(line3, line_points[2]);
157
+
158
+  buttonBack = lv_btn_create(scr, NULL);
159
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_OFFSET_RETURN, NULL, 0);
160
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
161
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
162
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
163
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
164
+  label_Back = lv_label_create(buttonBack, NULL);
165
+
166
+  #if HAS_ROTARY_ENCODER
167
+    if (gCfgItems.encoder_enable) {
168
+      lv_group_add_obj(g, buttonXValue);
169
+      lv_group_add_obj(g, buttonYValue);
170
+      lv_group_add_obj(g, buttonZValue);
171
+      lv_group_add_obj(g, buttonBack);
172
+    }
173
+  #endif
174
+
175
+  if (gCfgItems.multiple_language != 0) {
176
+    ZERO(public_buf_l);
177
+    sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
178
+    lv_label_set_text(labelXValue, public_buf_l);
179
+    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
180
+
181
+    ZERO(public_buf_l);
182
+    sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
183
+    lv_label_set_text(labelYValue, public_buf_l);
184
+    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
185
+
186
+    ZERO(public_buf_l);
187
+    sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
188
+    lv_label_set_text(labelZValue, public_buf_l);
189
+    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
190
+
191
+    lv_label_set_text(label_Back, common_menu.text_back);
192
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
193
+  }
194
+}
195
+
196
+void lv_clear_auto_level_offset_settings() {
197
+  #if HAS_ROTARY_ENCODER
198
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
199
+  #endif
200
+  lv_obj_del(scr);
201
+}
202
+
203
+#endif // HAS_TFT_LVGL_UI && HAS_BED_PROBE

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.h View File

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

+ 352
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp View File

@@ -0,0 +1,352 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../gcode/queue.h"
31
+#include "../../../../gcode/gcode.h"
32
+
33
+#if HAS_BED_PROBE
34
+  #include "../../../../module/probe.h"
35
+#endif
36
+
37
+extern lv_group_t * g;
38
+static lv_obj_t * scr;
39
+
40
+static lv_obj_t *labelV, *buttonV, * zOffsetText;
41
+
42
+#define ID_BABY_STEP_X_P    1
43
+#define ID_BABY_STEP_X_N    2
44
+#define ID_BABY_STEP_Y_P    3
45
+#define ID_BABY_STEP_Y_N    4
46
+#define ID_BABY_STEP_Z_P    5
47
+#define ID_BABY_STEP_Z_N    6
48
+#define ID_BABY_STEP_DIST   7
49
+#define ID_BABY_STEP_RETURN 8
50
+
51
+static float babystep_dist=0.01;
52
+static uint8_t has_adjust_z = 0;
53
+
54
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
55
+  char baby_buf[30]={0};
56
+  switch (obj->mks_obj_id) {
57
+    case ID_BABY_STEP_X_P:
58
+      if (event == LV_EVENT_CLICKED) {
59
+        // nothing to do
60
+      }
61
+      else if (event == LV_EVENT_RELEASED) {
62
+        ZERO(baby_buf);
63
+        sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist);
64
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
65
+        has_adjust_z = 1;
66
+      }
67
+      break;
68
+    case ID_BABY_STEP_X_N:
69
+      if (event == LV_EVENT_CLICKED) {
70
+        // nothing to do
71
+      }
72
+      else if (event == LV_EVENT_RELEASED) {
73
+        ZERO(baby_buf);
74
+        sprintf_P(baby_buf, PSTR("M290 X%.3f"),((float)0 - babystep_dist));
75
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
76
+        has_adjust_z = 1;
77
+      }
78
+      break;
79
+    case ID_BABY_STEP_Y_P:
80
+      if (event == LV_EVENT_CLICKED) {
81
+        // nothing to do
82
+      }
83
+      else if (event == LV_EVENT_RELEASED) {
84
+        ZERO(baby_buf);
85
+        sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
86
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
87
+        has_adjust_z = 1;
88
+      }
89
+      break;
90
+    case ID_BABY_STEP_Y_N:
91
+      if (event == LV_EVENT_CLICKED) {
92
+        // nothing to do
93
+      }
94
+      else if (event == LV_EVENT_RELEASED) {
95
+        ZERO(baby_buf);
96
+        sprintf_P(baby_buf, PSTR("M290 Y%.3f"),((float)0 - babystep_dist));
97
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
98
+        has_adjust_z = 1;
99
+      }
100
+      break;
101
+    case ID_BABY_STEP_Z_P:
102
+      if (event == LV_EVENT_CLICKED) {
103
+        // nothing to do
104
+      }
105
+      else if (event == LV_EVENT_RELEASED) {
106
+        ZERO(baby_buf);
107
+        sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
108
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
109
+        has_adjust_z = 1;
110
+      }
111
+      break;
112
+    case ID_BABY_STEP_Z_N:
113
+      if (event == LV_EVENT_CLICKED) {
114
+        // nothing to do
115
+      }
116
+      else if (event == LV_EVENT_RELEASED) {
117
+        ZERO(baby_buf);
118
+        sprintf_P(baby_buf, PSTR("M290 Z%.3f"),((float)0 - babystep_dist));
119
+        gcode.process_subcommands_now_P(PSTR(baby_buf));
120
+        has_adjust_z = 1;
121
+      }
122
+      break;
123
+    case ID_BABY_STEP_DIST:
124
+      if (event == LV_EVENT_CLICKED) {
125
+        // nothing to do
126
+      }
127
+      else if (event == LV_EVENT_RELEASED) {
128
+        if (abs((int)(100 * babystep_dist)) == 1)
129
+          babystep_dist = 0.05;
130
+        else if (abs((int)(100 * babystep_dist)) == 5)
131
+          babystep_dist = 0.1;
132
+        else
133
+          babystep_dist = 0.01;
134
+        disp_baby_step_dist();
135
+      }
136
+
137
+      break;
138
+    case ID_BABY_STEP_RETURN:
139
+      if (event == LV_EVENT_CLICKED) {
140
+        // nothing to do
141
+      }
142
+      else if (event == LV_EVENT_RELEASED) {
143
+        if (has_adjust_z == 1) {
144
+          gcode.process_subcommands_now_P(PSTR("M500"));
145
+          has_adjust_z = 0;
146
+        }
147
+        clear_cur_ui();
148
+        draw_return_ui();
149
+      }
150
+      break;
151
+  }
152
+}
153
+
154
+void lv_draw_baby_stepping(void) {
155
+  lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack;
156
+
157
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != BABY_STEP_UI) {
158
+    disp_state_stack._disp_index++;
159
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = BABY_STEP_UI;
160
+  }
161
+  disp_state = BABY_STEP_UI;
162
+
163
+  scr = lv_obj_create(NULL, NULL);
164
+
165
+  lv_obj_set_style(scr, &tft_style_scr);
166
+  lv_scr_load(scr);
167
+  lv_obj_clean(scr);
168
+
169
+  lv_obj_t * title = lv_label_create(scr, NULL);
170
+  lv_obj_set_style(title, &tft_style_label_rel);
171
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
172
+  lv_label_set_text(title, creat_title_text());
173
+
174
+  lv_refr_now(lv_refr_get_disp_refreshing());
175
+
176
+  // Create an Image button
177
+  buttonXI   = lv_imgbtn_create(scr, NULL);
178
+  buttonXD   = lv_imgbtn_create(scr, NULL);
179
+  buttonYI   = lv_imgbtn_create(scr, NULL);
180
+  buttonYD   = lv_imgbtn_create(scr, NULL);
181
+  buttonZI   = lv_imgbtn_create(scr, NULL);
182
+  buttonZD   = lv_imgbtn_create(scr, NULL);
183
+  buttonV    = lv_imgbtn_create(scr, NULL);
184
+  buttonBack = lv_imgbtn_create(scr, NULL);
185
+
186
+  lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_BABY_STEP_X_P, NULL, 0);
187
+  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin");
188
+  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin");
189
+  lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre);
190
+  lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel);
191
+
192
+  #if 1
193
+    lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_BABY_STEP_X_N, NULL, 0);
194
+    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin");
195
+    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin");
196
+    lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre);
197
+    lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel);
198
+
199
+    lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_BABY_STEP_Y_P, NULL, 0);
200
+    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin");
201
+    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin");
202
+    lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre);
203
+    lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel);
204
+
205
+    lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_BABY_STEP_Y_N, NULL, 0);
206
+    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin");
207
+    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin");
208
+    lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre);
209
+    lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel);
210
+
211
+    lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_BABY_STEP_Z_P, NULL, 0);
212
+    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin");
213
+    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin");
214
+    lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre);
215
+    lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel);
216
+
217
+    lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_BABY_STEP_Z_N, NULL, 0);
218
+    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin");
219
+    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin");
220
+    lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre);
221
+    lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel);
222
+
223
+    lv_obj_set_event_cb_mks(buttonV, event_handler, ID_BABY_STEP_DIST, NULL, 0);
224
+    lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre);
225
+    lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel);
226
+
227
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_BABY_STEP_RETURN, NULL, 0);
228
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
229
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
230
+    lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
231
+    lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
232
+
233
+  #endif // if 1
234
+  lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight);
235
+  lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
236
+  lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
237
+  lv_obj_set_pos(buttonV, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
238
+  lv_obj_set_pos(buttonXD, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
239
+  lv_obj_set_pos(buttonYD, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
240
+  lv_obj_set_pos(buttonZD, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
241
+  lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
242
+
243
+  // Create labels on the image buttons
244
+  lv_btn_set_layout(buttonXI, LV_LAYOUT_OFF);
245
+  lv_btn_set_layout(buttonXD, LV_LAYOUT_OFF);
246
+  lv_btn_set_layout(buttonYI, LV_LAYOUT_OFF);
247
+  lv_btn_set_layout(buttonYD, LV_LAYOUT_OFF);
248
+  lv_btn_set_layout(buttonZI, LV_LAYOUT_OFF);
249
+  lv_btn_set_layout(buttonZD, LV_LAYOUT_OFF);
250
+  lv_btn_set_layout(buttonV, LV_LAYOUT_OFF);
251
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
252
+
253
+  lv_obj_t *labelXI = lv_label_create(buttonXI, NULL);
254
+  lv_obj_t *labelXD = lv_label_create(buttonXD, NULL);
255
+  lv_obj_t *labelYI = lv_label_create(buttonYI, NULL);
256
+  lv_obj_t *labelYD = lv_label_create(buttonYD, NULL);
257
+  lv_obj_t *labelZI = lv_label_create(buttonZI, NULL);
258
+  lv_obj_t *labelZD = lv_label_create(buttonZD, NULL);
259
+  labelV = lv_label_create(buttonV, NULL);
260
+  lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
261
+
262
+  if (gCfgItems.multiple_language != 0) {
263
+    lv_label_set_text(labelXI, move_menu.x_add);
264
+    lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
265
+
266
+    lv_label_set_text(labelXD, move_menu.x_dec);
267
+    lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
268
+
269
+    lv_label_set_text(labelYI, move_menu.y_add);
270
+    lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
271
+
272
+    lv_label_set_text(labelYD, move_menu.y_dec);
273
+    lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
274
+
275
+    lv_label_set_text(labelZI, move_menu.z_add);
276
+    lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
277
+
278
+    lv_label_set_text(labelZD, move_menu.z_dec);
279
+    lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
280
+
281
+    lv_label_set_text(label_Back, common_menu.text_back);
282
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
283
+  }
284
+
285
+  #if HAS_ROTARY_ENCODER
286
+    if (gCfgItems.encoder_enable) {
287
+      lv_group_add_obj(g, buttonXI);
288
+      lv_group_add_obj(g, buttonXD);
289
+      lv_group_add_obj(g, buttonYI);
290
+      lv_group_add_obj(g, buttonYD);
291
+      lv_group_add_obj(g, buttonZI);
292
+      lv_group_add_obj(g, buttonZD);
293
+      lv_group_add_obj(g, buttonV);
294
+      lv_group_add_obj(g, buttonBack);
295
+    }
296
+  #endif
297
+
298
+  disp_baby_step_dist();
299
+
300
+  zOffsetText = lv_label_create(scr, NULL);
301
+  lv_obj_set_style(zOffsetText, &tft_style_label_rel);
302
+  lv_obj_set_pos(zOffsetText, 290, TITLE_YPOS);
303
+  disp_z_offset_value();
304
+}
305
+
306
+void disp_baby_step_dist() {
307
+  // char buf[30] = {0};
308
+
309
+  if ((int)(100 * babystep_dist) == 1) {
310
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_01.bin");
311
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_01.bin");
312
+  }
313
+  else if ((int)(100 * babystep_dist) == 5) {
314
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_05.bin");
315
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_05.bin");
316
+  }
317
+  else if ((int)(100 * babystep_dist) == 10) {
318
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_baby_move0_1.bin");
319
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_baby_move0_1.bin");
320
+  }
321
+  if (gCfgItems.multiple_language != 0) {
322
+    if ((int)(100 * babystep_dist) == 1) {
323
+      lv_label_set_text(labelV, move_menu.step_001mm);
324
+      lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
325
+    }
326
+    else if ((int)(100 * babystep_dist) == 5) {
327
+      lv_label_set_text(labelV, move_menu.step_005mm);
328
+      lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
329
+    }
330
+    else if ((int)(100 * babystep_dist) == 10) {
331
+      lv_label_set_text(labelV, move_menu.step_01mm);
332
+      lv_obj_align(labelV, buttonV, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
333
+    }
334
+  }
335
+}
336
+
337
+void disp_z_offset_value() {
338
+  char buf[20];
339
+
340
+  ZERO(buf);
341
+  sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0));
342
+  lv_label_set_text(zOffsetText, buf);
343
+}
344
+
345
+void lv_clear_baby_stepping() {
346
+  #if HAS_ROTARY_ENCODER
347
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
348
+  #endif
349
+  lv_obj_del(scr);
350
+}
351
+
352
+#endif // HAS_TFT_LVGL_UI

+ 36
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.h View File

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

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

@@ -34,9 +34,10 @@
34 34
 #include "../../../../module/temperature.h"
35 35
 #include "../../../../module/planner.h"
36 36
 
37
+extern lv_group_t * g;
37 38
 static lv_obj_t * scr;
38
-static lv_obj_t * labelStep, *buttonStep, *buttonMov, *buttonExt;
39
-static lv_obj_t * labelMov, *labelExt;
39
+static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt;
40
+static lv_obj_t *labelMov, *labelExt;
40 41
 static lv_obj_t * printSpeedText;
41 42
 
42 43
 #define ID_C_ADD    1
@@ -175,7 +176,6 @@ void lv_draw_change_speed(void) {
175 176
 
176 177
   lv_refr_now(lv_refr_get_disp_refreshing());
177 178
 
178
-  LV_IMG_DECLARE(bmp_pic);
179 179
 
180 180
   // Create an Image button
181 181
   buttonAdd  = lv_imgbtn_create(scr, NULL);
@@ -185,38 +185,34 @@ void lv_draw_change_speed(void) {
185 185
   buttonStep = lv_imgbtn_create(scr, NULL);
186 186
   buttonBack = lv_imgbtn_create(scr, NULL);
187 187
 
188
-  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, "bmp_Add.bin", 0);
189
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
190
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
188
+  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_C_ADD, NULL, 0);
189
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
190
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
191 191
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
192 192
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
193
-  lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
194 193
 
195 194
   #if 1
196
-    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, "bmp_Dec.bin", 0);
197
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
198
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
195
+    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_C_DEC, NULL, 0);
196
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
197
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
199 198
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
200 199
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
201 200
 
202
-    lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, &bmp_pic);
203
-    lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, &bmp_pic);
201
+    lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, NULL, 0);
204 202
     lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_PR, &tft_style_label_pre);
205 203
     lv_imgbtn_set_style(buttonMov, LV_BTN_STATE_REL, &tft_style_label_rel);
206 204
 
207
-    lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, &bmp_pic);
208
-    lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, &bmp_pic);
205
+    lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, NULL, 0);
209 206
     lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_PR, &tft_style_label_pre);
210 207
     lv_imgbtn_set_style(buttonExt, LV_BTN_STATE_REL, &tft_style_label_rel);
211 208
 
212
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
213
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
209
+    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, NULL, 0);
214 210
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
215 211
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
216 212
 
217
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, "bmp_return.bin", 0);
218
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
219
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
213
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_C_RETURN, NULL, 0);
214
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
215
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
220 216
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
221 217
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
222 218
   #endif
@@ -253,6 +249,17 @@ void lv_draw_change_speed(void) {
253 249
     lv_label_set_text(label_Back, common_menu.text_back);
254 250
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
255 251
   }
252
+  #if HAS_ROTARY_ENCODER
253
+    if (gCfgItems.encoder_enable) {
254
+      lv_group_add_obj(g, buttonAdd);
255
+      lv_group_add_obj(g, buttonDec);
256
+      lv_group_add_obj(g, buttonMov);
257
+      lv_group_add_obj(g, buttonExt);
258
+      lv_group_add_obj(g, buttonStep);
259
+      lv_group_add_obj(g, buttonBack);
260
+    }
261
+  #endif
262
+
256 263
   disp_speed_type();
257 264
   disp_speed_step();
258 265
 
@@ -262,13 +269,18 @@ void lv_draw_change_speed(void) {
262 269
 }
263 270
 
264 271
 void disp_speed_step() {
265
-  if (uiCfg.stepPrintSpeed == 1)
266
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step1_percent.bin", 0);
267
-  else if (uiCfg.stepPrintSpeed == 5)
268
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step5_percent.bin", 0);
269
-  else if (uiCfg.stepPrintSpeed == 10)
270
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_C_STEP, "bmp_step10_percent.bin", 0);
271
-
272
+  if (uiCfg.stepPrintSpeed == 1) {
273
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_percent.bin");
274
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_percent.bin");
275
+  }
276
+  else if (uiCfg.stepPrintSpeed == 5) {
277
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_percent.bin");
278
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_percent.bin");
279
+  }
280
+  else if (uiCfg.stepPrintSpeed == 10) {
281
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_percent.bin");
282
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_percent.bin");
283
+  }
272 284
   if (gCfgItems.multiple_language != 0) {
273 285
     if (uiCfg.stepPrintSpeed == 1) {
274 286
       lv_label_set_text(labelStep, speed_menu.step_1percent);
@@ -309,13 +321,17 @@ void disp_print_speed() {
309 321
 void disp_speed_type() {
310 322
   switch (speedType) {
311 323
     case 1:
312
-      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_extruct_sel.bin", 0);
313
-      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_changeSpeed.bin", 0);
324
+      lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_changeSpeed.bin");
325
+      lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_changeSpeed.bin");
326
+      lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_extruct_sel.bin");
327
+      lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_extruct_sel.bin");
314 328
       break;
315 329
 
316 330
     default:
317
-      lv_obj_set_event_cb_mks(buttonExt, event_handler, ID_C_EXT, "bmp_speed_extruct.bin", 0);
318
-      lv_obj_set_event_cb_mks(buttonMov, event_handler, ID_C_MOVE, "bmp_mov_sel.bin", 0);
331
+      lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_REL, "F:/bmp_mov_sel.bin");
332
+      lv_imgbtn_set_src(buttonMov, LV_BTN_STATE_PR, "F:/bmp_mov_sel.bin");
333
+      lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_REL, "F:/bmp_speed_extruct.bin");
334
+      lv_imgbtn_set_src(buttonExt, LV_BTN_STATE_PR, "F:/bmp_speed_extruct.bin");
319 335
       break;
320 336
   }
321 337
   lv_obj_refresh_ext_draw_pad(buttonExt);
@@ -330,6 +346,11 @@ void disp_speed_type() {
330 346
   }
331 347
 }
332 348
 
333
-void lv_clear_change_speed() { lv_obj_del(scr); }
349
+void lv_clear_change_speed() {
350
+  #if HAS_ROTARY_ENCODER
351
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
352
+  #endif
353
+  lv_obj_del(scr);
354
+}
334 355
 
335 356
 #endif // HAS_TFT_LVGL_UI

+ 392
- 63
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp View File

@@ -41,6 +41,7 @@
41 41
 #include "../../../../gcode/queue.h"
42 42
 #include "../../../../module/temperature.h"
43 43
 #include "../../../../module/planner.h"
44
+#include "../../../../gcode/gcode.h"
44 45
 
45 46
 #if ENABLED(POWER_LOSS_RECOVERY)
46 47
   #include "../../../../feature/powerloss.h"
@@ -51,20 +52,25 @@
51 52
 #endif
52 53
 #include "../../../../gcode/gcode.h"
53 54
 
54
-#include "pic_manager.h"
55
-
55
+extern lv_group_t * g;
56 56
 static lv_obj_t * scr;
57
+static lv_obj_t * tempText1;
58
+static lv_obj_t * filament_bar;
59
+
57 60
 extern uint8_t sel_id;
58 61
 extern uint8_t once_flag;
59 62
 extern uint8_t gcode_preview_over;
60
-uint8_t DialogType;
63
+extern int upload_result ;
64
+extern uint32_t upload_time;
65
+extern uint32_t upload_size;
66
+extern uint8_t temperature_change_frequency;
61 67
 
62 68
 static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
63 69
   if (event == LV_EVENT_CLICKED) {
64 70
     // nothing to do
65 71
   }
66 72
   else if (event == LV_EVENT_RELEASED) {
67
-    if (DialogType == DIALOG_TYPE_PRINT_FILE) {
73
+    if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) {
68 74
       #if HAS_GCODE_PREVIEW
69 75
         preview_gcode_prehandle(list_file.file_name[sel_id]);
70 76
       #endif
@@ -108,7 +114,8 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
108 114
         }
109 115
       #endif
110 116
     }
111
-    else if (DialogType == DIALOG_TYPE_STOP) {
117
+    else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
118
+      wait_for_heatup = false;
112 119
       stop_print_time();
113 120
       lv_clear_dialog();
114 121
       lv_draw_ready_print();
@@ -130,40 +137,57 @@ static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
130 137
         //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
131 138
       #endif
132 139
     }
133
-    else if (DialogType == DIALOG_TYPE_FINISH_PRINT) {
140
+    else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
134 141
       clear_cur_ui();
135 142
       lv_draw_ready_print();
136 143
     }
137 144
     #if ENABLED(ADVANCED_PAUSE_FEATURE)
138
-      else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING
139
-            || DialogType == DIALOG_PAUSE_MESSAGE_INSERT
140
-            || DialogType == DIALOG_PAUSE_MESSAGE_HEAT
145
+      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
146
+            || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
147
+            || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
141 148
       ) {
142 149
         wait_for_user = false;
143 150
       }
144
-      else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
151
+      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
145 152
         pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
146 153
       }
147
-      else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
154
+      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
148 155
         clear_cur_ui();
149 156
         draw_return_ui();
150 157
       }
151 158
     #endif
152
-    else if (DialogType == DIALOG_STORE_EEPROM_TIPS) {
159
+    else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
153 160
       gcode.process_subcommands_now_P(PSTR("M500"));
154 161
       clear_cur_ui();
155 162
       draw_return_ui();
156 163
     }
157
-    else if (DialogType == DIALOG_READ_EEPROM_TIPS) {
164
+    else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
158 165
       gcode.process_subcommands_now_P(PSTR("M501"));
159 166
       clear_cur_ui();
160 167
       draw_return_ui();
161 168
     }
162
-    else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) {
169
+    else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
163 170
       gcode.process_subcommands_now_P(PSTR("M502"));
164 171
       clear_cur_ui();
165 172
       draw_return_ui();
166 173
     }
174
+    else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
175
+      uiCfg.configWifi = 1;
176
+      clear_cur_ui();
177
+      draw_return_ui();
178
+    }
179
+    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
180
+      uiCfg.filament_heat_completed_load = 1;
181
+    }
182
+    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
183
+      uiCfg.filament_heat_completed_unload = 1;
184
+    }
185
+    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
186
+          || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
187
+    ) {
188
+      clear_cur_ui();
189
+      draw_return_ui();
190
+    }
167 191
   }
168 192
 }
169 193
 
@@ -172,11 +196,35 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) {
172 196
     // nothing to do
173 197
   }
174 198
   else if (event == LV_EVENT_RELEASED) {
175
-    if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
199
+    if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
176 200
       #if ENABLED(ADVANCED_PAUSE_FEATURE)
177 201
         pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
178 202
       #endif
179 203
     }
204
+    else if ((uiCfg.dialogType      == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
205
+          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT)
206
+          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED)
207
+          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)
208
+    ) {
209
+      thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
210
+      clear_cur_ui();
211
+      draw_return_ui();
212
+    }
213
+    else if ((uiCfg.dialogType   == DIALOG_TYPE_FILAMENT_LOADING)
214
+       || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING)
215
+    ) {
216
+      queue.enqueue_one_P(PSTR("M410"));
217
+      uiCfg.filament_rate                = 0;
218
+      uiCfg.filament_loading_completed   = 0;
219
+      uiCfg.filament_unloading_completed = 0;
220
+      uiCfg.filament_loading_time_flg    = 0;
221
+      uiCfg.filament_loading_time_cnt    = 0;
222
+      uiCfg.filament_unloading_time_flg  = 0;
223
+      uiCfg.filament_unloading_time_cnt  = 0;
224
+      thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
225
+      clear_cur_ui();
226
+      draw_return_ui();
227
+    }
180 228
     else {
181 229
       clear_cur_ui();
182 230
       draw_return_ui();
@@ -186,13 +234,15 @@ static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) {
186 234
 
187 235
 void lv_draw_dialog(uint8_t type) {
188 236
 
237
+  lv_obj_t * btnOk = NULL;
238
+  lv_obj_t * btnCancel = NULL;
189 239
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) {
190 240
     disp_state_stack._disp_index++;
191 241
     disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI;
192 242
   }
193 243
   disp_state = DIALOG_UI;
194 244
 
195
-  DialogType = type;
245
+  uiCfg.dialogType = type;
196 246
 
197 247
   scr = lv_obj_create(NULL, NULL);
198 248
 
@@ -208,7 +258,6 @@ void lv_draw_dialog(uint8_t type) {
208 258
 
209 259
   lv_refr_now(lv_refr_get_disp_refreshing());
210 260
 
211
-  //LV_IMG_DECLARE(bmp_pic);
212 261
 
213 262
   static lv_style_t style_btn_rel;                                 // A variable to store the released style
214 263
   lv_style_copy(&style_btn_rel, &lv_style_plain);                  // Initialize from a built-in style
@@ -231,60 +280,151 @@ void lv_draw_dialog(uint8_t type) {
231 280
   style_btn_pr.text.color        = lv_color_hex3(0xBCD);
232 281
   style_btn_pr.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
233 282
 
234
-  lv_obj_t * labelDialog = lv_label_create(scr, NULL);
283
+  lv_obj_t *labelDialog = lv_label_create(scr, NULL);
235 284
   lv_obj_set_style(labelDialog, &tft_style_label_rel);
236 285
 
237
-  if (DialogType == DIALOG_TYPE_FINISH_PRINT || DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
238
-    lv_obj_t * btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
239
-    lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);                // Set its position
240
-    lv_obj_set_size(btnOk, 100, 50);                               // Set its size
241
-    lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
242
-    lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);     // Set the button's released style
243
-    lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);       // Set the button's pressed style
244
-    lv_obj_t * labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
245
-    lv_label_set_text(labelOk, print_file_dialog_menu.confirm);    // Set the labels text
286
+  if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
287
+      btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
288
+      lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);                // Set its position
289
+      lv_obj_set_size(btnOk, 100, 50);                               // Set its size
290
+      lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
291
+      lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);     // Set the button's released style
292
+      lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);       // Set the button's pressed style
293
+      lv_obj_t *labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
294
+      lv_label_set_text(labelOk, print_file_dialog_menu.confirm);    // Set the labels text
246 295
   }
247
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING
248
-        || DialogType == DIALOG_PAUSE_MESSAGE_INSERT
249
-        || DialogType == DIALOG_PAUSE_MESSAGE_HEAT
296
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
297
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
298
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
250 299
   ) {
251
-    lv_obj_t * btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
300
+    btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
252 301
     lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);                // Set its position
253 302
     lv_obj_set_size(btnOk, 100, 50);                               // Set its size
254 303
     lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
255 304
     lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);     // Set the button's released style
256 305
     lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);       // Set the button's pressed style
257
-    lv_obj_t * labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
306
+    lv_obj_t *labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
258 307
     lv_label_set_text(labelOk, print_file_dialog_menu.confirm);    // Set the labels text
259 308
   }
260
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING
261
-        || DialogType == DIALOG_PAUSE_MESSAGE_CHANGING
262
-        || DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD
263
-        || DialogType == DIALOG_PAUSE_MESSAGE_LOAD
264
-        || DialogType == DIALOG_PAUSE_MESSAGE_PURGE
265
-        || DialogType == DIALOG_PAUSE_MESSAGE_RESUME
266
-        || DialogType == DIALOG_PAUSE_MESSAGE_HEATING
309
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING
310
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING
311
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD
312
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD
313
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE
314
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME
315
+        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING
267 316
   ) {
268 317
     // nothing to do
269 318
   }
319
+  else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) {
320
+    btnCancel = lv_btn_create(scr, NULL);
321
+    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
322
+    lv_obj_set_size(btnCancel, 100, 50);
323
+    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
324
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
325
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
326
+    lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
327
+    lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
328
+  }
329
+  else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
330
+    btnCancel = lv_btn_create(scr, NULL);
331
+    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
332
+    lv_obj_set_size(btnCancel, 100, 50);
333
+    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
334
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
335
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
336
+    lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
337
+    lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
338
+  }
339
+  #if ENABLED(USE_WIFI_FUNCTION)
340
+    else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
341
+      if (upload_result == 2) {
342
+        btnCancel = lv_btn_create(scr, NULL);
343
+        lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
344
+        lv_obj_set_size(btnCancel, 100, 50);
345
+        lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
346
+        lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
347
+        lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
348
+        lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
349
+        lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
350
+      }
351
+      else if (upload_result == 3) {
352
+        btnOk = lv_btn_create(scr, NULL);
353
+        lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y);
354
+        lv_obj_set_size(btnOk, 100, 50);
355
+        lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
356
+        lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);
357
+        lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);
358
+        lv_obj_t *labelOk = lv_label_create(btnOk, NULL);
359
+        lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
360
+      }
361
+    }
362
+  #endif //USE_WIFI_FUNCTION
363
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT
364
+        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT
365
+  ) {
366
+    btnCancel = lv_btn_create(scr, NULL);
367
+    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
368
+    lv_obj_set_size(btnCancel, 100, 50);
369
+    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
370
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
371
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
372
+    lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
373
+    lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
374
+
375
+    tempText1 = lv_label_create(scr, NULL);
376
+    lv_obj_set_style(tempText1, &tft_style_label_rel);
377
+    filament_sprayer_temp();
378
+  }
379
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
380
+        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
381
+  ) {
382
+    btnOk = lv_btn_create(scr, NULL);
383
+    lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y);
384
+    lv_obj_set_size(btnOk, 100, 50);
385
+    lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
386
+    lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);
387
+    lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);
388
+    lv_obj_t *labelOk = lv_label_create(btnOk, NULL);
389
+    lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
390
+  }
391
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
392
+        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
393
+  ) {
394
+    btnCancel = lv_btn_create(scr, NULL);
395
+    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
396
+    lv_obj_set_size(btnCancel, 100, 50);
397
+    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
398
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel);
399
+    lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);
400
+    lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);
401
+    lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
402
+
403
+    filament_bar = lv_bar_create(scr, NULL);
404
+    lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
405
+    lv_obj_set_size(filament_bar, 400, 25);
406
+    lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
407
+    lv_bar_set_anim_time(filament_bar, 1000);
408
+    lv_bar_set_value(filament_bar, 0, LV_ANIM_ON);
409
+  }
270 410
   else {
271
-    lv_obj_t * btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
411
+    btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
272 412
     lv_obj_set_pos(btnOk, BTN_OK_X, BTN_OK_Y);                     // Set its position
273 413
     lv_obj_set_size(btnOk, 100, 50);                               // Set its size
274 414
     lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
275 415
     lv_btn_set_style(btnOk, LV_BTN_STYLE_REL, &style_btn_rel);     // Set the button's released style
276 416
     lv_btn_set_style(btnOk, LV_BTN_STYLE_PR, &style_btn_pr);       // Set the button's pressed style
277
-    lv_obj_t * labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
417
+    lv_obj_t *labelOk = lv_label_create(btnOk, NULL);             // Add a label to the button
278 418
 
279
-    lv_obj_t * btnCancel = lv_btn_create(scr, NULL);               // Add a button the current screen
419
+    btnCancel = lv_btn_create(scr, NULL);               // Add a button the current screen
280 420
     lv_obj_set_pos(btnCancel, BTN_CANCEL_X, BTN_CANCEL_Y);         // Set its position
281 421
     lv_obj_set_size(btnCancel, 100, 50);                           // Set its size
282 422
     lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
283 423
     lv_btn_set_style(btnCancel, LV_BTN_STYLE_REL, &style_btn_rel); // Set the button's released style
284 424
     lv_btn_set_style(btnCancel, LV_BTN_STYLE_PR, &style_btn_pr);   // Set the button's pressed style
285
-    lv_obj_t * labelCancel = lv_label_create(btnCancel, NULL);     // Add a label to the button
425
+    lv_obj_t *labelCancel = lv_label_create(btnCancel, NULL);     // Add a label to the button
286 426
 
287
-    if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
427
+    if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
288 428
       lv_label_set_text(labelOk, pause_msg_menu.purgeMore);        // Set the labels text
289 429
       lv_label_set_text(labelCancel, pause_msg_menu.continuePrint);
290 430
     }
@@ -293,82 +433,271 @@ void lv_draw_dialog(uint8_t type) {
293 433
       lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
294 434
     }
295 435
   }
296
-  if (DialogType == DIALOG_TYPE_PRINT_FILE) {
436
+  if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) {
297 437
     lv_label_set_text(labelDialog, print_file_dialog_menu.print_file);
298 438
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
299 439
 
300
-    lv_obj_t * labelFile = lv_label_create(scr, NULL);
440
+    lv_obj_t *labelFile = lv_label_create(scr, NULL);
301 441
     lv_obj_set_style(labelFile, &tft_style_label_rel);
302 442
 
303 443
     lv_label_set_text(labelFile, list_file.long_name[sel_id]);
304 444
     lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60);
305 445
   }
306
-  else if (DialogType == DIALOG_TYPE_STOP) {
446
+  else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
307 447
     lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print);
308 448
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
309 449
   }
310
-  else if (DialogType == DIALOG_TYPE_FINISH_PRINT) {
450
+  else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
311 451
     lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish);
312 452
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
313 453
   }
314
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_PAUSING) {
454
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING) {
315 455
     lv_label_set_text(labelDialog, pause_msg_menu.pausing);
316 456
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
317 457
   }
318
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_CHANGING) {
458
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING) {
319 459
     lv_label_set_text(labelDialog, pause_msg_menu.changing);
320 460
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
321 461
   }
322
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) {
462
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) {
323 463
     lv_label_set_text(labelDialog, pause_msg_menu.unload);
324 464
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
325 465
   }
326
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_WAITING) {
466
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING) {
327 467
     lv_label_set_text(labelDialog, pause_msg_menu.waiting);
328 468
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
329 469
   }
330
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_INSERT) {
470
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT) {
331 471
     lv_label_set_text(labelDialog, pause_msg_menu.insert);
332 472
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
333 473
   }
334
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_LOAD) {
474
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD) {
335 475
     lv_label_set_text(labelDialog, pause_msg_menu.load);
336 476
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
337 477
   }
338
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_PURGE) {
478
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE) {
339 479
     lv_label_set_text(labelDialog, pause_msg_menu.purge);
340 480
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
341 481
   }
342
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
482
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
343 483
     lv_label_set_text(labelDialog, pause_msg_menu.resume);
344 484
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
345 485
   }
346
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_HEAT) {
486
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT) {
347 487
     lv_label_set_text(labelDialog, pause_msg_menu.heat);
348 488
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
349 489
   }
350
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_HEATING) {
490
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING) {
351 491
     lv_label_set_text(labelDialog, pause_msg_menu.heating);
352 492
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
353 493
   }
354
-  else if (DialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
494
+  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
355 495
     lv_label_set_text(labelDialog, pause_msg_menu.option);
356 496
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
357 497
   }
358
-  else if (DialogType == DIALOG_STORE_EEPROM_TIPS) {
498
+  else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
359 499
     lv_label_set_text(labelDialog, eeprom_menu.storeTips);
360 500
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
361 501
   }
362
-  else if (DialogType == DIALOG_READ_EEPROM_TIPS) {
502
+  else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
363 503
     lv_label_set_text(labelDialog, eeprom_menu.readTips);
364 504
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
365 505
   }
366
-  else if (DialogType == DIALOG_REVERT_EEPROM_TIPS) {
506
+  else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
367 507
     lv_label_set_text(labelDialog, eeprom_menu.revertTips);
368 508
     lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
369 509
   }
510
+  else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
511
+    lv_label_set_text(labelDialog, machine_menu.wifiConfigTips);
512
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
513
+  }
514
+  else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) {
515
+    lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips);
516
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
517
+  }
518
+  else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
519
+    lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN);
520
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
521
+  }
522
+  #if ENABLED(USE_WIFI_FUNCTION)
523
+    else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
524
+      if (upload_result == 1) {
525
+        lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN);
526
+        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
527
+      }
528
+      else if (upload_result == 2) {
529
+        lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN);
530
+        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
531
+      }
532
+      else if (upload_result == 3) {
533
+        char buf[200];
534
+        int _index = 0;
535
+
536
+        ZERO(buf);
537
+
538
+        strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
539
+        _index = strlen(buf);
540
+        buf[_index] = '\n';
541
+        _index++;
542
+        strcat(buf, DIALOG_UPLOAD_SIZE_EN);
543
+
544
+        _index = strlen(buf);
545
+        buf[_index] = ':';
546
+        _index++;
547
+        sprintf(&buf[_index], " %d KBytes\n", (int)(upload_size / 1024));
548
+
549
+        strcat(buf, DIALOG_UPLOAD_TIME_EN);
550
+        _index = strlen(buf);
551
+        buf[_index] = ':';
552
+        _index++;
553
+        sprintf(&buf[_index], " %d s\n", (int)upload_time);
554
+
555
+        strcat(buf, DIALOG_UPLOAD_SPEED_EN);
556
+        _index = strlen(buf);
557
+        buf[_index] = ':';
558
+        _index++;
559
+        sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
560
+
561
+        lv_label_set_text(labelDialog, buf);
562
+        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
563
+
564
+      }
565
+    }
566
+  #endif //USE_WIFI_FUNCTION
567
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) {
568
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
569
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
570
+  }
571
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
572
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm);
573
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
574
+  }
575
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) {
576
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat);
577
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
578
+  }
579
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
580
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm);
581
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
582
+  }
583
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED) {
584
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed);
585
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
586
+  }
587
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED) {
588
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed);
589
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
590
+  }
591
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) {
592
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading);
593
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
594
+  }
595
+  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) {
596
+    lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
597
+    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
598
+  }
599
+  #if HAS_ROTARY_ENCODER
600
+    if (gCfgItems.encoder_enable) {
601
+      if (btnOk) lv_group_add_obj(g, btnOk);
602
+      if (btnCancel) lv_group_add_obj(g, btnCancel);
603
+    }
604
+  #endif
605
+}
606
+
607
+void filament_sprayer_temp() {
608
+  char buf[20] = {0};
609
+
610
+  public_buf_l[0] = '\0';
611
+
612
+  if (uiCfg.curSprayerChoose < 1)
613
+    strcat(public_buf_l, preheat_menu.ext1);
614
+  else
615
+    strcat(public_buf_l, preheat_menu.ext2);
616
+  sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius,  (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
617
+
618
+  strcat_P(public_buf_l, PSTR(": "));
619
+  strcat(public_buf_l, buf);
620
+  lv_label_set_text(tempText1, public_buf_l);
621
+  lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
622
+}
623
+
624
+void filament_dialog_handle() {
625
+  if ((temperature_change_frequency == 1)
626
+      && ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
627
+      || (uiCfg.dialogType  == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT))
628
+  ) {
629
+    filament_sprayer_temp();
630
+    temperature_change_frequency = 0;
631
+  }
632
+  if (uiCfg.filament_heat_completed_load == 1) {
633
+    uiCfg.filament_heat_completed_load = 0;
634
+    lv_clear_dialog();
635
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOADING);
636
+    planner.synchronize();
637
+    uiCfg.filament_loading_time_flg = 1;
638
+    uiCfg.filament_loading_time_cnt = 0;
639
+    ZERO(public_buf_m);
640
+    sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_load_length,gCfgItems.filamentchange_load_speed);
641
+    queue.inject_P(PSTR(public_buf_m));
642
+    //gcode.process_subcommands_now_P(PSTR(public_buf_m));
643
+  }
644
+  if (uiCfg.filament_heat_completed_unload == 1) {
645
+    uiCfg.filament_heat_completed_unload = 0;
646
+    lv_clear_dialog();
647
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOADING);
648
+    planner.synchronize();
649
+    uiCfg.filament_unloading_time_flg = 1;
650
+    uiCfg.filament_unloading_time_cnt = 0;
651
+    ZERO(public_buf_m);
652
+    sprintf_P(public_buf_m,PSTR("T%d\nG91\nG1 E-%d F%d\nG90"),uiCfg.curSprayerChoose,gCfgItems.filamentchange_unload_length,gCfgItems.filamentchange_unload_speed);
653
+    queue.inject_P(PSTR(public_buf_m));
654
+  }
655
+
656
+  if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
657
+    || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
658
+    && (uiCfg.filament_load_heat_flg == 1)
659
+  ) {
660
+    uiCfg.filament_load_heat_flg = 0;
661
+    lv_clear_dialog();
662
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
663
+  }
664
+
665
+  if (uiCfg.filament_loading_completed == 1) {
666
+    uiCfg.filament_rate = 0;
667
+    uiCfg.filament_loading_completed = 0;
668
+    lv_clear_dialog();
669
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
670
+  }
671
+  if (((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius - gCfgItems.filament_limit_temper)) <= 1)
672
+     || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius > gCfgItems.filament_limit_temper))
673
+     && (uiCfg.filament_unload_heat_flg == 1)
674
+  ) {
675
+    uiCfg.filament_unload_heat_flg = 0;
676
+    lv_clear_dialog();
677
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
678
+  }
679
+
680
+  if (uiCfg.filament_unloading_completed == 1) {
681
+    uiCfg.filament_rate = 0;
682
+    uiCfg.filament_unloading_completed = 0;
683
+    lv_clear_dialog();
684
+    lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED);
685
+  }
686
+
687
+  if ( uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
688
+    || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
689
+  ) lv_filament_setbar();
370 690
 }
371 691
 
372
-void lv_clear_dialog() { lv_obj_del(scr); }
692
+void lv_filament_setbar() {
693
+  lv_bar_set_value(filament_bar, uiCfg.filament_rate, LV_ANIM_ON);
694
+}
695
+
696
+void lv_clear_dialog() {
697
+  #if HAS_ROTARY_ENCODER
698
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
699
+  #endif
700
+  lv_obj_del(scr);
701
+}
373 702
 
374 703
 #endif // HAS_TFT_LVGL_UI

+ 5
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h View File

@@ -69,6 +69,8 @@
69 69
 #define DIALOG_READ_EEPROM_TIPS                     33
70 70
 #define DIALOG_REVERT_EEPROM_TIPS                   34
71 71
 
72
+#define DIALOG_WIFI_CONFIG_TIPS                     35
73
+#define DIALOG_TRANSFER_NO_DEVICE                   36
72 74
 #define BTN_OK_X      100
73 75
 #define BTN_OK_Y      180
74 76
 #define BTN_CANCEL_X  280
@@ -76,6 +78,9 @@
76 78
 
77 79
 extern void lv_draw_dialog(uint8_t type);
78 80
 extern void lv_clear_dialog();
81
+extern void filament_sprayer_temp();
82
+extern void filament_dialog_handle();
83
+extern void lv_filament_setbar();
79 84
 
80 85
 //extern void disp_temp_ready_print();
81 86
 #ifdef __cplusplus

+ 63
- 76
Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp View File

@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "../../../../MarlinCore.h"
30 30
 
31
+extern lv_group_t * g;
31 32
 static lv_obj_t * scr;
32 33
 
33 34
 #define ID_EEPROM_RETURN        1
@@ -48,26 +49,25 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
48 49
         draw_return_ui();
49 50
       }
50 51
       break;
52
+    case ID_EEPROM_STORE:
53
+      if (event == LV_EVENT_CLICKED) {
51 54
 
52
-    #if 0
53
-      case ID_EEPROM_STORE:
54
-        if (event == LV_EVENT_CLICKED) {
55
-
56
-        }
57
-        else if (event == LV_EVENT_RELEASED) {
58
-          lv_clear_eeprom_settings();
59
-          lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
60
-        }
61
-        break;
62
-      case ID_EEPROM_STORE_ARROW:
63
-        if (event == LV_EVENT_CLICKED) {
55
+      }
56
+      else if (event == LV_EVENT_RELEASED) {
57
+        lv_clear_eeprom_settings();
58
+        lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
59
+      }
60
+      break;
61
+    case ID_EEPROM_STORE_ARROW:
62
+      if (event == LV_EVENT_CLICKED) {
64 63
 
65
-        }
66
-        else if (event == LV_EVENT_RELEASED) {
67
-          lv_clear_eeprom_settings();
68
-          lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
69
-        }
70
-        break;
64
+      }
65
+      else if (event == LV_EVENT_RELEASED) {
66
+        lv_clear_eeprom_settings();
67
+        lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
68
+      }
69
+      break;
70
+    #if 0
71 71
       case ID_EEPROM_READ:
72 72
         if (event == LV_EVENT_CLICKED) {
73 73
 
@@ -111,10 +111,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
111 111
 
112 112
 void lv_draw_eeprom_settings(void) {
113 113
   lv_obj_t *buttonBack, *label_Back;
114
-  //lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow;
114
+  lv_obj_t *buttonStore,*labelStore,*buttonStoreNarrow;
115 115
   //lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow;
116 116
   lv_obj_t *buttonRevert, *labelRevert, *buttonRevertNarrow;
117
-  lv_obj_t * line1; // * line2,* line3;
117
+  lv_obj_t * line1, * line2; //* line3;
118 118
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) {
119 119
     disp_state_stack._disp_index++;
120 120
     disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI;
@@ -134,53 +134,6 @@ void lv_draw_eeprom_settings(void) {
134 134
 
135 135
   lv_refr_now(lv_refr_get_disp_refreshing());
136 136
 
137
-  LV_IMG_DECLARE(bmp_para_back);
138
-  LV_IMG_DECLARE(bmp_para_arrow);
139
-  #if 0
140
-    buttonStore = lv_btn_create(scr, NULL); /*Add a button the current screen*/
141
-    lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y);                       /*Set its position*/
142
-    lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                     /*Set its size*/
143
-    //lv_obj_set_event_cb(buttonMachine, event_handler);
144
-    lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
145
-    lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
146
-    lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
147
-    lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
148
-    labelStore = lv_label_create(buttonStore, NULL);      /*Add a label to the button*/
149
-
150
-    buttonStoreNarrow = lv_imgbtn_create(scr, NULL);
151
-    lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
152
-    lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, "bmp_arrow.bin", 0);
153
-    lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
154
-    lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
155
-    lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
156
-    lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
157
-    lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF);
158
-
159
-    line1 = lv_line_create(scr, NULL);
160
-    lv_ex_line(line1, line_points[0]);
161
-
162
-    buttonRead = lv_btn_create(scr, NULL); /*Add a button the current screen*/
163
-    lv_obj_set_pos(buttonRead, PARA_UI_POS_X, PARA_UI_POS_Y * 2);                     /*Set its position*/
164
-    lv_obj_set_size(buttonRead, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                     /*Set its size*/
165
-    //lv_obj_set_event_cb(buttonMotor, event_handler);
166
-    lv_obj_set_event_cb_mks(buttonRead, event_handler, ID_EEPROM_READ, NULL, 0);
167
-    lv_btn_set_style(buttonRead, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
168
-    lv_btn_set_style(buttonRead, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
169
-    lv_btn_set_layout(buttonRead, LV_LAYOUT_OFF);
170
-    labelRead = lv_label_create(buttonRead, NULL);      /*Add a label to the button*/
171
-
172
-    buttonReadNarrow = lv_imgbtn_create(scr, NULL);
173
-    lv_obj_set_pos(buttonReadNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
174
-    lv_obj_set_event_cb_mks(buttonReadNarrow, event_handler, ID_EEPROM_READ_ARROW, "bmp_arrow.bin", 0);
175
-    lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
176
-    lv_imgbtn_set_src(buttonReadNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
177
-    lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
178
-    lv_imgbtn_set_style(buttonReadNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
179
-    lv_btn_set_layout(buttonReadNarrow, LV_LAYOUT_OFF);
180
-
181
-    line2 = lv_line_create(scr, NULL);
182
-    lv_ex_line(line2, line_points[1]);
183
-  #endif // if 0
184 137
   buttonRevert = lv_btn_create(scr, NULL);   /*Add a button the current screen*/
185 138
   lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y);                         /*Set its position*/
186 139
   lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
@@ -193,9 +146,9 @@ void lv_draw_eeprom_settings(void) {
193 146
 
194 147
   buttonRevertNarrow = lv_imgbtn_create(scr, NULL);
195 148
   lv_obj_set_pos(buttonRevertNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
196
-  lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, "bmp_arrow.bin", 0);
197
-  lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
198
-  lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
149
+  lv_obj_set_event_cb_mks(buttonRevertNarrow, event_handler, ID_EEPROM_REVERT_ARROW, NULL, 0);
150
+  lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
151
+  lv_imgbtn_set_src(buttonRevertNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
199 152
   lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
200 153
   lv_imgbtn_set_style(buttonRevertNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
201 154
   lv_btn_set_layout(buttonRevertNarrow, LV_LAYOUT_OFF);
@@ -205,10 +158,32 @@ void lv_draw_eeprom_settings(void) {
205 158
   line1 = lv_line_create(scr, NULL);
206 159
   lv_ex_line(line1, line_points[0]);
207 160
 
161
+  buttonStore = lv_btn_create(scr, NULL);   /*Add a button the current screen*/
162
+  lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y * 2);                      /*Set its position*/
163
+  lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
164
+  //lv_obj_set_event_cb(buttonMotor, event_handler);
165
+  lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
166
+  lv_btn_set_style(buttonStore, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
167
+  lv_btn_set_style(buttonStore, LV_BTN_STYLE_PR, &tft_style_label_pre);    /*Set the button's pressed style*/
168
+  lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
169
+  labelStore = lv_label_create(buttonStore, NULL);        /*Add a label to the button*/
170
+
171
+  buttonStoreNarrow = lv_imgbtn_create(scr, NULL);
172
+  lv_obj_set_pos(buttonStoreNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
173
+  lv_obj_set_event_cb_mks(buttonStoreNarrow, event_handler, ID_EEPROM_STORE_ARROW, NULL, 0);
174
+  lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
175
+  lv_imgbtn_set_src(buttonStoreNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
176
+  lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
177
+  lv_imgbtn_set_style(buttonStoreNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
178
+  lv_btn_set_layout(buttonStoreNarrow, LV_LAYOUT_OFF);
179
+
180
+  line2 = lv_line_create(scr, NULL);
181
+  lv_ex_line(line2, line_points[1]);
182
+
208 183
   buttonBack = lv_imgbtn_create(scr, NULL);
209
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, "bmp_back70x40.bin", 0);
210
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
211
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
184
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_EEPROM_RETURN, NULL, 0);
185
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
186
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
212 187
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
213 188
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
214 189
 
@@ -220,8 +195,8 @@ void lv_draw_eeprom_settings(void) {
220 195
     lv_label_set_text(label_Back, common_menu.text_back);
221 196
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
222 197
 
223
-    //lv_label_set_text(labelStore, eeprom_menu.store);
224
-    //lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0);
198
+    lv_label_set_text(labelStore, eeprom_menu.store);
199
+    lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0);
225 200
 
226 201
     //lv_label_set_text(labelRead, eeprom_menu.read);
227 202
     //lv_obj_align(labelRead, buttonRead, LV_ALIGN_IN_LEFT_MID,0, 0);
@@ -229,9 +204,21 @@ void lv_draw_eeprom_settings(void) {
229 204
     lv_label_set_text(labelRevert, eeprom_menu.revert);
230 205
     lv_obj_align(labelRevert, buttonRevert, LV_ALIGN_IN_LEFT_MID, 0, 0);
231 206
   }
207
+  #if HAS_ROTARY_ENCODER
208
+    if (gCfgItems.encoder_enable) {
209
+      lv_group_add_obj(g, buttonRevert);
210
+      lv_group_add_obj(g, buttonStore);
211
+      lv_group_add_obj(g, buttonBack);
212
+    }
213
+  #endif
232 214
 
233 215
 }
234 216
 
235
-void lv_clear_eeprom_settings() { lv_obj_del(scr); }
217
+void lv_clear_eeprom_settings() {
218
+  #if HAS_ROTARY_ENCODER
219
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
220
+  #endif
221
+  lv_obj_del(scr);
222
+}
236 223
 
237 224
 #endif // HAS_TFT_LVGL_UI

+ 172
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp View File

@@ -0,0 +1,172 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/planner.h"
31
+#include "../../../../module/stepper/indirection.h"
32
+#include "../../../../feature/tmc_util.h"
33
+#include "../../../../gcode/gcode.h"
34
+#include "../../../../module/planner.h"
35
+
36
+#if BUTTONS_EXIST(EN1, EN2)
37
+
38
+extern lv_group_t * g;
39
+static lv_obj_t * scr;
40
+static lv_obj_t * buttonEncoderState = NULL;
41
+static lv_obj_t *labelEncoderState = NULL;
42
+
43
+#define ID_ENCODER_RETURN 1
44
+#define ID_ENCODER_STATE 2
45
+
46
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
47
+  switch (obj->mks_obj_id) {
48
+    case ID_ENCODER_RETURN:
49
+      if (event == LV_EVENT_CLICKED) {
50
+
51
+      }
52
+      else if (event == LV_EVENT_RELEASED) {
53
+        lv_clear_encoder_settings();
54
+        draw_return_ui();
55
+      }
56
+      break;
57
+    case ID_ENCODER_STATE:
58
+      if (event == LV_EVENT_CLICKED) {
59
+
60
+      }
61
+      else if (event == LV_EVENT_RELEASED) {
62
+        if (gCfgItems.encoder_enable) {
63
+          gCfgItems.encoder_enable = false;
64
+          lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
65
+          lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
66
+          lv_label_set_text(labelEncoderState, machine_menu.disable);
67
+          update_spi_flash();
68
+        }
69
+        else {
70
+          gCfgItems.encoder_enable = true;
71
+          lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
72
+          lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
73
+          lv_label_set_text(labelEncoderState, machine_menu.enable);
74
+          update_spi_flash();
75
+        }
76
+      }
77
+      break;
78
+  }
79
+}
80
+
81
+void lv_draw_encoder_settings(void) {
82
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
83
+  lv_obj_t *labelEncoderTips = NULL;
84
+
85
+  lv_obj_t * line1 = NULL;
86
+
87
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) {
88
+    disp_state_stack._disp_index++;
89
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI;
90
+  }
91
+  disp_state = ENCODER_SETTINGS_UI;
92
+
93
+  scr = lv_obj_create(NULL, NULL);
94
+
95
+  lv_obj_set_style(scr, &tft_style_scr);
96
+  lv_scr_load(scr);
97
+  lv_obj_clean(scr);
98
+
99
+  lv_obj_t * title = lv_label_create(scr, NULL);
100
+  lv_obj_set_style(title, &tft_style_label_rel);
101
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
102
+  lv_label_set_text(title, machine_menu.EncoderConfTitle);
103
+
104
+  lv_refr_now(lv_refr_get_disp_refreshing());
105
+
106
+  labelEncoderTips = lv_label_create(scr, NULL);
107
+  lv_obj_set_style(labelEncoderTips, &tft_style_label_rel);
108
+  lv_obj_set_pos(labelEncoderTips, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
109
+  lv_label_set_text(labelEncoderTips, machine_menu.EncoderConfText);
110
+
111
+  buttonEncoderState = lv_imgbtn_create(scr, NULL);
112
+  lv_obj_set_pos(buttonEncoderState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
113
+  if (gCfgItems.encoder_enable) {
114
+    lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
115
+    lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
116
+  }
117
+  else {
118
+    lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
119
+    lv_imgbtn_set_src(buttonEncoderState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
120
+  }
121
+
122
+  lv_obj_set_event_cb_mks(buttonEncoderState, event_handler, ID_ENCODER_STATE, NULL, 0);
123
+
124
+  lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_PR, &tft_style_label_pre);
125
+  lv_imgbtn_set_style(buttonEncoderState, LV_BTN_STATE_REL, &tft_style_label_rel);
126
+  lv_btn_set_layout(buttonEncoderState, LV_LAYOUT_OFF);
127
+  labelEncoderState = lv_label_create(buttonEncoderState, NULL);
128
+
129
+  line1 = lv_line_create(scr, NULL);
130
+  lv_ex_line(line1, line_points[0]);
131
+
132
+  buttonBack = lv_imgbtn_create(scr, NULL);
133
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_ENCODER_RETURN, NULL, 0);
134
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
135
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
136
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
137
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
138
+
139
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
140
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
141
+  label_Back = lv_label_create(buttonBack, NULL);
142
+
143
+  if (gCfgItems.encoder_enable) {
144
+    lv_label_set_text(labelEncoderState, machine_menu.enable);
145
+    lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0);
146
+  }
147
+  else {
148
+    lv_label_set_text(labelEncoderState, machine_menu.disable);
149
+    lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0);
150
+  }
151
+
152
+  lv_label_set_text(label_Back, common_menu.text_back);
153
+  lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
154
+
155
+  #if HAS_ROTARY_ENCODER
156
+    if (gCfgItems.encoder_enable) {
157
+      lv_group_add_obj(g, buttonEncoderState);
158
+      lv_group_add_obj(g, buttonBack);
159
+    }
160
+  #endif
161
+}
162
+
163
+void lv_clear_encoder_settings() {
164
+  #if HAS_ROTARY_ENCODER
165
+    lv_group_remove_all_objs(g);
166
+  #endif
167
+  lv_obj_del(scr);
168
+}
169
+
170
+#endif // BUTTONS_EXIST(EN1, EN2)
171
+
172
+#endif // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.h View File

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

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

@@ -35,10 +35,11 @@
35 35
 #include "../../../../gcode/queue.h"
36 36
 
37 37
 static lv_obj_t * scr;
38
+extern lv_group_t*  g;
38 39
 static lv_obj_t * buttoType, *buttonStep, *buttonSpeed;
39
-static lv_obj_t * labelType;
40
-static lv_obj_t * labelStep;
41
-static lv_obj_t * labelSpeed;
40
+static lv_obj_t *labelType;
41
+static lv_obj_t *labelStep;
42
+static lv_obj_t *labelSpeed;
42 43
 static lv_obj_t * tempText;
43 44
 static lv_obj_t * ExtruText;
44 45
 
@@ -171,8 +172,6 @@ void lv_draw_extrusion(void) {
171 172
 
172 173
   lv_refr_now(lv_refr_get_disp_refreshing());
173 174
 
174
-  LV_IMG_DECLARE(bmp_pic);
175
-
176 175
   // Create image buttons
177 176
   buttonAdd   = lv_imgbtn_create(scr, NULL);
178 177
   buttonDec   = lv_imgbtn_create(scr, NULL);
@@ -181,37 +180,35 @@ void lv_draw_extrusion(void) {
181 180
   buttonSpeed = lv_imgbtn_create(scr, NULL);
182 181
   buttonBack  = lv_imgbtn_create(scr, NULL);
183 182
 
184
-  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, "bmp_in.bin", 0);
185
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
186
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
183
+  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_E_ADD, NULL, 0);
184
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_in.bin");
185
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_in.bin");
187 186
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
188 187
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
189 188
   lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
189
+
190 190
   #if 1
191
-    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, "bmp_out.bin", 0);
192
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
193
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
191
+    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_E_DEC, NULL, 0);
192
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_out.bin");
193
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_out.bin");
194 194
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
195 195
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
196 196
 
197
-    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic);
198
-    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic);
197
+    lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, NULL, 0);
199 198
     lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
200 199
     lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
201 200
 
202
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
203
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
201
+    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, NULL, 0);
204 202
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
205 203
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
206 204
 
207
-    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic);
208
-    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic);
205
+    lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, NULL, 0);
209 206
     lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
210 207
     lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
211 208
 
212
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, "bmp_return.bin", 0);
213
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
214
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
209
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_E_RETURN, NULL, 0);
210
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
211
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
215 212
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
216 213
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
217 214
   #endif
@@ -249,6 +246,17 @@ void lv_draw_extrusion(void) {
249 246
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
250 247
   }
251 248
 
249
+  #if HAS_ROTARY_ENCODER
250
+    if (gCfgItems.encoder_enable) {
251
+      lv_group_add_obj(g, buttonAdd);
252
+      lv_group_add_obj(g, buttonDec);
253
+      lv_group_add_obj(g, buttoType);
254
+      lv_group_add_obj(g, buttonStep);
255
+      lv_group_add_obj(g, buttonSpeed);
256
+      lv_group_add_obj(g, buttonBack);
257
+    }
258
+  #endif
259
+
252 260
   disp_ext_type();
253 261
   disp_ext_step();
254 262
   disp_ext_speed();
@@ -264,14 +272,16 @@ void lv_draw_extrusion(void) {
264 272
 
265 273
 void disp_ext_type() {
266 274
   if (uiCfg.curSprayerChoose == 1) {
267
-    lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru2.bin", 0);
275
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
276
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
268 277
     if (gCfgItems.multiple_language != 0) {
269 278
       lv_label_set_text(labelType, extrude_menu.ext2);
270 279
       lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
271 280
     }
272 281
   }
273 282
   else {
274
-    lv_obj_set_event_cb_mks(buttoType, event_handler, ID_E_TYPE, "bmp_extru1.bin", 0);
283
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
284
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
275 285
     if (gCfgItems.multiple_language != 0) {
276 286
       lv_label_set_text(labelType, extrude_menu.ext1);
277 287
       lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -280,12 +290,18 @@ void disp_ext_type() {
280 290
 }
281 291
 
282 292
 void disp_ext_speed() {
283
-  if (uiCfg.extruSpeed == 20)
284
-    lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_high.bin", 0);
285
-  else if (uiCfg.extruSpeed == 1)
286
-    lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_slow.bin", 0);
287
-  else
288
-    lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_E_SPEED, "bmp_speed_normal.bin", 0);
293
+  if (uiCfg.extruSpeed == 20) {
294
+    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_high.bin");
295
+    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_high.bin");
296
+  }
297
+  else if (uiCfg.extruSpeed == 1) {
298
+  lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_slow.bin");
299
+    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_slow.bin");
300
+  }
301
+  else {
302
+  lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed_normal.bin");
303
+    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed_normal.bin");
304
+  }
289 305
 
290 306
   if (gCfgItems.multiple_language != 0) {
291 307
     if (uiCfg.extruSpeed == 20) {
@@ -348,12 +364,18 @@ void disp_extru_amount() {
348 364
 }
349 365
 
350 366
 void disp_ext_step() {
351
-  if (uiCfg.extruStep == 1)
352
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step1_mm.bin", 0);
353
-  else if (uiCfg.extruStep == 5)
354
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step5_mm.bin", 0);
355
-  else if (uiCfg.extruStep == 10)
356
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_E_STEP, "bmp_step10_mm.bin", 0);
367
+  if (uiCfg.extruStep == 1) {
368
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_mm.bin");
369
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_mm.bin");
370
+  }
371
+  else if (uiCfg.extruStep == 5) {
372
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_mm.bin");
373
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_mm.bin");
374
+  }
375
+  else if (uiCfg.extruStep == 10) {
376
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_mm.bin");
377
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_mm.bin");
378
+  }
357 379
 
358 380
   if (gCfgItems.multiple_language != 0) {
359 381
     if (uiCfg.extruStep == 1) {
@@ -371,6 +393,11 @@ void disp_ext_step() {
371 393
   }
372 394
 }
373 395
 
374
-void lv_clear_extrusion() { lv_obj_del(scr); }
396
+void lv_clear_extrusion() {
397
+  #if HAS_ROTARY_ENCODER
398
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
399
+  #endif
400
+  lv_obj_del(scr);
401
+}
375 402
 
376 403
 #endif // HAS_TFT_LVGL_UI

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

@@ -35,6 +35,7 @@
35 35
 #include "../../../../gcode/queue.h"
36 36
 #include "../../../../gcode/gcode.h"
37 37
 
38
+extern lv_group_t * g;
38 39
 static lv_obj_t * scr;
39 40
 static lv_obj_t * fanText;
40 41
 
@@ -138,8 +139,6 @@ void lv_draw_fan(void) {
138 139
 
139 140
   lv_refr_now(lv_refr_get_disp_refreshing());
140 141
 
141
-  LV_IMG_DECLARE(bmp_pic);
142
-
143 142
   // Create an Image button
144 143
   buttonAdd  = lv_imgbtn_create(scr, NULL);
145 144
   buttonDec  = lv_imgbtn_create(scr, NULL);
@@ -148,41 +147,41 @@ void lv_draw_fan(void) {
148 147
   buttonOff  = lv_imgbtn_create(scr, NULL);
149 148
   buttonBack = lv_imgbtn_create(scr, NULL);
150 149
 
151
-  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, "bmp_Add.bin", 0);
152
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
153
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
150
+  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_F_ADD, NULL, 0);
151
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
152
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
154 153
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
155 154
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
156 155
   lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
157 156
 
158 157
   #if 1
159
-    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, "bmp_Dec.bin", 0);
160
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
161
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
158
+    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_F_DEC, NULL, 0);
159
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
160
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
162 161
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
163 162
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
164 163
 
165
-    lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH,"bmp_speed255.bin",0);
166
-    lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, &bmp_pic);
167
-    lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, &bmp_pic);
164
+    lv_obj_set_event_cb_mks(buttonHigh, event_handler,ID_F_HIGH, NULL,0);
165
+    lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_REL, "F:/bmp_speed255.bin");
166
+    lv_imgbtn_set_src(buttonHigh, LV_BTN_STATE_PR, "F:/bmp_speed255.bin");
168 167
     lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_PR, &tft_style_label_pre);
169 168
     lv_imgbtn_set_style(buttonHigh, LV_BTN_STATE_REL, &tft_style_label_rel);
170 169
 
171
-    lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID,"bmp_speed127.bin",0);
172
-    lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, &bmp_pic);
173
-    lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, &bmp_pic);
170
+    lv_obj_set_event_cb_mks(buttonMid, event_handler,ID_F_MID, NULL,0);
171
+    lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_REL, "F:/bmp_speed127.bin");
172
+    lv_imgbtn_set_src(buttonMid, LV_BTN_STATE_PR, "F:/bmp_speed127.bin");
174 173
     lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_PR, &tft_style_label_pre);
175 174
     lv_imgbtn_set_style(buttonMid, LV_BTN_STATE_REL, &tft_style_label_rel);
176 175
 
177
-    lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF,"bmp_speed0.bin",0);
178
-    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic);
179
-    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic);
176
+    lv_obj_set_event_cb_mks(buttonOff, event_handler,ID_F_OFF, NULL,0);
177
+    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin");
178
+    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin");
180 179
     lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre);
181 180
     lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel);
182 181
 
183
-    lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN,"bmp_return.bin",0);
184
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
185
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
182
+    lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_F_RETURN, NULL,0);
183
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
184
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
186 185
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
187 186
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
188 187
 
@@ -229,6 +228,16 @@ void lv_draw_fan(void) {
229 228
     lv_label_set_text(label_Back, common_menu.text_back);
230 229
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
231 230
   }
231
+  #if HAS_ROTARY_ENCODER
232
+    if (gCfgItems.encoder_enable) {
233
+      lv_group_add_obj(g, buttonAdd);
234
+      lv_group_add_obj(g, buttonDec);
235
+      lv_group_add_obj(g, buttonHigh);
236
+      lv_group_add_obj(g, buttonMid);
237
+      lv_group_add_obj(g, buttonOff);
238
+      lv_group_add_obj(g, buttonBack);
239
+    }
240
+  #endif
232 241
 
233 242
   fanText = lv_label_create(scr, NULL);
234 243
   lv_obj_set_style(fanText, &tft_style_label_rel);
@@ -246,6 +255,11 @@ void disp_fan_value() {
246 255
   lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65);
247 256
 }
248 257
 
249
-void lv_clear_fan() { lv_obj_del(scr); }
258
+void lv_clear_fan() {
259
+  #if HAS_ROTARY_ENCODER
260
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
261
+  #endif
262
+  lv_obj_del(scr);
263
+}
250 264
 
251 265
 #endif // HAS_TFT_LVGL_UI

+ 270
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp View File

@@ -0,0 +1,270 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/temperature.h"
31
+#include "../../../../gcode/queue.h"
32
+#include "../../../../gcode/gcode.h"
33
+#include "../../../../module/motion.h"
34
+#include "../../../../module/planner.h"
35
+
36
+extern lv_group_t * g;
37
+static lv_obj_t * scr;
38
+static lv_obj_t *buttoType;
39
+static lv_obj_t *labelType;
40
+static lv_obj_t * tempText1;
41
+
42
+#define ID_FILAMNT_IN     1
43
+#define ID_FILAMNT_OUT    2
44
+#define ID_FILAMNT_TYPE   3
45
+#define ID_FILAMNT_RETURN 4
46
+
47
+extern feedRate_t feedrate_mm_s;
48
+
49
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
50
+  switch (obj->mks_obj_id) {
51
+    case ID_FILAMNT_IN:
52
+      if (event == LV_EVENT_CLICKED) {
53
+        // nothing to do
54
+      }
55
+      else if (event == LV_EVENT_RELEASED) {
56
+        uiCfg.filament_load_heat_flg = 1;
57
+        if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1)
58
+            || (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) {
59
+          lv_clear_filament_change();
60
+          lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
61
+        }
62
+        else {
63
+          lv_clear_filament_change();
64
+          lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
65
+          if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
66
+            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
67
+            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
68
+          }
69
+        }
70
+      }
71
+      break;
72
+    case ID_FILAMNT_OUT:
73
+      if (event == LV_EVENT_CLICKED) {
74
+        // nothing to do
75
+      }
76
+      else if (event == LV_EVENT_RELEASED) {
77
+        uiCfg.filament_unload_heat_flg=1;
78
+        if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0)
79
+          && ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1)
80
+          || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper))
81
+        ) {
82
+          lv_clear_filament_change();
83
+          lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
84
+        }
85
+        else {
86
+          lv_clear_filament_change();
87
+          lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
88
+          if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
89
+            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
90
+            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
91
+          }
92
+          filament_sprayer_temp();
93
+        }
94
+      }
95
+      break;
96
+    case ID_FILAMNT_TYPE:
97
+      if (event == LV_EVENT_CLICKED) {
98
+        // nothing to do
99
+      }
100
+      else if (event == LV_EVENT_RELEASED) {
101
+        #if HAS_MULTI_EXTRUDER
102
+          if (uiCfg.curSprayerChoose == 0)
103
+            uiCfg.curSprayerChoose = 1;
104
+          else if (uiCfg.curSprayerChoose == 1)
105
+            uiCfg.curSprayerChoose = 0;
106
+        #endif
107
+        disp_filament_type();
108
+      }
109
+      break;
110
+    case ID_FILAMNT_RETURN:
111
+      if (event == LV_EVENT_CLICKED) {
112
+        // nothing to do
113
+      }
114
+      else if (event == LV_EVENT_RELEASED) {
115
+        #if HAS_MULTI_EXTRUDER
116
+          if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
117
+            gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
118
+        #endif
119
+        feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
120
+        if (uiCfg.print_state == PAUSED)
121
+          planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
122
+          //current_position.e = destination.e = uiCfg.current_e_position_bak;
123
+        thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
124
+
125
+        clear_cur_ui();
126
+        draw_return_ui();
127
+      }
128
+      break;
129
+  }
130
+}
131
+
132
+void lv_draw_filament_change(void) {
133
+  lv_obj_t *buttonIn, *buttonOut;
134
+  lv_obj_t *buttonBack;
135
+
136
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) {
137
+    disp_state_stack._disp_index++;
138
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI;
139
+  }
140
+  disp_state = FILAMENTCHANGE_UI;
141
+
142
+  scr = lv_obj_create(NULL, NULL);
143
+
144
+  lv_obj_set_style(scr, &tft_style_scr);
145
+  lv_scr_load(scr);
146
+  lv_obj_clean(scr);
147
+
148
+  lv_obj_t * title = lv_label_create(scr, NULL);
149
+  lv_obj_set_style(title, &tft_style_label_rel);
150
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
151
+  lv_label_set_text(title, creat_title_text());
152
+
153
+  lv_refr_now(lv_refr_get_disp_refreshing());
154
+
155
+  // Create an Image button
156
+  buttonIn   = lv_imgbtn_create(scr, NULL);
157
+  buttonOut  = lv_imgbtn_create(scr, NULL);
158
+  buttoType  = lv_imgbtn_create(scr, NULL);
159
+  buttonBack = lv_imgbtn_create(scr, NULL);
160
+
161
+  lv_obj_set_event_cb_mks(buttonIn, event_handler, ID_FILAMNT_IN, NULL, 0);
162
+  lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_REL, "F:/bmp_in.bin");
163
+  lv_imgbtn_set_src(buttonIn, LV_BTN_STATE_PR, "F:/bmp_in.bin");
164
+  lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_PR, &tft_style_label_pre);
165
+  lv_imgbtn_set_style(buttonIn, LV_BTN_STATE_REL, &tft_style_label_rel);
166
+  lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
167
+
168
+  lv_obj_set_event_cb_mks(buttonOut, event_handler, ID_FILAMNT_OUT, NULL, 0);
169
+  lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_REL, "F:/bmp_out.bin");
170
+  lv_imgbtn_set_src(buttonOut, LV_BTN_STATE_PR, "F:/bmp_out.bin");
171
+  lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_PR, &tft_style_label_pre);
172
+  lv_imgbtn_set_style(buttonOut, LV_BTN_STATE_REL, &tft_style_label_rel);
173
+
174
+  lv_obj_set_event_cb_mks(buttoType, event_handler, ID_FILAMNT_TYPE, NULL, 0);
175
+  lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
176
+  lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
177
+
178
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMNT_RETURN, NULL, 0);
179
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
180
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
181
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
182
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
183
+
184
+  lv_obj_set_pos(buttonIn, INTERVAL_V, titleHeight);
185
+  lv_obj_set_pos(buttonOut, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
186
+  lv_obj_set_pos(buttoType, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
187
+  lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
188
+
189
+  // Create labels on the image buttons
190
+  lv_btn_set_layout(buttonIn, LV_LAYOUT_OFF);
191
+  lv_btn_set_layout(buttonOut, LV_LAYOUT_OFF);
192
+  lv_btn_set_layout(buttoType, LV_LAYOUT_OFF);
193
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
194
+
195
+  lv_obj_t *labelIn  = lv_label_create(buttonIn, NULL);
196
+  lv_obj_t *labelOut = lv_label_create(buttonOut, NULL);
197
+  labelType = lv_label_create(buttoType, NULL);
198
+  lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
199
+
200
+  if (gCfgItems.multiple_language != 0) {
201
+    lv_label_set_text(labelIn, filament_menu.in);
202
+    lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
203
+
204
+    lv_label_set_text(labelOut, filament_menu.out);
205
+    lv_obj_align(labelOut, buttonOut, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
206
+
207
+    lv_label_set_text(label_Back, common_menu.text_back);
208
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
209
+  }
210
+
211
+  #if HAS_ROTARY_ENCODER
212
+    if (gCfgItems.encoder_enable) {
213
+      lv_group_add_obj(g, buttonIn);
214
+      lv_group_add_obj(g, buttonOut);
215
+      lv_group_add_obj(g, buttoType);
216
+      lv_group_add_obj(g, buttonBack);
217
+    }
218
+  #endif
219
+
220
+  disp_filament_type();
221
+
222
+  tempText1 = lv_label_create(scr, NULL);
223
+  lv_obj_set_style(tempText1, &tft_style_label_rel);
224
+  disp_filament_temp();
225
+}
226
+
227
+void disp_filament_type() {
228
+  if (uiCfg.curSprayerChoose == 1) {
229
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
230
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
231
+    if (gCfgItems.multiple_language != 0) {
232
+      lv_label_set_text(labelType, preheat_menu.ext2);
233
+      lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
234
+    }
235
+  }
236
+  else {
237
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
238
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
239
+    if (gCfgItems.multiple_language != 0) {
240
+      lv_label_set_text(labelType, preheat_menu.ext1);
241
+      lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
242
+    }
243
+  }
244
+}
245
+
246
+void disp_filament_temp() {
247
+  char buf[20] = {0};
248
+
249
+  public_buf_l[0] = '\0';
250
+
251
+  if (uiCfg.curSprayerChoose < 1)
252
+    strcat(public_buf_l, preheat_menu.ext1);
253
+  else
254
+    strcat(public_buf_l, preheat_menu.ext2);
255
+  sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius,  (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
256
+
257
+  strcat_P(public_buf_l, PSTR(": "));
258
+  strcat(public_buf_l, buf);
259
+  lv_label_set_text(tempText1, public_buf_l);
260
+  lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
261
+}
262
+
263
+void lv_clear_filament_change() {
264
+  #if HAS_ROTARY_ENCODER
265
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
266
+  #endif
267
+  lv_obj_del(scr);
268
+}
269
+
270
+#endif // HAS_TFT_LVGL_UI

+ 36
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.h View File

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

+ 329
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp View File

@@ -0,0 +1,329 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/planner.h"
31
+
32
+extern lv_group_t * g;
33
+static lv_obj_t * scr;
34
+
35
+#define ID_FILAMENT_SET_RETURN      1
36
+#define ID_FILAMENT_SET_IN_LENGTH   2
37
+#define ID_FILAMENT_SET_IN_SPEED    3
38
+#define ID_FILAMENT_SET_OUT_LENGTH  4
39
+#define ID_FILAMENT_SET_OUT_SPEED   5
40
+#define ID_FILAMENT_SET_TEMP        6
41
+#define ID_FILAMENT_SET_DOWN        12
42
+#define ID_FILAMENT_SET_UP          13
43
+
44
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
45
+  switch (obj->mks_obj_id) {
46
+    case ID_FILAMENT_SET_RETURN:
47
+      if (event == LV_EVENT_CLICKED) {
48
+
49
+      }
50
+      else if (event == LV_EVENT_RELEASED) {
51
+        uiCfg.para_ui_page = 0;
52
+        lv_clear_filament_settings();
53
+        draw_return_ui();
54
+      }
55
+      break;
56
+    case ID_FILAMENT_SET_IN_LENGTH:
57
+      if (event == LV_EVENT_CLICKED) {
58
+
59
+      }
60
+      else if (event == LV_EVENT_RELEASED) {
61
+        value = load_length;
62
+        lv_clear_filament_settings();
63
+        lv_draw_number_key();
64
+      }
65
+      break;
66
+    case ID_FILAMENT_SET_IN_SPEED:
67
+      if (event == LV_EVENT_CLICKED) {
68
+
69
+      }
70
+      else if (event == LV_EVENT_RELEASED) {
71
+        value = load_speed;
72
+        lv_clear_filament_settings();
73
+        lv_draw_number_key();
74
+      }
75
+      break;
76
+    case ID_FILAMENT_SET_OUT_LENGTH:
77
+      if (event == LV_EVENT_CLICKED) {
78
+
79
+      }
80
+      else if (event == LV_EVENT_RELEASED) {
81
+        value = unload_length;
82
+        lv_clear_filament_settings();
83
+        lv_draw_number_key();
84
+      }
85
+      break;
86
+    case ID_FILAMENT_SET_OUT_SPEED:
87
+      if (event == LV_EVENT_CLICKED) {
88
+
89
+      }
90
+      else if (event == LV_EVENT_RELEASED) {
91
+        value = unload_speed;
92
+        lv_clear_filament_settings();
93
+        lv_draw_number_key();
94
+      }
95
+      break;
96
+    case ID_FILAMENT_SET_TEMP:
97
+      if (event == LV_EVENT_CLICKED) {
98
+
99
+      }
100
+      else if (event == LV_EVENT_RELEASED) {
101
+        value = filament_temp;
102
+        lv_clear_filament_settings();
103
+        lv_draw_number_key();
104
+      }
105
+      break;
106
+    case ID_FILAMENT_SET_UP:
107
+      if (event == LV_EVENT_CLICKED) {
108
+
109
+      }
110
+      else if (event == LV_EVENT_RELEASED) {
111
+        uiCfg.para_ui_page = 0;
112
+        lv_clear_filament_settings();
113
+        lv_draw_filament_settings();
114
+      }
115
+      break;
116
+    case ID_FILAMENT_SET_DOWN:
117
+      if (event == LV_EVENT_CLICKED) {
118
+
119
+      }
120
+      else if (event == LV_EVENT_RELEASED) {
121
+        uiCfg.para_ui_page = 1;
122
+        lv_clear_filament_settings();
123
+        lv_draw_filament_settings();
124
+      }
125
+      break;
126
+  }
127
+}
128
+
129
+void lv_draw_filament_settings(void) {
130
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
131
+  lv_obj_t *labelInLengthText = NULL, *buttonInLengthValue = NULL, *labelInLengthValue = NULL;
132
+  lv_obj_t *labelInSpeedText = NULL, *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL;
133
+  lv_obj_t *labelOutLengthText = NULL, *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL;
134
+  lv_obj_t *labelOutSpeedText = NULL, *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL;
135
+  lv_obj_t *labelTemperText = NULL, *buttonTemperValue = NULL, *labelTemperValue = NULL;
136
+  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
137
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) {
138
+    disp_state_stack._disp_index++;
139
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI;
140
+  }
141
+  disp_state = FILAMENT_SETTINGS_UI;
142
+
143
+  scr = lv_obj_create(NULL, NULL);
144
+
145
+  lv_obj_set_style(scr, &tft_style_scr);
146
+  lv_scr_load(scr);
147
+  lv_obj_clean(scr);
148
+
149
+  lv_obj_t * title = lv_label_create(scr, NULL);
150
+  lv_obj_set_style(title, &tft_style_label_rel);
151
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
152
+  lv_label_set_text(title, machine_menu.FilamentConfTitle);
153
+
154
+  lv_refr_now(lv_refr_get_disp_refreshing());
155
+
156
+  if (uiCfg.para_ui_page != 1) {
157
+    labelInLengthText = lv_label_create(scr, NULL);
158
+    lv_obj_set_style(labelInLengthText, &tft_style_label_rel);
159
+    lv_obj_set_pos(labelInLengthText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
160
+    lv_label_set_text(labelInLengthText, machine_menu.InLength);
161
+
162
+    buttonInLengthValue = lv_btn_create(scr, NULL);
163
+    lv_obj_set_pos(buttonInLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
164
+    lv_obj_set_size(buttonInLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
165
+    lv_obj_set_event_cb_mks(buttonInLengthValue, event_handler, ID_FILAMENT_SET_IN_LENGTH, NULL, 0);
166
+    lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_REL, &style_para_value);
167
+    lv_btn_set_style(buttonInLengthValue, LV_BTN_STYLE_PR, &style_para_value);
168
+    labelInLengthValue = lv_label_create(buttonInLengthValue, NULL);
169
+
170
+    line1 = lv_line_create(scr, NULL);
171
+    lv_ex_line(line1, line_points[0]);
172
+
173
+    labelInSpeedText = lv_label_create(scr, NULL);
174
+    lv_obj_set_style(labelInSpeedText, &tft_style_label_rel);
175
+    lv_obj_set_pos(labelInSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
176
+    lv_label_set_text(labelInSpeedText, machine_menu.InSpeed);
177
+
178
+    buttonInSpeedValue = lv_btn_create(scr, NULL);
179
+    lv_obj_set_pos(buttonInSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
180
+    lv_obj_set_size(buttonInSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
181
+    lv_obj_set_event_cb_mks(buttonInSpeedValue, event_handler, ID_FILAMENT_SET_IN_SPEED, NULL, 0);
182
+    lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_REL, &style_para_value);
183
+    lv_btn_set_style(buttonInSpeedValue, LV_BTN_STYLE_PR, &style_para_value);
184
+    labelInSpeedValue = lv_label_create(buttonInSpeedValue, NULL);
185
+
186
+    line2 = lv_line_create(scr, NULL);
187
+    lv_ex_line(line2, line_points[1]);
188
+
189
+    labelOutLengthText = lv_label_create(scr, NULL);
190
+    lv_obj_set_style(labelOutLengthText, &tft_style_label_rel);
191
+    lv_obj_set_pos(labelOutLengthText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6);
192
+    lv_label_set_text(labelOutLengthText, machine_menu.OutLength);
193
+
194
+    buttonOutLengthValue = lv_btn_create(scr, NULL);
195
+    lv_obj_set_pos(buttonOutLengthValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
196
+    lv_obj_set_size(buttonOutLengthValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
197
+    lv_obj_set_event_cb_mks(buttonOutLengthValue, event_handler, ID_FILAMENT_SET_OUT_LENGTH, NULL, 0);
198
+    lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_REL, &style_para_value);
199
+    lv_btn_set_style(buttonOutLengthValue, LV_BTN_STYLE_PR, &style_para_value);
200
+    labelOutLengthValue = lv_label_create(buttonOutLengthValue, NULL);
201
+
202
+    line3 = lv_line_create(scr, NULL);
203
+    lv_ex_line(line3, line_points[2]);
204
+
205
+    labelOutSpeedText = lv_label_create(scr, NULL);
206
+    lv_obj_set_style(labelOutSpeedText, &tft_style_label_rel);
207
+    lv_obj_set_pos(labelOutSpeedText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
208
+    lv_label_set_text(labelOutSpeedText, machine_menu.OutSpeed);
209
+
210
+    buttonOutSpeedValue = lv_btn_create(scr, NULL);
211
+    lv_obj_set_pos(buttonOutSpeedValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
212
+    lv_obj_set_size(buttonOutSpeedValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
213
+    lv_obj_set_event_cb_mks(buttonOutSpeedValue, event_handler, ID_FILAMENT_SET_OUT_SPEED, NULL, 0);
214
+    lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_REL, &style_para_value);
215
+    lv_btn_set_style(buttonOutSpeedValue, LV_BTN_STYLE_PR, &style_para_value);
216
+    labelOutSpeedValue = lv_label_create(buttonOutSpeedValue, NULL);
217
+
218
+    line4 = lv_line_create(scr, NULL);
219
+    lv_ex_line(line4, line_points[3]);
220
+
221
+    buttonTurnPage = lv_btn_create(scr, NULL);
222
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_DOWN, NULL, 0);
223
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
224
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
225
+
226
+    #if HAS_ROTARY_ENCODER
227
+      if (gCfgItems.encoder_enable) {
228
+        lv_group_add_obj(g, buttonInLengthValue);
229
+        lv_group_add_obj(g, buttonInSpeedValue);
230
+        lv_group_add_obj(g, buttonOutLengthValue);
231
+        lv_group_add_obj(g, buttonOutSpeedValue);
232
+        lv_group_add_obj(g, buttonTurnPage);
233
+      }
234
+    #endif
235
+  }
236
+  else {
237
+    labelTemperText = lv_label_create(scr, NULL);
238
+    lv_obj_set_style(labelTemperText, &tft_style_label_rel);
239
+    lv_obj_set_pos(labelTemperText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
240
+    lv_label_set_text(labelTemperText, machine_menu.FilamentTemperature);
241
+
242
+    buttonTemperValue = lv_btn_create(scr, NULL);
243
+    lv_obj_set_pos(buttonTemperValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
244
+    lv_obj_set_size(buttonTemperValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
245
+    lv_obj_set_event_cb_mks(buttonTemperValue, event_handler, ID_FILAMENT_SET_TEMP, NULL, 0);
246
+    lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_REL, &style_para_value);
247
+    lv_btn_set_style(buttonTemperValue, LV_BTN_STYLE_PR, &style_para_value);
248
+    labelTemperValue = lv_label_create(buttonTemperValue, NULL);
249
+
250
+    line1 = lv_line_create(scr, NULL);
251
+    lv_ex_line(line1, line_points[0]);
252
+
253
+    buttonTurnPage = lv_btn_create(scr, NULL);
254
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FILAMENT_SET_UP, NULL, 0);
255
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
256
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
257
+
258
+    #if HAS_ROTARY_ENCODER
259
+      if (gCfgItems.encoder_enable) {
260
+        lv_group_add_obj(g, buttonTemperValue);
261
+        lv_group_add_obj(g, buttonTurnPage);
262
+      }
263
+    #endif
264
+  }
265
+
266
+  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
267
+  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
268
+  labelTurnPage = lv_label_create(buttonTurnPage, NULL);
269
+
270
+  buttonBack = lv_btn_create(scr, NULL);
271
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FILAMENT_SET_RETURN, NULL, 0);
272
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
273
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
274
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
275
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
276
+  label_Back = lv_label_create(buttonBack, NULL);
277
+
278
+  #if HAS_ROTARY_ENCODER
279
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
280
+  #endif
281
+
282
+  if (gCfgItems.multiple_language != 0) {
283
+    if (uiCfg.para_ui_page != 1) {
284
+      ZERO(public_buf_l);
285
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length);
286
+      lv_label_set_text(labelInLengthValue, public_buf_l);
287
+      lv_obj_align(labelInLengthValue, buttonInLengthValue, LV_ALIGN_CENTER, 0, 0);
288
+
289
+      ZERO(public_buf_l);
290
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed);
291
+      lv_label_set_text(labelInSpeedValue, public_buf_l);
292
+      lv_obj_align(labelInSpeedValue, buttonInSpeedValue, LV_ALIGN_CENTER, 0, 0);
293
+
294
+      ZERO(public_buf_l);
295
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length);
296
+      lv_label_set_text(labelOutLengthValue, public_buf_l);
297
+      lv_obj_align(labelOutLengthValue, buttonOutLengthValue, LV_ALIGN_CENTER, 0, 0);
298
+
299
+      ZERO(public_buf_l);
300
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
301
+      lv_label_set_text(labelOutSpeedValue, public_buf_l);
302
+      lv_obj_align(labelOutSpeedValue, buttonOutSpeedValue, LV_ALIGN_CENTER, 0, 0);
303
+
304
+      lv_label_set_text(labelTurnPage, machine_menu.next);
305
+      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
306
+    }
307
+    else {
308
+      ZERO(public_buf_l);
309
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
310
+      lv_label_set_text(labelTemperValue, public_buf_l);
311
+      lv_obj_align(labelTemperValue, buttonTemperValue, LV_ALIGN_CENTER, 0, 0);
312
+
313
+      lv_label_set_text(labelTurnPage, machine_menu.previous);
314
+      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
315
+    }
316
+
317
+    lv_label_set_text(label_Back, common_menu.text_back);
318
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
319
+  }
320
+}
321
+
322
+void lv_clear_filament_settings() {
323
+  #if HAS_ROTARY_ENCODER
324
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
325
+  #endif
326
+  lv_obj_del(scr);
327
+}
328
+
329
+#endif // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.h View File

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

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

@@ -34,6 +34,7 @@
34 34
 #include "draw_ui.h"
35 35
 #include "../../../../gcode/queue.h"
36 36
 
37
+extern lv_group_t * g;
37 38
 static lv_obj_t * scr;
38 39
 
39 40
 #define ID_H_ALL      1
@@ -92,7 +93,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
92 93
       if (event == LV_EVENT_CLICKED) {
93 94
       }
94 95
       else if (event == LV_EVENT_RELEASED) {
95
-        lv_obj_del(scr);
96
+        lv_clear_home();
96 97
         lv_draw_tool();
97 98
       }
98 99
       break;
@@ -125,128 +126,93 @@ void lv_draw_home(void) {
125 126
 
126 127
   lv_refr_now(lv_refr_get_disp_refreshing());
127 128
 
128
-  LV_IMG_DECLARE(bmp_pic);
129
-
130
-  /*Create an Image button*/
131
-  //buttonWifi = lv_imgbtn_create(scr, NULL);
132
-  buttonHomeAll = lv_imgbtn_create(scr, NULL);
133
-  buttonHomeX = lv_imgbtn_create(scr, NULL);
129
+  // Create image buttons
130
+  //buttonWifi     = lv_imgbtn_create(scr, NULL);
131
+  buttonHomeAll    = lv_imgbtn_create(scr, NULL);
132
+  buttonHomeX      = lv_imgbtn_create(scr, NULL);
134 133
   //buttonContinue = lv_imgbtn_create(scr, NULL);
135
-  buttonHomeY = lv_imgbtn_create(scr, NULL);
136
-  buttonHomeZ = lv_imgbtn_create(scr, NULL);
137
-  buttonBack = lv_imgbtn_create(scr, NULL);
138
-  buttonOffAll = lv_imgbtn_create(scr, NULL);
139
-  buttonOffXY = lv_imgbtn_create(scr, NULL);
140
-
141
-  //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0);
142
-  //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic);
143
-  //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic);
144
-  //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
145
-  //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
146
-  //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW);
134
+  buttonHomeY      = lv_imgbtn_create(scr, NULL);
135
+  buttonHomeZ      = lv_imgbtn_create(scr, NULL);
136
+  buttonOffAll     = lv_imgbtn_create(scr, NULL);
137
+  buttonOffXY      = lv_imgbtn_create(scr, NULL);
138
+  buttonBack       = lv_imgbtn_create(scr, NULL);
139
+
147 140
   #if 1
148
-    lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL,"bmp_zero.bin",0);
149
-    lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, &bmp_pic);
150
-    lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, &bmp_pic);
141
+    lv_obj_set_event_cb_mks(buttonHomeAll, event_handler,ID_H_ALL, NULL,0);
142
+    lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_REL, "F:/bmp_zeroAll.bin");
143
+    lv_imgbtn_set_src(buttonHomeAll, LV_BTN_STATE_PR, "F:/bmp_zeroAll.bin");
151 144
     lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_PR, &tft_style_label_pre);
152 145
     lv_imgbtn_set_style(buttonHomeAll, LV_BTN_STATE_REL, &tft_style_label_rel);
153 146
 
154
-    lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, "bmp_zeroX.bin", 0);
155
-    lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, &bmp_pic);
156
-    lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, &bmp_pic);
147
+    lv_obj_set_event_cb_mks(buttonHomeX, event_handler, ID_H_X, NULL, 0);
148
+    lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_REL, "F:/bmp_zeroX.bin");
149
+    lv_imgbtn_set_src(buttonHomeX, LV_BTN_STATE_PR, "F:/bmp_zeroX.bin");
157 150
     lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_PR, &tft_style_label_pre);
158 151
     lv_imgbtn_set_style(buttonHomeX, LV_BTN_STATE_REL, &tft_style_label_rel);
159 152
 
160
-    //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0);
161
-    //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic);
162
-    //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic);
163
-    //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre);
164
-    //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel);
165
-
166
-    lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, "bmp_zeroY.bin", 0);
167
-    lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, &bmp_pic);
168
-    lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, &bmp_pic);
153
+    lv_obj_set_event_cb_mks(buttonHomeY, event_handler, ID_H_Y, NULL, 0);
154
+    lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_REL, "F:/bmp_zeroY.bin");
155
+    lv_imgbtn_set_src(buttonHomeY, LV_BTN_STATE_PR, "F:/bmp_zeroY.bin");
169 156
     lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_PR, &tft_style_label_pre);
170 157
     lv_imgbtn_set_style(buttonHomeY, LV_BTN_STATE_REL, &tft_style_label_rel);
171 158
 
172
-    lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, "bmp_zeroZ.bin", 0);
173
-    lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, &bmp_pic);
174
-    lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, &bmp_pic);
159
+    lv_obj_set_event_cb_mks(buttonHomeZ, event_handler, ID_H_Z, NULL, 0);
160
+    lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_REL, "F:/bmp_zeroZ.bin");
161
+    lv_imgbtn_set_src(buttonHomeZ, LV_BTN_STATE_PR, "F:/bmp_zeroZ.bin");
175 162
     lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_PR, &tft_style_label_pre);
176 163
     lv_imgbtn_set_style(buttonHomeZ, LV_BTN_STATE_REL, &tft_style_label_rel);
177 164
 
178
-    lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL,"bmp_function1.bin",0);
179
-    lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, &bmp_pic);
180
-    lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, &bmp_pic);
165
+    lv_obj_set_event_cb_mks(buttonOffAll, event_handler,ID_H_OFF_ALL, NULL,0);
166
+    lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
167
+    lv_imgbtn_set_src(buttonOffAll, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
181 168
     lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_PR, &tft_style_label_pre);
182 169
     lv_imgbtn_set_style(buttonOffAll, LV_BTN_STATE_REL, &tft_style_label_rel);
183 170
 
184
-    lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY,"bmp_function1.bin",0);
185
-    lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, &bmp_pic);
186
-    lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, &bmp_pic);
171
+    lv_obj_set_event_cb_mks(buttonOffXY, event_handler,ID_H_OFF_XY, NULL,0);
172
+    lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
173
+    lv_imgbtn_set_src(buttonOffXY, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
187 174
     lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_PR, &tft_style_label_pre);
188 175
     lv_imgbtn_set_style(buttonOffXY, LV_BTN_STATE_REL, &tft_style_label_rel);
189 176
 
190
-    lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN,"bmp_return.bin",0);
191
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
192
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
177
+    lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_H_RETURN, NULL,0);
178
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
179
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
193 180
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
194 181
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
195 182
   #endif
196 183
 
197
-  /*lv_obj_set_pos(buttonWifi, INTERVAL_V, titleHeight);
198
-  lv_obj_set_pos(buttonFan, BTN_X_PIXEL+INTERVAL_V*2, titleHeight);
199
-  lv_obj_set_pos(buttonAbout, BTN_X_PIXEL*2+INTERVAL_V*3, titleHeight);
200
-  lv_obj_set_pos(buttonContinue, BTN_X_PIXEL*3+INTERVAL_V*4, titleHeight);
201
-  lv_obj_set_pos(buMotorOff, INTERVAL_V,  BTN_Y_PIXEL+INTERVAL_H+titleHeight);
202
-  lv_obj_set_pos(buttonLanguage, BTN_X_PIXEL+INTERVAL_V*2, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
203
-  lv_obj_set_pos(buttonBack, BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/
204
-
205
-  //lv_obj_set_pos(buttonWifi, INTERVAL_V, titleHeight);
184
+  lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight);
206 185
   lv_obj_set_pos(buttonHomeX, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
207 186
   lv_obj_set_pos(buttonHomeY, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
208
-  //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
209 187
   lv_obj_set_pos(buttonHomeZ, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
210
-  lv_obj_set_pos(buttonHomeAll, INTERVAL_V, titleHeight);
211 188
   lv_obj_set_pos(buttonOffAll, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
212 189
   lv_obj_set_pos(buttonOffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
213 190
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
214 191
 
215
-  /*Create a label on the Image button*/
216
-  //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
192
+  // Create labels on the image buttons
217 193
   lv_btn_set_layout(buttonHomeAll, LV_LAYOUT_OFF);
218 194
   lv_btn_set_layout(buttonHomeX, LV_LAYOUT_OFF);
219
-  //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF);
220 195
   lv_btn_set_layout(buttonHomeY, LV_LAYOUT_OFF);
221 196
   lv_btn_set_layout(buttonHomeZ, LV_LAYOUT_OFF);
222 197
   lv_btn_set_layout(buttonOffAll, LV_LAYOUT_OFF);
223 198
   lv_btn_set_layout(buttonOffXY, LV_LAYOUT_OFF);
224 199
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
225 200
 
226
-  //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL);
227
-  lv_obj_t * labelHomeAll = lv_label_create(buttonHomeAll, NULL);
228
-  lv_obj_t * labelHomeX = lv_label_create(buttonHomeX, NULL);
229
-  //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL);
230
-  lv_obj_t * labelHomeY = lv_label_create(buttonHomeY, NULL);
231
-  lv_obj_t * labelHomeZ = lv_label_create(buttonHomeZ, NULL);
232
-  lv_obj_t * labelOffAll = lv_label_create(buttonOffAll, NULL);
233
-  lv_obj_t * labelOffXY = lv_label_create(buttonOffXY, NULL);
234
-  lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
235
-
201
+  lv_obj_t *labelHomeAll = lv_label_create(buttonHomeAll, NULL);
202
+  lv_obj_t *labelHomeX = lv_label_create(buttonHomeX, NULL);
203
+  lv_obj_t *labelHomeY = lv_label_create(buttonHomeY, NULL);
204
+  lv_obj_t *labelHomeZ = lv_label_create(buttonHomeZ, NULL);
205
+  lv_obj_t *labelOffAll = lv_label_create(buttonOffAll, NULL);
206
+  lv_obj_t *labelOffXY = lv_label_create(buttonOffXY, NULL);
207
+  lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
236 208
 
237 209
   if (gCfgItems.multiple_language != 0) {
238
-    //lv_label_set_text(labelWifi, set_menu.wifi);
239
-    //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
240
-
241 210
     lv_label_set_text(labelHomeAll, home_menu.home_all);
242 211
     lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
243 212
 
244 213
     lv_label_set_text(labelHomeX, home_menu.home_x);
245 214
     lv_obj_align(labelHomeX, buttonHomeX, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
246 215
 
247
-    //lv_label_set_text(label_Continue, set_menu.breakpoint);
248
-    //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
249
-
250 216
     lv_label_set_text(labelHomeY, home_menu.home_y);
251 217
     lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
252 218
 
@@ -262,8 +228,25 @@ void lv_draw_home(void) {
262 228
     lv_label_set_text(label_Back, common_menu.text_back);
263 229
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
264 230
   }
231
+
232
+  #if HAS_ROTARY_ENCODER
233
+    if (gCfgItems.encoder_enable) {
234
+      lv_group_add_obj(g, buttonHomeAll);
235
+      lv_group_add_obj(g, buttonHomeX);
236
+      lv_group_add_obj(g, buttonHomeY);
237
+      lv_group_add_obj(g, buttonHomeZ);
238
+      lv_group_add_obj(g, buttonOffAll);
239
+      lv_group_add_obj(g, buttonOffXY);
240
+      lv_group_add_obj(g, buttonBack);
241
+    }
242
+  #endif
265 243
 }
266 244
 
267
-void lv_clear_home() { lv_obj_del(scr); }
245
+void lv_clear_home() {
246
+  #if HAS_ROTARY_ENCODER
247
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
248
+  #endif
249
+  lv_obj_del(scr);
250
+}
268 251
 
269 252
 #endif // HAS_TFT_LVGL_UI

+ 262
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp View File

@@ -0,0 +1,262 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/planner.h"
31
+#include "../../../../module/probe.h"
32
+
33
+#if USE_SENSORLESS
34
+#include "../../../../module/stepper/indirection.h"
35
+#include "../../../../feature/tmc_util.h"
36
+
37
+extern lv_group_t * g;
38
+static lv_obj_t * scr;
39
+
40
+#define ID_SENSITIVITY_RETURN   1
41
+#define ID_SENSITIVITY_X        2
42
+#define ID_SENSITIVITY_Y        3
43
+#define ID_SENSITIVITY_Z        4
44
+#define ID_SENSITIVITY_Z2       5
45
+
46
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
47
+  switch (obj->mks_obj_id) {
48
+    case ID_SENSITIVITY_RETURN:
49
+      if (event == LV_EVENT_CLICKED) {
50
+
51
+      }
52
+      else if (event == LV_EVENT_RELEASED) {
53
+        lv_clear_homing_sensitivity_settings();
54
+        draw_return_ui();
55
+      }
56
+      break;
57
+    case ID_SENSITIVITY_X:
58
+      if (event == LV_EVENT_CLICKED) {
59
+
60
+      }
61
+      else if (event == LV_EVENT_RELEASED) {
62
+        value = x_sensitivity;
63
+        lv_clear_homing_sensitivity_settings();
64
+        lv_draw_number_key();
65
+      }
66
+      break;
67
+    case ID_SENSITIVITY_Y:
68
+      if (event == LV_EVENT_CLICKED) {
69
+
70
+      }
71
+      else if (event == LV_EVENT_RELEASED) {
72
+        value = y_sensitivity;
73
+        lv_clear_homing_sensitivity_settings();
74
+        lv_draw_number_key();
75
+      }
76
+      break;
77
+    case ID_SENSITIVITY_Z:
78
+      if (event == LV_EVENT_CLICKED) {
79
+
80
+      }
81
+      else if (event == LV_EVENT_RELEASED) {
82
+        value = z_sensitivity;
83
+        lv_clear_homing_sensitivity_settings();
84
+        lv_draw_number_key();
85
+      }
86
+      break;
87
+    #if Z2_SENSORLESS
88
+      case ID_SENSITIVITY_Z2:
89
+      if (event == LV_EVENT_CLICKED) {
90
+
91
+      }
92
+      else if (event == LV_EVENT_RELEASED) {
93
+        value = z2_sensitivity;
94
+        lv_clear_homing_sensitivity_settings();
95
+        lv_draw_number_key();
96
+      }
97
+      break;
98
+    #endif
99
+  }
100
+}
101
+
102
+void lv_draw_homing_sensitivity_settings(void) {
103
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
104
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
105
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
106
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
107
+  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
108
+  #if Z2_SENSORLESS
109
+    lv_obj_t *labelZ2Text = NULL, *buttonZ2Value = NULL, *labelZ2Value = NULL;
110
+    lv_obj_t * line4 = NULL;
111
+  #endif
112
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) {
113
+    disp_state_stack._disp_index++;
114
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI;
115
+  }
116
+  disp_state = HOMING_SENSITIVITY_UI;
117
+
118
+  scr = lv_obj_create(NULL, NULL);
119
+
120
+  lv_obj_set_style(scr, &tft_style_scr);
121
+  lv_scr_load(scr);
122
+  lv_obj_clean(scr);
123
+
124
+  lv_obj_t * title = lv_label_create(scr, NULL);
125
+  lv_obj_set_style(title, &tft_style_label_rel);
126
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
127
+  lv_label_set_text(title, machine_menu.HomingSensitivityConfTitle);
128
+
129
+  lv_refr_now(lv_refr_get_disp_refreshing());
130
+
131
+  labelXText = lv_label_create(scr, NULL);
132
+  lv_obj_set_style(labelXText, &tft_style_label_rel);
133
+  lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
134
+  lv_label_set_text(labelXText, machine_menu.X_Sensitivity);
135
+
136
+  buttonXValue = lv_btn_create(scr, NULL);
137
+  lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
138
+  lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
139
+  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_SENSITIVITY_X, NULL, 0);
140
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
141
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
142
+  labelXValue = lv_label_create(buttonXValue, NULL);
143
+
144
+  #if HAS_ROTARY_ENCODER
145
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue);
146
+  #endif
147
+
148
+  line1 = lv_line_create(scr, NULL);
149
+  lv_ex_line(line1, line_points[0]);
150
+
151
+  labelYText = lv_label_create(scr, NULL);
152
+  lv_obj_set_style(labelYText, &tft_style_label_rel);
153
+  lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
154
+  lv_label_set_text(labelYText, machine_menu.Y_Sensitivity);
155
+
156
+  buttonYValue = lv_btn_create(scr, NULL);
157
+  lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
158
+  lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
159
+  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_SENSITIVITY_Y, NULL, 0);
160
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
161
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
162
+  labelYValue = lv_label_create(buttonYValue, NULL);
163
+
164
+  #if HAS_ROTARY_ENCODER
165
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYValue);
166
+  #endif
167
+
168
+  line2 = lv_line_create(scr, NULL);
169
+  lv_ex_line(line2, line_points[1]);
170
+
171
+  labelZText = lv_label_create(scr, NULL);
172
+  lv_obj_set_style(labelZText, &tft_style_label_rel);
173
+  lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
174
+  lv_label_set_text(labelZText, machine_menu.Z_Sensitivity);
175
+
176
+  buttonZValue = lv_btn_create(scr, NULL);
177
+  lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
178
+  lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
179
+  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_SENSITIVITY_Z, NULL, 0);
180
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
181
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
182
+  labelZValue = lv_label_create(buttonZValue, NULL);
183
+
184
+  #if HAS_ROTARY_ENCODER
185
+    if (gCfgItems.encoder_enable == true) lv_group_add_obj(g, buttonZValue);
186
+  #endif
187
+
188
+  line3 = lv_line_create(scr, NULL);
189
+  lv_ex_line(line3, line_points[2]);
190
+
191
+  #if Z2_SENSORLESS
192
+    labelZ2Text = lv_label_create(scr, NULL);
193
+    lv_obj_set_style(labelZ2Text, &tft_style_label_rel);
194
+    lv_obj_set_pos(labelZ2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
195
+    lv_label_set_text(labelZ2Text, machine_menu.Z2_Sensitivity);
196
+
197
+    buttonZ2Value = lv_btn_create(scr, NULL);
198
+    lv_obj_set_pos(buttonZ2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
199
+    lv_obj_set_size(buttonZ2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
200
+    lv_obj_set_event_cb_mks(buttonZ2Value, event_handler, ID_SENSITIVITY_Z2, NULL, 0);
201
+    lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_REL, &style_para_value);
202
+    lv_btn_set_style(buttonZ2Value, LV_BTN_STYLE_PR, &style_para_value);
203
+    labelZ2Value = lv_label_create(buttonZ2Value, NULL);
204
+
205
+    #if HAS_ROTARY_ENCODER
206
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZ2Value);
207
+    #endif
208
+
209
+    line4 = lv_line_create(scr, NULL);
210
+    lv_ex_line(line4, line_points[3]);
211
+  #endif
212
+
213
+  buttonBack = lv_btn_create(scr, NULL);
214
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_SENSITIVITY_RETURN, NULL, 0);
215
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
216
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
217
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
218
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
219
+  label_Back = lv_label_create(buttonBack, NULL);
220
+
221
+  #if HAS_ROTARY_ENCODER
222
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
223
+  #endif
224
+
225
+  if (gCfgItems.multiple_language != 0) {
226
+    ZERO(public_buf_l);
227
+    sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
228
+    lv_label_set_text(labelXValue, public_buf_l);
229
+    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
230
+
231
+    ZERO(public_buf_l);
232
+    sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
233
+    lv_label_set_text(labelYValue, public_buf_l);
234
+    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
235
+
236
+    ZERO(public_buf_l);
237
+    sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
238
+    lv_label_set_text(labelZValue, public_buf_l);
239
+    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
240
+
241
+    #if Z2_SENSORLESS
242
+      ZERO(public_buf_l);
243
+      sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
244
+      lv_label_set_text(labelZ2Value, public_buf_l);
245
+      lv_obj_align(labelZ2Value, buttonZ2Value, LV_ALIGN_CENTER, 0, 0);
246
+    #endif
247
+
248
+    lv_label_set_text(label_Back, common_menu.text_back);
249
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
250
+  }
251
+}
252
+
253
+void lv_clear_homing_sensitivity_settings() {
254
+  #if HAS_ROTARY_ENCODER
255
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
256
+  #endif
257
+  lv_obj_del(scr);
258
+}
259
+
260
+#endif // USE_SENSORLESS
261
+
262
+#endif // HAS_TFT_LVGL_UI && USE_SENSORLESS

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.h View File

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

+ 62
- 88
Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp View File

@@ -29,6 +29,7 @@
29 29
 #include "../../../../MarlinCore.h"
30 30
 #include "../../../../module/planner.h"
31 31
 
32
+extern lv_group_t * g;
32 33
 static lv_obj_t * scr;
33 34
 
34 35
 #define ID_JERK_RETURN  1
@@ -93,10 +94,10 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
93 94
 
94 95
 void lv_draw_jerk_settings(void) {
95 96
   lv_obj_t *buttonBack = NULL, *label_Back = NULL;
96
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
97
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
98
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
99
-  lv_obj_t *buttonEText = NULL, *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL;
97
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
98
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
99
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
100
+  lv_obj_t *labelEText = NULL, *buttonEValue = NULL, *labelEValue = NULL;
100 101
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
101 102
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) {
102 103
     disp_state_stack._disp_index++;
@@ -117,109 +118,89 @@ void lv_draw_jerk_settings(void) {
117 118
 
118 119
   lv_refr_now(lv_refr_get_disp_refreshing());
119 120
 
120
-  LV_IMG_DECLARE(bmp_para_back);
121
-  // LV_IMG_DECLARE(bmp_para_arrow);
122
-  LV_IMG_DECLARE(bmp_para_bank);
121
+  labelXText = lv_label_create(scr, NULL);
122
+  lv_obj_set_style(labelXText, &tft_style_label_rel);
123
+  lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
124
+  lv_label_set_text(labelXText, machine_menu.X_Jerk);
123 125
 
124
-  buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
125
-  lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
126
-  lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
127
-  lv_obj_set_event_cb(buttonXText, event_handler);
128
-  lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
129
-  lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
130
-  lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
131
-  labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
132
-
133
-  buttonXValue = lv_imgbtn_create(scr, NULL);
126
+  buttonXValue = lv_btn_create(scr, NULL);
134 127
   lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
135
-  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, "bmp_value_blank.bin", 0);
136
-  lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
137
-  lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
138
-  lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
139
-  lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
140
-  lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
128
+  lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
129
+  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_JERK_X, NULL, 0);
130
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
131
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
141 132
   labelXValue = lv_label_create(buttonXValue, NULL);
142 133
 
143 134
   line1 = lv_line_create(scr, NULL);
144 135
   lv_ex_line(line1, line_points[0]);
145 136
 
146
-  buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
147
-  lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
148
-  lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
149
-  lv_obj_set_event_cb(buttonYText, event_handler);
150
-  lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
151
-  lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
152
-  lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
153
-  labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
137
+  labelYText = lv_label_create(scr, NULL);
138
+  lv_obj_set_style(labelYText, &tft_style_label_rel);
139
+  lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
140
+  lv_label_set_text(labelYText, machine_menu.Y_Jerk);
154 141
 
155
-  buttonYValue = lv_imgbtn_create(scr, NULL);
142
+  buttonYValue = lv_btn_create(scr, NULL);
156 143
   lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
157
-  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, "bmp_value_blank.bin", 0);
158
-  lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
159
-  lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
160
-  lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
161
-  lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
162
-  lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
144
+  lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
145
+  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_JERK_Y, NULL, 0);
146
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
147
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
163 148
   labelYValue = lv_label_create(buttonYValue, NULL);
164 149
 
165 150
   line2 = lv_line_create(scr, NULL);
166 151
   lv_ex_line(line2, line_points[1]);
167 152
 
168
-  buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
169
-  lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
170
-  lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
171
-  lv_obj_set_event_cb(buttonZText, event_handler);
172
-  lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
173
-  lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
174
-  lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
175
-  labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
153
+  labelZText = lv_label_create(scr, NULL);
154
+  lv_obj_set_style(labelZText, &tft_style_label_rel);
155
+  lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
156
+  lv_label_set_text(labelZText, machine_menu.Z_Jerk);
176 157
 
177
-  buttonZValue = lv_imgbtn_create(scr, NULL);
158
+  buttonZValue = lv_btn_create(scr, NULL);
178 159
   lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
179
-  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, "bmp_value_blank.bin", 0);
180
-  lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
181
-  lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
182
-  lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
183
-  lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
184
-  lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
160
+  lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
161
+  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_JERK_Z, NULL, 0);
162
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
163
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
185 164
   labelZValue = lv_label_create(buttonZValue, NULL);
186 165
 
187 166
   line3 = lv_line_create(scr, NULL);
188 167
   lv_ex_line(line3, line_points[2]);
189 168
 
190
-  buttonEText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
191
-  lv_obj_set_pos(buttonEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4);          /*Set its position*/
192
-  lv_obj_set_size(buttonEText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
193
-  lv_obj_set_event_cb(buttonEText, event_handler);
194
-  lv_btn_set_style(buttonEText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
195
-  lv_btn_set_style(buttonEText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
196
-  lv_btn_set_layout(buttonEText, LV_LAYOUT_OFF);
197
-  labelEText = lv_label_create(buttonEText, NULL);                        /*Add a label to the button*/
169
+  labelEText = lv_label_create(scr, NULL);
170
+  lv_obj_set_style(labelEText, &tft_style_label_rel);
171
+  lv_obj_set_pos(labelEText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
172
+  lv_label_set_text(labelEText, machine_menu.E_Jerk);
198 173
 
199
-  buttonEValue = lv_imgbtn_create(scr, NULL);
174
+  buttonEValue = lv_btn_create(scr, NULL);
200 175
   lv_obj_set_pos(buttonEValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
201
-  lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, "bmp_value_blank.bin", 0);
202
-  lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_REL, &bmp_para_bank);
203
-  lv_imgbtn_set_src(buttonEValue, LV_BTN_STATE_PR, &bmp_para_bank);
204
-  lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_PR, &style_para_value_pre);
205
-  lv_imgbtn_set_style(buttonEValue, LV_BTN_STATE_REL, &style_para_value_rel);
206
-  lv_btn_set_layout(buttonEValue, LV_LAYOUT_OFF);
176
+  lv_obj_set_size(buttonEValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
177
+  lv_obj_set_event_cb_mks(buttonEValue, event_handler, ID_JERK_E, NULL, 0);
178
+  lv_btn_set_style(buttonEValue, LV_BTN_STYLE_REL, &style_para_value);
179
+  lv_btn_set_style(buttonEValue, LV_BTN_STYLE_PR, &style_para_value);
207 180
   labelEValue = lv_label_create(buttonEValue, NULL);
208 181
 
209 182
   line4 = lv_line_create(scr, NULL);
210 183
   lv_ex_line(line4, line_points[3]);
211 184
 
212
-  buttonBack = lv_imgbtn_create(scr, NULL);
213
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, "bmp_back70x40.bin", 0);
214
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
215
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
216
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
217
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
185
+  buttonBack = lv_btn_create(scr, NULL);
186
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_JERK_RETURN, NULL, 0);
187
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
188
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
218 189
 
219 190
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
220
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
191
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
221 192
   label_Back = lv_label_create(buttonBack, NULL);
222 193
 
194
+  #if HAS_ROTARY_ENCODER
195
+    if (gCfgItems.encoder_enable == true) {
196
+      lv_group_add_obj(g, buttonXValue);
197
+      lv_group_add_obj(g, buttonYValue);
198
+      lv_group_add_obj(g, buttonZValue);
199
+      lv_group_add_obj(g, buttonEValue);
200
+      lv_group_add_obj(g, buttonBack);
201
+    }
202
+  #endif
203
+
223 204
   if (gCfgItems.multiple_language != 0) {
224 205
     ZERO(public_buf_l);
225 206
     sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
@@ -241,23 +222,16 @@ void lv_draw_jerk_settings(void) {
241 222
     lv_label_set_text(labelEValue, public_buf_l);
242 223
     lv_obj_align(labelEValue, buttonEValue, LV_ALIGN_CENTER, 0, 0);
243 224
 
244
-    lv_label_set_text(labelXText, machine_menu.X_Jerk);
245
-    lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
246
-
247
-    lv_label_set_text(labelYText, machine_menu.Y_Jerk);
248
-    lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
249
-
250
-    lv_label_set_text(labelZText, machine_menu.Z_Jerk);
251
-    lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
252
-
253
-    lv_label_set_text(labelEText, machine_menu.E_Jerk);
254
-    lv_obj_align(labelEText, buttonEText, LV_ALIGN_IN_LEFT_MID, 0, 0);
255
-
256 225
     lv_label_set_text(label_Back, common_menu.text_back);
257 226
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
258 227
   }
259 228
 }
260 229
 
261
-void lv_clear_jerk_settings() { lv_obj_del(scr); }
230
+void lv_clear_jerk_settings() {
231
+  #if HAS_ROTARY_ENCODER
232
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
233
+  #endif
234
+  lv_obj_del(scr);
235
+}
262 236
 
263 237
 #endif // HAS_TFT_LVGL_UI && HAS_CLASSIC_JERK

+ 286
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp View File

@@ -0,0 +1,286 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../../Configuration.h"
30
+#include "../../../../MarlinCore.h"
31
+
32
+extern lv_group_t * g;
33
+static lv_obj_t * scr;
34
+
35
+#define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
36
+
37
+static const char * kb_map_lc[] = {"1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
38
+                                   "ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n",
39
+                                   "_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
40
+                                   LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
41
+
42
+static const lv_btnm_ctrl_t kb_ctrl_lc_map[] = {
43
+    LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
44
+    LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
45
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
46
+    LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
47
+
48
+static const char * kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", LV_SYMBOL_BACKSPACE, "\n",
49
+                                   "abc", "A", "S", "D", "F", "G", "H", "J", "K", "L", LV_SYMBOL_NEW_LINE, "\n",
50
+                                   "_", "-", "Z", "X", "C", "V", "B", "N", "M", ".", ",", ":", "\n",
51
+                                   LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
52
+
53
+static const lv_btnm_ctrl_t kb_ctrl_uc_map[] = {
54
+    LV_KB_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7,
55
+    LV_KB_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7,
56
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
57
+    LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
58
+
59
+static const char * kb_map_spec[] = {"0", "1", "2", "3", "4" ,"5", "6", "7", "8", "9", LV_SYMBOL_BACKSPACE, "\n",
60
+                                     "abc", "+", "-", "/", "*", "=", "%", "!", "?", "#", "<", ">", "\n",
61
+                                     "\\",  "@", "$", "(", ")", "{", "}", "[", "]", ";", "\"", "'", "\n",
62
+                                     LV_SYMBOL_CLOSE, LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""};
63
+
64
+static const lv_btnm_ctrl_t kb_ctrl_spec_map[] = {
65
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
66
+    LV_KB_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
67
+    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
68
+    LV_KB_CTRL_BTN_FLAGS | 2, 2, 6, 2, LV_KB_CTRL_BTN_FLAGS | 2};
69
+
70
+static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
71
+        1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
72
+        1, 1, 1, LV_KB_CTRL_BTN_FLAGS | 2,
73
+        1, 1, 1, 2,
74
+        1, 1, 1, 1, 1};
75
+
76
+static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
77
+  //LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
78
+
79
+  if (event != LV_EVENT_VALUE_CHANGED) return;
80
+
81
+  lv_kb_ext_t * ext = (lv_kb_ext_t * )lv_obj_get_ext_attr(kb);
82
+  const uint16_t btn_id = lv_btnm_get_active_btn(kb);
83
+  if (btn_id == LV_BTNM_BTN_NONE) return;
84
+  if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return;
85
+  if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
86
+
87
+  const char * txt = lv_btnm_get_active_btn_text(kb);
88
+  if (txt == NULL) return;
89
+
90
+  // Do the corresponding action according to the text of the button
91
+  if (strcmp(txt, "abc") == 0) {
92
+    lv_btnm_set_map(kb, kb_map_lc);
93
+    lv_btnm_set_ctrl_map(kb, kb_ctrl_lc_map);
94
+    return;
95
+  }
96
+  else if (strcmp(txt, "ABC") == 0) {
97
+    lv_btnm_set_map(kb, kb_map_uc);
98
+    lv_btnm_set_ctrl_map(kb, kb_ctrl_uc_map);
99
+    return;
100
+  }
101
+  else if (strcmp(txt, "1#") == 0) {
102
+    lv_btnm_set_map(kb, kb_map_spec);
103
+    lv_btnm_set_ctrl_map(kb, kb_ctrl_spec_map);
104
+    return;
105
+  }
106
+  else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
107
+    if (kb->event_cb != lv_kb_def_event_cb) {
108
+      //lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL);
109
+      //if (res != LV_RES_OK) return;
110
+      lv_clear_keyboard();
111
+      draw_return_ui();
112
+    }
113
+    else {
114
+      lv_kb_set_ta(kb, NULL); /*De-assign the text area  to hide it cursor if needed*/
115
+      lv_obj_del(kb);
116
+      return;
117
+    }
118
+  return;
119
+  }
120
+  else if (strcmp(txt, LV_SYMBOL_OK) == 0) {
121
+    if (kb->event_cb != lv_kb_def_event_cb) {
122
+      //lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL);
123
+      //if (res != LV_RES_OK) return;
124
+      const char * ret_ta_txt = lv_ta_get_text(ext->ta);
125
+      switch (keyboard_value) {
126
+        #if ENABLED(USE_WIFI_FUNCTION)
127
+          case wifiName:
128
+            memcpy(uiCfg.wifi_name,ret_ta_txt,sizeof(uiCfg.wifi_name));
129
+            lv_clear_keyboard();
130
+            draw_return_ui();
131
+            break;
132
+          case wifiPassWord:
133
+            memcpy(uiCfg.wifi_key,ret_ta_txt,sizeof(uiCfg.wifi_name));
134
+            lv_clear_keyboard();
135
+            draw_return_ui();
136
+            break;
137
+          case wifiConfig:
138
+            memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name));
139
+            memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32);
140
+
141
+            memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key));
142
+            memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key));
143
+
144
+            gCfgItems.wifi_mode_sel = STA_MODEL;
145
+
146
+            package_to_wifi(WIFI_PARA_SET, (char *)0, 0);
147
+
148
+            memset(public_buf_l,0,sizeof(public_buf_l));
149
+
150
+            public_buf_l[0] = 0xA5;
151
+            public_buf_l[1] = 0x09;
152
+            public_buf_l[2] = 0x01;
153
+            public_buf_l[3] = 0x00;
154
+            public_buf_l[4] = 0x01;
155
+            public_buf_l[5] = 0xFC;
156
+            public_buf_l[6] = 0x00;
157
+            raw_send_to_wifi(public_buf_l, 6);
158
+
159
+            last_disp_state = KEY_BOARD_UI;
160
+            lv_clear_keyboard();
161
+            wifi_tips_type = TIPS_TYPE_JOINING;
162
+            lv_draw_wifi_tips();
163
+            break;
164
+        #endif // USE_WIFI_FUNCTION
165
+        case gcodeCommand:
166
+          uint8_t buf[100];
167
+          strncpy((char *)buf,ret_ta_txt,sizeof(buf));
168
+          update_gcode_command(AUTO_LEVELING_COMMAND_ADDR,buf);
169
+          lv_clear_keyboard();
170
+          draw_return_ui();
171
+          break;
172
+        default: break;
173
+      }
174
+    }
175
+    else {
176
+      lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
177
+    }
178
+  return;
179
+  }
180
+
181
+  /*Add the characters to the text area if set*/
182
+  if (ext->ta == NULL) return;
183
+
184
+  if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
185
+    lv_ta_add_char(ext->ta, '\n');
186
+  else if (strcmp(txt, LV_SYMBOL_LEFT) == 0)
187
+    lv_ta_cursor_left(ext->ta);
188
+  else if (strcmp(txt, LV_SYMBOL_RIGHT) == 0)
189
+    lv_ta_cursor_right(ext->ta);
190
+  else if (strcmp(txt, LV_SYMBOL_BACKSPACE) == 0)
191
+    lv_ta_del_char(ext->ta);
192
+  else if (strcmp(txt, "+/-") == 0) {
193
+    uint16_t cur = lv_ta_get_cursor_pos(ext->ta);
194
+    const char * ta_txt = lv_ta_get_text(ext->ta);
195
+    if (ta_txt[0] == '-') {
196
+      lv_ta_set_cursor_pos(ext->ta, 1);
197
+      lv_ta_del_char(ext->ta);
198
+      lv_ta_add_char(ext->ta, '+');
199
+      lv_ta_set_cursor_pos(ext->ta, cur);
200
+    }
201
+    else if (ta_txt[0] == '+') {
202
+      lv_ta_set_cursor_pos(ext->ta, 1);
203
+      lv_ta_del_char(ext->ta);
204
+      lv_ta_add_char(ext->ta, '-');
205
+      lv_ta_set_cursor_pos(ext->ta, cur);
206
+    }
207
+    else {
208
+      lv_ta_set_cursor_pos(ext->ta, 0);
209
+      lv_ta_add_char(ext->ta, '-');
210
+      lv_ta_set_cursor_pos(ext->ta, cur + 1);
211
+    }
212
+  }
213
+  else {
214
+    lv_ta_add_text(ext->ta, txt);
215
+  }
216
+}
217
+
218
+void lv_draw_keyboard() {
219
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != KEY_BOARD_UI) {
220
+    disp_state_stack._disp_index++;
221
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = KEY_BOARD_UI;
222
+  }
223
+  disp_state = KEY_BOARD_UI;
224
+
225
+  scr = lv_obj_create(NULL, NULL);
226
+
227
+  lv_obj_set_style(scr, &tft_style_scr);
228
+  lv_scr_load(scr);
229
+  lv_obj_clean(scr);
230
+
231
+  lv_refr_now(lv_refr_get_disp_refreshing());
232
+
233
+  /*Create styles for the keyboard*/
234
+  static lv_style_t rel_style, pr_style;
235
+
236
+  lv_style_copy(&rel_style, &lv_style_btn_rel);
237
+  rel_style.body.radius = 0;
238
+  rel_style.body.border.width = 1;
239
+  rel_style.body.main_color = lv_color_make(0xa9, 0x62, 0x1d);
240
+  rel_style.body.grad_color = lv_color_make(0xa7, 0x59, 0x0e);
241
+
242
+  lv_style_copy(&pr_style, &lv_style_btn_pr);
243
+  pr_style.body.radius = 0;
244
+  pr_style.body.border.width = 1;
245
+  pr_style.body.main_color = lv_color_make(0x72, 0x42, 0x15);
246
+  pr_style.body.grad_color = lv_color_make(0x6a, 0x3a, 0x0c);
247
+
248
+  /*Create a keyboard and apply the styles*/
249
+  lv_obj_t *kb = lv_kb_create(scr, NULL);
250
+  lv_obj_set_event_cb(kb, lv_kb_event_cb);
251
+  lv_kb_set_cursor_manage(kb, true);
252
+  lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight);
253
+  lv_kb_set_style(kb, LV_KB_STYLE_BTN_REL, &rel_style);
254
+  lv_kb_set_style(kb, LV_KB_STYLE_BTN_PR, &pr_style);
255
+  #if HAS_ROTARY_ENCODER
256
+    if (gCfgItems.encoder_enable) {
257
+      //lv_group_add_obj(g, kb);
258
+      //lv_group_set_editing(g, true);
259
+    }
260
+  #endif
261
+
262
+  /*Create a text area. The keyboard will write here*/
263
+  lv_obj_t *ta = lv_ta_create(scr, NULL);
264
+  lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
265
+  if (keyboard_value == gcodeCommand) {
266
+    get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
267
+    public_buf_m[sizeof(public_buf_m)-1] = 0;
268
+    lv_ta_set_text(ta, public_buf_m);
269
+  }
270
+  else {
271
+    lv_ta_set_text(ta, "");
272
+  }
273
+
274
+  /*Assign the text area to the keyboard*/
275
+  lv_kb_set_ta(kb, ta);
276
+}
277
+
278
+void lv_clear_keyboard() {
279
+  #if HAS_ROTARY_ENCODER
280
+    if (gCfgItems.encoder_enable) { /* lv_group_remove_all_objs(g); */ }
281
+  #endif
282
+  lv_obj_del(scr);
283
+}
284
+
285
+
286
+#endif  // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.h View File

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

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

@@ -49,6 +49,7 @@
49 49
 
50 50
 static void disp_language(uint8_t language, uint8_t state);
51 51
 
52
+extern lv_group_t * g;
52 53
 static lv_obj_t * scr;
53 54
 static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU;
54 55
 static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack;
@@ -61,9 +62,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
61 62
       }
62 63
       else if (event == LV_EVENT_RELEASED) {
63 64
         disp_language(gCfgItems.language, UNSELECTED);
64
-        lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn_sel.bin", 0);
65
+        lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn_sel.bin");
66
+        lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn_sel.bin");
67
+        lv_obj_refresh_ext_draw_pad(buttonCN);
65 68
         gCfgItems.language = LANG_SIMPLE_CHINESE;
66
-        gCfg_to_spiFlah();
69
+        update_spi_flash();
67 70
         disp_language_init();
68 71
       }
69 72
       break;
@@ -73,9 +76,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
73 76
       }
74 77
       else if (event == LV_EVENT_RELEASED) {
75 78
         disp_language(gCfgItems.language, UNSELECTED);
76
-        lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn_sel.bin", 0);
79
+        lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn_sel.bin");
80
+        lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn_sel.bin");
81
+        lv_obj_refresh_ext_draw_pad(buttonT_CN);
77 82
         gCfgItems.language = LANG_COMPLEX_CHINESE;
78
-        gCfg_to_spiFlah();
83
+        update_spi_flash();
79 84
         disp_language_init();
80 85
       }
81 86
       break;
@@ -85,9 +90,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
85 90
       }
86 91
       else if (event == LV_EVENT_RELEASED) {
87 92
         disp_language(gCfgItems.language, UNSELECTED);
88
-        lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english_sel.bin", 0);
93
+        lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english_sel.bin");
94
+        lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english_sel.bin");
95
+        lv_obj_refresh_ext_draw_pad(buttonEN);
89 96
         gCfgItems.language = LANG_ENGLISH;
90
-        gCfg_to_spiFlah();
97
+        update_spi_flash();
91 98
         disp_language_init();
92 99
       }
93 100
       break;
@@ -97,9 +104,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
97 104
       }
98 105
       else if (event == LV_EVENT_RELEASED) {
99 106
         disp_language(gCfgItems.language, UNSELECTED);
100
-        lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian_sel.bin", 0);
107
+        lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian_sel.bin");
108
+        lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian_sel.bin");
109
+        lv_obj_refresh_ext_draw_pad(buttonRU);
101 110
         gCfgItems.language = LANG_RUSSIAN;
102
-        gCfg_to_spiFlah();
111
+        update_spi_flash();
103 112
         disp_language_init();
104 113
       }
105 114
       break;
@@ -109,9 +118,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
109 118
       }
110 119
       else if (event == LV_EVENT_RELEASED) {
111 120
         disp_language(gCfgItems.language, UNSELECTED);
112
-        lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish_sel.bin", 0);
121
+        lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish_sel.bin");
122
+        lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish_sel.bin");
123
+        lv_obj_refresh_ext_draw_pad(buttonES);
113 124
         gCfgItems.language = LANG_SPANISH;
114
-        gCfg_to_spiFlah();
125
+        update_spi_flash();
115 126
         disp_language_init();
116 127
       }
117 128
       break;
@@ -121,9 +132,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
121 132
       }
122 133
       else if (event == LV_EVENT_RELEASED) {
123 134
         disp_language(gCfgItems.language, UNSELECTED);
124
-        lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french_sel.bin", 0);
135
+        lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french_sel.bin");
136
+        lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french_sel.bin");
137
+        lv_obj_refresh_ext_draw_pad(buttonFR);
125 138
         gCfgItems.language = LANG_FRENCH;
126
-        gCfg_to_spiFlah();
139
+        update_spi_flash();
127 140
         disp_language_init();
128 141
       }
129 142
       break;
@@ -133,9 +146,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
133 146
       }
134 147
       else if (event == LV_EVENT_RELEASED) {
135 148
         disp_language(gCfgItems.language, UNSELECTED);
136
-        lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_FR, "bmp_italy_sel.bin", 0);
149
+        lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy_sel.bin");
150
+        lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy_sel.bin");
151
+        lv_obj_refresh_ext_draw_pad(buttonIT);
137 152
         gCfgItems.language = LANG_ITALY;
138
-        gCfg_to_spiFlah();
153
+        update_spi_flash();
139 154
         disp_language_init();
140 155
       }
141 156
       break;
@@ -154,8 +169,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
154 169
         buttonFR   = NULL;
155 170
         buttonIT   = NULL;
156 171
         buttonBack = NULL;
157
-
158
-        lv_obj_del(scr);
172
+        lv_clear_language();
159 173
         lv_draw_set();
160 174
       }
161 175
       break;
@@ -172,42 +186,42 @@ static void disp_language(uint8_t language, uint8_t state) {
172 186
   switch (language) {
173 187
     case LANG_SIMPLE_CHINESE:
174 188
       id = ID_CN;
175
-      strcpy_P(public_buf_l, PSTR("bmp_simplified_cn"));
189
+      strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
176 190
       obj = buttonCN;
177 191
       break;
178 192
     case LANG_COMPLEX_CHINESE:
179 193
       id = ID_T_CN;
180
-      strcpy_P(public_buf_l, PSTR("bmp_traditional_cn"));
194
+      strcpy_P(public_buf_l, PSTR("F:/bmp_traditional_cn"));
181 195
       obj = buttonT_CN;
182 196
       break;
183 197
     case LANG_ENGLISH:
184 198
       id = ID_EN;
185
-      strcpy_P(public_buf_l, PSTR("bmp_english"));
199
+      strcpy_P(public_buf_l, PSTR("F:/bmp_english"));
186 200
       obj = buttonEN;
187 201
       break;
188 202
     case LANG_RUSSIAN:
189 203
       id = ID_RU;
190
-      strcpy_P(public_buf_l, PSTR("bmp_russian"));
204
+      strcpy_P(public_buf_l, PSTR("F:/bmp_russian"));
191 205
       obj = buttonRU;
192 206
       break;
193 207
     case LANG_SPANISH:
194 208
       id = ID_ES;
195
-      strcpy_P(public_buf_l, PSTR("bmp_spanish"));
209
+      strcpy_P(public_buf_l, PSTR("F:/bmp_spanish"));
196 210
       obj = buttonES;
197 211
       break;
198 212
     case LANG_FRENCH:
199 213
       id = ID_FR;
200
-      strcpy_P(public_buf_l, PSTR("bmp_french"));
214
+      strcpy_P(public_buf_l, PSTR("F:/bmp_french"));
201 215
       obj = buttonFR;
202 216
       break;
203 217
     case LANG_ITALY:
204 218
       id = ID_IT;
205
-      strcpy_P(public_buf_l, PSTR("bmp_italy"));
219
+      strcpy_P(public_buf_l, PSTR("F:/bmp_italy"));
206 220
       obj = buttonIT;
207 221
       break;
208 222
     default:
209 223
       id = ID_CN;
210
-      strcpy_P(public_buf_l, PSTR("bmp_simplified_cn"));
224
+      strcpy_P(public_buf_l, PSTR("F:/bmp_simplified_cn"));
211 225
       obj = buttonCN;
212 226
       break;
213 227
   }
@@ -216,7 +230,9 @@ static void disp_language(uint8_t language, uint8_t state) {
216 230
 
217 231
   strcat_P(public_buf_l, PSTR(".bin"));
218 232
 
219
-  lv_obj_set_event_cb_mks(obj, event_handler, id, public_buf_l, 0);
233
+  lv_obj_set_event_cb_mks(obj, event_handler, id, NULL, 0);
234
+  lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, public_buf_l);
235
+  lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, public_buf_l);
220 236
 
221 237
   if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
222 238
 }
@@ -244,8 +260,6 @@ void lv_draw_language(void) {
244 260
 
245 261
   lv_refr_now(lv_refr_get_disp_refreshing());
246 262
 
247
-  LV_IMG_DECLARE(bmp_pic);
248
-
249 263
   // Create image buttons
250 264
   buttonCN   = lv_imgbtn_create(scr, NULL);
251 265
   buttonT_CN = lv_imgbtn_create(scr, NULL);
@@ -256,52 +270,53 @@ void lv_draw_language(void) {
256 270
   buttonIT   = lv_imgbtn_create(scr, NULL);
257 271
   buttonBack = lv_imgbtn_create(scr, NULL);
258 272
 
259
-  lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, "bmp_simplified_cn.bin", 0);
260
-  lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, &bmp_pic);
261
-  lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, &bmp_pic);
273
+  lv_obj_set_event_cb_mks(buttonCN, event_handler, ID_CN, NULL, 0);
274
+  lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_REL, "F:/bmp_simplified_cn.bin");
275
+  lv_imgbtn_set_src(buttonCN, LV_BTN_STATE_PR, "F:/bmp_simplified_cn.bin");
262 276
   lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_PR, &tft_style_label_pre);
263 277
   lv_imgbtn_set_style(buttonCN, LV_BTN_STATE_REL, &tft_style_label_rel);
264 278
   lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
279
+
265 280
   #if 1
266
-    lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, "bmp_traditional_cn.bin", 0);
267
-    lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, &bmp_pic);
268
-    lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, &bmp_pic);
281
+    lv_obj_set_event_cb_mks(buttonT_CN, event_handler, ID_T_CN, NULL, 0);
282
+    lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_REL, "F:/bmp_traditional_cn.bin");
283
+    lv_imgbtn_set_src(buttonT_CN, LV_BTN_STATE_PR, "F:/bmp_traditional_cn.bin");
269 284
     lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_PR, &tft_style_label_pre);
270 285
     lv_imgbtn_set_style(buttonT_CN, LV_BTN_STATE_REL, &tft_style_label_rel);
271 286
 
272
-    lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, "bmp_english.bin", 0);
273
-    lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, &bmp_pic);
274
-    lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, &bmp_pic);
287
+    lv_obj_set_event_cb_mks(buttonEN, event_handler, ID_EN, NULL, 0);
288
+    lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_REL, "F:/bmp_english.bin");
289
+    lv_imgbtn_set_src(buttonEN, LV_BTN_STATE_PR, "F:/bmp_english.bin");
275 290
     lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_PR, &tft_style_label_pre);
276 291
     lv_imgbtn_set_style(buttonEN, LV_BTN_STATE_REL, &tft_style_label_rel);
277 292
 
278
-    lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, "bmp_russian.bin", 0);
279
-    lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, &bmp_pic);
280
-    lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, &bmp_pic);
293
+    lv_obj_set_event_cb_mks(buttonRU, event_handler, ID_RU, NULL, 0);
294
+    lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_REL, "F:/bmp_russian.bin");
295
+    lv_imgbtn_set_src(buttonRU, LV_BTN_STATE_PR, "F:/bmp_russian.bin");
281 296
     lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_PR, &tft_style_label_pre);
282 297
     lv_imgbtn_set_style(buttonRU, LV_BTN_STATE_REL, &tft_style_label_rel);
283 298
 
284
-    lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, "bmp_spanish.bin", 0);
285
-    lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, &bmp_pic);
286
-    lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, &bmp_pic);
299
+    lv_obj_set_event_cb_mks(buttonES, event_handler, ID_ES, NULL, 0);
300
+    lv_imgbtn_set_src(buttonES, LV_BTN_STATE_REL, "F:/bmp_spanish.bin");
301
+    lv_imgbtn_set_src(buttonES, LV_BTN_STATE_PR, "F:/bmp_spanish.bin");
287 302
     lv_imgbtn_set_style(buttonES, LV_BTN_STATE_PR, &tft_style_label_pre);
288 303
     lv_imgbtn_set_style(buttonES, LV_BTN_STATE_REL, &tft_style_label_rel);
289 304
 
290
-    lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, "bmp_french.bin", 0);
291
-    lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, &bmp_pic);
292
-    lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, &bmp_pic);
305
+    lv_obj_set_event_cb_mks(buttonFR, event_handler, ID_FR, NULL, 0);
306
+    lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_REL, "F:/bmp_french.bin");
307
+    lv_imgbtn_set_src(buttonFR, LV_BTN_STATE_PR, "F:/bmp_french.bin");
293 308
     lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_PR, &tft_style_label_pre);
294 309
     lv_imgbtn_set_style(buttonFR, LV_BTN_STATE_REL, &tft_style_label_rel);
295 310
 
296
-    lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, "bmp_italy.bin", 0);
297
-    lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, &bmp_pic);
298
-    lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, &bmp_pic);
311
+    lv_obj_set_event_cb_mks(buttonIT, event_handler, ID_IT, NULL, 0);
312
+    lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_REL, "F:/bmp_italy.bin");
313
+    lv_imgbtn_set_src(buttonIT, LV_BTN_STATE_PR, "F:/bmp_italy.bin");
299 314
     lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_PR, &tft_style_label_pre);
300 315
     lv_imgbtn_set_style(buttonIT, LV_BTN_STATE_REL, &tft_style_label_rel);
301 316
 
302
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, "bmp_return.bin", 0);
303
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
304
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
317
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_L_RETURN, NULL, 0);
318
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
319
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
305 320
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
306 321
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
307 322
 
@@ -362,8 +377,25 @@ void lv_draw_language(void) {
362 377
     lv_label_set_text(label_Back, common_menu.text_back);
363 378
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
364 379
   }
380
+  #if HAS_ROTARY_ENCODER
381
+    if (gCfgItems.encoder_enable) {
382
+      lv_group_add_obj(g, buttonCN);
383
+      lv_group_add_obj(g, buttonT_CN);
384
+      lv_group_add_obj(g, buttonEN);
385
+      lv_group_add_obj(g, buttonRU);
386
+      lv_group_add_obj(g, buttonES);
387
+      lv_group_add_obj(g, buttonFR);
388
+      lv_group_add_obj(g, buttonIT);
389
+      lv_group_add_obj(g, buttonBack);
390
+    }
391
+  #endif
365 392
 }
366 393
 
367
-void lv_clear_language() { lv_obj_del(scr); }
394
+void lv_clear_language() {
395
+  #if HAS_ROTARY_ENCODER
396
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
397
+  #endif
398
+  lv_obj_del(scr);
399
+}
368 400
 
369 401
 #endif // HAS_TFT_LVGL_UI

+ 261
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp View File

@@ -0,0 +1,261 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+
31
+extern lv_group_t * g;
32
+static lv_obj_t * scr;
33
+
34
+#define ID_LEVEL_RETURN           1
35
+#define ID_LEVEL_POSITION         2
36
+#define ID_LEVEL_POSITION_ARROW   3
37
+#define ID_LEVEL_COMMAND          4
38
+#define ID_LEVEL_COMMAND_ARROW    5
39
+#define ID_LEVEL_ZOFFSET          6
40
+#define ID_LEVEL_ZOFFSET_ARROW    7
41
+
42
+
43
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
44
+  switch (obj->mks_obj_id) {
45
+    case ID_LEVEL_RETURN:
46
+      if (event == LV_EVENT_CLICKED) {
47
+
48
+      }
49
+      else if (event == LV_EVENT_RELEASED) {
50
+        lv_clear_level_settings();
51
+        draw_return_ui();
52
+      }
53
+      break;
54
+    case ID_LEVEL_POSITION:
55
+      if (event == LV_EVENT_CLICKED) {
56
+
57
+      }
58
+      else if (event == LV_EVENT_RELEASED) {
59
+        lv_clear_level_settings();
60
+        lv_draw_manual_level_pos_settings();
61
+      }
62
+      break;
63
+    case ID_LEVEL_POSITION_ARROW:
64
+      if (event == LV_EVENT_CLICKED) {
65
+
66
+      }
67
+      else if (event == LV_EVENT_RELEASED) {
68
+        lv_clear_level_settings();
69
+        lv_draw_manual_level_pos_settings();
70
+      }
71
+      break;
72
+    case ID_LEVEL_COMMAND:
73
+      if (event == LV_EVENT_CLICKED) {
74
+
75
+      }
76
+      else if (event == LV_EVENT_RELEASED) {
77
+        keyboard_value = gcodeCommand;
78
+        lv_clear_level_settings();
79
+        lv_draw_keyboard();
80
+      }
81
+      break;
82
+    case ID_LEVEL_COMMAND_ARROW:
83
+      if (event == LV_EVENT_CLICKED) {
84
+
85
+      }
86
+      else if (event == LV_EVENT_RELEASED) {
87
+        keyboard_value = gcodeCommand;
88
+        lv_clear_level_settings();
89
+        lv_draw_keyboard();
90
+      }
91
+      break;
92
+    #if HAS_BED_PROBE
93
+      case ID_LEVEL_ZOFFSET:
94
+        if (event == LV_EVENT_CLICKED) {
95
+
96
+        }
97
+        else if (event == LV_EVENT_RELEASED) {
98
+          lv_clear_level_settings();
99
+          lv_draw_auto_level_offset_settings();
100
+        }
101
+        break;
102
+      case ID_LEVEL_ZOFFSET_ARROW:
103
+        if (event == LV_EVENT_CLICKED) {
104
+
105
+        }
106
+        else if (event == LV_EVENT_RELEASED) {
107
+          lv_clear_level_settings();
108
+          lv_draw_auto_level_offset_settings();
109
+        }
110
+        break;
111
+    #endif
112
+  }
113
+}
114
+
115
+void lv_draw_level_settings(void) {
116
+  lv_obj_t *buttonBack, *label_Back;
117
+  lv_obj_t *buttonPosition, *labelPosition, *buttonPositionNarrow;
118
+  lv_obj_t *buttonCommand, *labelCommand, *buttonCommandNarrow;
119
+  #if HAS_BED_PROBE
120
+    lv_obj_t *buttonZoffset, *labelZoffset, *buttonZoffsetNarrow;
121
+    lv_obj_t * line3;
122
+  #endif
123
+  lv_obj_t * line1, * line2;
124
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) {
125
+    disp_state_stack._disp_index++;
126
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI;
127
+  }
128
+  disp_state = LEVELING_PARA_UI;
129
+
130
+  scr = lv_obj_create(NULL, NULL);
131
+
132
+  lv_obj_set_style(scr, &tft_style_scr);
133
+  lv_scr_load(scr);
134
+  lv_obj_clean(scr);
135
+
136
+  lv_obj_t * title = lv_label_create(scr, NULL);
137
+  lv_obj_set_style(title, &tft_style_label_rel);
138
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
139
+  lv_label_set_text(title, machine_menu.LevelingParaConfTitle);
140
+
141
+  lv_refr_now(lv_refr_get_disp_refreshing());
142
+
143
+
144
+  buttonPosition = lv_btn_create(scr, NULL);                                   /*Add a button the current screen*/
145
+  lv_obj_set_pos(buttonPosition, PARA_UI_POS_X, PARA_UI_POS_Y);                /*Set its position*/
146
+  lv_obj_set_size(buttonPosition, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);             /*Set its size*/
147
+  lv_obj_set_event_cb_mks(buttonPosition, event_handler, ID_LEVEL_POSITION, NULL, 0);
148
+  lv_btn_set_style(buttonPosition, LV_BTN_STYLE_REL, &tft_style_label_rel);    /*Set the button's released style*/
149
+  lv_btn_set_style(buttonPosition, LV_BTN_STYLE_PR, &tft_style_label_pre);     /*Set the button's pressed style*/
150
+  lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF);
151
+  labelPosition = lv_label_create(buttonPosition, NULL);                       /*Add a label to the button*/
152
+
153
+  #if HAS_ROTARY_ENCODER
154
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPosition);
155
+  #endif
156
+
157
+  buttonPositionNarrow = lv_imgbtn_create(scr, NULL);
158
+  lv_obj_set_pos(buttonPositionNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
159
+  lv_obj_set_event_cb_mks(buttonPositionNarrow, event_handler, ID_LEVEL_POSITION_ARROW, NULL, 0);
160
+  lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
161
+  lv_imgbtn_set_src(buttonPositionNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
162
+  lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
163
+  lv_imgbtn_set_style(buttonPositionNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
164
+  lv_btn_set_layout(buttonPositionNarrow, LV_LAYOUT_OFF);
165
+
166
+  line1 = lv_line_create(scr, NULL);
167
+  lv_ex_line(line1, line_points[0]);
168
+
169
+  buttonCommand = lv_btn_create(scr, NULL);
170
+  lv_obj_set_pos(buttonCommand, PARA_UI_POS_X, PARA_UI_POS_Y * 2);
171
+  lv_obj_set_size(buttonCommand, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
172
+  lv_obj_set_event_cb_mks(buttonCommand, event_handler, ID_LEVEL_COMMAND, NULL, 0);
173
+  lv_btn_set_style(buttonCommand, LV_BTN_STYLE_REL, &tft_style_label_rel);
174
+  lv_btn_set_style(buttonCommand, LV_BTN_STYLE_PR, &tft_style_label_pre);
175
+  lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF);
176
+  labelCommand = lv_label_create(buttonCommand, NULL);
177
+
178
+  #if HAS_ROTARY_ENCODER
179
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand);
180
+  #endif
181
+
182
+  buttonCommandNarrow = lv_imgbtn_create(scr, NULL);
183
+  lv_obj_set_pos(buttonCommandNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
184
+  lv_obj_set_event_cb_mks(buttonCommandNarrow, event_handler, ID_LEVEL_COMMAND_ARROW, NULL, 0);
185
+  lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
186
+  lv_imgbtn_set_src(buttonCommandNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
187
+  lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
188
+  lv_imgbtn_set_style(buttonCommandNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
189
+  lv_btn_set_layout(buttonCommandNarrow, LV_LAYOUT_OFF);
190
+
191
+  line2 = lv_line_create(scr, NULL);
192
+  lv_ex_line(line2, line_points[1]);
193
+
194
+  #if HAS_BED_PROBE
195
+
196
+    buttonZoffset = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
197
+    lv_obj_set_pos(buttonZoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
198
+    lv_obj_set_size(buttonZoffset, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
199
+    lv_obj_set_event_cb_mks(buttonZoffset, event_handler, ID_LEVEL_ZOFFSET, NULL, 0);
200
+    lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
201
+    lv_btn_set_style(buttonZoffset, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
202
+    lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF);
203
+    labelZoffset = lv_label_create(buttonZoffset, NULL);                      /*Add a label to the button*/
204
+
205
+    #if HAS_ROTARY_ENCODER
206
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZoffset);
207
+    #endif
208
+
209
+    buttonZoffsetNarrow = lv_imgbtn_create(scr, NULL);
210
+    lv_obj_set_pos(buttonZoffsetNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
211
+    lv_obj_set_event_cb_mks(buttonZoffsetNarrow, event_handler, ID_LEVEL_ZOFFSET_ARROW, NULL, 0);
212
+    lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
213
+    lv_imgbtn_set_src(buttonZoffsetNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
214
+    lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
215
+    lv_imgbtn_set_style(buttonZoffsetNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
216
+    lv_btn_set_layout(buttonZoffsetNarrow, LV_LAYOUT_OFF);
217
+
218
+    line3 = lv_line_create(scr, NULL);
219
+    lv_ex_line(line3, line_points[2]);
220
+
221
+  #endif // HAS_BED_PROBE
222
+
223
+  buttonBack = lv_imgbtn_create(scr, NULL);
224
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_LEVEL_RETURN, NULL, 0);
225
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
226
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
227
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
228
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
229
+  #if HAS_ROTARY_ENCODER
230
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
231
+  #endif
232
+
233
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
234
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
235
+  label_Back = lv_label_create(buttonBack, NULL);
236
+
237
+  if (gCfgItems.multiple_language != 0) {
238
+    lv_label_set_text(label_Back, common_menu.text_back);
239
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
240
+
241
+    lv_label_set_text(labelPosition, machine_menu.LevelingManuPosConf);
242
+    lv_obj_align(labelPosition, buttonPosition, LV_ALIGN_IN_LEFT_MID, 0, 0);
243
+
244
+    lv_label_set_text(labelCommand, machine_menu.LevelingAutoCommandConf);
245
+    lv_obj_align(labelCommand, buttonCommand, LV_ALIGN_IN_LEFT_MID, 0, 0);
246
+    #if HAS_BED_PROBE
247
+      lv_label_set_text(labelZoffset, machine_menu.LevelingAutoZoffsetConf);
248
+      lv_obj_align(labelZoffset, buttonZoffset, LV_ALIGN_IN_LEFT_MID, 0, 0);
249
+    #endif
250
+  }
251
+
252
+}
253
+
254
+void lv_clear_level_settings() {
255
+  #if HAS_ROTARY_ENCODER
256
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
257
+  #endif
258
+  lv_obj_del(scr);
259
+}
260
+
261
+#endif // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.h View File

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

+ 86
- 28
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp View File

@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "../../../../MarlinCore.h"
30 30
 
31
+extern lv_group_t * g;
31 32
 static lv_obj_t * scr;
32 33
 
33 34
 #define ID_PARA_RETURN        1
@@ -35,8 +36,10 @@ static lv_obj_t * scr;
35 36
 #define ID_PARA_MACHINE_ARROW 3
36 37
 #define ID_PARA_MOTOR         4
37 38
 #define ID_PARA_MOTOR_ARROW   5
38
-#define ID_PARA_ADVANCE       6
39
-#define ID_PARA_ADVANCE_ARROW 7
39
+#define ID_PARA_LEVEL         6
40
+#define ID_PARA_LEVEL_ARROW   7
41
+#define ID_PARA_ADVANCE       8
42
+#define ID_PARA_ADVANCE_ARROW 9
40 43
 
41 44
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
42 45
   switch (obj->mks_obj_id) {
@@ -85,6 +88,24 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
85 88
         lv_draw_motor_settings();
86 89
       }
87 90
       break;
91
+    case ID_PARA_LEVEL:
92
+      if (event == LV_EVENT_CLICKED) {
93
+
94
+      }
95
+      else if (event == LV_EVENT_RELEASED) {
96
+        lv_clear_machine_para();
97
+        lv_draw_level_settings();
98
+      }
99
+      break;
100
+    case ID_PARA_LEVEL_ARROW:
101
+      if (event == LV_EVENT_CLICKED) {
102
+
103
+      }
104
+      else if (event == LV_EVENT_RELEASED) {
105
+        lv_clear_machine_para();
106
+        lv_draw_level_settings();
107
+      }
108
+      break;
88 109
     case ID_PARA_ADVANCE:
89 110
       if (event == LV_EVENT_CLICKED) {
90 111
 
@@ -110,8 +131,9 @@ void lv_draw_machine_para(void) {
110 131
   lv_obj_t *buttonBack, *label_Back;
111 132
   lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow;
112 133
   lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow;
134
+  lv_obj_t *buttonLevel, *labelLevel, *buttonLevelNarrow;
113 135
   lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow;
114
-  lv_obj_t * line1, * line2, * line3;
136
+  lv_obj_t * line1, * line2, * line3, * line4;
115 137
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
116 138
     disp_state_stack._disp_index++;
117 139
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
@@ -131,9 +153,6 @@ void lv_draw_machine_para(void) {
131 153
 
132 154
   lv_refr_now(lv_refr_get_disp_refreshing());
133 155
 
134
-  LV_IMG_DECLARE(bmp_para_back);
135
-  LV_IMG_DECLARE(bmp_para_arrow);
136
-
137 156
   buttonMachine = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
138 157
   lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
139 158
   lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
@@ -146,9 +165,9 @@ void lv_draw_machine_para(void) {
146 165
 
147 166
   buttonMachineNarrow = lv_imgbtn_create(scr, NULL);
148 167
   lv_obj_set_pos(buttonMachineNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
149
-  lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, "bmp_arrow.bin", 0);
150
-  lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
151
-  lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
168
+  lv_obj_set_event_cb_mks(buttonMachineNarrow, event_handler, ID_PARA_MACHINE_ARROW, NULL, 0);
169
+  lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
170
+  lv_imgbtn_set_src(buttonMachineNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
152 171
   lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
153 172
   lv_imgbtn_set_style(buttonMachineNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
154 173
   lv_btn_set_layout(buttonMachineNarrow, LV_LAYOUT_OFF);
@@ -168,9 +187,9 @@ void lv_draw_machine_para(void) {
168 187
 
169 188
   buttonMotorNarrow = lv_imgbtn_create(scr, NULL);
170 189
   lv_obj_set_pos(buttonMotorNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
171
-  lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, "bmp_arrow.bin", 0);
172
-  lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
173
-  lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
190
+  lv_obj_set_event_cb_mks(buttonMotorNarrow, event_handler, ID_PARA_MOTOR_ARROW, NULL, 0);
191
+  lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
192
+  lv_imgbtn_set_src(buttonMotorNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
174 193
   lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
175 194
   lv_imgbtn_set_style(buttonMotorNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
176 195
   lv_btn_set_layout(buttonMotorNarrow, LV_LAYOUT_OFF);
@@ -178,8 +197,30 @@ void lv_draw_machine_para(void) {
178 197
   line2 = lv_line_create(scr, NULL);
179 198
   lv_ex_line(line2, line_points[1]);
180 199
 
200
+  buttonLevel = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
201
+  lv_obj_set_pos(buttonLevel, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
202
+  lv_obj_set_size(buttonLevel, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
203
+  //lv_obj_set_event_cb(buttonMotor, event_handler);
204
+  lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_PARA_LEVEL, NULL, 0);
205
+  lv_btn_set_style(buttonLevel, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
206
+  lv_btn_set_style(buttonLevel, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
207
+  lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
208
+  labelLevel = lv_label_create(buttonLevel, NULL);                      /*Add a label to the button*/
209
+
210
+  buttonLevelNarrow = lv_imgbtn_create(scr, NULL);
211
+  lv_obj_set_pos(buttonLevelNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
212
+  lv_obj_set_event_cb_mks(buttonLevelNarrow, event_handler, ID_PARA_LEVEL_ARROW, NULL, 0);
213
+  lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
214
+  lv_imgbtn_set_src(buttonLevelNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
215
+  lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
216
+  lv_imgbtn_set_style(buttonLevelNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
217
+  lv_btn_set_layout(buttonLevelNarrow, LV_LAYOUT_OFF);
218
+
219
+  line3 = lv_line_create(scr, NULL);
220
+  lv_ex_line(line3, line_points[2]);
221
+
181 222
   buttonAdvance = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
182
-  lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
223
+  lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 4);          /*Set its position*/
183 224
   lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
184 225
   //lv_obj_set_event_cb(buttonMotor, event_handler);
185 226
   lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0);
@@ -189,44 +230,61 @@ void lv_draw_machine_para(void) {
189 230
   labelAdvance = lv_label_create(buttonAdvance, NULL);                      /*Add a label to the button*/
190 231
 
191 232
   buttonAdvanceNarrow = lv_imgbtn_create(scr, NULL);
192
-  lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
193
-  lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, "bmp_arrow.bin", 0);
194
-  lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
195
-  lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
233
+  lv_obj_set_pos(buttonAdvanceNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V);
234
+  lv_obj_set_event_cb_mks(buttonAdvanceNarrow, event_handler, ID_PARA_ADVANCE_ARROW, NULL, 0);
235
+  lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
236
+  lv_imgbtn_set_src(buttonAdvanceNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
196 237
   lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
197 238
   lv_imgbtn_set_style(buttonAdvanceNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
198 239
   lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
199 240
 
200
-  line3 = lv_line_create(scr, NULL);
201
-  lv_ex_line(line3, line_points[2]);
241
+  line4 = lv_line_create(scr, NULL);
242
+  lv_ex_line(line4, line_points[3]);
202 243
 
203 244
   buttonBack = lv_imgbtn_create(scr, NULL);
204
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, "bmp_back70x40.bin", 0);
205
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
206
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
245
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PARA_RETURN, NULL, 0);
246
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
247
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
207 248
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
208 249
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
209 250
 
210
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
251
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y);
211 252
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
212 253
   label_Back = lv_label_create(buttonBack, NULL);
213 254
 
214 255
   if (gCfgItems.multiple_language != 0) {
215 256
     lv_label_set_text(label_Back, common_menu.text_back);
216
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
257
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -2);
217 258
 
218 259
     lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting);
219
-    lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, 0);
260
+    lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, -3);
220 261
 
221 262
     lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting);
222
-    lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, 0);
263
+    lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, -3);
264
+
265
+    lv_label_set_text(labelLevel, MachinePara_menu.leveling);
266
+    lv_obj_align(labelLevel, buttonLevel, LV_ALIGN_IN_LEFT_MID, 0, -3);
223 267
 
224 268
     lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting);
225
-    lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, 0);
269
+    lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, -3);
226 270
   }
271
+  #if HAS_ROTARY_ENCODER
272
+    if (gCfgItems.encoder_enable) {
273
+      lv_group_add_obj(g, buttonMachine);
274
+      lv_group_add_obj(g, buttonMotor);
275
+      lv_group_add_obj(g, buttonLevel);
276
+      lv_group_add_obj(g, buttonAdvance);
277
+      lv_group_add_obj(g, buttonBack);
278
+    }
279
+  #endif
227 280
 
228 281
 }
229 282
 
230
-void lv_clear_machine_para() { lv_obj_del(scr); }
283
+void lv_clear_machine_para() {
284
+  #if HAS_ROTARY_ENCODER
285
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
286
+  #endif
287
+  lv_obj_del(scr);
288
+}
231 289
 
232 290
 #endif // HAS_TFT_LVGL_UI

+ 47
- 34
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp View File

@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "../../../../MarlinCore.h"
30 30
 
31
+extern lv_group_t * g;
31 32
 static lv_obj_t * scr;
32 33
 
33 34
 #define ID_MACHINE_RETURN             1
@@ -138,24 +139,21 @@ void lv_draw_machine_settings(void) {
138 139
 
139 140
   lv_refr_now(lv_refr_get_disp_refreshing());
140 141
 
141
-  LV_IMG_DECLARE(bmp_para_back);
142
-  LV_IMG_DECLARE(bmp_para_arrow);
143
-
144
-  buttonAcceleration = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
145
-  lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y);             /*Set its position*/
146
-  lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          /*Set its size*/
142
+  buttonAcceleration = lv_btn_create(scr, NULL);                                // Add a button the current screen
143
+  lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y);             // Set its position
144
+  lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          // Set its size
147 145
   //lv_obj_set_event_cb(buttonMachine, event_handler);
148 146
   lv_obj_set_event_cb_mks(buttonAcceleration, event_handler, ID_MACHINE_ACCELERATION, NULL, 0);
149
-  lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
150
-  lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
147
+  lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_REL, &tft_style_label_rel); // Set the button's released style
148
+  lv_btn_set_style(buttonAcceleration, LV_BTN_STYLE_PR, &tft_style_label_pre);  // Set the button's pressed style
151 149
   lv_btn_set_layout(buttonAcceleration, LV_LAYOUT_OFF);
152
-  labelAcceleration = lv_label_create(buttonAcceleration, NULL);                /*Add a label to the button*/
150
+  labelAcceleration = lv_label_create(buttonAcceleration, NULL);                // Add a label to the button
153 151
 
154 152
   buttonAccelerationNarrow = lv_imgbtn_create(scr, NULL);
155 153
   lv_obj_set_pos(buttonAccelerationNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
156
-  lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, "bmp_arrow.bin", 0);
157
-  lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
158
-  lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
154
+  lv_obj_set_event_cb_mks(buttonAccelerationNarrow, event_handler, ID_MACHINE_ACCELERATION_ARROW, NULL, 0);
155
+  lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
156
+  lv_imgbtn_set_src(buttonAccelerationNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
159 157
   lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
160 158
   lv_imgbtn_set_style(buttonAccelerationNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
161 159
   lv_btn_set_layout(buttonAccelerationNarrow, LV_LAYOUT_OFF);
@@ -163,21 +161,21 @@ void lv_draw_machine_settings(void) {
163 161
   line1 = lv_line_create(lv_scr_act(), NULL);
164 162
   lv_ex_line(line1, line_points[0]);
165 163
 
166
-  buttonMaxFeedrate = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
167
-  lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
168
-  lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
164
+  buttonMaxFeedrate = lv_btn_create(scr, NULL);                                 // Add a button the current screen
165
+  lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          // Set its position
166
+  lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           // Set its size
169 167
   //lv_obj_set_event_cb(buttonMachine, event_handler);
170 168
   lv_obj_set_event_cb_mks(buttonMaxFeedrate, event_handler, ID_MACHINE_FEEDRATE, NULL, 0);
171
-  lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
172
-  lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
169
+  lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_REL, &tft_style_label_rel);  // Set the button's released style
170
+  lv_btn_set_style(buttonMaxFeedrate, LV_BTN_STYLE_PR, &tft_style_label_pre);   // Set the button's pressed style
173 171
   lv_btn_set_layout(buttonMaxFeedrate, LV_LAYOUT_OFF);
174
-  labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL);                  /*Add a label to the button*/
172
+  labelMaxFeedrate = lv_label_create(buttonMaxFeedrate, NULL);                  // Add a label to the button
175 173
 
176 174
   buttonMaxFeedrateNarrow = lv_imgbtn_create(scr, NULL);
177 175
   lv_obj_set_pos(buttonMaxFeedrateNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
178
-  lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, "bmp_arrow.bin", 0);
179
-  lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
180
-  lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
176
+  lv_obj_set_event_cb_mks(buttonMaxFeedrateNarrow, event_handler, ID_MACHINE_FEEDRATE_ARROW, NULL, 0);
177
+  lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
178
+  lv_imgbtn_set_src(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
181 179
   lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
182 180
   lv_imgbtn_set_style(buttonMaxFeedrateNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
183 181
   lv_btn_set_layout(buttonMaxFeedrateNarrow, LV_LAYOUT_OFF);
@@ -186,21 +184,21 @@ void lv_draw_machine_settings(void) {
186 184
   lv_ex_line(line2, line_points[1]);
187 185
 
188 186
   #if HAS_CLASSIC_JERK
189
-    buttonJerk = lv_btn_create(scr, NULL);                                      /*Add a button the current screen*/
190
-    lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3);               /*Set its position*/
191
-    lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                /*Set its size*/
187
+    buttonJerk = lv_btn_create(scr, NULL);                                      // Add a button the current screen
188
+    lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3);               // Set its position
189
+    lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                // Set its size
192 190
     //lv_obj_set_event_cb(buttonMotor, event_handler);
193 191
     lv_obj_set_event_cb_mks(buttonJerk, event_handler, ID_MACHINE_JERK, NULL, 0);
194
-    lv_btn_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel);       /*Set the button's released style*/
195
-    lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre);        /*Set the button's pressed style*/
192
+    lv_btn_set_style(buttonJerk, LV_BTN_STYLE_REL, &tft_style_label_rel);       // Set the button's released style
193
+    lv_btn_set_style(buttonJerk, LV_BTN_STYLE_PR, &tft_style_label_pre);        // Set the button's pressed style
196 194
     lv_btn_set_layout(buttonJerk, LV_LAYOUT_OFF);
197
-    labelJerk = lv_label_create(buttonJerk, NULL);                              /*Add a label to the button*/
195
+    labelJerk = lv_label_create(buttonJerk, NULL);                              // Add a label to the button
198 196
 
199 197
     buttonJerkNarrow = lv_imgbtn_create(scr, NULL);
200 198
     lv_obj_set_pos(buttonJerkNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
201
-    lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, "bmp_arrow.bin", 0);
202
-    lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
203
-    lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
199
+    lv_obj_set_event_cb_mks(buttonJerkNarrow, event_handler, ID_MACHINE_JERK_ARROW, NULL, 0);
200
+    lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
201
+    lv_imgbtn_set_src(buttonJerkNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
204 202
     lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
205 203
     lv_imgbtn_set_style(buttonJerkNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
206 204
     lv_btn_set_layout(buttonJerkNarrow, LV_LAYOUT_OFF);
@@ -210,9 +208,9 @@ void lv_draw_machine_settings(void) {
210 208
   #endif
211 209
 
212 210
   buttonBack = lv_imgbtn_create(scr, NULL);
213
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, "bmp_back70x40.bin", 0);
214
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
215
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
211
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MACHINE_RETURN, NULL, 0);
212
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
213
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
216 214
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
217 215
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
218 216
 
@@ -234,8 +232,23 @@ void lv_draw_machine_settings(void) {
234 232
       lv_obj_align(labelJerk, buttonJerk, LV_ALIGN_IN_LEFT_MID, 0, 0);
235 233
     #endif
236 234
   }
235
+  #if HAS_ROTARY_ENCODER
236
+    if (gCfgItems.encoder_enable) {
237
+      lv_group_add_obj(g, buttonAcceleration);
238
+      lv_group_add_obj(g, buttonMaxFeedrate);
239
+      #if HAS_CLASSIC_JERK
240
+        lv_group_add_obj(g, buttonJerk);
241
+      #endif
242
+      lv_group_add_obj(g, buttonBack);
243
+    }
244
+  #endif
237 245
 }
238 246
 
239
-void lv_clear_machine_settings() { lv_obj_del(scr); }
247
+void lv_clear_machine_settings() {
248
+  #if HAS_ROTARY_ENCODER
249
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
250
+  #endif
251
+  lv_obj_del(scr);
252
+}
240 253
 
241 254
 #endif // HAS_TFT_LVGL_UI

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

@@ -32,7 +32,7 @@
32 32
 #include "draw_ui.h"
33 33
 #include "../../../../gcode/queue.h"
34 34
 
35
-//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn;
35
+extern lv_group_t * g;
36 36
 static lv_obj_t * scr;
37 37
 
38 38
 #define ID_M_POINT1      1
@@ -59,7 +59,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
59 59
           queue.enqueue_now_P(PSTR("G1 Z10"));
60 60
 
61 61
           ZERO(public_buf_l);
62
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MIN_POS + 30);
62
+          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
63 63
           queue.enqueue_one_now(public_buf_l);
64 64
           queue.enqueue_now_P(PSTR("G1 Z0"));
65 65
         }
@@ -79,7 +79,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
79 79
           queue.enqueue_now_P(PSTR("G1 Z10"));
80 80
 
81 81
           ZERO(public_buf_l);
82
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MIN_POS + 30);
82
+          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
83 83
           queue.enqueue_one_now(public_buf_l);
84 84
           queue.enqueue_now_P(PSTR("G1 Z0"));
85 85
         }
@@ -99,7 +99,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
99 99
           queue.enqueue_now_P(PSTR("G1 Z10"));
100 100
 
101 101
           ZERO(public_buf_l);
102
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MAX_POS - 30, Y_MAX_POS - 30);
102
+          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
103 103
           queue.enqueue_one_now(public_buf_l);
104 104
           queue.enqueue_now_P(PSTR("G1 Z0"));
105 105
         }
@@ -120,7 +120,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
120 120
           queue.enqueue_now_P(PSTR("G1 Z10"));
121 121
 
122 122
           ZERO(public_buf_l);
123
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_MIN_POS + 30, Y_MAX_POS - 30);
123
+          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
124 124
           queue.enqueue_one_now(public_buf_l);
125 125
           queue.enqueue_now_P(PSTR("G1 Z0"));
126 126
         }
@@ -140,7 +140,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
140 140
           queue.enqueue_now_P(PSTR("G1 Z10"));
141 141
 
142 142
           ZERO(public_buf_l);
143
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), X_BED_SIZE / 2, Y_BED_SIZE / 2);
143
+          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
144 144
           queue.enqueue_one_now(public_buf_l);
145 145
           queue.enqueue_now_P(PSTR("G1 Z0"));
146 146
         }
@@ -159,7 +159,6 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
159 159
   }
160 160
 }
161 161
 
162
-
163 162
 void lv_draw_manualLevel(void) {
164 163
   lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5;
165 164
   lv_obj_t *buttonBack;
@@ -185,8 +184,6 @@ void lv_draw_manualLevel(void) {
185 184
 
186 185
   lv_refr_now(lv_refr_get_disp_refreshing());
187 186
 
188
-  LV_IMG_DECLARE(bmp_pic);
189
-
190 187
   // Create an Image button
191 188
   buttonPoint1 = lv_imgbtn_create(scr, NULL);
192 189
   buttonPoint2 = lv_imgbtn_create(scr, NULL);
@@ -195,40 +192,41 @@ void lv_draw_manualLevel(void) {
195 192
   buttonPoint5 = lv_imgbtn_create(scr, NULL);
196 193
   buttonBack   = lv_imgbtn_create(scr, NULL);
197 194
 
198
-  lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, "bmp_leveling1.bin", 0);
199
-  lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, &bmp_pic);
200
-  lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, &bmp_pic);
195
+  lv_obj_set_event_cb_mks(buttonPoint1, event_handler, ID_M_POINT1, NULL, 0);
196
+  lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_REL, "F:/bmp_leveling1.bin");
197
+  lv_imgbtn_set_src(buttonPoint1, LV_BTN_STATE_PR, "F:/bmp_leveling1.bin");
201 198
   lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_PR, &tft_style_label_pre);
202 199
   lv_imgbtn_set_style(buttonPoint1, LV_BTN_STATE_REL, &tft_style_label_rel);
203 200
   lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
201
+
204 202
   #if 1
205
-    lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, "bmp_leveling2.bin", 0);
206
-    lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, &bmp_pic);
207
-    lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, &bmp_pic);
203
+    lv_obj_set_event_cb_mks(buttonPoint2, event_handler, ID_M_POINT2, NULL, 0);
204
+    lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_REL, "F:/bmp_leveling2.bin");
205
+    lv_imgbtn_set_src(buttonPoint2, LV_BTN_STATE_PR, "F:/bmp_leveling2.bin");
208 206
     lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_PR, &tft_style_label_pre);
209 207
     lv_imgbtn_set_style(buttonPoint2, LV_BTN_STATE_REL, &tft_style_label_rel);
210 208
 
211
-    lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, "bmp_leveling3.bin", 0);
212
-    lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, &bmp_pic);
213
-    lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, &bmp_pic);
209
+    lv_obj_set_event_cb_mks(buttonPoint3, event_handler, ID_M_POINT3, NULL, 0);
210
+    lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_REL, "F:/bmp_leveling3.bin");
211
+    lv_imgbtn_set_src(buttonPoint3, LV_BTN_STATE_PR, "F:/bmp_leveling3.bin");
214 212
     lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_PR, &tft_style_label_pre);
215 213
     lv_imgbtn_set_style(buttonPoint3, LV_BTN_STATE_REL, &tft_style_label_rel);
216 214
 
217
-    lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, "bmp_leveling4.bin", 0);
218
-    lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, &bmp_pic);
219
-    lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, &bmp_pic);
215
+    lv_obj_set_event_cb_mks(buttonPoint4, event_handler, ID_M_POINT4, NULL, 0);
216
+    lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_REL, "F:/bmp_leveling4.bin");
217
+    lv_imgbtn_set_src(buttonPoint4, LV_BTN_STATE_PR, "F:/bmp_leveling4.bin");
220 218
     lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_PR, &tft_style_label_pre);
221 219
     lv_imgbtn_set_style(buttonPoint4, LV_BTN_STATE_REL, &tft_style_label_rel);
222 220
 
223
-    lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, "bmp_leveling5.bin", 0);
224
-    lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, &bmp_pic);
225
-    lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, &bmp_pic);
221
+    lv_obj_set_event_cb_mks(buttonPoint5, event_handler, ID_M_POINT5, NULL, 0);
222
+    lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_REL, "F:/bmp_leveling5.bin");
223
+    lv_imgbtn_set_src(buttonPoint5, LV_BTN_STATE_PR, "F:/bmp_leveling5.bin");
226 224
     lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_PR, &tft_style_label_pre);
227 225
     lv_imgbtn_set_style(buttonPoint5, LV_BTN_STATE_REL, &tft_style_label_rel);
228 226
 
229
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, "bmp_return.bin", 0);
230
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
231
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
227
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_RETURN, NULL, 0);
228
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
229
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
232 230
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
233 231
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
234 232
   #endif
@@ -274,8 +272,23 @@ void lv_draw_manualLevel(void) {
274 272
     lv_label_set_text(label_Back, common_menu.text_back);
275 273
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
276 274
   }
275
+  #if HAS_ROTARY_ENCODER
276
+    if (gCfgItems.encoder_enable) {
277
+      lv_group_add_obj(g, buttonPoint1);
278
+      lv_group_add_obj(g, buttonPoint2);
279
+      lv_group_add_obj(g, buttonPoint3);
280
+      lv_group_add_obj(g, buttonPoint4);
281
+      lv_group_add_obj(g, buttonPoint5);
282
+      lv_group_add_obj(g, buttonBack);
283
+    }
284
+  #endif
277 285
 }
278 286
 
279
-void lv_clear_manualLevel() { lv_obj_del(scr); }
287
+void lv_clear_manualLevel() {
288
+  #if HAS_ROTARY_ENCODER
289
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
290
+  #endif
291
+  lv_obj_del(scr);
292
+}
280 293
 
281 294
 #endif // HAS_TFT_LVGL_UI

+ 459
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp View File

@@ -0,0 +1,459 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#include "../../../../MarlinCore.h"
30
+#include "../../../../module/planner.h"
31
+
32
+extern lv_group_t * g;
33
+static lv_obj_t * scr;
34
+
35
+#define ID_MANUAL_POS_RETURN   1
36
+#define ID_MANUAL_POS_X1       2
37
+#define ID_MANUAL_POS_Y1       3
38
+#define ID_MANUAL_POS_X2       4
39
+#define ID_MANUAL_POS_Y2       5
40
+#define ID_MANUAL_POS_X3       6
41
+#define ID_MANUAL_POS_Y3       7
42
+#define ID_MANUAL_POS_X4       8
43
+#define ID_MANUAL_POS_Y4       9
44
+#define ID_MANUAL_POS_X5       10
45
+#define ID_MANUAL_POS_Y5       11
46
+#define ID_MANUAL_POS_DOWN     12
47
+#define ID_MANUAL_POS_UP       13
48
+
49
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
50
+  switch (obj->mks_obj_id) {
51
+    case ID_MANUAL_POS_RETURN:
52
+      if (event == LV_EVENT_CLICKED) {
53
+
54
+      }
55
+      else if (event == LV_EVENT_RELEASED) {
56
+        uiCfg.para_ui_page = 0;
57
+        lv_clear_manual_level_pos_settings();
58
+        draw_return_ui();
59
+      }
60
+      break;
61
+    case ID_MANUAL_POS_X1:
62
+      if (event == LV_EVENT_CLICKED) {
63
+
64
+      }
65
+      else if (event == LV_EVENT_RELEASED) {
66
+        value = level_pos_x1;
67
+        lv_clear_manual_level_pos_settings();
68
+        lv_draw_number_key();
69
+      }
70
+      break;
71
+    case ID_MANUAL_POS_Y1:
72
+      if (event == LV_EVENT_CLICKED) {
73
+
74
+      }
75
+      else if (event == LV_EVENT_RELEASED) {
76
+        value = level_pos_y1;
77
+        lv_clear_manual_level_pos_settings();
78
+        lv_draw_number_key();
79
+      }
80
+      break;
81
+    case ID_MANUAL_POS_X2:
82
+      if (event == LV_EVENT_CLICKED) {
83
+
84
+      }
85
+      else if (event == LV_EVENT_RELEASED) {
86
+        value = level_pos_x2;
87
+        lv_clear_manual_level_pos_settings();
88
+        lv_draw_number_key();
89
+      }
90
+      break;
91
+    case ID_MANUAL_POS_Y2:
92
+      if (event == LV_EVENT_CLICKED) {
93
+
94
+      }
95
+      else if (event == LV_EVENT_RELEASED) {
96
+        value = level_pos_y2;
97
+        lv_clear_manual_level_pos_settings();
98
+        lv_draw_number_key();
99
+      }
100
+      break;
101
+    case ID_MANUAL_POS_X3:
102
+      if (event == LV_EVENT_CLICKED) {
103
+
104
+      }
105
+      else if (event == LV_EVENT_RELEASED) {
106
+        value = level_pos_x3;
107
+        lv_clear_manual_level_pos_settings();
108
+        lv_draw_number_key();
109
+      }
110
+      break;
111
+    case ID_MANUAL_POS_Y3:
112
+      if (event == LV_EVENT_CLICKED) {
113
+
114
+      }
115
+      else if (event == LV_EVENT_RELEASED) {
116
+        value = level_pos_y3;
117
+        lv_clear_manual_level_pos_settings();
118
+        lv_draw_number_key();
119
+      }
120
+      break;
121
+    case ID_MANUAL_POS_X4:
122
+      if (event == LV_EVENT_CLICKED) {
123
+
124
+      }
125
+      else if (event == LV_EVENT_RELEASED) {
126
+        value = level_pos_x4;
127
+        lv_clear_manual_level_pos_settings();
128
+        lv_draw_number_key();
129
+      }
130
+      break;
131
+    case ID_MANUAL_POS_Y4:
132
+      if (event == LV_EVENT_CLICKED) {
133
+
134
+      }
135
+      else if (event == LV_EVENT_RELEASED) {
136
+        value = level_pos_y4;
137
+        lv_clear_manual_level_pos_settings();
138
+        lv_draw_number_key();
139
+      }
140
+      break;
141
+    case ID_MANUAL_POS_X5:
142
+      if (event == LV_EVENT_CLICKED) {
143
+
144
+      }
145
+      else if (event == LV_EVENT_RELEASED) {
146
+        value = level_pos_y5;
147
+        lv_clear_manual_level_pos_settings();
148
+        lv_draw_number_key();
149
+      }
150
+      break;
151
+    case ID_MANUAL_POS_Y5:
152
+      if (event == LV_EVENT_CLICKED) {
153
+
154
+      }
155
+      else if (event == LV_EVENT_RELEASED) {
156
+        value = level_pos_y5;
157
+        lv_clear_manual_level_pos_settings();
158
+        lv_draw_number_key();
159
+      }
160
+      break;
161
+    case ID_MANUAL_POS_UP:
162
+      if (event == LV_EVENT_CLICKED) {
163
+
164
+      }
165
+      else if (event == LV_EVENT_RELEASED) {
166
+        uiCfg.para_ui_page = 0;
167
+        lv_clear_manual_level_pos_settings();
168
+        lv_draw_manual_level_pos_settings();
169
+      }
170
+      break;
171
+    case ID_MANUAL_POS_DOWN:
172
+      if (event == LV_EVENT_CLICKED) {
173
+
174
+      }
175
+      else if (event == LV_EVENT_RELEASED) {
176
+        uiCfg.para_ui_page = 1;
177
+        lv_clear_manual_level_pos_settings();
178
+        lv_draw_manual_level_pos_settings();
179
+      }
180
+      break;
181
+  }
182
+}
183
+
184
+void lv_draw_manual_level_pos_settings(void) {
185
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
186
+  lv_obj_t *labelPoint1Text = NULL, *buttonX1Value = NULL, *labelX1Value = NULL;
187
+  lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL;
188
+  lv_obj_t *labelPoint2Text = NULL, *buttonX2Value = NULL, *labelX2Value = NULL;
189
+  lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL;
190
+  lv_obj_t *labelPoint3Text = NULL, *buttonX3Value = NULL, *labelX3Value = NULL;
191
+  lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL;
192
+  lv_obj_t *labelPoint4Text = NULL, *buttonX4Value = NULL, *labelX4Value = NULL;
193
+  lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL;
194
+  lv_obj_t *labelPoint5Text = NULL, *buttonX5Value = NULL, *labelX5Value = NULL;
195
+  lv_obj_t *buttonY5Value = NULL, *labelY5Value = NULL;
196
+  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
197
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) {
198
+    disp_state_stack._disp_index++;
199
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI;
200
+  }
201
+  disp_state = MANUAL_LEVELING_POSIGION_UI;
202
+
203
+  scr = lv_obj_create(NULL, NULL);
204
+
205
+  lv_obj_set_style(scr, &tft_style_scr);
206
+  lv_scr_load(scr);
207
+  lv_obj_clean(scr);
208
+
209
+  lv_obj_t * title = lv_label_create(scr, NULL);
210
+  lv_obj_set_style(title, &tft_style_label_rel);
211
+  lv_obj_set_pos(title, TITLE_XPOS, TITLE_YPOS);
212
+  lv_label_set_text(title, machine_menu.LevelingParaConfTitle);
213
+
214
+  lv_refr_now(lv_refr_get_disp_refreshing());
215
+
216
+  if (uiCfg.para_ui_page != 1) {
217
+    labelPoint1Text = lv_label_create(scr, NULL);
218
+    lv_obj_set_style(labelPoint1Text, &tft_style_label_rel);
219
+    lv_obj_set_pos(labelPoint1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
220
+    lv_label_set_text(labelPoint1Text, leveling_menu.position1);
221
+
222
+    buttonX1Value = lv_btn_create(scr, NULL);
223
+    lv_obj_set_pos(buttonX1Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
224
+    lv_obj_set_size(buttonX1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
225
+    lv_obj_set_event_cb_mks(buttonX1Value, event_handler, ID_MANUAL_POS_X1, NULL, 0);
226
+    lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_REL, &style_para_value);
227
+    lv_btn_set_style(buttonX1Value, LV_BTN_STYLE_PR, &style_para_value);
228
+    labelX1Value = lv_label_create(buttonX1Value, NULL);
229
+
230
+    buttonY1Value = lv_btn_create(scr, NULL);
231
+    lv_obj_set_pos(buttonY1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
232
+    lv_obj_set_size(buttonY1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
233
+    lv_obj_set_event_cb_mks(buttonY1Value, event_handler, ID_MANUAL_POS_Y1, NULL, 0);
234
+    lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_REL, &style_para_value);
235
+    lv_btn_set_style(buttonY1Value, LV_BTN_STYLE_PR, &style_para_value);
236
+    labelY1Value = lv_label_create(buttonY1Value, NULL);
237
+
238
+    line1 = lv_line_create(scr, NULL);
239
+    lv_ex_line(line1, line_points[0]);
240
+
241
+    labelPoint2Text = lv_label_create(scr, NULL);
242
+    lv_obj_set_style(labelPoint2Text, &tft_style_label_rel);
243
+    lv_obj_set_pos(labelPoint2Text, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
244
+    lv_label_set_text(labelPoint2Text, leveling_menu.position2);
245
+
246
+    buttonX2Value = lv_btn_create(scr, NULL);
247
+    lv_obj_set_pos(buttonX2Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
248
+    lv_obj_set_size(buttonX2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
249
+    lv_obj_set_event_cb_mks(buttonX2Value, event_handler, ID_MANUAL_POS_X2, NULL, 0);
250
+    lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_REL, &style_para_value);
251
+    lv_btn_set_style(buttonX2Value, LV_BTN_STYLE_PR, &style_para_value);
252
+    labelX2Value = lv_label_create(buttonX2Value, NULL);
253
+
254
+    buttonY2Value = lv_btn_create(scr, NULL);
255
+    lv_obj_set_pos(buttonY2Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2);
256
+    lv_obj_set_size(buttonY2Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
257
+    lv_obj_set_event_cb_mks(buttonY2Value, event_handler, ID_MANUAL_POS_Y2, NULL, 0);
258
+    lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_REL, &style_para_value);
259
+    lv_btn_set_style(buttonY2Value, LV_BTN_STYLE_PR, &style_para_value);
260
+    labelY2Value = lv_label_create(buttonY2Value, NULL);
261
+
262
+    line2 = lv_line_create(scr, NULL);
263
+    lv_ex_line(line2, line_points[1]);
264
+
265
+    labelPoint3Text = lv_label_create(scr, NULL);
266
+    lv_obj_set_style(labelPoint3Text, &tft_style_label_rel);
267
+    lv_obj_set_pos(labelPoint3Text, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
268
+    lv_label_set_text(labelPoint3Text, leveling_menu.position3);
269
+
270
+    buttonX3Value = lv_btn_create(scr, NULL);
271
+    lv_obj_set_pos(buttonX3Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
272
+    lv_obj_set_size(buttonX3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
273
+    lv_obj_set_event_cb_mks(buttonX3Value, event_handler, ID_MANUAL_POS_X3, NULL, 0);
274
+    lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_REL, &style_para_value);
275
+    lv_btn_set_style(buttonX3Value, LV_BTN_STYLE_PR, &style_para_value);
276
+    labelX3Value = lv_label_create(buttonX3Value, NULL);
277
+
278
+    buttonY3Value = lv_btn_create(scr, NULL);
279
+    lv_obj_set_pos(buttonY3Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2);
280
+    lv_obj_set_size(buttonY3Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
281
+    lv_obj_set_event_cb_mks(buttonY3Value, event_handler, ID_MANUAL_POS_Y3, NULL, 0);
282
+    lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_REL, &style_para_value);
283
+    lv_btn_set_style(buttonY3Value, LV_BTN_STYLE_PR, &style_para_value);
284
+    labelY3Value = lv_label_create(buttonY3Value, NULL);
285
+
286
+    line3 = lv_line_create(scr, NULL);
287
+    lv_ex_line(line3, line_points[2]);
288
+
289
+    labelPoint4Text = lv_label_create(scr, NULL);
290
+    lv_obj_set_style(labelPoint4Text, &tft_style_label_rel);
291
+    lv_obj_set_pos(labelPoint4Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
292
+    lv_label_set_text(labelPoint4Text, leveling_menu.position4);
293
+
294
+    buttonX4Value = lv_btn_create(scr, NULL);
295
+    lv_obj_set_pos(buttonX4Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
296
+    lv_obj_set_size(buttonX4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
297
+    lv_obj_set_event_cb_mks(buttonX4Value, event_handler, ID_MANUAL_POS_X4, NULL, 0);
298
+    lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_REL, &style_para_value);
299
+    lv_btn_set_style(buttonX4Value, LV_BTN_STYLE_PR, &style_para_value);
300
+    labelX4Value = lv_label_create(buttonX4Value, NULL);
301
+
302
+    buttonY4Value = lv_btn_create(scr, NULL);
303
+    lv_obj_set_pos(buttonY4Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2);
304
+    lv_obj_set_size(buttonY4Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
305
+    lv_obj_set_event_cb_mks(buttonY4Value, event_handler, ID_MANUAL_POS_Y4, NULL, 0);
306
+    lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_REL, &style_para_value);
307
+    lv_btn_set_style(buttonY4Value, LV_BTN_STYLE_PR, &style_para_value);
308
+    labelY4Value = lv_label_create(buttonY4Value, NULL);
309
+
310
+    line4 = lv_line_create(scr, NULL);
311
+    lv_ex_line(line4, line_points[3]);
312
+
313
+    buttonTurnPage = lv_btn_create(scr, NULL);
314
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_DOWN, NULL, 0);
315
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
316
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
317
+
318
+    #if HAS_ROTARY_ENCODER
319
+      if (gCfgItems.encoder_enable) {
320
+        lv_group_add_obj(g, buttonX1Value);
321
+        lv_group_add_obj(g, buttonY1Value);
322
+        lv_group_add_obj(g, buttonX2Value);
323
+        lv_group_add_obj(g, buttonY2Value);
324
+        lv_group_add_obj(g, buttonX3Value);
325
+        lv_group_add_obj(g, buttonY3Value);
326
+        lv_group_add_obj(g, buttonX4Value);
327
+        lv_group_add_obj(g, buttonY4Value);
328
+        lv_group_add_obj(g, buttonTurnPage);
329
+      }
330
+    #endif
331
+  }
332
+  else {
333
+    labelPoint5Text = lv_label_create(scr, NULL);
334
+    lv_obj_set_style(labelPoint5Text, &tft_style_label_rel);
335
+    lv_obj_set_pos(labelPoint5Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
336
+    lv_label_set_text(labelPoint5Text, leveling_menu.position5);
337
+
338
+    buttonX5Value = lv_btn_create(scr, NULL);
339
+    lv_obj_set_pos(buttonX5Value, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
340
+    lv_obj_set_size(buttonX5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
341
+    lv_obj_set_event_cb_mks(buttonX5Value, event_handler, ID_MANUAL_POS_X5, NULL, 0);
342
+    lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_REL, &style_para_value);
343
+    lv_btn_set_style(buttonX5Value, LV_BTN_STYLE_PR, &style_para_value);
344
+    labelX5Value = lv_label_create(buttonX5Value, NULL);
345
+
346
+    buttonY5Value = lv_btn_create(scr, NULL);
347
+    lv_obj_set_pos(buttonY5Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2);
348
+    lv_obj_set_size(buttonY5Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
349
+    lv_obj_set_event_cb_mks(buttonY5Value, event_handler, ID_MANUAL_POS_Y5, NULL, 0);
350
+    lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_REL, &style_para_value);
351
+    lv_btn_set_style(buttonY5Value, LV_BTN_STYLE_PR, &style_para_value);
352
+    labelY5Value = lv_label_create(buttonY5Value, NULL);
353
+
354
+    line1 = lv_line_create(scr, NULL);
355
+    lv_ex_line(line1, line_points[0]);
356
+
357
+    buttonTurnPage = lv_btn_create(scr, NULL);
358
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_UP, NULL, 0);
359
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
360
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
361
+
362
+    #if HAS_ROTARY_ENCODER
363
+      if (gCfgItems.encoder_enable) {
364
+        lv_group_add_obj(g, buttonX5Value);
365
+        lv_group_add_obj(g, buttonY5Value);
366
+        lv_group_add_obj(g, buttonTurnPage);
367
+      }
368
+    #endif
369
+  }
370
+
371
+  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
372
+  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
373
+  labelTurnPage = lv_label_create(buttonTurnPage, NULL);
374
+
375
+  buttonBack = lv_btn_create(scr, NULL);
376
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_POS_RETURN, NULL, 0);
377
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
378
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
379
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
380
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
381
+  label_Back = lv_label_create(buttonBack, NULL);
382
+
383
+  #if HAS_ROTARY_ENCODER
384
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
385
+  #endif
386
+
387
+  if (gCfgItems.multiple_language != 0) {
388
+    if (uiCfg.para_ui_page != 1) {
389
+      ZERO(public_buf_l);
390
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]);
391
+      lv_label_set_text(labelX1Value, public_buf_l);
392
+      lv_obj_align(labelX1Value, buttonX1Value, LV_ALIGN_CENTER, 0, 0);
393
+
394
+      ZERO(public_buf_l);
395
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][1]);
396
+      lv_label_set_text(labelY1Value, public_buf_l);
397
+      lv_obj_align(labelY1Value, buttonY1Value, LV_ALIGN_CENTER, 0, 0);
398
+
399
+      ZERO(public_buf_l);
400
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]);
401
+      lv_label_set_text(labelX2Value, public_buf_l);
402
+      lv_obj_align(labelX2Value, buttonX2Value, LV_ALIGN_CENTER, 0, 0);
403
+
404
+      ZERO(public_buf_l);
405
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][1]);
406
+      lv_label_set_text(labelY2Value, public_buf_l);
407
+      lv_obj_align(labelY2Value, buttonY2Value, LV_ALIGN_CENTER, 0, 0);
408
+
409
+      ZERO(public_buf_l);
410
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]);
411
+      lv_label_set_text(labelX3Value, public_buf_l);
412
+      lv_obj_align(labelX3Value, buttonX3Value, LV_ALIGN_CENTER, 0, 0);
413
+
414
+      ZERO(public_buf_l);
415
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][1]);
416
+      lv_label_set_text(labelY3Value, public_buf_l);
417
+      lv_obj_align(labelY3Value, buttonY3Value, LV_ALIGN_CENTER, 0, 0);
418
+
419
+      ZERO(public_buf_l);
420
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]);
421
+      lv_label_set_text(labelX4Value, public_buf_l);
422
+      lv_obj_align(labelX4Value, buttonX4Value, LV_ALIGN_CENTER, 0, 0);
423
+
424
+      ZERO(public_buf_l);
425
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][1]);
426
+      lv_label_set_text(labelY4Value, public_buf_l);
427
+      lv_obj_align(labelY4Value, buttonY4Value, LV_ALIGN_CENTER, 0, 0);
428
+
429
+      lv_label_set_text(labelTurnPage, machine_menu.next);
430
+      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
431
+    }
432
+    else {
433
+      ZERO(public_buf_l);
434
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]);
435
+      lv_label_set_text(labelX5Value, public_buf_l);
436
+      lv_obj_align(labelX5Value, buttonX5Value, LV_ALIGN_CENTER, 0, 0);
437
+
438
+      ZERO(public_buf_l);
439
+      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][1]);
440
+      lv_label_set_text(labelY5Value, public_buf_l);
441
+      lv_obj_align(labelY5Value, buttonY5Value, LV_ALIGN_CENTER, 0, 0);
442
+
443
+      lv_label_set_text(labelTurnPage, machine_menu.previous);
444
+      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
445
+    }
446
+
447
+    lv_label_set_text(label_Back, common_menu.text_back);
448
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
449
+  }
450
+}
451
+
452
+void lv_clear_manual_level_pos_settings() {
453
+  #if HAS_ROTARY_ENCODER
454
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
455
+  #endif
456
+  lv_obj_del(scr);
457
+}
458
+
459
+#endif // HAS_TFT_LVGL_UI

+ 33
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.h View File

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

+ 94
- 118
Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp View File

@@ -29,6 +29,7 @@
29 29
 #include "../../../../MarlinCore.h"
30 30
 #include "../../../../module/planner.h"
31 31
 
32
+extern lv_group_t * g;
32 33
 static lv_obj_t * scr;
33 34
 
34 35
 #define ID_FEED_RETURN  1
@@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
127 128
 
128 129
 void lv_draw_max_feedrate_settings(void) {
129 130
   lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
130
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
131
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
132
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
133
-  lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
134
-  lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
131
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
132
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
133
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
134
+  lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
135
+  lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
135 136
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
136 137
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) {
137 138
     disp_state_stack._disp_index++;
@@ -152,166 +153,139 @@ void lv_draw_max_feedrate_settings(void) {
152 153
 
153 154
   lv_refr_now(lv_refr_get_disp_refreshing());
154 155
 
155
-  LV_IMG_DECLARE(bmp_para_back);
156
-  // LV_IMG_DECLARE(bmp_para_arrow);
157
-  LV_IMG_DECLARE(bmp_para_bank);
158
-
159 156
   if (uiCfg.para_ui_page != 1) {
160
-    buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
161
-    lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
162
-    lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
163
-    lv_obj_set_event_cb(buttonXText, event_handler);
164
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
165
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
166
-    lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
167
-    labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
168
-
169
-    buttonXValue = lv_imgbtn_create(scr, NULL);
157
+    labelXText = lv_label_create(scr, NULL);
158
+    lv_obj_set_style(labelXText, &tft_style_label_rel);
159
+    lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
160
+    lv_label_set_text(labelXText, machine_menu.XMaxFeedRate);
161
+
162
+    buttonXValue = lv_btn_create(scr, NULL);
170 163
     lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
171
-    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, "bmp_value_blank.bin", 0);
172
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
173
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
174
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
175
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
164
+    lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
165
+    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_FEED_X, NULL, 0);
166
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
167
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
176 168
     lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
177 169
     labelXValue = lv_label_create(buttonXValue, NULL);
178 170
 
179 171
     line1 = lv_line_create(scr, NULL);
180 172
     lv_ex_line(line1, line_points[0]);
181 173
 
182
-    buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
183
-    lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
184
-    lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
185
-    lv_obj_set_event_cb(buttonYText, event_handler);
186
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
187
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
188
-    lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
189
-    labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
174
+    labelYText = lv_label_create(scr, NULL);
175
+    lv_obj_set_style(labelYText, &tft_style_label_rel);
176
+    lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
177
+    lv_label_set_text(labelYText, machine_menu.YMaxFeedRate);
190 178
 
191
-    buttonYValue = lv_imgbtn_create(scr, NULL);
179
+    buttonYValue = lv_btn_create(scr, NULL);
192 180
     lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
193
-    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, "bmp_value_blank.bin", 0);
194
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
195
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
196
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
197
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
181
+    lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
182
+    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_FEED_Y, NULL, 0);
183
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
184
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
198 185
     lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
199 186
     labelYValue = lv_label_create(buttonYValue, NULL);
200 187
 
201 188
     line2 = lv_line_create(scr, NULL);
202 189
     lv_ex_line(line2, line_points[1]);
203 190
 
204
-    buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
205
-    lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
206
-    lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
207
-    lv_obj_set_event_cb(buttonZText, event_handler);
208
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
209
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
210
-    lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
211
-    labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
191
+    labelZText = lv_label_create(scr, NULL);
192
+    lv_obj_set_style(labelZText, &tft_style_label_rel);
193
+    lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
194
+    lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate);
212 195
 
213
-    buttonZValue = lv_imgbtn_create(scr, NULL);
196
+    buttonZValue = lv_btn_create(scr, NULL);
214 197
     lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
215
-    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, "bmp_value_blank.bin", 0);
216
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
217
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
218
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
219
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
198
+    lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
199
+    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_FEED_Z, NULL, 0);
200
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
201
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
220 202
     lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
221 203
     labelZValue = lv_label_create(buttonZValue, NULL);
222 204
 
223 205
     line3 = lv_line_create(scr, NULL);
224 206
     lv_ex_line(line3, line_points[2]);
225 207
 
226
-    buttonE0Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
227
-    lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4);         /*Set its position*/
228
-    lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
229
-    lv_obj_set_event_cb(buttonE0Text, event_handler);
230
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
231
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
232
-    lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
233
-    labelE0Text = lv_label_create(buttonE0Text, NULL);                      /*Add a label to the button*/
208
+    labelE0Text = lv_label_create(scr, NULL);
209
+    lv_obj_set_style(labelE0Text, &tft_style_label_rel);
210
+    lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
211
+    lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate);
234 212
 
235
-    buttonE0Value = lv_imgbtn_create(scr, NULL);
213
+    buttonE0Value = lv_btn_create(scr, NULL);
236 214
     lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
237
-    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, "bmp_value_blank.bin", 0);
238
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
239
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
240
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
241
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
215
+    lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
216
+    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_FEED_E0, NULL, 0);
217
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
218
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
242 219
     lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
243 220
     labelE0Value = lv_label_create(buttonE0Value, NULL);
244 221
 
245 222
     line4 = lv_line_create(scr, NULL);
246 223
     lv_ex_line(line4, line_points[3]);
247 224
 
248
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
249
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, "bmp_back70x40.bin", 0);
250
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
251
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
252
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
253
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
225
+    buttonTurnPage = lv_btn_create(scr, NULL);
226
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, NULL, 0);
227
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
228
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
229
+
230
+    #if HAS_ROTARY_ENCODER
231
+      if (gCfgItems.encoder_enable) {
232
+        lv_group_add_obj(g, buttonXValue);
233
+        lv_group_add_obj(g, buttonYValue);
234
+        lv_group_add_obj(g, buttonZValue);
235
+        lv_group_add_obj(g, buttonE0Value);
236
+        lv_group_add_obj(g, buttonTurnPage);
237
+      }
238
+    #endif
254 239
   }
255 240
   else {
256
-    buttonE1Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
257
-    lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y);             /*Set its position*/
258
-    lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
259
-    lv_obj_set_event_cb(buttonE1Text, event_handler);
260
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
261
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
262
-    lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
263
-    labelE1Text = lv_label_create(buttonE1Text, NULL);                      /*Add a label to the button*/
264
-
265
-    buttonE1Value = lv_imgbtn_create(scr, NULL);
241
+    labelE1Text = lv_label_create(scr, NULL);
242
+    lv_obj_set_style(labelE1Text, &tft_style_label_rel);
243
+    lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
244
+    lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate);
245
+
246
+    buttonE1Value = lv_btn_create(scr, NULL);
266 247
     lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
267
-    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, "bmp_value_blank.bin", 0);
268
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
269
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
270
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
271
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
248
+    lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
249
+    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_FEED_E1, NULL, 0);
250
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
251
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
272 252
     lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
273 253
     labelE1Value = lv_label_create(buttonE1Value, NULL);
274 254
 
255
+
275 256
     line1 = lv_line_create(scr, NULL);
276 257
     lv_ex_line(line1, line_points[0]);
277 258
 
278
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
279
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, "bmp_back70x40.bin", 0);
280
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
281
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
282
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
283
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
259
+    buttonTurnPage = lv_btn_create(scr, NULL);
260
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, NULL, 0);
261
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
262
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
263
+
264
+    #if HAS_ROTARY_ENCODER
265
+      if (gCfgItems.encoder_enable) {
266
+        lv_group_add_obj(g, buttonE1Value);
267
+        lv_group_add_obj(g, buttonTurnPage);
268
+      }
269
+    #endif
284 270
   }
285 271
 
286 272
   lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
287
-  lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
273
+  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
288 274
   labelTurnPage = lv_label_create(buttonTurnPage, NULL);
289 275
 
290
-
291
-  buttonBack = lv_imgbtn_create(scr, NULL);
292
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, "bmp_back70x40.bin", 0);
293
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
294
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
295
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
296
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
297
-
276
+  buttonBack = lv_btn_create(scr, NULL);
277
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, NULL, 0);
298 278
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
299
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
279
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
280
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
281
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
300 282
   label_Back = lv_label_create(buttonBack, NULL);
283
+  #if HAS_ROTARY_ENCODER
284
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
285
+  #endif
301 286
 
302 287
   if (gCfgItems.multiple_language != 0) {
303 288
     if (uiCfg.para_ui_page != 1) {
304
-      lv_label_set_text(labelXText, machine_menu.XMaxFeedRate);
305
-      lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
306
-
307
-      lv_label_set_text(labelYText, machine_menu.YMaxFeedRate);
308
-      lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
309
-
310
-      lv_label_set_text(labelZText, machine_menu.ZMaxFeedRate);
311
-      lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
312
-
313
-      lv_label_set_text(labelE0Text, machine_menu.E0MaxFeedRate);
314
-      lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
315 289
 
316 290
       lv_label_set_text(labelTurnPage, machine_menu.next);
317 291
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
@@ -337,9 +311,6 @@ void lv_draw_max_feedrate_settings(void) {
337 311
       lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
338 312
     }
339 313
     else {
340
-      lv_label_set_text(labelE1Text, machine_menu.E1MaxFeedRate);
341
-      lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
342
-
343 314
       lv_label_set_text(labelTurnPage, machine_menu.previous);
344 315
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
345 316
 
@@ -354,6 +325,11 @@ void lv_draw_max_feedrate_settings(void) {
354 325
   }
355 326
 }
356 327
 
357
-void lv_clear_max_feedrate_settings() { lv_obj_del(scr); }
328
+void lv_clear_max_feedrate_settings() {
329
+  #if HAS_ROTARY_ENCODER
330
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
331
+  #endif
332
+  lv_obj_del(scr);
333
+}
358 334
 
359 335
 #endif // HAS_TFT_LVGL_UI

+ 128
- 32
Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp View File

@@ -28,6 +28,7 @@
28 28
 
29 29
 #include "../../../../MarlinCore.h"
30 30
 
31
+extern lv_group_t * g;
31 32
 static lv_obj_t * scr;
32 33
 
33 34
 #define ID_MOTOR_RETURN            1
@@ -37,6 +38,8 @@ static lv_obj_t * scr;
37 38
 #define ID_MOTOR_TMC_CURRENT_ARROW 5
38 39
 #define ID_MOTOR_STEP_MODE         6
39 40
 #define ID_MOTOR_STEP_MODE_ARROW   7
41
+#define ID_HOME_SENSE              8
42
+#define ID_HOME_SENSE_ARROW        9
40 43
 
41 44
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
42 45
   switch (obj->mks_obj_id) {
@@ -67,6 +70,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
67 70
         lv_draw_step_settings();
68 71
       }
69 72
       break;
73
+    #if USE_SENSORLESS
74
+    case ID_HOME_SENSE:
75
+      if (event == LV_EVENT_CLICKED) {
76
+
77
+      }
78
+      else if (event == LV_EVENT_RELEASED) {
79
+        lv_clear_motor_settings();
80
+        lv_draw_homing_sensitivity_settings();
81
+      }
82
+      break;
83
+    case ID_HOME_SENSE_ARROW:
84
+      if (event == LV_EVENT_CLICKED) {
85
+
86
+      }
87
+      else if (event == LV_EVENT_RELEASED) {
88
+        lv_clear_motor_settings();
89
+        lv_draw_homing_sensitivity_settings();
90
+      }
91
+      break;
92
+    #endif
70 93
       #if HAS_TRINAMIC_CONFIG
71 94
         case ID_MOTOR_TMC_CURRENT:
72 95
           if (event == LV_EVENT_CLICKED) {
@@ -113,15 +136,27 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
113 136
 void lv_draw_motor_settings(void) {
114 137
   lv_obj_t *buttonBack, *label_Back;
115 138
   lv_obj_t *buttonSteps, *labelSteps, *buttonStepsNarrow;
139
+  lv_obj_t * line1;
140
+  #if USE_SENSORLESS
141
+    lv_obj_t *buttonSensitivity, *labelSensitivity, *buttonSensitivityNarrow;
142
+    lv_obj_t * line2;
143
+  #endif
116 144
   #if HAS_TRINAMIC_CONFIG
145
+    #if USE_SENSORLESS
146
+      lv_obj_t * line3;
147
+    #else
148
+      lv_obj_t * line2;
149
+    #endif
117 150
     lv_obj_t *buttonTMCcurrent, *labelTMCcurrent, *buttonTMCcurrentNarrow;
118
-    lv_obj_t * line2;
119 151
     #if HAS_STEALTHCHOP
152
+      #if USE_SENSORLESS
153
+        lv_obj_t * line4;
154
+      #else
155
+        lv_obj_t * line3;
156
+      #endif
120 157
       lv_obj_t *buttonStepMode, *labelStepMode, *buttonStepModeNarrow;
121
-      lv_obj_t * line3;
122 158
     #endif
123 159
   #endif
124
-  lv_obj_t * line1;
125 160
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) {
126 161
     disp_state_stack._disp_index++;
127 162
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI;
@@ -141,9 +176,6 @@ void lv_draw_motor_settings(void) {
141 176
 
142 177
   lv_refr_now(lv_refr_get_disp_refreshing());
143 178
 
144
-  LV_IMG_DECLARE(bmp_para_back);
145
-  LV_IMG_DECLARE(bmp_para_arrow);
146
-
147 179
   buttonSteps = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
148 180
   lv_obj_set_pos(buttonSteps, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
149 181
   lv_obj_set_size(buttonSteps, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
@@ -154,20 +186,54 @@ void lv_draw_motor_settings(void) {
154 186
   lv_btn_set_layout(buttonSteps, LV_LAYOUT_OFF);
155 187
   labelSteps = lv_label_create(buttonSteps, NULL);                        /*Add a label to the button*/
156 188
 
189
+  #if HAS_ROTARY_ENCODER
190
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSteps);
191
+  #endif
192
+
157 193
   buttonStepsNarrow = lv_imgbtn_create(scr, NULL);
158 194
   lv_obj_set_pos(buttonStepsNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V);
159
-  lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, "bmp_arrow.bin", 0);
160
-  lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
161
-  lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
195
+  lv_obj_set_event_cb_mks(buttonStepsNarrow, event_handler, ID_MOTOR_STEPS_ARROW, NULL, 0);
196
+  lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
197
+  lv_imgbtn_set_src(buttonStepsNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
162 198
   lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
163 199
   lv_imgbtn_set_style(buttonStepsNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
164 200
   lv_btn_set_layout(buttonStepsNarrow, LV_LAYOUT_OFF);
165 201
 
166
-  line1 = lv_line_create(lv_scr_act(), NULL);
202
+  line1 = lv_line_create(scr, NULL);
167 203
   lv_ex_line(line1, line_points[0]);
204
+
205
+  #if USE_SENSORLESS
206
+    buttonSensitivity = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
207
+    lv_obj_set_pos(buttonSensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
208
+    lv_obj_set_size(buttonSensitivity, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
209
+    //lv_obj_set_event_cb(buttonMachine, event_handler);
210
+    lv_obj_set_event_cb_mks(buttonSensitivity, event_handler, ID_HOME_SENSE, NULL, 0);
211
+    lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
212
+    lv_btn_set_style(buttonSensitivity, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
213
+    lv_btn_set_layout(buttonSensitivity, LV_LAYOUT_OFF);
214
+    labelSensitivity = lv_label_create(buttonSensitivity, NULL);                  /*Add a label to the button*/
215
+
216
+    #if HAS_ROTARY_ENCODER
217
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSensitivity);
218
+    #endif
219
+
220
+    buttonSensitivityNarrow = lv_imgbtn_create(scr, NULL);
221
+    lv_obj_set_pos(buttonSensitivityNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
222
+    lv_obj_set_event_cb_mks(buttonSensitivityNarrow, event_handler, ID_HOME_SENSE_ARROW, NULL, 0);
223
+    lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
224
+    lv_imgbtn_set_src(buttonSensitivityNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
225
+    lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
226
+    lv_imgbtn_set_style(buttonSensitivityNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
227
+    lv_btn_set_layout(buttonSensitivityNarrow, LV_LAYOUT_OFF);
228
+
229
+    line2 = lv_line_create(scr, NULL);
230
+    lv_ex_line(line2, line_points[1]);
231
+  #endif
232
+
233
+
168 234
   #if HAS_TRINAMIC_CONFIG
169 235
     buttonTMCcurrent = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
170
-    lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, PARA_UI_POS_Y * 2);         /*Set its position*/
236
+    lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2));
171 237
     lv_obj_set_size(buttonTMCcurrent, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          /*Set its size*/
172 238
     //lv_obj_set_event_cb(buttonMachine, event_handler);
173 239
     lv_obj_set_event_cb_mks(buttonTMCcurrent, event_handler, ID_MOTOR_TMC_CURRENT, NULL, 0);
@@ -175,61 +241,86 @@ void lv_draw_motor_settings(void) {
175 241
     lv_btn_set_style(buttonTMCcurrent, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
176 242
     lv_btn_set_layout(buttonTMCcurrent, LV_LAYOUT_OFF);
177 243
     labelTMCcurrent = lv_label_create(buttonTMCcurrent, NULL);                  /*Add a label to the button*/
244
+    #if HAS_ROTARY_ENCODER
245
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTMCcurrent);
246
+    #endif
178 247
 
179 248
     buttonTMCcurrentNarrow = lv_imgbtn_create(scr, NULL);
180
-    lv_obj_set_pos(buttonTMCcurrentNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V);
181
-    lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, "bmp_arrow.bin", 0);
182
-    lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
183
-    lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
249
+    lv_obj_set_pos(buttonTMCcurrentNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2) + PARA_UI_ARROW_V);
250
+    lv_obj_set_event_cb_mks(buttonTMCcurrentNarrow, event_handler, ID_MOTOR_TMC_CURRENT_ARROW, NULL, 0);
251
+    lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
252
+    lv_imgbtn_set_src(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
184 253
     lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
185 254
     lv_imgbtn_set_style(buttonTMCcurrentNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
186 255
     lv_btn_set_layout(buttonTMCcurrentNarrow, LV_LAYOUT_OFF);
187
-
188
-    line2 = lv_line_create(lv_scr_act(), NULL);
189
-    lv_ex_line(line2, line_points[1]);
256
+    #if USE_SENSORLESS
257
+      line3 = lv_line_create(scr, NULL);
258
+      lv_ex_line(line3, line_points[2]);
259
+    #else
260
+      line2 = lv_line_create(scr, NULL);
261
+      lv_ex_line(line2, line_points[1]);
262
+    #endif
190 263
 
191 264
     #if HAS_STEALTHCHOP
192 265
       buttonStepMode = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
193
-      lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3);         /*Set its position*/
266
+      lv_obj_set_pos(buttonStepMode, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3));
194 267
       lv_obj_set_size(buttonStepMode, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          /*Set its size*/
195
-      //lv_obj_set_event_cb(buttonMachine, event_handler);
196 268
       lv_obj_set_event_cb_mks(buttonStepMode, event_handler, ID_MOTOR_STEP_MODE, NULL, 0);
197 269
       lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
198 270
       lv_btn_set_style(buttonStepMode, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
199 271
       lv_btn_set_layout(buttonStepMode, LV_LAYOUT_OFF);
200 272
       labelStepMode = lv_label_create(buttonStepMode, NULL);                    /*Add a label to the button*/
201 273
 
274
+      #if HAS_ROTARY_ENCODER
275
+        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonStepMode);
276
+      #endif
277
+
202 278
       buttonStepModeNarrow = lv_imgbtn_create(scr, NULL);
203
-      lv_obj_set_pos(buttonStepModeNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V);
204
-      lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, "bmp_arrow.bin", 0);
205
-      lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, &bmp_para_arrow);
206
-      lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, &bmp_para_arrow);
279
+      lv_obj_set_pos(buttonStepModeNarrow, PARA_UI_POS_X + PARA_UI_SIZE_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3) + PARA_UI_ARROW_V);
280
+      lv_obj_set_event_cb_mks(buttonStepModeNarrow, event_handler, ID_MOTOR_STEP_MODE_ARROW, NULL, 0);
281
+      lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_REL, "F:/bmp_arrow.bin");
282
+      lv_imgbtn_set_src(buttonStepModeNarrow, LV_BTN_STATE_PR, "F:/bmp_arrow.bin");
207 283
       lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_PR, &tft_style_label_pre);
208 284
       lv_imgbtn_set_style(buttonStepModeNarrow, LV_BTN_STATE_REL, &tft_style_label_rel);
209 285
       lv_btn_set_layout(buttonStepModeNarrow, LV_LAYOUT_OFF);
210 286
 
211
-      line3 = lv_line_create(lv_scr_act(), NULL);
212
-      lv_ex_line(line3, line_points[2]);
213
-    #endif
287
+      #if USE_SENSORLESS
288
+        line4 = lv_line_create(scr, NULL);
289
+        lv_ex_line(line4, line_points[3]);
290
+      #else
291
+        line3 = lv_line_create(scr, NULL);
292
+        lv_ex_line(line3, line_points[2]);
293
+      #endif
294
+
295
+    #endif // HAS_STEALTHCHOP
296
+
214 297
   #endif // HAS_TRINAMIC_CONFIG
215 298
 
216 299
   buttonBack = lv_imgbtn_create(scr, NULL);
217
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, "bmp_back70x40.bin", 0);
218
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
219
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
300
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MOTOR_RETURN, NULL, 0);
301
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
302
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
220 303
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
221 304
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
222
-
223 305
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
224 306
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
225 307
   label_Back = lv_label_create(buttonBack, NULL);
226 308
 
309
+  #if HAS_ROTARY_ENCODER
310
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
311
+  #endif
312
+
227 313
   if (gCfgItems.multiple_language != 0) {
228 314
     lv_label_set_text(label_Back, common_menu.text_back);
229 315
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
230 316
 
231 317
     lv_label_set_text(labelSteps, machine_menu.StepsConf);
232 318
     lv_obj_align(labelSteps, buttonSteps, LV_ALIGN_IN_LEFT_MID, 0, 0);
319
+
320
+    #if USE_SENSORLESS
321
+      lv_label_set_text(labelSensitivity, machine_menu.HomingSensitivityConf);
322
+      lv_obj_align(labelSensitivity, buttonSensitivity, LV_ALIGN_IN_LEFT_MID, 0, 0);
323
+    #endif
233 324
     #if HAS_TRINAMIC_CONFIG
234 325
       lv_label_set_text(labelTMCcurrent, machine_menu.TMCcurrentConf);
235 326
       lv_obj_align(labelTMCcurrent, buttonTMCcurrent, LV_ALIGN_IN_LEFT_MID, 0, 0);
@@ -242,6 +333,11 @@ void lv_draw_motor_settings(void) {
242 333
 
243 334
 }
244 335
 
245
-void lv_clear_motor_settings() { lv_obj_del(scr); }
336
+void lv_clear_motor_settings() {
337
+  #if HAS_ROTARY_ENCODER
338
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
339
+  #endif
340
+  lv_obj_del(scr);
341
+}
246 342
 
247 343
 #endif // HAS_TFT_LVGL_UI

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

@@ -32,6 +32,7 @@
32 32
 #include "draw_ui.h"
33 33
 #include "../../../../gcode/queue.h"
34 34
 
35
+extern lv_group_t * g;
35 36
 static lv_obj_t * scr;
36 37
 
37 38
 static lv_obj_t *labelV, *buttonV;
@@ -179,8 +180,6 @@ void lv_draw_move_motor(void) {
179 180
 
180 181
   lv_refr_now(lv_refr_get_disp_refreshing());
181 182
 
182
-  LV_IMG_DECLARE(bmp_pic);
183
-
184 183
   // Create an Image button
185 184
   buttonXI   = lv_imgbtn_create(scr, NULL);
186 185
   buttonXD   = lv_imgbtn_create(scr, NULL);
@@ -191,55 +190,56 @@ void lv_draw_move_motor(void) {
191 190
   buttonV    = lv_imgbtn_create(scr, NULL);
192 191
   buttonBack = lv_imgbtn_create(scr, NULL);
193 192
 
194
-  lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, "bmp_xAdd.bin", 0);
195
-  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, &bmp_pic);
196
-  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, &bmp_pic);
193
+  lv_obj_set_event_cb_mks(buttonXI, event_handler, ID_M_X_P, NULL, 0);
194
+  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_REL, "F:/bmp_xAdd.bin");
195
+  lv_imgbtn_set_src(buttonXI, LV_BTN_STATE_PR, "F:/bmp_xAdd.bin");
197 196
   lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_PR, &tft_style_label_pre);
198 197
   lv_imgbtn_set_style(buttonXI, LV_BTN_STATE_REL, &tft_style_label_rel);
199 198
   lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW);
199
+
200 200
   #if 1
201
-    lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, "bmp_xDec.bin", 0);
202
-    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, &bmp_pic);
203
-    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, &bmp_pic);
201
+    lv_obj_set_event_cb_mks(buttonXD, event_handler, ID_M_X_N, NULL, 0);
202
+    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_REL, "F:/bmp_xDec.bin");
203
+    lv_imgbtn_set_src(buttonXD, LV_BTN_STATE_PR, "F:/bmp_xDec.bin");
204 204
     lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_PR, &tft_style_label_pre);
205 205
     lv_imgbtn_set_style(buttonXD, LV_BTN_STATE_REL, &tft_style_label_rel);
206 206
 
207
-    lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, "bmp_yAdd.bin", 0);
208
-    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, &bmp_pic);
209
-    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, &bmp_pic);
207
+    lv_obj_set_event_cb_mks(buttonYI, event_handler, ID_M_Y_P, NULL, 0);
208
+    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_REL, "F:/bmp_yAdd.bin");
209
+    lv_imgbtn_set_src(buttonYI, LV_BTN_STATE_PR, "F:/bmp_yAdd.bin");
210 210
     lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_PR, &tft_style_label_pre);
211 211
     lv_imgbtn_set_style(buttonYI, LV_BTN_STATE_REL, &tft_style_label_rel);
212 212
 
213
-    lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, "bmp_yDec.bin", 0);
214
-    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, &bmp_pic);
215
-    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, &bmp_pic);
213
+    lv_obj_set_event_cb_mks(buttonYD, event_handler, ID_M_Y_N, NULL, 0);
214
+    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_REL, "F:/bmp_yDec.bin");
215
+    lv_imgbtn_set_src(buttonYD, LV_BTN_STATE_PR, "F:/bmp_yDec.bin");
216 216
     lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_PR, &tft_style_label_pre);
217 217
     lv_imgbtn_set_style(buttonYD, LV_BTN_STATE_REL, &tft_style_label_rel);
218 218
 
219
-    lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, "bmp_zAdd.bin", 0);
220
-    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, &bmp_pic);
221
-    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, &bmp_pic);
219
+    lv_obj_set_event_cb_mks(buttonZI, event_handler, ID_M_Z_P, NULL, 0);
220
+    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_REL, "F:/bmp_zAdd.bin");
221
+    lv_imgbtn_set_src(buttonZI, LV_BTN_STATE_PR, "F:/bmp_zAdd.bin");
222 222
     lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_PR, &tft_style_label_pre);
223 223
     lv_imgbtn_set_style(buttonZI, LV_BTN_STATE_REL, &tft_style_label_rel);
224 224
 
225
-    lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, "bmp_zDec.bin", 0);
226
-    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, &bmp_pic);
227
-    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, &bmp_pic);
225
+    lv_obj_set_event_cb_mks(buttonZD, event_handler, ID_M_Z_N, NULL, 0);
226
+    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_REL, "F:/bmp_zDec.bin");
227
+    lv_imgbtn_set_src(buttonZD, LV_BTN_STATE_PR, "F:/bmp_zDec.bin");
228 228
     lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_PR, &tft_style_label_pre);
229 229
     lv_imgbtn_set_style(buttonZD, LV_BTN_STATE_REL, &tft_style_label_rel);
230 230
 
231 231
     //lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0);
232
-    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, &bmp_pic);
233
-    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, &bmp_pic);
232
+    lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, NULL, 0);
234 233
     lv_imgbtn_set_style(buttonV, LV_BTN_STATE_PR, &tft_style_label_pre);
235 234
     lv_imgbtn_set_style(buttonV, LV_BTN_STATE_REL, &tft_style_label_rel);
236 235
 
237
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, "bmp_return.bin", 0);
238
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
239
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
236
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_M_RETURN, NULL, 0);
237
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
238
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
240 239
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
241 240
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
242 241
   #endif // if 1
242
+
243 243
   lv_obj_set_pos(buttonXI, INTERVAL_V, titleHeight);
244 244
   lv_obj_set_pos(buttonYI, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
245 245
   lv_obj_set_pos(buttonZI, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
@@ -290,6 +290,18 @@ void lv_draw_move_motor(void) {
290 290
     lv_label_set_text(label_Back, common_menu.text_back);
291 291
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
292 292
   }
293
+  #if HAS_ROTARY_ENCODER
294
+    if (gCfgItems.encoder_enable) {
295
+      lv_group_add_obj(g, buttonXI);
296
+      lv_group_add_obj(g, buttonXD);
297
+      lv_group_add_obj(g, buttonYI);
298
+      lv_group_add_obj(g, buttonYD);
299
+      lv_group_add_obj(g, buttonZI);
300
+      lv_group_add_obj(g, buttonZD);
301
+      lv_group_add_obj(g, buttonV);
302
+      lv_group_add_obj(g, buttonBack);
303
+    }
304
+  #endif
293 305
 
294 306
   disp_move_dist();
295 307
 }
@@ -297,12 +309,18 @@ void lv_draw_move_motor(void) {
297 309
 void disp_move_dist() {
298 310
   // char buf[30] = {0};
299 311
 
300
-  if ((int)(10 * uiCfg.move_dist) == 1)
301
-    lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move0_1.bin", 0);
302
-  else if ((int)(10 * uiCfg.move_dist) == 10)
303
-    lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move1.bin", 0);
304
-  else if ((int)(10 * uiCfg.move_dist) == 100)
305
-    lv_obj_set_event_cb_mks(buttonV, event_handler, ID_M_STEP, "bmp_step_move10.bin", 0);
312
+  if ((int)(10 * uiCfg.move_dist) == 1) {
313
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move0_1.bin");
314
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move0_1.bin");
315
+  }
316
+  else if ((int)(10 * uiCfg.move_dist) == 10) {
317
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move1.bin");
318
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move1.bin");
319
+  }
320
+  else if ((int)(10 * uiCfg.move_dist) == 100) {
321
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_REL, "F:/bmp_step_move10.bin");
322
+    lv_imgbtn_set_src(buttonV, LV_BTN_STATE_PR, "F:/bmp_step_move10.bin");
323
+  }
306 324
   if (gCfgItems.multiple_language != 0) {
307 325
     if ((int)(10 * uiCfg.move_dist) == 1) {
308 326
       lv_label_set_text(labelV, move_menu.step_01mm);
@@ -319,6 +337,11 @@ void disp_move_dist() {
319 337
   }
320 338
 }
321 339
 
322
-void lv_clear_move_motor() { lv_obj_del(scr); }
340
+void lv_clear_move_motor() {
341
+  #if HAS_ROTARY_ENCODER
342
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
343
+  #endif
344
+  lv_obj_del(scr);
345
+}
323 346
 
324 347
 #endif // HAS_TFT_LVGL_UI

+ 242
- 49
Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp View File

@@ -47,6 +47,11 @@
47 47
   #include "../../../../feature/tmc_util.h"
48 48
 #endif
49 49
 
50
+#if HAS_BED_PROBE
51
+  #include "../../../../module/probe.h"
52
+#endif
53
+
54
+extern lv_group_t * g;
50 55
 static lv_obj_t * scr;
51 56
 static lv_obj_t *buttonValue = NULL;
52 57
 static lv_obj_t *labelValue  = NULL;
@@ -77,113 +82,92 @@ static void disp_key_value() {
77 82
     float milliamps;
78 83
   #endif
79 84
 
85
+  ZERO(public_buf_m);
86
+
80 87
   switch (value) {
81 88
     case PrintAcceleration:
82
-      ZERO(public_buf_m);
83 89
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration);
84 90
       break;
85 91
     case RetractAcceleration:
86
-      ZERO(public_buf_m);
87 92
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.retract_acceleration);
88 93
       break;
89 94
     case TravelAcceleration:
90
-      ZERO(public_buf_m);
91 95
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.travel_acceleration);
92 96
       break;
93 97
     case XAcceleration:
94
-      ZERO(public_buf_m);
95 98
       sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
96 99
       break;
97 100
     case YAcceleration:
98
-      ZERO(public_buf_m);
99 101
       sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
100 102
       break;
101 103
     case ZAcceleration:
102
-      ZERO(public_buf_m);
103 104
       sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
104 105
       break;
105 106
     case E0Acceleration:
106
-      ZERO(public_buf_m);
107 107
       sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
108 108
       break;
109 109
     case E1Acceleration:
110
-      ZERO(public_buf_m);
111 110
       sprintf_P(public_buf_m, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
112 111
       break;
113 112
     case XMaxFeedRate:
114
-      ZERO(public_buf_m);
115 113
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
116 114
       break;
117 115
     case YMaxFeedRate:
118
-      ZERO(public_buf_m);
119 116
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
120 117
       break;
121 118
     case ZMaxFeedRate:
122
-      ZERO(public_buf_m);
123 119
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
124 120
       break;
125 121
     case E0MaxFeedRate:
126
-      ZERO(public_buf_m);
127 122
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
128 123
       break;
129 124
     case E1MaxFeedRate:
130
-      ZERO(public_buf_m);
131 125
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
132 126
       break;
133 127
 
134 128
     case XJerk:
135 129
       #if HAS_CLASSIC_JERK
136
-        ZERO(public_buf_m);
137 130
         sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
138 131
       #endif
139 132
       break;
140 133
     case YJerk:
141 134
       #if HAS_CLASSIC_JERK
142
-        ZERO(public_buf_m);
143 135
         sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
144 136
       #endif
145 137
       break;
146 138
     case ZJerk:
147 139
       #if HAS_CLASSIC_JERK
148
-        ZERO(public_buf_m);
149 140
         sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
150 141
       #endif
151 142
       break;
152 143
     case EJerk:
153 144
       #if HAS_CLASSIC_JERK
154
-        ZERO(public_buf_m);
155 145
         sprintf_P(public_buf_m, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
156 146
       #endif
157 147
       break;
158 148
 
159 149
     case Xstep:
160
-      ZERO(public_buf_m);
161 150
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
162 151
 
163 152
       break;
164 153
     case Ystep:
165
-      ZERO(public_buf_m);
166 154
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]);
167 155
 
168 156
       break;
169 157
     case Zstep:
170
-      ZERO(public_buf_m);
171 158
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]);
172 159
 
173 160
       break;
174 161
     case E0step:
175
-      ZERO(public_buf_m);
176 162
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
177 163
 
178 164
       break;
179 165
     case E1step:
180
-      ZERO(public_buf_m);
181 166
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
182 167
       break;
183 168
 
184 169
     case Xcurrent:
185 170
       #if AXIS_IS_TMC(X)
186
-        ZERO(public_buf_m);
187 171
         milliamps = stepperX.getMilliamps();
188 172
         sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
189 173
       #endif
@@ -191,7 +175,6 @@ static void disp_key_value() {
191 175
 
192 176
     case Ycurrent:
193 177
       #if AXIS_IS_TMC(Y)
194
-        ZERO(public_buf_m);
195 178
         milliamps = stepperY.getMilliamps();
196 179
         sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
197 180
       #endif
@@ -199,7 +182,6 @@ static void disp_key_value() {
199 182
 
200 183
     case Zcurrent:
201 184
       #if AXIS_IS_TMC(Z)
202
-        ZERO(public_buf_m);
203 185
         milliamps = stepperZ.getMilliamps();
204 186
         sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
205 187
       #endif
@@ -207,7 +189,6 @@ static void disp_key_value() {
207 189
 
208 190
     case E0current:
209 191
       #if AXIS_IS_TMC(E0)
210
-        ZERO(public_buf_m);
211 192
         milliamps = stepperE0.getMilliamps();
212 193
         sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
213 194
       #endif
@@ -215,24 +196,100 @@ static void disp_key_value() {
215 196
 
216 197
     case E1current:
217 198
       #if AXIS_IS_TMC(E1)
218
-        ZERO(public_buf_m);
219 199
         milliamps = stepperE1.getMilliamps();
220 200
         sprintf_P(public_buf_m, PSTR("%.1f"), milliamps);
221 201
       #endif
222 202
       break;
223 203
 
224 204
     case pause_pos_x:
225
-      ZERO(public_buf_m);
226 205
       sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosX);
227 206
       break;
228 207
     case pause_pos_y:
229
-      ZERO(public_buf_m);
230 208
       sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosY);
231 209
       break;
232 210
     case pause_pos_z:
233
-      ZERO(public_buf_m);
234 211
       sprintf_P(public_buf_m, PSTR("%.1f"), gCfgItems.pausePosZ);
235 212
       break;
213
+    case level_pos_x1:
214
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][0]);
215
+      break;
216
+    case level_pos_y1:
217
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[0][1]);
218
+      break;
219
+    case level_pos_x2:
220
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][0]);
221
+      break;
222
+    case level_pos_y2:
223
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[1][1]);
224
+      break;
225
+    case level_pos_x3:
226
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][0]);
227
+      break;
228
+    case level_pos_y3:
229
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[2][1]);
230
+      break;
231
+    case level_pos_x4:
232
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][0]);
233
+      break;
234
+    case level_pos_y4:
235
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[3][1]);
236
+      break;
237
+    case level_pos_x5:
238
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][0]);
239
+      break;
240
+    case level_pos_y5:
241
+      sprintf_P(public_buf_m, PSTR("%d"), (int)gCfgItems.levelingPos[4][1]);
242
+      break;
243
+    #if HAS_BED_PROBE
244
+      case x_offset:
245
+        #if HAS_PROBE_XY_OFFSET
246
+        sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.x);
247
+        #endif
248
+        break;
249
+      case y_offset:
250
+        #if HAS_PROBE_XY_OFFSET
251
+        sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.y);
252
+        #endif
253
+        break;
254
+      case z_offset:
255
+        sprintf_P(public_buf_m, PSTR("%.1f"), probe.offset.z);
256
+        break;
257
+    #endif
258
+    case load_length:
259
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_length);
260
+      break;
261
+    case load_speed:
262
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_load_speed);
263
+      break;
264
+    case unload_length:
265
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_length);
266
+      break;
267
+    case unload_speed:
268
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
269
+      break;
270
+    case filament_temp:
271
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper);
272
+      break;
273
+    case x_sensitivity:
274
+      #if X_SENSORLESS
275
+        sprintf_P(public_buf_m, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
276
+      #endif
277
+      break;
278
+    case y_sensitivity:
279
+      #if Y_SENSORLESS
280
+        sprintf_P(public_buf_m, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
281
+      #endif
282
+      break;
283
+    case z_sensitivity:
284
+      #if Z_SENSORLESS
285
+        sprintf_P(public_buf_m, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
286
+      #endif
287
+      break;
288
+    case z2_sensitivity:
289
+      #if Z2_SENSORLESS
290
+        sprintf_P(public_buf_m, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
291
+      #endif
292
+      break;
236 293
   }
237 294
   ZERO(key_value);
238 295
   strcpy(key_value, public_buf_m);
@@ -313,18 +370,23 @@ static void set_value_confirm() {
313 370
       break;
314 371
     case Xstep:
315 372
       planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value);
373
+      planner.refresh_positioning();
316 374
       break;
317 375
     case Ystep:
318 376
       planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value);
377
+      planner.refresh_positioning();
319 378
       break;
320 379
     case Zstep:
321 380
       planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value);
381
+      planner.refresh_positioning();
322 382
       break;
323 383
     case E0step:
324 384
       planner.settings.axis_steps_per_mm[E_AXIS] = atof(key_value);
385
+      planner.refresh_positioning();
325 386
       break;
326 387
     case E1step:
327 388
       planner.settings.axis_steps_per_mm[E_AXIS_N(1)] = atof(key_value);
389
+      planner.refresh_positioning();
328 390
       break;
329 391
     case Xcurrent:
330 392
       #if AXIS_IS_TMC(X)
@@ -368,6 +430,114 @@ static void set_value_confirm() {
368 430
       gCfgItems.pausePosZ = atof(key_value);
369 431
       update_spi_flash();
370 432
       break;
433
+    case level_pos_x1:
434
+      gCfgItems.levelingPos[0][0] = atoi(key_value);
435
+      update_spi_flash();
436
+      break;
437
+    case level_pos_y1:
438
+      gCfgItems.levelingPos[0][1] = atoi(key_value);
439
+      update_spi_flash();
440
+      break;
441
+    case level_pos_x2:
442
+      gCfgItems.levelingPos[1][0] = atoi(key_value);
443
+      update_spi_flash();
444
+      break;
445
+    case level_pos_y2:
446
+      gCfgItems.levelingPos[1][1] = atoi(key_value);
447
+      update_spi_flash();
448
+      break;
449
+    case level_pos_x3:
450
+      gCfgItems.levelingPos[2][0] = atoi(key_value);
451
+      update_spi_flash();
452
+      break;
453
+    case level_pos_y3:
454
+      gCfgItems.levelingPos[2][1] = atoi(key_value);
455
+      update_spi_flash();
456
+      break;
457
+    case level_pos_x4:
458
+      gCfgItems.levelingPos[3][0] = atoi(key_value);
459
+      update_spi_flash();
460
+      break;
461
+    case level_pos_y4:
462
+      gCfgItems.levelingPos[3][1] = atoi(key_value);
463
+      update_spi_flash();
464
+      break;
465
+    case level_pos_x5:
466
+      gCfgItems.levelingPos[4][0] = atoi(key_value);
467
+      update_spi_flash();
468
+      break;
469
+    case level_pos_y5:
470
+      gCfgItems.levelingPos[4][1] = atoi(key_value);
471
+      update_spi_flash();
472
+      break;
473
+    #if HAS_BED_PROBE
474
+      case x_offset:
475
+        #if HAS_PROBE_XY_OFFSET
476
+          float x;
477
+          x = atof(key_value);
478
+          if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
479
+            probe.offset.x = x;
480
+        #endif
481
+        break;
482
+      case y_offset:
483
+        #if HAS_PROBE_XY_OFFSET
484
+          float y;
485
+          y = atof(key_value);
486
+          if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
487
+            probe.offset.y = y;
488
+        #endif
489
+        break;
490
+      case z_offset:
491
+        float z;
492
+        z = atof(key_value);
493
+        if (WITHIN(z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX))
494
+          probe.offset.z = z;
495
+        break;
496
+    #endif
497
+    case load_length:
498
+      gCfgItems.filamentchange_load_length = atoi(key_value);
499
+      uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
500
+      update_spi_flash();
501
+      break;
502
+    case load_speed:
503
+      gCfgItems.filamentchange_load_speed = atoi(key_value);
504
+      uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length*60.0/gCfgItems.filamentchange_load_speed)+0.5);
505
+      update_spi_flash();
506
+      break;
507
+    case unload_length:
508
+      gCfgItems.filamentchange_unload_length = atoi(key_value);
509
+      uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
510
+      update_spi_flash();
511
+      break;
512
+    case unload_speed:
513
+      gCfgItems.filamentchange_unload_speed = atoi(key_value);
514
+      uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length*60.0/gCfgItems.filamentchange_unload_speed)+0.5);
515
+      update_spi_flash();
516
+      break;
517
+    case filament_temp:
518
+      gCfgItems.filament_limit_temper = atoi(key_value);
519
+      update_spi_flash();
520
+      break;
521
+    case x_sensitivity:
522
+      #if X_SENSORLESS
523
+        stepperX.homing_threshold(atoi(key_value));
524
+      #endif
525
+      break;
526
+    case y_sensitivity:
527
+      #if Y_SENSORLESS
528
+        stepperY.homing_threshold(atoi(key_value));
529
+      #endif
530
+      break;
531
+    case z_sensitivity:
532
+      #if Z_SENSORLESS
533
+        stepperZ.homing_threshold(atoi(key_value));
534
+      #endif
535
+      break;
536
+    case z2_sensitivity:
537
+      #if Z2_SENSORLESS
538
+        stepperZ2.homing_threshold(atoi(key_value));
539
+      #endif
540
+      break;
371 541
   }
372 542
   gcode.process_subcommands_now_P(PSTR("M500"));
373 543
 }
@@ -604,15 +774,13 @@ void lv_draw_number_key(void) {
604 774
 
605 775
   lv_refr_now(lv_refr_get_disp_refreshing());
606 776
 
607
-  //LV_IMG_DECLARE(bmp_pic);
608
-
609 777
   buttonValue = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
610 778
   lv_obj_set_pos(buttonValue, 92, 40);                                  /*Set its position*/
611 779
   lv_obj_set_size(buttonValue, 296, 40);
612 780
   lv_obj_set_event_cb_mks(buttonValue, event_handler, ID_NUM_KEY1, NULL, 0);
613 781
   lv_btn_set_style(buttonValue, LV_BTN_STYLE_REL, &style_num_text);     /*Set the button's released style*/
614 782
   lv_btn_set_style(buttonValue, LV_BTN_STYLE_PR, &style_num_text);      /*Set the button's pressed style*/
615
-  lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF);
783
+  //lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF);
616 784
   labelValue = lv_label_create(buttonValue, NULL);                      /*Add a label to the button*/
617 785
 
618 786
   NumberKey_1 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
@@ -621,7 +789,7 @@ void lv_draw_number_key(void) {
621 789
   lv_obj_set_event_cb_mks(NumberKey_1, event_handler, ID_NUM_KEY1, NULL, 0);
622 790
   lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
623 791
   lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
624
-  lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF);
792
+  //lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF);
625 793
   labelKey_1 = lv_label_create(NumberKey_1, NULL);                      /*Add a label to the button*/
626 794
   lv_label_set_text(labelKey_1, machine_menu.key_1);
627 795
   lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0);
@@ -632,7 +800,7 @@ void lv_draw_number_key(void) {
632 800
   lv_obj_set_event_cb_mks(NumberKey_2, event_handler, ID_NUM_KEY2, NULL, 0);
633 801
   lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
634 802
   lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
635
-  lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF);
803
+  //lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF);
636 804
   labelKey_2 = lv_label_create(NumberKey_2, NULL);                      /*Add a label to the button*/
637 805
   lv_label_set_text(labelKey_2, machine_menu.key_2);
638 806
   lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0);
@@ -643,7 +811,7 @@ void lv_draw_number_key(void) {
643 811
   lv_obj_set_event_cb_mks(NumberKey_3, event_handler, ID_NUM_KEY3, NULL, 0);
644 812
   lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
645 813
   lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
646
-  lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF);
814
+  //lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF);
647 815
   labelKey_3 = lv_label_create(NumberKey_3, NULL);                      /*Add a label to the button*/
648 816
   lv_label_set_text(labelKey_3, machine_menu.key_3);
649 817
   lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0);
@@ -654,7 +822,7 @@ void lv_draw_number_key(void) {
654 822
   lv_obj_set_event_cb_mks(NumberKey_4, event_handler, ID_NUM_KEY4, NULL, 0);
655 823
   lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
656 824
   lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
657
-  lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF);
825
+  //lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF);
658 826
   labelKey_4 = lv_label_create(NumberKey_4, NULL);                      /*Add a label to the button*/
659 827
   lv_label_set_text(labelKey_4, machine_menu.key_4);
660 828
   lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0);
@@ -665,7 +833,7 @@ void lv_draw_number_key(void) {
665 833
   lv_obj_set_event_cb_mks(NumberKey_5, event_handler, ID_NUM_KEY5, NULL, 0);
666 834
   lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
667 835
   lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
668
-  lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF);
836
+  //lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF);
669 837
   labelKey_5 = lv_label_create(NumberKey_5, NULL);                      /*Add a label to the button*/
670 838
   lv_label_set_text(labelKey_5, machine_menu.key_5);
671 839
   lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0);
@@ -676,7 +844,7 @@ void lv_draw_number_key(void) {
676 844
   lv_obj_set_event_cb_mks(NumberKey_6, event_handler, ID_NUM_KEY6, NULL, 0);
677 845
   lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
678 846
   lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
679
-  lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF);
847
+  //lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF);
680 848
   labelKey_6 = lv_label_create(NumberKey_6, NULL);                      /*Add a label to the button*/
681 849
   lv_label_set_text(labelKey_6, machine_menu.key_6);
682 850
   lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0);
@@ -687,7 +855,7 @@ void lv_draw_number_key(void) {
687 855
   lv_obj_set_event_cb_mks(NumberKey_7, event_handler, ID_NUM_KEY7, NULL, 0);
688 856
   lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
689 857
   lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
690
-  lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF);
858
+  //lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF);
691 859
   labelKey_7 = lv_label_create(NumberKey_7, NULL);                      /*Add a label to the button*/
692 860
   lv_label_set_text(labelKey_7, machine_menu.key_7);
693 861
   lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0);
@@ -698,7 +866,7 @@ void lv_draw_number_key(void) {
698 866
   lv_obj_set_event_cb_mks(NumberKey_8, event_handler, ID_NUM_KEY8, NULL, 0);
699 867
   lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
700 868
   lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
701
-  lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF);
869
+  //lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF);
702 870
   labelKey_8 = lv_label_create(NumberKey_8, NULL);                      /*Add a label to the button*/
703 871
   lv_label_set_text(labelKey_8, machine_menu.key_8);
704 872
   lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0);
@@ -709,7 +877,7 @@ void lv_draw_number_key(void) {
709 877
   lv_obj_set_event_cb_mks(NumberKey_9, event_handler, ID_NUM_KEY9, NULL, 0);
710 878
   lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
711 879
   lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
712
-  lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF);
880
+  //lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF);
713 881
   labelKey_9 = lv_label_create(NumberKey_9, NULL);                      /*Add a label to the button*/
714 882
   lv_label_set_text(labelKey_9, machine_menu.key_9);
715 883
   lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0);
@@ -720,7 +888,7 @@ void lv_draw_number_key(void) {
720 888
   lv_obj_set_event_cb_mks(NumberKey_0, event_handler, ID_NUM_KEY0, NULL, 0);
721 889
   lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
722 890
   lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
723
-  lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF);
891
+  //lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF);
724 892
   labelKey_0 = lv_label_create(NumberKey_0, NULL);                      /*Add a label to the button*/
725 893
   lv_label_set_text(labelKey_0, machine_menu.key_0);
726 894
   lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0);
@@ -731,7 +899,7 @@ void lv_draw_number_key(void) {
731 899
   lv_obj_set_event_cb_mks(KeyBack, event_handler, ID_NUM_BACK, NULL, 0);
732 900
   lv_btn_set_style(KeyBack, LV_BTN_STYLE_REL, &style_num_key_pre);      /*Set the button's released style*/
733 901
   lv_btn_set_style(KeyBack, LV_BTN_STYLE_PR, &style_num_key_rel);       /*Set the button's pressed style*/
734
-  lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF);
902
+  //lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF);
735 903
   labelKeyBack = lv_label_create(KeyBack, NULL);                        /*Add a label to the button*/
736 904
   lv_label_set_text(labelKeyBack, machine_menu.key_back);
737 905
   lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
@@ -742,7 +910,7 @@ void lv_draw_number_key(void) {
742 910
   lv_obj_set_event_cb_mks(KeyReset, event_handler, ID_NUM_RESET, NULL, 0);
743 911
   lv_btn_set_style(KeyReset, LV_BTN_STYLE_REL, &style_num_key_pre);     /*Set the button's released style*/
744 912
   lv_btn_set_style(KeyReset, LV_BTN_STYLE_PR, &style_num_key_rel);      /*Set the button's pressed style*/
745
-  lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF);
913
+  //lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF);
746 914
   labelKeyReset = lv_label_create(KeyReset, NULL);                      /*Add a label to the button*/
747 915
   lv_label_set_text(labelKeyReset, machine_menu.key_reset);
748 916
   lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
@@ -753,7 +921,7 @@ void lv_draw_number_key(void) {
753 921
   lv_obj_set_event_cb_mks(KeyConfirm, event_handler, ID_NUM_CONFIRM, NULL, 0);
754 922
   lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_REL, &style_num_key_pre);   /*Set the button's released style*/
755 923
   lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_PR, &style_num_key_rel);    /*Set the button's pressed style*/
756
-  lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF);
924
+  //lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF);
757 925
   labelKeyConfirm = lv_label_create(KeyConfirm, NULL);                  /*Add a label to the button*/
758 926
   lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
759 927
   lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
@@ -764,7 +932,7 @@ void lv_draw_number_key(void) {
764 932
   lv_obj_set_event_cb_mks(KeyPoint, event_handler, ID_NUM_POINT, NULL, 0);
765 933
   lv_btn_set_style(KeyPoint, LV_BTN_STYLE_REL, &style_num_key_pre);     /*Set the button's released style*/
766 934
   lv_btn_set_style(KeyPoint, LV_BTN_STYLE_PR, &style_num_key_rel);      /*Set the button's pressed style*/
767
-  lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF);
935
+  //lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF);
768 936
   labelKeyPoint = lv_label_create(KeyPoint, NULL);                      /*Add a label to the button*/
769 937
   lv_label_set_text(labelKeyPoint, machine_menu.key_point);
770 938
   lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
@@ -775,14 +943,39 @@ void lv_draw_number_key(void) {
775 943
   lv_obj_set_event_cb_mks(Minus, event_handler, ID_NUM_NAGETIVE, NULL, 0);
776 944
   lv_btn_set_style(Minus, LV_BTN_STYLE_REL, &style_num_key_pre);        /*Set the button's released style*/
777 945
   lv_btn_set_style(Minus, LV_BTN_STYLE_PR, &style_num_key_rel);         /*Set the button's pressed style*/
778
-  lv_btn_set_layout(Minus, LV_LAYOUT_OFF);
946
+  //lv_btn_set_layout(Minus, LV_LAYOUT_OFF);
779 947
   labelMinus = lv_label_create(Minus, NULL);                            /*Add a label to the button*/
780 948
   lv_label_set_text(labelMinus, machine_menu.negative);
781 949
   lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);
782 950
 
951
+  #if HAS_ROTARY_ENCODER
952
+    if (gCfgItems.encoder_enable) {
953
+      lv_group_add_obj(g, NumberKey_1);
954
+      lv_group_add_obj(g, NumberKey_2);
955
+      lv_group_add_obj(g, NumberKey_3);
956
+      lv_group_add_obj(g, KeyBack);
957
+      lv_group_add_obj(g, NumberKey_4);
958
+      lv_group_add_obj(g, NumberKey_5);
959
+      lv_group_add_obj(g, NumberKey_6);
960
+      lv_group_add_obj(g, KeyReset);
961
+      lv_group_add_obj(g, NumberKey_7);
962
+      lv_group_add_obj(g, NumberKey_8);
963
+      lv_group_add_obj(g, NumberKey_9);
964
+      lv_group_add_obj(g, NumberKey_0);
965
+      lv_group_add_obj(g, Minus);
966
+      lv_group_add_obj(g, KeyPoint);
967
+      lv_group_add_obj(g, KeyConfirm);
968
+    }
969
+  #endif
970
+
783 971
   disp_key_value();
784 972
 }
785 973
 
786
-void lv_clear_number_key() { lv_obj_del(scr); }
974
+void lv_clear_number_key() {
975
+  #if HAS_ROTARY_ENCODER
976
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
977
+  #endif
978
+  lv_obj_del(scr);
979
+}
787 980
 
788 981
 #endif // HAS_TFT_LVGL_UI

+ 174
- 87
Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp View File

@@ -31,7 +31,11 @@
31 31
 //#include "../lvgl/src/lv_core/lv_refr.h"
32 32
 
33 33
 #include "../../../../MarlinCore.h"
34
+#include "../../../../module/temperature.h"
35
+#include "../../../../module/motion.h"
36
+#include "../../../../sd/cardreader.h"
34 37
 
38
+extern lv_group_t * g;
35 39
 static lv_obj_t * scr;
36 40
 
37 41
 #define ID_O_PRE_HEAT   1
@@ -42,10 +46,13 @@ static lv_obj_t * scr;
42 46
 #define ID_O_RETURN     6
43 47
 #define ID_O_FAN        7
44 48
 #define ID_O_POWER_OFF  8
49
+#define ID_O_BABY_STEP  9
45 50
 
46 51
 static lv_obj_t *label_PowerOff;
47 52
 static lv_obj_t *buttonPowerOff;
48 53
 
54
+extern feedRate_t feedrate_mm_s;
55
+
49 56
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
50 57
   switch (obj->mks_obj_id) {
51 58
     case ID_O_PRE_HEAT:
@@ -80,6 +87,20 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
80 87
         // nothing to do
81 88
       }
82 89
       else if (event == LV_EVENT_RELEASED) {
90
+        #if HAS_MULTI_EXTRUDER
91
+          uiCfg.curSprayerChoose_bak = active_extruder;
92
+        #endif
93
+        if (uiCfg.print_state == WORKING) {
94
+          #if ENABLED(SDSUPPORT)
95
+            card.pauseSDPrint();
96
+            stop_print_time();
97
+            uiCfg.print_state = PAUSING;
98
+          #endif
99
+        }
100
+        uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
101
+        uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
102
+        lv_clear_operation();
103
+        lv_draw_filament_change();
83 104
       }
84 105
       break;
85 106
     case ID_O_FAN:
@@ -116,7 +137,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
116 137
       else if (event == LV_EVENT_RELEASED) {
117 138
         if (gCfgItems.finish_power_off == 1) {
118 139
           gCfgItems.finish_power_off = 0;
119
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0); // didn't find bmp_Mamual...
140
+          lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
141
+          lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
120 142
           lv_label_set_text(label_PowerOff, printing_more_menu.manual);
121 143
           lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
122 144
           lv_obj_refresh_ext_draw_pad(label_PowerOff);
@@ -124,7 +146,8 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
124 146
         }
125 147
         else {
126 148
           gCfgItems.finish_power_off = 1;
127
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
149
+          lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin");
150
+          lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin");
128 151
           lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
129 152
           lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
130 153
           lv_obj_refresh_ext_draw_pad(label_PowerOff);
@@ -132,16 +155,26 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
132 155
         }
133 156
       }
134 157
       break;
135
-
158
+    case ID_O_BABY_STEP:
159
+      if (event == LV_EVENT_CLICKED) {
160
+        // nothing to do
161
+      }
162
+      else if (event == LV_EVENT_RELEASED) {
163
+        lv_clear_operation();
164
+        lv_draw_baby_stepping();
165
+      }
166
+      break;
136 167
   }
137 168
 }
138 169
 
139 170
 void lv_draw_operation(void) {
140
-  lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonSpeed;
141
-  lv_obj_t *buttonBack, *buttonFan;
142
-  lv_obj_t *labelPreHeat, *labelExtrusion;
143
-  lv_obj_t *label_Back, *label_Speed, *label_Fan;
171
+  lv_obj_t *buttonPreHeat = NULL, *buttonExtrusion = NULL, *buttonSpeed = NULL;
172
+  lv_obj_t *buttonBack = NULL, *buttonFan = NULL;
173
+  lv_obj_t *labelPreHeat = NULL, *labelExtrusion = NULL;
174
+  lv_obj_t *label_Back = NULL, *label_Speed = NULL, *label_Fan = NULL;
144 175
   lv_obj_t *buttonMove = NULL, *label_Move = NULL;
176
+  lv_obj_t *buttonBabyStep = NULL, *label_BabyStep = NULL;
177
+  lv_obj_t *buttonFilament = NULL, *label_Filament = NULL;
145 178
 
146 179
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) {
147 180
     disp_state_stack._disp_index++;
@@ -162,143 +195,188 @@ void lv_draw_operation(void) {
162 195
 
163 196
   lv_refr_now(lv_refr_get_disp_refreshing());
164 197
 
165
-  LV_IMG_DECLARE(bmp_pic);
166
-
167
-  /*Create an Image button*/
168
-  buttonPreHeat   = lv_imgbtn_create(scr, NULL);
169
-  buttonExtrusion = lv_imgbtn_create(scr, NULL);
170
-  buttonFan       = lv_imgbtn_create(scr, NULL);
171
-  buttonSpeed     = lv_imgbtn_create(scr, NULL);
172
-
198
+  // Create image buttons
199
+  buttonPreHeat     = lv_imgbtn_create(scr, NULL);
200
+  buttonFilament    = lv_imgbtn_create(scr, NULL);
201
+  buttonFan         = lv_imgbtn_create(scr, NULL);
202
+  buttonPowerOff    = lv_imgbtn_create(scr, NULL);
173 203
   if (uiCfg.print_state != WORKING) {
174
-    //buttonFilament = lv_imgbtn_create(scr, NULL);
175
-    //} else {
176
-    buttonMove = lv_imgbtn_create(scr, NULL);
204
+    buttonExtrusion = lv_imgbtn_create(scr, NULL);
205
+    buttonMove      = lv_imgbtn_create(scr, NULL);
177 206
   }
207
+  else {
208
+    buttonSpeed    = lv_imgbtn_create(scr, NULL);
209
+    buttonBabyStep = lv_imgbtn_create(scr, NULL);
210
+  }
211
+  buttonBack       = lv_imgbtn_create(scr, NULL);
178 212
 
179
-  buttonPowerOff = lv_imgbtn_create(scr, NULL);
180
-  buttonBack     = lv_imgbtn_create(scr, NULL);
181
-
182
-  lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, "bmp_temp.bin", 0);
183
-  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic);
184
-  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic);
213
+  lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_O_PRE_HEAT, NULL, 0);
214
+  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_temp.bin");
215
+  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_temp.bin");
185 216
   lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre);
186 217
   lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel);
187
-  lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW);
218
+
219
+  lv_obj_set_event_cb_mks(buttonFilament, event_handler, ID_O_FILAMENT, NULL, 0);
220
+  lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin");
221
+  lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin");
222
+  lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
223
+  lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
224
+
188 225
   #if 1
189
-    lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, "bmp_extrude_opr.bin", 0);
190
-    lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic);
191
-    lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic);
192
-    lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
193
-    lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
194
-
195
-    lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, "bmp_fan.bin", 0);
196
-    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic);
197
-    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic);
226
+    lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_O_FAN, NULL, 0);
227
+    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin");
228
+    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin");
198 229
     lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre);
199 230
     lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel);
200 231
 
201
-    lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, "bmp_speed.bin", 0);
202
-    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, &bmp_pic);
203
-    lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, &bmp_pic);
204
-    lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
205
-    lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
232
+    if (gCfgItems.finish_power_off == 1) {
233
+      lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_auto_off.bin");
234
+      lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_auto_off.bin");
235
+    }
236
+    else {
237
+      lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
238
+      lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
239
+    }
240
+    lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, NULL, 0);
241
+    lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre);
242
+    lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel);
243
+
244
+    #if HAS_ROTARY_ENCODER
245
+      if (gCfgItems.encoder_enable) {
246
+        lv_group_add_obj(g, buttonPreHeat);
247
+        lv_group_add_obj(g, buttonFilament);
248
+        lv_group_add_obj(g, buttonFan);
249
+        lv_group_add_obj(g, buttonPowerOff);
250
+      }
251
+    #endif
206 252
 
207 253
     if (uiCfg.print_state != WORKING) {
208
-      /*
209
-        lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_O_FILAMENT,"bmp_Filamentchange.bin",0);
210
-        lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic);
211
-        lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic);
212
-        lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
213
-        lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
214
-      } else {
215
-      */
216
-      lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, "bmp_move_opr.bin", 0);
217
-      lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic);
218
-      lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic);
254
+      lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_O_EXTRUCT, NULL, 0);
255
+      lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extrude_opr.bin");
256
+      lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extrude_opr.bin");
257
+      lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
258
+      lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
259
+
260
+      lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_O_MOV, NULL, 0);
261
+      lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_move_opr.bin");
262
+      lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_move_opr.bin");
219 263
       lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
220 264
       lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
265
+
266
+      #if HAS_ROTARY_ENCODER
267
+        if (gCfgItems.encoder_enable) {
268
+          lv_group_add_obj(g, buttonExtrusion);
269
+          lv_group_add_obj(g, buttonMove);
270
+        }
271
+      #endif
272
+    }
273
+    else {
274
+      lv_obj_set_event_cb_mks(buttonSpeed, event_handler, ID_O_SPEED, NULL, 0);
275
+      lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_REL, "F:/bmp_speed.bin");
276
+      lv_imgbtn_set_src(buttonSpeed, LV_BTN_STATE_PR, "F:/bmp_speed.bin");
277
+      lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_PR, &tft_style_label_pre);
278
+      lv_imgbtn_set_style(buttonSpeed, LV_BTN_STATE_REL, &tft_style_label_rel);
279
+
280
+      lv_obj_set_event_cb_mks(buttonBabyStep, event_handler, ID_O_BABY_STEP, NULL, 0);
281
+      lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_REL, "F:/bmp_mov.bin");
282
+      lv_imgbtn_set_src(buttonBabyStep, LV_BTN_STATE_PR, "F:/bmp_mov.bin");
283
+      lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_PR, &tft_style_label_pre);
284
+      lv_imgbtn_set_style(buttonBabyStep, LV_BTN_STATE_REL, &tft_style_label_rel);
285
+
286
+      #if HAS_ROTARY_ENCODER
287
+        if (gCfgItems.encoder_enable) {
288
+          lv_group_add_obj(g, buttonSpeed);
289
+          lv_group_add_obj(g, buttonBabyStep);
290
+        }
291
+      #endif
221 292
     }
222
-    if (gCfgItems.finish_power_off == 1)
223
-      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_auto_off.bin", 0);
224
-    else
225
-      lv_obj_set_event_cb_mks(buttonPowerOff, event_handler, ID_O_POWER_OFF, "bmp_manual_off.bin", 0);
226
-    lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_REL, &bmp_pic);
227
-    lv_imgbtn_set_src(buttonPowerOff, LV_BTN_STATE_PR, &bmp_pic);
228
-    lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_PR, &tft_style_label_pre);
229
-    lv_imgbtn_set_style(buttonPowerOff, LV_BTN_STATE_REL, &tft_style_label_rel);
230 293
 
231
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, "bmp_return.bin", 0);
232
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
233
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
294
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_O_RETURN, NULL, 0);
295
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
296
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
234 297
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
235 298
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
236 299
   #endif // if 1
237 300
 
238
-  lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
239
-  lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
301
+  #if HAS_ROTARY_ENCODER
302
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
303
+  #endif
240 304
 
305
+  lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
306
+  lv_obj_set_pos(buttonFilament, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
241 307
   lv_obj_set_pos(buttonFan, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
242
-  lv_obj_set_pos(buttonSpeed, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
308
+  lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
243 309
 
244 310
   if (uiCfg.print_state != WORKING) {
245 311
     /*
246 312
       lv_obj_set_pos(buttonFilament,INTERVAL_V,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
247 313
     } else {
248 314
     */
249
-    lv_obj_set_pos(buttonMove, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
250
-    lv_obj_set_pos(buttonPowerOff, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
315
+    lv_obj_set_pos(buttonExtrusion, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
316
+    lv_obj_set_pos(buttonMove, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
251 317
   }
252 318
   else {
253
-    lv_obj_set_pos(buttonPowerOff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
319
+    lv_obj_set_pos(buttonSpeed, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
320
+    lv_obj_set_pos(buttonBabyStep, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
254 321
   }
322
+
255 323
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
256 324
 
257
-  /*Create a label on the Image button*/
325
+  // Create labels on the image buttons
258 326
   lv_btn_set_layout(buttonPreHeat, LV_LAYOUT_OFF);
259
-  lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF);
327
+  lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
260 328
   lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF);
261
-  lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF);
329
+  lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF);
262 330
 
263 331
   if (uiCfg.print_state != WORKING) {
264 332
     /*
265 333
       lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
266 334
     } else {
267 335
     */
336
+    lv_btn_set_layout(buttonExtrusion, LV_LAYOUT_OFF);
268 337
     lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF);
269 338
   }
270
-  lv_btn_set_layout(buttonPowerOff, LV_LAYOUT_OFF);
339
+  else {
340
+    lv_btn_set_layout(buttonSpeed, LV_LAYOUT_OFF);
341
+    lv_btn_set_layout(buttonBabyStep, LV_LAYOUT_OFF);
342
+  }
343
+
271 344
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
272 345
 
273 346
   labelPreHeat   = lv_label_create(buttonPreHeat, NULL);
274
-  labelExtrusion = lv_label_create(buttonExtrusion, NULL);
275
-
347
+  label_Filament = lv_label_create(buttonFilament, NULL);
276 348
   label_Fan   = lv_label_create(buttonFan, NULL);
277
-  label_Speed = lv_label_create(buttonSpeed, NULL);
349
+  label_PowerOff = lv_label_create(buttonPowerOff, NULL);
278 350
 
279 351
   if (uiCfg.print_state != WORKING) {
280 352
     /*
281 353
       label_Filament = lv_label_create(buttonFilament, NULL);
282 354
     } else {
283 355
     */
284
-      label_Move = lv_label_create(buttonMove, NULL);
356
+    labelExtrusion = lv_label_create(buttonExtrusion, NULL);
357
+    label_Move = lv_label_create(buttonMove, NULL);
358
+  }
359
+  else {
360
+    label_Speed = lv_label_create(buttonSpeed, NULL);
361
+    label_BabyStep = lv_label_create(buttonBabyStep, NULL);
285 362
   }
286
-  label_PowerOff = lv_label_create(buttonPowerOff, NULL);
287
-
288 363
   label_Back = lv_label_create(buttonBack, NULL);
289 364
 
290 365
   if (gCfgItems.multiple_language != 0) {
291 366
     lv_label_set_text(labelPreHeat, operation_menu.temp);
292 367
     lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
293 368
 
294
-    lv_label_set_text(labelExtrusion, operation_menu.extr);
295
-    lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
369
+    lv_label_set_text(label_Filament, operation_menu.filament);
370
+    lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
296 371
 
297 372
     lv_label_set_text(label_Fan, operation_menu.fan);
298 373
     lv_obj_align(label_Fan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
299 374
 
300
-    lv_label_set_text(label_Speed, operation_menu.speed);
301
-    lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
375
+    if (gCfgItems.finish_power_off == 1)
376
+      lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
377
+    else
378
+      lv_label_set_text(label_PowerOff, printing_more_menu.manual);
379
+    lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
302 380
 
303 381
     if (uiCfg.print_state != WORKING) {
304 382
       /*
@@ -306,21 +384,30 @@ void lv_draw_operation(void) {
306 384
         lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
307 385
       } else {
308 386
       */
387
+      lv_label_set_text(labelExtrusion, operation_menu.extr);
388
+      lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
389
+
309 390
       lv_label_set_text(label_Move, operation_menu.move);
310 391
       lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
311 392
     }
393
+    else {
394
+      lv_label_set_text(label_Speed, operation_menu.speed);
395
+      lv_obj_align(label_Speed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
312 396
 
313
-    if (gCfgItems.finish_power_off == 1)
314
-      lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
315
-    else
316
-      lv_label_set_text(label_PowerOff, printing_more_menu.manual);
317
-    lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
397
+      lv_label_set_text(label_BabyStep, operation_menu.babystep);
398
+      lv_obj_align(label_BabyStep, buttonBabyStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
399
+    }
318 400
 
319 401
     lv_label_set_text(label_Back, common_menu.text_back);
320 402
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
321 403
   }
322 404
 }
323 405
 
324
-void lv_clear_operation() { lv_obj_del(scr); }
406
+void lv_clear_operation() {
407
+  #if HAS_ROTARY_ENCODER
408
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
409
+  #endif
410
+  lv_obj_del(scr);
411
+}
325 412
 
326 413
 #endif // HAS_TFT_LVGL_UI

+ 50
- 70
Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp View File

@@ -29,6 +29,7 @@
29 29
 #include "../../../../MarlinCore.h"
30 30
 #include "../../../../module/planner.h"
31 31
 
32
+extern lv_group_t * g;
32 33
 static lv_obj_t * scr;
33 34
 
34 35
 #define ID_PAUSE_RETURN 1
@@ -82,9 +83,9 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
82 83
 
83 84
 void lv_draw_pause_position(void) {
84 85
   lv_obj_t *buttonBack = NULL, *label_Back = NULL;
85
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
86
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
87
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
86
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
87
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
88
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
88 89
 
89 90
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
90 91
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) {
@@ -106,85 +107,60 @@ void lv_draw_pause_position(void) {
106 107
 
107 108
   lv_refr_now(lv_refr_get_disp_refreshing());
108 109
 
109
-  LV_IMG_DECLARE(bmp_para_back);
110
-  // LV_IMG_DECLARE(bmp_para_arrow);
111
-  LV_IMG_DECLARE(bmp_para_bank);
110
+  labelXText = lv_label_create(scr, NULL);
111
+  lv_obj_set_style(labelXText, &tft_style_label_rel);
112
+  lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
113
+  lv_label_set_text(labelXText, machine_menu.xPos);
112 114
 
113
-  buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
114
-  lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
115
-  lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
116
-  lv_obj_set_event_cb(buttonXText, event_handler);
117
-  lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
118
-  lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
119
-  lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
120
-  labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
121
-
122
-  buttonXValue = lv_imgbtn_create(scr, NULL);
115
+  buttonXValue = lv_btn_create(scr, NULL);
123 116
   lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
124
-  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, "bmp_value_blank.bin", 0);
125
-  lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
126
-  lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
127
-  lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
128
-  lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
129
-  lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
117
+  lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
118
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
119
+  lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
120
+  lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_PAUSE_X, NULL, 0);
130 121
   labelXValue = lv_label_create(buttonXValue, NULL);
131 122
 
132 123
   line1 = lv_line_create(scr, NULL);
133 124
   lv_ex_line(line1, line_points[0]);
134 125
 
135
-  buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
136
-  lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
137
-  lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
138
-  lv_obj_set_event_cb(buttonYText, event_handler);
139
-  lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
140
-  lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
141
-  lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
142
-  labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
126
+  labelYText = lv_label_create(scr, NULL);
127
+  lv_obj_set_style(labelYText, &tft_style_label_rel);
128
+  lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
129
+  lv_label_set_text(labelYText, machine_menu.yPos);
143 130
 
144
-  buttonYValue = lv_imgbtn_create(scr, NULL);
131
+  buttonYValue = lv_btn_create(scr, NULL);
145 132
   lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
146
-  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, "bmp_value_blank.bin", 0);
147
-  lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
148
-  lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
149
-  lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
150
-  lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
151
-  lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
133
+  lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
134
+  lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_PAUSE_Y, NULL, 0);
135
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
136
+  lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
152 137
   labelYValue = lv_label_create(buttonYValue, NULL);
153 138
 
154 139
   line2 = lv_line_create(scr, NULL);
155 140
   lv_ex_line(line2, line_points[1]);
156 141
 
157
-  buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
158
-  lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
159
-  lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
160
-  lv_obj_set_event_cb(buttonZText, event_handler);
161
-  lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
162
-  lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
163
-  lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
164
-  labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
142
+  labelZText = lv_label_create(scr, NULL);
143
+  lv_obj_set_style(labelZText, &tft_style_label_rel);
144
+  lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
145
+  lv_label_set_text(labelZText, machine_menu.zPos);
165 146
 
166
-  buttonZValue = lv_imgbtn_create(scr, NULL);
147
+  buttonZValue = lv_btn_create(scr, NULL);
167 148
   lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
168
-  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, "bmp_value_blank.bin", 0);
169
-  lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
170
-  lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
171
-  lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
172
-  lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
173
-  lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
149
+  lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
150
+  lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_PAUSE_Z, NULL, 0);
151
+  lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
152
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
174 153
   labelZValue = lv_label_create(buttonZValue, NULL);
175 154
 
176 155
   line3 = lv_line_create(scr, NULL);
177 156
   lv_ex_line(line3, line_points[2]);
178 157
 
179
-  buttonBack = lv_imgbtn_create(scr, NULL);
180
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PAUSE_RETURN, "bmp_back70x40.bin", 0);
181
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
182
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
183
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
184
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
185
-
158
+  buttonBack = lv_btn_create(scr, NULL);
186 159
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
187
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
160
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
161
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_PAUSE_RETURN, NULL, 0);
162
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
163
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
188 164
   label_Back = lv_label_create(buttonBack, NULL);
189 165
 
190 166
   if (gCfgItems.multiple_language != 0) {
@@ -203,20 +179,24 @@ void lv_draw_pause_position(void) {
203 179
     lv_label_set_text(labelZValue, public_buf_l);
204 180
     lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
205 181
 
206
-    lv_label_set_text(labelXText, machine_menu.xPos);
207
-    lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
208
-
209
-    lv_label_set_text(labelYText, machine_menu.yPos);
210
-    lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
211
-
212
-    lv_label_set_text(labelZText, machine_menu.zPos);
213
-    lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
214
-
215 182
     lv_label_set_text(label_Back, common_menu.text_back);
216 183
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
217 184
   }
185
+  #if HAS_ROTARY_ENCODER
186
+    if (gCfgItems.encoder_enable) {
187
+      lv_group_add_obj(g, buttonXValue);
188
+      lv_group_add_obj(g, buttonYValue);
189
+      lv_group_add_obj(g, buttonZValue);
190
+      lv_group_add_obj(g, buttonBack);
191
+    }
192
+  #endif
218 193
 }
219 194
 
220
-void lv_clear_pause_position() { lv_obj_del(scr); }
195
+void lv_clear_pause_position() {
196
+  #if HAS_ROTARY_ENCODER
197
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
198
+  #endif
199
+  lv_obj_del(scr);
200
+}
221 201
 
222 202
 #endif // HAS_TFT_LVGL_UI

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

@@ -34,9 +34,10 @@
34 34
 #include "../../../../module/temperature.h"
35 35
 
36 36
 static lv_obj_t * scr;
37
+extern lv_group_t*  g;
37 38
 static lv_obj_t *buttoType, *buttonStep;
38
-static lv_obj_t * labelType;
39
-static lv_obj_t * labelStep;
39
+static lv_obj_t *labelType;
40
+static lv_obj_t *labelStep;
40 41
 static lv_obj_t * tempText1;
41 42
 
42 43
 #define ID_P_ADD    1
@@ -58,23 +59,22 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
58 59
           if (uiCfg.curSprayerChoose == 0) {
59 60
             if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
60 61
               thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
61
-              thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
62 62
             }
63 63
           }
64 64
           #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
65 65
             else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
66 66
               thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
67
-              thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
68 67
             }
69 68
           #endif
69
+          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
70 70
         }
71 71
         #if HAS_HEATED_BED
72 72
           else {
73 73
             thermalManager.temp_bed.target += uiCfg.stepHeat;
74 74
             if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
75 75
               thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
76
-              thermalManager.start_watching_bed();
77 76
             }
77
+            thermalManager.start_watching_bed();
78 78
           }
79 79
         #endif
80 80
         disp_desire_temp();
@@ -88,23 +88,21 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
88 88
         if (uiCfg.curTempType == 0) {
89 89
           if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) {
90 90
             thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
91
-            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
92 91
           }
93 92
           else {
94 93
             thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0;
95
-            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
96 94
           }
95
+          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
97 96
         }
98 97
         #if HAS_HEATED_BED
99 98
           else {
100 99
             if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) {
101 100
               thermalManager.temp_bed.target -= uiCfg.stepHeat;
102
-              thermalManager.start_watching_bed();
103 101
             }
104 102
             else {
105 103
               thermalManager.temp_bed.target = (float)0;
106
-              thermalManager.start_watching_bed();
107 104
             }
105
+            thermalManager.start_watching_bed();
108 106
           }
109 107
         #endif
110 108
         disp_desire_temp();
@@ -212,9 +210,7 @@ void lv_draw_preHeat(void) {
212 210
 
213 211
   lv_refr_now(lv_refr_get_disp_refreshing());
214 212
 
215
-  LV_IMG_DECLARE(bmp_pic);
216
-
217
-  /*Create an Image button*/
213
+  // Create image buttons
218 214
   buttonAdd  = lv_imgbtn_create(scr, NULL);
219 215
   buttonDec  = lv_imgbtn_create(scr, NULL);
220 216
   buttoType  = lv_imgbtn_create(scr, NULL);
@@ -222,40 +218,37 @@ void lv_draw_preHeat(void) {
222 218
   buttonOff  = lv_imgbtn_create(scr, NULL);
223 219
   buttonBack = lv_imgbtn_create(scr, NULL);
224 220
 
225
-  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, "bmp_Add.bin", 0);
226
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, &bmp_pic);
227
-  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, &bmp_pic);
221
+  lv_obj_set_event_cb_mks(buttonAdd, event_handler, ID_P_ADD, NULL, 0);
222
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_REL, "F:/bmp_Add.bin");
223
+  lv_imgbtn_set_src(buttonAdd, LV_BTN_STATE_PR, "F:/bmp_Add.bin");
228 224
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_PR, &tft_style_label_pre);
229 225
   lv_imgbtn_set_style(buttonAdd, LV_BTN_STATE_REL, &tft_style_label_rel);
230 226
   lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
227
+
231 228
   #if 1
232
-    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, "bmp_Dec.bin", 0);
233
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, &bmp_pic);
234
-    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, &bmp_pic);
229
+    lv_obj_set_event_cb_mks(buttonDec, event_handler, ID_P_DEC, NULL, 0);
230
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_REL, "F:/bmp_Dec.bin");
231
+    lv_imgbtn_set_src(buttonDec, LV_BTN_STATE_PR, "F:/bmp_Dec.bin");
235 232
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_PR, &tft_style_label_pre);
236 233
     lv_imgbtn_set_style(buttonDec, LV_BTN_STATE_REL, &tft_style_label_rel);
237 234
 
238
-
239
-    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, &bmp_pic);
240
-    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, &bmp_pic);
235
+    lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, NULL, 0);
241 236
     lv_imgbtn_set_style(buttoType, LV_BTN_STATE_PR, &tft_style_label_pre);
242 237
     lv_imgbtn_set_style(buttoType, LV_BTN_STATE_REL, &tft_style_label_rel);
243 238
 
244
-
245
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, &bmp_pic);
246
-    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, &bmp_pic);
239
+    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, NULL, 0);
247 240
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_PR, &tft_style_label_pre);
248 241
     lv_imgbtn_set_style(buttonStep, LV_BTN_STATE_REL, &tft_style_label_rel);
249 242
 
250
-    lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, "bmp_speed0.bin", 0);
251
-    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, &bmp_pic);
252
-    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, &bmp_pic);
243
+    lv_obj_set_event_cb_mks(buttonOff, event_handler, ID_P_OFF, NULL, 0);
244
+    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_REL, "F:/bmp_speed0.bin");
245
+    lv_imgbtn_set_src(buttonOff, LV_BTN_STATE_PR, "F:/bmp_speed0.bin");
253 246
     lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_PR, &tft_style_label_pre);
254 247
     lv_imgbtn_set_style(buttonOff, LV_BTN_STATE_REL, &tft_style_label_rel);
255 248
 
256
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_return.bin", 0);
257
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
258
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
249
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0);
250
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
251
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
259 252
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
260 253
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
261 254
   #endif
@@ -295,6 +288,16 @@ void lv_draw_preHeat(void) {
295 288
     lv_label_set_text(label_Back, common_menu.text_back);
296 289
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
297 290
   }
291
+  #if HAS_ROTARY_ENCODER
292
+    if (gCfgItems.encoder_enable) {
293
+      lv_group_add_obj(g, buttonAdd);
294
+      lv_group_add_obj(g, buttonDec);
295
+      lv_group_add_obj(g, buttoType);
296
+      lv_group_add_obj(g, buttonStep);
297
+      lv_group_add_obj(g, buttonOff);
298
+      lv_group_add_obj(g, buttonBack);
299
+    }
300
+  #endif
298 301
 
299 302
   disp_temp_type();
300 303
   disp_step_heat();
@@ -307,14 +310,16 @@ void lv_draw_preHeat(void) {
307 310
 void disp_temp_type() {
308 311
   if (uiCfg.curTempType == 0) {
309 312
     if (uiCfg.curSprayerChoose == 1) {
310
-      lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru2.bin", 0);
313
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru2.bin");
314
+      lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru2.bin");
311 315
       if (gCfgItems.multiple_language != 0) {
312 316
         lv_label_set_text(labelType, preheat_menu.ext2);
313 317
         lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
314 318
       }
315 319
     }
316 320
     else {
317
-      lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_extru1.bin", 0);
321
+    lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_extru1.bin");
322
+      lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_extru1.bin");
318 323
       if (gCfgItems.multiple_language != 0) {
319 324
         lv_label_set_text(labelType, preheat_menu.ext1);
320 325
         lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -323,7 +328,8 @@ void disp_temp_type() {
323 328
 
324 329
   }
325 330
   else {
326
-    lv_obj_set_event_cb_mks(buttoType, event_handler, ID_P_TYPE, "bmp_bed.bin", 0);
331
+  lv_imgbtn_set_src(buttoType, LV_BTN_STATE_REL, "F:/bmp_bed.bin");
332
+      lv_imgbtn_set_src(buttoType, LV_BTN_STATE_PR, "F:/bmp_bed.bin");
327 333
     if (gCfgItems.multiple_language != 0) {
328 334
       lv_label_set_text(labelType, preheat_menu.hotbed);
329 335
       lv_obj_align(labelType, buttoType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -356,12 +362,18 @@ void disp_desire_temp() {
356 362
 }
357 363
 
358 364
 void disp_step_heat() {
359
-  if (uiCfg.stepHeat == 1)
360
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step1_degree.bin", 0);
361
-  else if (uiCfg.stepHeat == 5)
362
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step5_degree.bin", 0);
363
-  else if (uiCfg.stepHeat == 10)
364
-    lv_obj_set_event_cb_mks(buttonStep, event_handler, ID_P_STEP, "bmp_step10_degree.bin", 0);
365
+  if (uiCfg.stepHeat == 1) {
366
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step1_degree.bin");
367
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step1_degree.bin");
368
+  }
369
+  else if (uiCfg.stepHeat == 5) {
370
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step5_degree.bin");
371
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step5_degree.bin");
372
+  }
373
+  else if (uiCfg.stepHeat == 10) {
374
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_REL, "F:/bmp_step10_degree.bin");
375
+    lv_imgbtn_set_src(buttonStep, LV_BTN_STATE_PR, "F:/bmp_step10_degree.bin");
376
+  }
365 377
 
366 378
   if (gCfgItems.multiple_language != 0) {
367 379
     if (uiCfg.stepHeat == 1) {
@@ -379,6 +391,11 @@ void disp_step_heat() {
379 391
   }
380 392
 }
381 393
 
382
-void lv_clear_preHeat() { lv_obj_del(scr); }
394
+void lv_clear_preHeat() {
395
+  #if HAS_ROTARY_ENCODER
396
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
397
+  #endif
398
+  lv_obj_del(scr);
399
+}
383 400
 
384 401
 #endif // HAS_TFT_LVGL_UI

+ 61
- 42
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp View File

@@ -33,6 +33,7 @@
33 33
 #include "../../../../sd/cardreader.h"
34 34
 
35 35
 static lv_obj_t * scr;
36
+extern lv_group_t*  g;
36 37
 
37 38
 static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
38 39
                 *buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
@@ -132,11 +133,6 @@ uint8_t have_pre_pic(char *path) {
132 133
   return 0;
133 134
 }
134 135
 
135
-LV_IMG_DECLARE(bmp_pic_117x92);
136
-LV_IMG_DECLARE(bmp_pic_100x100);
137
-LV_IMG_DECLARE(bmp_pic);
138
-LV_IMG_DECLARE(bmp_pic_100x40);
139
-
140 136
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
141 137
   uint8_t i, file_count = 0;
142 138
   //switch (obj->mks_obj_id)
@@ -157,7 +153,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
157 153
         #endif
158 154
         if (file_count != 0) {
159 155
           dir_offset[curDirLever].curPage--;
160
-          lv_obj_del(scr);
156
+          lv_clear_print_file();
161 157
           disp_gcode_icon(file_count);
162 158
         }
163 159
       }
@@ -175,7 +171,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
175 171
         #endif
176 172
         if (file_count != 0) {
177 173
           dir_offset[curDirLever].curPage++;
178
-          lv_obj_del(scr);
174
+          lv_clear_print_file();
179 175
           disp_gcode_icon(file_count);
180 176
         }
181 177
         if (file_count < FILE_NUM)
@@ -202,12 +198,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
202 198
           #if ENABLED(SDSUPPORT)
203 199
             file_count = search_file();
204 200
           #endif
205
-          lv_obj_del(scr);
201
+          lv_clear_print_file();
206 202
           disp_gcode_icon(file_count);
207 203
         }
208 204
       }
209 205
       else {
210
-        lv_obj_del(scr);
206
+        lv_clear_print_file();
211 207
         lv_draw_ready_print();
212 208
       }
213 209
     }
@@ -227,12 +223,12 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
227 223
               #if ENABLED(SDSUPPORT)
228 224
                 file_count = search_file();
229 225
               #endif
230
-              lv_obj_del(scr);
226
+              lv_clear_print_file();
231 227
               disp_gcode_icon(file_count);
232 228
             }
233 229
             else {
234 230
               sel_id = i;
235
-              lv_obj_del(scr);
231
+              lv_clear_print_file();
236 232
               lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
237 233
             }
238 234
             break;
@@ -269,9 +265,9 @@ void lv_draw_print_file(void) {
269 265
   #endif
270 266
   disp_gcode_icon(file_count);
271 267
 
272
-  //lv_obj_t * labelPageUp = lv_label_create(buttonPageUp, NULL);
273
-  //lv_obj_t * labelPageDown = lv_label_create(buttonPageDown, NULL);
274
-  //lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
268
+  //lv_obj_t *labelPageUp = lv_label_create(buttonPageUp, NULL);
269
+  //lv_obj_t *labelPageDown = lv_label_create(buttonPageDown, NULL);
270
+  //lv_obj_t *label_Back = lv_label_create(buttonBack, NULL);
275 271
 
276 272
   /*
277 273
   if (gCfgItems.multiple_language != 0) {
@@ -286,7 +282,7 @@ void lv_draw_print_file(void) {
286 282
   }
287 283
   */
288 284
 }
289
-
285
+static char test_public_buf_l[40];
290 286
 void disp_gcode_icon(uint8_t file_num) {
291 287
   uint8_t i;
292 288
 
@@ -310,23 +306,22 @@ void disp_gcode_icon(uint8_t file_num) {
310 306
   buttonPageDown = lv_imgbtn_create(scr, NULL);
311 307
   buttonBack     = lv_imgbtn_create(scr, NULL);
312 308
 
313
-  lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, "bmp_pageUp.bin", 0);
314
-  lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, &bmp_pic_117x92);
315
-  lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, &bmp_pic_117x92);
309
+  lv_obj_set_event_cb_mks(buttonPageUp, event_handler, ID_P_UP, NULL, 0);
310
+  lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_REL, "F:/bmp_pageUp.bin");
311
+  lv_imgbtn_set_src(buttonPageUp, LV_BTN_STATE_PR, "F:/bmp_pageUp.bin");
316 312
   lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_PR, &tft_style_label_pre);
317 313
   lv_imgbtn_set_style(buttonPageUp, LV_BTN_STATE_REL, &tft_style_label_rel);
318
-  lv_obj_clear_protect(buttonPageUp, LV_PROTECT_FOLLOW);
319 314
 
320 315
   #if 1
321
-    lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, "bmp_pageDown.bin", 0);
322
-    lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, &bmp_pic_117x92);
323
-    lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, &bmp_pic_117x92);
316
+    lv_obj_set_event_cb_mks(buttonPageDown, event_handler, ID_P_DOWN, NULL, 0);
317
+    lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin");
318
+    lv_imgbtn_set_src(buttonPageDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin");
324 319
     lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_PR, &tft_style_label_pre);
325 320
     lv_imgbtn_set_style(buttonPageDown, LV_BTN_STATE_REL, &tft_style_label_rel);
326 321
 
327
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, "bmp_back.bin", 0);
328
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic_117x92);
329
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic_117x92);
322
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_P_RETURN, NULL, 0);
323
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin");
324
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin");
330 325
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
331 326
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
332 327
   #endif
@@ -365,9 +360,9 @@ void disp_gcode_icon(uint8_t file_num) {
365 360
       cutFileName((char *)list_file.long_name[i], 16, 8,  (char *)public_buf_m);
366 361
 
367 362
       if (list_file.IsFolder[i] == 1) {
368
-        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_dir.bin", 0);
369
-        lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic);
370
-        lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic);
363
+        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
364
+        lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_dir.bin");
365
+        lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_dir.bin");
371 366
         if (i < 3)
372 367
           lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
373 368
         else
@@ -380,9 +375,17 @@ void disp_gcode_icon(uint8_t file_num) {
380 375
       }
381 376
       else {
382 377
         if (have_pre_pic((char *)list_file.file_name[i])) {
383
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
384
-          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic_100x100);
385
-          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic_100x100);
378
+
379
+          //lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
380
+
381
+          ZERO(test_public_buf_l);
382
+          strcat(test_public_buf_l,"S:");
383
+          strcat(test_public_buf_l,list_file.file_name[i]);
384
+          char *temp = strstr(test_public_buf_l,".GCO");
385
+          if (temp) { strcpy(temp,".bin"); }
386
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
387
+          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, test_public_buf_l);
388
+          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, test_public_buf_l);
386 389
           if (i < 3) {
387 390
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET);
388 391
             buttonText[i] = lv_btn_create(scr, NULL);
@@ -395,8 +398,6 @@ void disp_gcode_icon(uint8_t file_num) {
395 398
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
396 399
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
397 400
             //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0);
398
-            //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40);
399
-            //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40);
400 401
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1) + FILE_PRE_PIC_X_OFFSET, titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
401 402
             lv_obj_set_size(buttonText[i], 100, 40);
402 403
           }
@@ -412,8 +413,6 @@ void disp_gcode_icon(uint8_t file_num) {
412 413
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
413 414
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
414 415
             //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL,0);
415
-            //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_REL, &bmp_pic_100x40);
416
-            //lv_imgbtn_set_src(buttonText[i], LV_BTN_STATE_PR, &bmp_pic_100x40);
417 416
             lv_obj_set_pos(buttonText[i], BTN_X_PIXEL * (i - 3) + INTERVAL_V * ((i - 3) + 1) + FILE_PRE_PIC_X_OFFSET, BTN_Y_PIXEL + INTERVAL_H + titleHeight + FILE_PRE_PIC_Y_OFFSET + 100);
418 417
             lv_obj_set_size(buttonText[i], 100, 40);
419 418
           }
@@ -423,9 +422,9 @@ void disp_gcode_icon(uint8_t file_num) {
423 422
           lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
424 423
         }
425 424
         else {
426
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), "bmp_file.bin", 0);
427
-          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, &bmp_pic);
428
-          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, &bmp_pic);
425
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
426
+          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_REL, "F:/bmp_file.bin");
427
+          lv_imgbtn_set_src(buttonGcode[i], LV_BTN_STATE_PR, "F:/bmp_file.bin");
429 428
           if (i < 3)
430 429
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
431 430
           else
@@ -437,15 +436,26 @@ void disp_gcode_icon(uint8_t file_num) {
437 436
           lv_obj_align(labelPageUp[i], buttonGcode[i], LV_ALIGN_IN_BOTTOM_MID, 0, -5);
438 437
         }
439 438
       }
439
+      #if HAS_ROTARY_ENCODER
440
+        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonGcode[i]);
441
+      #endif
442
+
440 443
     #else // !TFT35
441 444
     #endif // !TFT35
442 445
   }
446
+  #if HAS_ROTARY_ENCODER
447
+    if (gCfgItems.encoder_enable) {
448
+      lv_group_add_obj(g, buttonPageUp);
449
+      lv_group_add_obj(g, buttonPageDown);
450
+      lv_group_add_obj(g, buttonBack);
451
+    }
452
+  #endif
443 453
 }
444 454
 
445
-void lv_open_gcode_file(char *path) {
455
+uint32_t lv_open_gcode_file(char *path) {
446 456
   #if ENABLED(SDSUPPORT)
447 457
     uint32_t *ps4;
448
-    int pre_sread_cnt;
458
+    uint32_t pre_sread_cnt = 0;
449 459
     char *cur_name;
450 460
 
451 461
     cur_name = strrchr(path, '/');
@@ -458,10 +468,10 @@ void lv_open_gcode_file(char *path) {
458 468
       pre_sread_cnt = (uint32_t)ps4 - (uint32_t)((uint32_t *)(&public_buf[0]));
459 469
       card.setIndex(pre_sread_cnt);
460 470
     }
471
+    return pre_sread_cnt;
461 472
   #endif // SDSUPPORT
462 473
 }
463 474
 
464
-
465 475
 int ascii2dec_test(char *ascii) {
466 476
   int result = 0;
467 477
   if (ascii == 0) return 0;
@@ -534,6 +544,10 @@ void lv_gcode_file_read(uint8_t *data_buf) {
534 544
 
535 545
 void lv_close_gcode_file() {TERN_(SDSUPPORT, card.closefile());}
536 546
 
547
+void lv_gcode_file_seek(uint32_t pos) {
548
+  card.setIndex(pos);
549
+}
550
+
537 551
 void cutFileName(char *path, int len, int bytePerLine,  char *outStr) {
538 552
   #if _LFN_UNICODE
539 553
     TCHAR *tmpFile;
@@ -616,6 +630,11 @@ void cutFileName(char *path, int len, int bytePerLine,  char *outStr) {
616 630
   #endif
617 631
 }
618 632
 
619
-void lv_clear_print_file() { lv_obj_del(scr); }
633
+void lv_clear_print_file() {
634
+  #if HAS_ROTARY_ENCODER
635
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
636
+  #endif
637
+  lv_obj_del(scr);
638
+}
620 639
 
621 640
 #endif // HAS_TFT_LVGL_UI

+ 2
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h View File

@@ -52,12 +52,13 @@ extern LIST_FILE list_file;
52 52
 
53 53
 extern void disp_gcode_icon(uint8_t file_num);
54 54
 extern void lv_draw_print_file(void);
55
-extern void lv_open_gcode_file(char *path);
55
+extern uint32_t lv_open_gcode_file(char *path);
56 56
 extern void lv_gcode_file_read(uint8_t *data_buf);
57 57
 extern void lv_close_gcode_file();
58 58
 extern void cutFileName(char *path, int len, int bytePerLine,  char *outStr);
59 59
 extern int ascii2dec_test(char *ascii);
60 60
 extern void lv_clear_print_file();
61
+extern void lv_gcode_file_seek(uint32_t pos);
61 62
 
62 63
 //extern void disp_temp_ready_print();
63 64
 #ifdef __cplusplus

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

@@ -35,6 +35,7 @@
35 35
 #include "../../../../module/motion.h"
36 36
 #include "../../../../sd/cardreader.h"
37 37
 #include "../../../../gcode/queue.h"
38
+#include "../../../../gcode/gcode.h"
38 39
 
39 40
 #if ENABLED(POWER_LOSS_RECOVERY)
40 41
   #include "../../../../feature/powerloss.h"
@@ -43,10 +44,11 @@
43 44
   #include "../../../ultralcd.h"
44 45
 #endif
45 46
 
47
+extern lv_group_t * g;
46 48
 static lv_obj_t * scr;
47
-static lv_obj_t * labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
48
-static lv_obj_t * labelPause, * labelStop, * labelOperat;
49
-static lv_obj_t * bar1;
49
+static lv_obj_t *labelExt1, * labelExt2, * labelFan, * labelZpos, * labelTime;
50
+static lv_obj_t *labelPause, * labelStop, * labelOperat;
51
+static lv_obj_t * bar1, *bar1ValueText;
50 52
 static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
51 53
 
52 54
 #if HAS_HEATED_BED
@@ -57,8 +59,6 @@ static lv_obj_t * buttonPause, *buttonOperat, *buttonStop;
57 59
 #define ID_STOP   2
58 60
 #define ID_OPTION 3
59 61
 
60
-lv_style_t lv_bar_style_indic;
61
-
62 62
 uint8_t once_flag = 0;
63 63
 extern uint32_t To_pre_view;
64 64
 extern uint8_t flash_preview_begin;
@@ -82,21 +82,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
82 82
               stop_print_time();
83 83
               uiCfg.print_state = PAUSING;
84 84
             #endif
85
-            lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
85
+            lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
86
+            lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
86 87
             lv_label_set_text(labelPause, printing_menu.resume);
87 88
             lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
88 89
           }
89 90
           else if (uiCfg.print_state == PAUSED) {
90 91
             uiCfg.print_state = RESUMING;
91
-            // if (IS_SD_PAUSED())queue.inject_P(PSTR("M24"));// queue.inject_P(M24_STR);
92
-            lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
92
+            lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
93
+            lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
93 94
             lv_label_set_text(labelPause, printing_menu.pause);
94 95
             lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
95 96
           }
96 97
           #if ENABLED(POWER_LOSS_RECOVERY)
97 98
             else if (uiCfg.print_state == REPRINTING) {
98 99
               uiCfg.print_state = REPRINTED;
99
-              lv_obj_set_event_cb_mks(obj, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
100
+              lv_imgbtn_set_src(obj, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
101
+              lv_imgbtn_set_src(obj, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
100 102
               lv_label_set_text(labelPause, printing_menu.pause);
101 103
               lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
102 104
               // recovery.resume();
@@ -115,7 +117,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
115 117
       }
116 118
       else if (event == LV_EVENT_RELEASED) {
117 119
         if (gcode_preview_over != 1) {
118
-          lv_obj_del(scr);
120
+          lv_clear_printing();
119 121
           lv_draw_dialog(DIALOG_TYPE_STOP);
120 122
         }
121 123
       }
@@ -126,7 +128,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
126 128
       }
127 129
       else if (event == LV_EVENT_RELEASED) {
128 130
         if (gcode_preview_over != 1) {
129
-          lv_obj_del(scr);
131
+          lv_clear_printing();
130 132
           lv_draw_operation();
131 133
         }
132 134
       }
@@ -159,88 +161,71 @@ void lv_draw_printing(void) {
159 161
 
160 162
   lv_refr_now(lv_refr_get_disp_refreshing());
161 163
 
162
-  LV_IMG_DECLARE(bmp_pic_150x80);
163
-  LV_IMG_DECLARE(bmp_pic_45x45);
164
-
165
-  /*Create an Image button*/
166
-  buttonExt1 = lv_imgbtn_create(scr, NULL);
167
-  if (EXTRUDERS == 2)
168
-    buttonExt2 = lv_imgbtn_create(scr, NULL);
169
-
164
+  // Create image buttons
165
+  buttonExt1 = lv_img_create(scr, NULL);
166
+  #if HAS_MULTI_EXTRUDER
167
+    buttonExt2 = lv_img_create(scr, NULL);
168
+  #endif
170 169
   #if HAS_HEATED_BED
171
-    buttonBedstate = lv_imgbtn_create(scr, NULL);
170
+    buttonBedstate = lv_img_create(scr, NULL);
172 171
   #endif
173
-
174
-  buttonFanstate = lv_imgbtn_create(scr, NULL);
175
-  buttonZpos     = lv_imgbtn_create(scr, NULL);
172
+  buttonFanstate = lv_img_create(scr, NULL);
173
+  buttonTime     = lv_img_create(scr, NULL);
174
+  buttonZpos     = lv_img_create(scr, NULL);
176 175
   buttonPause    = lv_imgbtn_create(scr, NULL);
177 176
   buttonStop     = lv_imgbtn_create(scr, NULL);
178 177
   buttonOperat   = lv_imgbtn_create(scr, NULL);
179
-  buttonTime     = lv_imgbtn_create(scr, NULL);
180
-
181
-  lv_obj_set_event_cb_mks(buttonExt1, event_handler, 0, "bmp_ext1_state.bin", 0);
182
-  lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_REL, &bmp_pic_45x45);
183
-  lv_imgbtn_set_src(buttonExt1, LV_BTN_STATE_PR, &bmp_pic_45x45);
184
-  lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_PR, &tft_style_label_pre);
185
-  lv_imgbtn_set_style(buttonExt1, LV_BTN_STATE_REL, &tft_style_label_rel);
186
-  lv_obj_clear_protect(buttonExt1, LV_PROTECT_FOLLOW);
178
+
179
+  lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
187 180
   #if 1
188
-    if (EXTRUDERS == 2) {
189
-      lv_obj_set_event_cb_mks(buttonExt2, event_handler, 0, "bmp_ext2_state.bin", 0);
190
-      lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_REL, &bmp_pic_45x45);
191
-      lv_imgbtn_set_src(buttonExt2, LV_BTN_STATE_PR, &bmp_pic_45x45);
192
-      lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_PR, &tft_style_label_pre);
193
-      lv_imgbtn_set_style(buttonExt2, LV_BTN_STATE_REL, &tft_style_label_rel);
194
-    }
181
+    #if HAS_MULTI_EXTRUDER
182
+      lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
183
+    #endif
195 184
     #if HAS_HEATED_BED
196
-      lv_obj_set_event_cb_mks(buttonBedstate, event_handler, 0, "bmp_bed_state.bin", 0);
197
-      lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
198
-      lv_imgbtn_set_src(buttonBedstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
199
-      lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_PR, &tft_style_label_pre);
200
-      lv_imgbtn_set_style(buttonBedstate, LV_BTN_STATE_REL, &tft_style_label_rel);
185
+      lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
201 186
     #endif
202 187
 
203
-    lv_obj_set_event_cb_mks(buttonFanstate, event_handler, 0, "bmp_fan_state.bin", 0);
204
-    lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_REL, &bmp_pic_45x45);
205
-    lv_imgbtn_set_src(buttonFanstate, LV_BTN_STATE_PR, &bmp_pic_45x45);
206
-    lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_PR, &tft_style_label_pre);
207
-    lv_imgbtn_set_style(buttonFanstate, LV_BTN_STATE_REL, &tft_style_label_rel);
208
-
209
-    lv_obj_set_event_cb_mks(buttonTime, event_handler, 0, "bmp_time_state.bin", 0);
210
-    lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_REL, &bmp_pic_45x45);
211
-    lv_imgbtn_set_src(buttonTime, LV_BTN_STATE_PR, &bmp_pic_45x45);
212
-    lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_PR, &tft_style_label_pre);
213
-    lv_imgbtn_set_style(buttonTime, LV_BTN_STATE_REL, &tft_style_label_rel);
214
-
215
-    lv_obj_set_event_cb_mks(buttonZpos, event_handler, 0, "bmp_zpos_state.bin", 0);
216
-    lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_REL, &bmp_pic_45x45);
217
-    lv_imgbtn_set_src(buttonZpos, LV_BTN_STATE_PR, &bmp_pic_45x45);
218
-    lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_PR, &tft_style_label_pre);
219
-    lv_imgbtn_set_style(buttonZpos, LV_BTN_STATE_REL, &tft_style_label_rel);
220
-
221
-    if (uiCfg.print_state == WORKING)
222
-      lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_pause.bin", 0);
223
-    else
224
-      lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, "bmp_resume.bin", 0);
225
-
226
-    lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, &bmp_pic_150x80);
227
-    lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, &bmp_pic_150x80);
188
+    lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
189
+
190
+    lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
191
+
192
+    lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
193
+
194
+    if (uiCfg.print_state == WORKING) {
195
+      lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_pause.bin");
196
+      lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_pause.bin");
197
+    }
198
+    else {
199
+      lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_REL, "F:/bmp_resume.bin");
200
+      lv_imgbtn_set_src(buttonPause, LV_BTN_STATE_PR, "F:/bmp_resume.bin");
201
+    }
202
+
203
+    lv_obj_set_event_cb_mks(buttonPause, event_handler, ID_PAUSE, NULL, 0);
228 204
     lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_PR, &tft_style_label_pre);
229 205
     lv_imgbtn_set_style(buttonPause, LV_BTN_STATE_REL, &tft_style_label_rel);
230 206
 
231
-    lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, "bmp_stop.bin", 0);
232
-    lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, &bmp_pic_150x80);
233
-    lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, &bmp_pic_150x80);
207
+    lv_obj_set_event_cb_mks(buttonStop, event_handler, ID_STOP, NULL, 0);
208
+    lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_REL, "F:/bmp_stop.bin");
209
+    lv_imgbtn_set_src(buttonStop, LV_BTN_STATE_PR, "F:/bmp_stop.bin");
234 210
     lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_PR, &tft_style_label_pre);
235 211
     lv_imgbtn_set_style(buttonStop, LV_BTN_STATE_REL, &tft_style_label_rel);
236 212
 
237
-    lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, "bmp_operate.bin", 0);
238
-    lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, &bmp_pic_150x80);
239
-    lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, &bmp_pic_150x80);
213
+    lv_obj_set_event_cb_mks(buttonOperat, event_handler, ID_OPTION, NULL, 0);
214
+    lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_REL, "F:/bmp_operate.bin");
215
+    lv_imgbtn_set_src(buttonOperat, LV_BTN_STATE_PR, "F:/bmp_operate.bin");
240 216
     lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_PR, &tft_style_label_pre);
241 217
     lv_imgbtn_set_style(buttonOperat, LV_BTN_STATE_REL, &tft_style_label_rel);
218
+
242 219
   #endif // if 1
243 220
 
221
+  #if HAS_ROTARY_ENCODER
222
+    if (gCfgItems.encoder_enable) {
223
+      lv_group_add_obj(g, buttonPause);
224
+      lv_group_add_obj(g, buttonStop);
225
+      lv_group_add_obj(g, buttonOperat);
226
+    }
227
+  #endif
228
+
244 229
   lv_obj_set_pos(buttonExt1, 205, 136);
245 230
 
246 231
   #if HAS_MULTI_EXTRUDER
@@ -258,17 +243,19 @@ void lv_draw_printing(void) {
258 243
   lv_obj_set_pos(buttonStop, 165, 240);
259 244
   lv_obj_set_pos(buttonOperat, 325, 240);
260 245
 
261
-  /*Create a label on the Image button*/
262
-  lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
263
-  if (EXTRUDERS == 2)
264
-    lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
246
+  // Create labels on the image buttons
247
+  //lv_btn_set_layout(buttonExt1, LV_LAYOUT_OFF);
248
+  //#if HAS_MULTI_EXTRUDER
249
+    //lv_btn_set_layout(buttonExt2, LV_LAYOUT_OFF);
250
+  //#endif
265 251
 
266
-  #if HAS_HEATED_BED
267
-    lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
268
-  #endif
252
+  //#if HAS_HEATED_BED
253
+    //lv_btn_set_layout(buttonBedstate, LV_LAYOUT_OFF);
254
+  //#endif
269 255
 
270
-  lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
271
-  lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
256
+  //lv_btn_set_layout(buttonFanstate, LV_LAYOUT_OFF);
257
+  //lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
258
+  //lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
272 259
   lv_btn_set_layout(buttonPause, LV_LAYOUT_OFF);
273 260
   lv_btn_set_layout(buttonStop, LV_LAYOUT_OFF);
274 261
   lv_btn_set_layout(buttonOperat, LV_LAYOUT_OFF);
@@ -293,23 +280,20 @@ void lv_draw_printing(void) {
293 280
   lv_obj_set_style(labelFan, &tft_style_label_rel);
294 281
   lv_obj_set_pos(labelFan, 395, 196);
295 282
 
296
-  labelZpos = lv_label_create(scr, NULL);
297
-  lv_obj_set_style(labelZpos, &tft_style_label_rel);
298
-  lv_obj_set_pos(labelZpos, 395, 96);
299
-
300 283
   labelTime = lv_label_create(scr, NULL);
301 284
   lv_obj_set_style(labelTime, &tft_style_label_rel);
302 285
   lv_obj_set_pos(labelTime, 250, 96);
303 286
 
287
+  labelZpos = lv_label_create(scr, NULL);
288
+  lv_obj_set_style(labelZpos, &tft_style_label_rel);
289
+  lv_obj_set_pos(labelZpos, 395, 96);
290
+
304 291
   labelPause  = lv_label_create(buttonPause, NULL);
305 292
   labelStop   = lv_label_create(buttonStop, NULL);
306 293
   labelOperat = lv_label_create(buttonOperat, NULL);
307 294
 
308 295
   if (gCfgItems.multiple_language != 0) {
309
-    if (uiCfg.print_state == WORKING)
310
-      lv_label_set_text(labelPause, printing_menu.pause);
311
-    else
312
-      lv_label_set_text(labelPause, printing_menu.resume);
296
+    lv_label_set_text(labelPause, uiCfg.print_state == WORKING ? printing_menu.pause : printing_menu.resume);
313 297
     lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 20, 0);
314 298
 
315 299
     lv_label_set_text(labelStop, printing_menu.stop);
@@ -319,20 +303,15 @@ void lv_draw_printing(void) {
319 303
     lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
320 304
   }
321 305
 
322
-  lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
323
-  lv_bar_style_indic.text.color        = lv_color_hex3(0xADF);
324
-  lv_bar_style_indic.image.color       = lv_color_hex3(0xADF);
325
-  lv_bar_style_indic.line.color        = lv_color_hex3(0xADF);
326
-  lv_bar_style_indic.body.main_color   = lv_color_hex3(0xADF);
327
-  lv_bar_style_indic.body.grad_color   = lv_color_hex3(0xADF);
328
-  lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
329
-
330 306
   bar1 = lv_bar_create(scr, NULL);
331 307
   lv_obj_set_pos(bar1, 205, 36);
332 308
   lv_obj_set_size(bar1, 270, 40);
333 309
   lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
334 310
   lv_bar_set_anim_time(bar1, 1000);
335 311
   lv_bar_set_value(bar1, 0, LV_ANIM_ON);
312
+  bar1ValueText  = lv_label_create(bar1, NULL);
313
+  lv_label_set_text(bar1ValueText,"0%");
314
+  lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
336 315
 
337 316
   disp_ext_temp();
338 317
   disp_bed_temp();
@@ -419,6 +398,10 @@ void setProBarRate() {
419 398
 
420 399
   if (disp_state == PRINTING_UI) {
421 400
     lv_bar_set_value(bar1, rate, LV_ANIM_ON);
401
+    ZERO(public_buf_l);
402
+    sprintf_P(public_buf_l, "%d%%", rate);
403
+    lv_label_set_text(bar1ValueText,public_buf_l);
404
+    lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);
422 405
 
423 406
     if (marlin_state == MF_SD_COMPLETE) {
424 407
       if (once_flag == 0) {
@@ -432,14 +415,22 @@ void setProBarRate() {
432 415
         once_flag = 1;
433 416
 
434 417
         #if HAS_SUICIDE
435
-          if (gCfgItems.finish_power_off == 1)
436
-            suicide();
418
+          if (gCfgItems.finish_power_off == 1) {
419
+            gcode.process_subcommands_now_P(PSTR("M1001"));
420
+            queue.inject_P(PSTR("M81"));
421
+            marlin_state = MF_RUNNING;
422
+          }
437 423
         #endif
438 424
       }
439 425
     }
440 426
   }
441 427
 }
442 428
 
443
-void lv_clear_printing() { lv_obj_del(scr); }
429
+void lv_clear_printing() {
430
+  #if HAS_ROTARY_ENCODER
431
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
432
+  #endif
433
+  lv_obj_del(scr);
434
+}
444 435
 
445 436
 #endif // HAS_TFT_LVGL_UI

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

@@ -42,6 +42,7 @@
42 42
 #include <stdio.h>
43 43
 
44 44
 //static lv_obj_t *buttonPrint,*buttonTool,*buttonSet;
45
+extern lv_group_t*  g;
45 46
 static lv_obj_t * scr;
46 47
 #if ENABLED(MKS_TEST)
47 48
   uint8_t curent_disp_ui = 0;
@@ -59,7 +60,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
59 60
       }
60 61
       else if (event == LV_EVENT_RELEASED) {
61 62
 
62
-        lv_obj_del(scr);
63
+        lv_clear_ready_print();
63 64
         lv_draw_tool();
64 65
       }
65 66
       break;
@@ -68,7 +69,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
68 69
         // nothing to do
69 70
       }
70 71
       else if (event == LV_EVENT_RELEASED) {
71
-        lv_obj_del(scr);
72
+        lv_clear_ready_print();
72 73
         lv_draw_set();
73 74
       }
74 75
       break;
@@ -77,7 +78,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
77 78
         // nothing to do
78 79
       }
79 80
       else if (event == LV_EVENT_RELEASED) {
80
-        lv_obj_del(scr);
81
+        lv_clear_ready_print();
81 82
         lv_draw_print_file();
82 83
       }
83 84
       break;
@@ -111,7 +112,7 @@ void disp_det_error() {
111 112
 lv_obj_t *e1, *e2, *e3, *bed;
112 113
 void mks_disp_test() {
113 114
   char buf[30] = {0};
114
-  //lv_obj_t * label_tool2 = lv_label_create(scr, NULL);
115
+  //lv_obj_t *label_tool2 = lv_label_create(scr, NULL);
115 116
   //lv_obj_set_pos(label_tool,20,50);
116 117
   ZERO(buf);
117 118
   sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
@@ -132,7 +133,6 @@ void mks_disp_test() {
132 133
   #endif
133 134
 }
134 135
 
135
-extern unsigned char bmp_public_buf[17 * 1024];
136 136
 void lv_draw_ready_print(void) {
137 137
   char buf[30] = {0};
138 138
   lv_obj_t *buttonPrint, *buttonTool, *buttonSet;
@@ -151,9 +151,7 @@ void lv_draw_ready_print(void) {
151 151
   //lv_obj_set_hidden(scr,true);
152 152
   lv_refr_now(lv_refr_get_disp_refreshing());
153 153
 
154
-  LV_IMG_DECLARE(bmp_pic);
155
-
156
-  if (mks_test_flag == 0x1e) {
154
+  if (mks_test_flag == 0x1E) {
157 155
     //lv_obj_t * title = lv_label_create(scr, NULL);
158 156
     //lv_obj_set_style(title, &tft_style_label_rel);
159 157
     //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
@@ -164,26 +162,10 @@ void lv_draw_ready_print(void) {
164 162
     buttonTool = lv_imgbtn_create(scr, NULL);
165 163
     //buttonSet = lv_imgbtn_create(scr, NULL);
166 164
 
167
-    //lv_obj_set_event_cb_mks(buttonPrint, event_handler,ID_PRINT,"bmp_printing.bin",0);
168
-    //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin");
169
-    //lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic);
170
-    //lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic);
171
-    //lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre);
172
-    //lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel);
173
-    //lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW);
174
-
175 165
     #if 1
176
-      //lv_obj_set_event_cb_mks(buttonSet, event_handler,ID_SET,"bmp_set.bin",0);
177
-      //lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin");
178
-      //lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic);
179
-      //lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic);
180
-      //lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
181
-      //lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
182
-
183
-      lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0);
184
-      //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin");
185
-      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic);
186
-      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic);
166
+      lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0);
167
+      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin");
168
+      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin");
187 169
       lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
188 170
       lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
189 171
     #endif
@@ -266,56 +248,37 @@ void lv_draw_ready_print(void) {
266 248
 
267 249
   }
268 250
   else {
269
-    //lv_obj_t * title = lv_label_create(scr, NULL);
270
-    //lv_obj_set_style(title, &tft_style_label_rel);
271
-    //lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
272
-    //lv_label_set_text(title, creat_title_text());
251
+    // Create an Image button
252
+    buttonTool = lv_imgbtn_create(scr, NULL);
253
+    lv_obj_set_pos(buttonTool, 20, 90);
254
+    lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, NULL, 0);
255
+    lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, "F:/bmp_tool.bin");
256
+    lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, "F:/bmp_tool.bin");
257
+    lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
258
+    lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
259
+    lv_obj_t *label_tool  = lv_label_create(buttonTool, NULL);
260
+    lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF);
273 261
 
274
-    /*Create an Image button*/
275
-    buttonPrint = lv_imgbtn_create(scr, NULL);
276
-    buttonTool  = lv_imgbtn_create(scr, NULL);
277
-    buttonSet   = lv_imgbtn_create(scr, NULL);
262
+    buttonSet = lv_imgbtn_create(scr, NULL);
263
+    lv_obj_set_pos(buttonSet, 180, 90);
264
+    lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, NULL, 0);
265
+    lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, "F:/bmp_set.bin");
266
+    lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, "F:/bmp_set.bin");
267
+    lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
268
+    lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
269
+    lv_obj_t *label_set   = lv_label_create(buttonSet, NULL);
270
+    lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF);
278 271
 
279
-    lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, "bmp_printing.bin", 0);
280
-    //lv_imgbtn_set_src_mks(buttonPrint, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_printing.bin");
281
-    lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, &bmp_pic);
282
-    lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, &bmp_pic);
272
+    buttonPrint = lv_imgbtn_create(scr, NULL);
273
+    lv_obj_set_pos(buttonPrint, 340, 90);
274
+    lv_obj_set_event_cb_mks(buttonPrint, event_handler, ID_PRINT, NULL, 0);
275
+    lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_REL, "F:/bmp_printing.bin");
276
+    lv_imgbtn_set_src(buttonPrint, LV_BTN_STATE_PR, "F:/bmp_printing.bin");
283 277
     lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_PR, &tft_style_label_pre);
284 278
     lv_imgbtn_set_style(buttonPrint, LV_BTN_STATE_REL, &tft_style_label_rel);
285
-    lv_obj_clear_protect(buttonPrint, LV_PROTECT_FOLLOW);
286
-
287
-    #if 1
288
-      lv_obj_set_event_cb_mks(buttonSet, event_handler, ID_SET, "bmp_set.bin", 0);
289
-      //lv_imgbtn_set_src_mks(buttonSet, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_set.bin");
290
-      lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_REL, &bmp_pic);
291
-      lv_imgbtn_set_src(buttonSet, LV_BTN_STATE_PR, &bmp_pic);
292
-      lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_PR, &tft_style_label_pre);
293
-      lv_imgbtn_set_style(buttonSet, LV_BTN_STATE_REL, &tft_style_label_rel);
294
-
295
-      lv_obj_set_event_cb_mks(buttonTool, event_handler, ID_TOOL, "bmp_tool.bin", 0);
296
-      //lv_imgbtn_set_src_mks(buttonTool, LV_BTN_STATE_REL, &bmp_pic,(uint8_t *)"bmp_tool.bin");
297
-      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_REL, &bmp_pic);
298
-      lv_imgbtn_set_src(buttonTool, LV_BTN_STATE_PR, &bmp_pic);
299
-      lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_PR, &tft_style_label_pre);
300
-      lv_imgbtn_set_style(buttonTool, LV_BTN_STATE_REL, &tft_style_label_rel);
301
-    #endif
302
-
303
-    lv_obj_set_pos(buttonTool, 20, 90);
304
-    lv_obj_set_pos(buttonSet, 180, 90);
305
-    lv_obj_set_pos(buttonPrint, 340, 90);
306
-
307
-    //lv_obj_set_pos(buttonTool,SIMPLE_FIRST_PAGE_GRAP+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
308
-    //lv_obj_set_pos(buttonSet,BTN_X_PIXEL+SIMPLE_FIRST_PAGE_GRAP*2+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
309
-    //lv_obj_set_pos(buttonPrint,BTN_X_PIXEL*2+SIMPLE_FIRST_PAGE_GRAP*3+1,(TFT_HEIGHT-BTN_Y_PIXEL)/2+2);
310
-
311
-    /*Create a label on the Image button*/
279
+    lv_obj_t *label_print = lv_label_create(buttonPrint, NULL);
312 280
     lv_btn_set_layout(buttonPrint, LV_LAYOUT_OFF);
313
-    lv_btn_set_layout(buttonSet, LV_LAYOUT_OFF);
314
-    lv_btn_set_layout(buttonTool, LV_LAYOUT_OFF);
315 281
 
316
-    lv_obj_t * label_print = lv_label_create(buttonPrint, NULL);
317
-    lv_obj_t * label_set   = lv_label_create(buttonSet, NULL);
318
-    lv_obj_t * label_tool  = lv_label_create(buttonTool, NULL);
319 282
     if (gCfgItems.multiple_language != 0) {
320 283
       lv_label_set_text(label_print, main_menu.print);
321 284
       lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -323,14 +286,25 @@ void lv_draw_ready_print(void) {
323 286
       lv_label_set_text(label_set, main_menu.set);
324 287
       lv_obj_align(label_set, buttonSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
325 288
 
326
-      //lv_label_set_style(label_tool,LV_BTN_STATE_PR,&tft_style_label_pre);
327
-      //lv_label_set_style(label_tool,LV_BTN_STATE_REL,&tft_style_label_rel);
328 289
       lv_label_set_text(label_tool, main_menu.tool);
329 290
       lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
330 291
     }
292
+
293
+    #if HAS_ROTARY_ENCODER
294
+      if (gCfgItems.encoder_enable == true) {
295
+        lv_group_add_obj(g, buttonTool);
296
+        lv_group_add_obj(g, buttonSet);
297
+        lv_group_add_obj(g, buttonPrint);
298
+      }
299
+    #endif
331 300
   }
332 301
 }
333 302
 
334
-void lv_clear_ready_print() { lv_obj_del(scr); }
303
+void lv_clear_ready_print() {
304
+  #if HAS_ROTARY_ENCODER
305
+    if (gCfgItems.encoder_enable == true) lv_group_remove_all_objs(g);
306
+  #endif
307
+  lv_obj_del(scr);
308
+}
335 309
 
336 310
 #endif // HAS_TFT_LVGL_UI

+ 160
- 89
Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp View File

@@ -36,6 +36,7 @@
36 36
 #include "pic_manager.h"
37 37
 
38 38
 static lv_obj_t * scr;
39
+extern lv_group_t*  g;
39 40
 
40 41
 #define ID_S_WIFI         1
41 42
 #define ID_S_FAN          2
@@ -48,20 +49,17 @@ static lv_obj_t * scr;
48 49
 #define ID_S_RETURN       9
49 50
 
50 51
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
52
+  #if ENABLED(USE_WIFI_FUNCTION)
53
+    char buf[6] = { 0 };
54
+  #endif
51 55
   switch (obj->mks_obj_id) {
52
-    case ID_S_WIFI:
53
-      if (event == LV_EVENT_CLICKED) {
54
-        // nothing to do
55
-      }
56
-      else if (event == LV_EVENT_RELEASED) {
57
-      }
58
-      break;
56
+
59 57
     case ID_S_FAN:
60 58
       if (event == LV_EVENT_CLICKED) {
61 59
         // nothing to do
62 60
       }
63 61
       else if (event == LV_EVENT_RELEASED) {
64
-        lv_obj_del(scr);
62
+        lv_clear_set();
65 63
         lv_draw_fan();
66 64
       }
67 65
       break;
@@ -70,7 +68,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
70 68
         // nothing to do
71 69
       }
72 70
       else if (event == LV_EVENT_RELEASED) {
73
-        lv_obj_del(scr);
71
+        lv_clear_set();
74 72
         lv_draw_about();
75 73
       }
76 74
       break;
@@ -94,7 +92,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
94 92
         // nothing to do
95 93
       }
96 94
       else if (event == LV_EVENT_RELEASED) {
97
-        lv_obj_del(scr);
95
+        lv_clear_set();
98 96
         lv_draw_language();
99 97
       }
100 98
       break;
@@ -103,7 +101,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
103 101
 
104 102
       }
105 103
       else if (event == LV_EVENT_RELEASED) {
106
-        lv_obj_del(scr);
104
+        lv_clear_set();
107 105
         lv_draw_machine_para();
108 106
       }
109 107
       break;
@@ -112,7 +110,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
112 110
 
113 111
       }
114 112
       else if (event == LV_EVENT_RELEASED) {
115
-        lv_obj_del(scr);
113
+        lv_clear_set();
116 114
         lv_draw_eeprom_settings();
117 115
       }
118 116
       break;
@@ -121,11 +119,50 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
121 119
         // nothing to do
122 120
       }
123 121
       else if (event == LV_EVENT_RELEASED) {
124
-        lv_obj_del(scr);
122
+        lv_clear_set();
125 123
         lv_draw_ready_print();
126 124
       }
127 125
       break;
128
-
126
+    #if ENABLED(USE_WIFI_FUNCTION)
127
+      case ID_S_WIFI:
128
+        if (event == LV_EVENT_CLICKED) {
129
+
130
+        }
131
+        else if (event == LV_EVENT_RELEASED) {
132
+        if (gCfgItems.wifi_mode_sel == STA_MODEL) {
133
+          if (wifi_link_state == WIFI_CONNECTED) {
134
+            last_disp_state = SET_UI;
135
+            lv_clear_set();
136
+            lv_draw_wifi();
137
+          }
138
+          else {
139
+            if (uiCfg.command_send == 1) {
140
+              buf[0] = 0xA5;
141
+              buf[1] = 0x07;
142
+              buf[2] = 0x00;
143
+              buf[3] = 0x00;
144
+              buf[4] = 0xFC;
145
+              raw_send_to_wifi(buf, 5);
146
+
147
+              last_disp_state = SET_UI;
148
+              lv_clear_set();
149
+              lv_draw_wifi_list();
150
+            }
151
+            else {
152
+              last_disp_state = SET_UI;
153
+              lv_clear_set();
154
+              lv_draw_dialog(WIFI_ENABLE_TIPS);
155
+            }
156
+          }
157
+        }
158
+        else {
159
+          last_disp_state = SET_UI;
160
+          lv_clear_set();
161
+          lv_draw_wifi();
162
+        }
163
+      }
164
+      break;
165
+    #endif
129 166
   }
130 167
 }
131 168
 
@@ -137,6 +174,9 @@ void lv_draw_set(void) {
137 174
   #endif
138 175
   lv_obj_t *buttonMachinePara;
139 176
   lv_obj_t *buttonEepromSet;
177
+  #if ENABLED(USE_WIFI_FUNCTION)
178
+    lv_obj_t *buttonWifi;
179
+  #endif
140 180
 
141 181
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) {
142 182
     disp_state_stack._disp_index++;
@@ -159,79 +199,81 @@ void lv_draw_set(void) {
159 199
 
160 200
   lv_refr_now(lv_refr_get_disp_refreshing());
161 201
 
162
-  LV_IMG_DECLARE(bmp_pic);
163
-
164
-  /*Create an Image button*/
165
-  //buttonWifi = lv_imgbtn_create(scr, NULL);
166
-  buttonFan   = lv_imgbtn_create(scr, NULL);
167
-  buttonAbout = lv_imgbtn_create(scr, NULL);
168
-  //buttonContinue = lv_imgbtn_create(scr, NULL);
169
-  buMotorOff = lv_imgbtn_create(scr, NULL);
202
+  // Create image buttons
203
+  buttonEepromSet   = lv_imgbtn_create(scr, NULL);
204
+  //buttonWifi      = lv_imgbtn_create(scr, NULL);
205
+  buttonFan         = lv_imgbtn_create(scr, NULL);
206
+  buttonAbout       = lv_imgbtn_create(scr, NULL);
207
+  //buttonContinue  = lv_imgbtn_create(scr, NULL);
208
+  buMotorOff        = lv_imgbtn_create(scr, NULL);
209
+  buttonMachinePara = lv_imgbtn_create(scr, NULL);
170 210
   #if HAS_LANG_SELECT_SCREEN
171
-    buttonLanguage = lv_imgbtn_create(scr, NULL);
211
+    buttonLanguage  = lv_imgbtn_create(scr, NULL);
212
+  #endif
213
+  #if ENABLED(USE_WIFI_FUNCTION)
214
+  buttonWifi        = lv_imgbtn_create(scr, NULL);
172 215
   #endif
173
-  buttonMachinePara = lv_imgbtn_create(scr, NULL);
174
-  buttonEepromSet   = lv_imgbtn_create(scr, NULL);
175 216
   buttonBack        = lv_imgbtn_create(scr, NULL);
176 217
 
218
+  lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, NULL, 0);
219
+  lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, "F:/bmp_eeprom_settings.bin");
220
+  lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, "F:/bmp_eeprom_settings.bin");
221
+  lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre);
222
+  lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel);
177 223
 
178
-  //lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,"bmp_Wifi.bin",0);
179
-  //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, &bmp_pic);
180
-  //lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, &bmp_pic);
181
-  //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
182
-  //lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
183
-  //lv_obj_clear_protect(buttonWifi, LV_PROTECT_FOLLOW);
184 224
   #if 1
185
-    lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, "bmp_fan.bin", 0);
186
-    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, &bmp_pic);
187
-    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, &bmp_pic);
225
+    lv_obj_set_event_cb_mks(buttonFan, event_handler, ID_S_FAN, NULL, 0);
226
+    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_REL, "F:/bmp_fan.bin");
227
+    lv_imgbtn_set_src(buttonFan, LV_BTN_STATE_PR, "F:/bmp_fan.bin");
188 228
     lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_PR, &tft_style_label_pre);
189 229
     lv_imgbtn_set_style(buttonFan, LV_BTN_STATE_REL, &tft_style_label_rel);
190 230
 
191
-    lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, "bmp_about.bin", 0);
192
-    lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, &bmp_pic);
193
-    lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, &bmp_pic);
231
+    lv_obj_set_event_cb_mks(buttonAbout, event_handler, ID_S_ABOUT, NULL, 0);
232
+    lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_REL, "F:/bmp_about.bin");
233
+    lv_imgbtn_set_src(buttonAbout, LV_BTN_STATE_PR, "F:/bmp_about.bin");
194 234
     lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_PR, &tft_style_label_pre);
195 235
     lv_imgbtn_set_style(buttonAbout, LV_BTN_STATE_REL, &tft_style_label_rel);
196 236
 
197
-    //lv_obj_set_event_cb_mks(buttonContinue, event_handler,ID_S_CONTINUE,"bmp_Breakpoint.bin",0);
198
-    //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_REL, &bmp_pic);
199
-    //lv_imgbtn_set_src(buttonContinue, LV_BTN_STATE_PR, &bmp_pic);
200
-    //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_PR, &tft_style_label_pre);
201
-    //lv_imgbtn_set_style(buttonContinue, LV_BTN_STATE_REL, &tft_style_label_rel);
237
+    lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, NULL, 0);
238
+
202 239
     #if HAS_SUICIDE
203
-      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_Mamual.bin", 0);
240
+      lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_manual_off.bin");
241
+      lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_manual_off.bin");
204 242
     #else
205
-      lv_obj_set_event_cb_mks(buMotorOff, event_handler, ID_S_MOTOR_OFF, "bmp_function1.bin", 0);
243
+      lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, "F:/bmp_function1.bin");
244
+      lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, "F:/bmp_function1.bin");
206 245
     #endif
207
-    lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_REL, &bmp_pic);
208
-    lv_imgbtn_set_src(buMotorOff, LV_BTN_STATE_PR, &bmp_pic);
209 246
     lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_PR, &tft_style_label_pre);
210 247
     lv_imgbtn_set_style(buMotorOff, LV_BTN_STATE_REL, &tft_style_label_rel);
211 248
 
249
+    lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, NULL, 0);
250
+    lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, "F:/bmp_machine_para.bin");
251
+    lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, "F:/bmp_machine_para.bin");
252
+    lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre);
253
+    lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel);
254
+
212 255
     #if HAS_LANG_SELECT_SCREEN
213
-      lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, "bmp_language.bin", 0);
214
-      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, &bmp_pic);
215
-      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, &bmp_pic);
256
+      lv_obj_set_event_cb_mks(buttonLanguage, event_handler, ID_S_LANGUAGE, NULL, 0);
257
+      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_REL, "F:/bmp_language.bin");
258
+      lv_imgbtn_set_src(buttonLanguage, LV_BTN_STATE_PR, "F:/bmp_language.bin");
216 259
       lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_PR, &tft_style_label_pre);
217 260
       lv_imgbtn_set_style(buttonLanguage, LV_BTN_STATE_REL, &tft_style_label_rel);
218 261
     #endif
219
-    lv_obj_set_event_cb_mks(buttonMachinePara, event_handler, ID_S_MACHINE_PARA, "bmp_machine_para.bin", 0);
220
-    lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_REL, &bmp_pic);
221
-    lv_imgbtn_set_src(buttonMachinePara, LV_BTN_STATE_PR, &bmp_pic);
222
-    lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_PR, &tft_style_label_pre);
223
-    lv_imgbtn_set_style(buttonMachinePara, LV_BTN_STATE_REL, &tft_style_label_rel);
224 262
 
225
-    lv_obj_set_event_cb_mks(buttonEepromSet, event_handler, ID_S_EEPROM_SET, "bmp_eeprom_settings.bin", 0);
226
-    lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_REL, &bmp_pic);
227
-    lv_imgbtn_set_src(buttonEepromSet, LV_BTN_STATE_PR, &bmp_pic);
228
-    lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_PR, &tft_style_label_pre);
229
-    lv_imgbtn_set_style(buttonEepromSet, LV_BTN_STATE_REL, &tft_style_label_rel);
230
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN, "bmp_return.bin", 0);
231
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
232
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
263
+    #if ENABLED(USE_WIFI_FUNCTION)
264
+      lv_obj_set_event_cb_mks(buttonWifi, event_handler,ID_S_WIFI,NULL,0);
265
+      lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_REL, "F:/bmp_wifi.bin");
266
+      lv_imgbtn_set_src(buttonWifi, LV_BTN_STATE_PR, "F:/bmp_wifi.bin");
267
+      lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_PR, &tft_style_label_pre);
268
+      lv_imgbtn_set_style(buttonWifi, LV_BTN_STATE_REL, &tft_style_label_rel);
269
+    #endif
270
+
271
+    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_S_RETURN,NULL , 0);
272
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
273
+    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
233 274
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
234 275
     lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
276
+
235 277
   #endif // if 1
236 278
 
237 279
   /*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
@@ -243,45 +285,56 @@ void lv_draw_set(void) {
243 285
   lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/
244 286
 
245 287
   //lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
288
+  lv_obj_set_pos(buttonEepromSet, INTERVAL_V, titleHeight);
246 289
   lv_obj_set_pos(buttonFan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
247 290
   lv_obj_set_pos(buttonAbout, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
248 291
   //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
249 292
   lv_obj_set_pos(buMotorOff, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
293
+
294
+  lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
250 295
   #if HAS_LANG_SELECT_SCREEN
251
-    lv_obj_set_pos(buttonLanguage, INTERVAL_V, titleHeight);
296
+    lv_obj_set_pos(buttonLanguage, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
297
+  #endif
298
+  #if ENABLED(USE_WIFI_FUNCTION)
299
+    lv_obj_set_pos(buttonWifi,BTN_X_PIXEL*2+INTERVAL_V*3,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
252 300
   #endif
253
-  lv_obj_set_pos(buttonMachinePara, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
254
-  lv_obj_set_pos(buttonEepromSet, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
255 301
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
256 302
 
257
-  /*Create a label on the Image button*/
303
+  /// Create labels on the buttons
258 304
   //lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
305
+  lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF);
259 306
   lv_btn_set_layout(buttonFan, LV_LAYOUT_OFF);
260 307
   lv_btn_set_layout(buttonAbout, LV_LAYOUT_OFF);
261 308
   //lv_btn_set_layout(buttonContinue, LV_LAYOUT_OFF);
262 309
   lv_btn_set_layout(buMotorOff, LV_LAYOUT_OFF);
310
+  lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF);
263 311
   #if HAS_LANG_SELECT_SCREEN
264 312
     lv_btn_set_layout(buttonLanguage, LV_LAYOUT_OFF);
265 313
   #endif
266
-  lv_btn_set_layout(buttonMachinePara, LV_LAYOUT_OFF);
267
-  lv_btn_set_layout(buttonEepromSet, LV_LAYOUT_OFF);
314
+  #if ENABLED(USE_WIFI_FUNCTION)
315
+    lv_btn_set_layout(buttonWifi, LV_LAYOUT_OFF);
316
+  #endif
268 317
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
269 318
 
270
-  //lv_obj_t * labelWifi= lv_label_create(buttonWifi, NULL);
271
-  lv_obj_t * labelFan    = lv_label_create(buttonFan, NULL);
272
-  lv_obj_t * label_About = lv_label_create(buttonAbout, NULL);
273
-  //lv_obj_t * label_Continue = lv_label_create(buttonContinue, NULL);
274
-  lv_obj_t * label_MotorOff = lv_label_create(buMotorOff, NULL);
319
+  //lv_obj_t *labelWifi= lv_label_create(buttonWifi, NULL);
320
+  lv_obj_t *label_EepromSet   = lv_label_create(buttonEepromSet, NULL);
321
+  lv_obj_t *labelFan          = lv_label_create(buttonFan, NULL);
322
+  lv_obj_t *label_About       = lv_label_create(buttonAbout, NULL);
323
+  //lv_obj_t *label_Continue  = lv_label_create(buttonContinue, NULL);
324
+  lv_obj_t *label_MotorOff    = lv_label_create(buMotorOff, NULL);
325
+  lv_obj_t *label_MachinePara = lv_label_create(buttonMachinePara, NULL);
275 326
   #if HAS_LANG_SELECT_SCREEN
276
-    lv_obj_t * label_Language = lv_label_create(buttonLanguage, NULL);
327
+    lv_obj_t *label_Language  = lv_label_create(buttonLanguage, NULL);
277 328
   #endif
278
-  lv_obj_t * label_MachinePara = lv_label_create(buttonMachinePara, NULL);
279
-  lv_obj_t * label_EepromSet   = lv_label_create(buttonEepromSet, NULL);
280
-  lv_obj_t * label_Back        = lv_label_create(buttonBack, NULL);
329
+  #if ENABLED(USE_WIFI_FUNCTION)
330
+    lv_obj_t *label_Wifi      = lv_label_create(buttonWifi, NULL);
331
+  #endif
332
+  lv_obj_t *label_Back        = lv_label_create(buttonBack, NULL);
281 333
 
282 334
   if (gCfgItems.multiple_language != 0) {
283
-    //lv_label_set_text(labelWifi, set_menu.wifi);
284
-    //lv_obj_align(labelWifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
335
+
336
+    lv_label_set_text(label_EepromSet, set_menu.eepromSet);
337
+    lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
285 338
 
286 339
     lv_label_set_text(labelFan, set_menu.fan);
287 340
     lv_obj_align(labelFan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -291,28 +344,46 @@ void lv_draw_set(void) {
291 344
 
292 345
     //lv_label_set_text(label_Continue, set_menu.breakpoint);
293 346
     //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
294
-    #if HAS_SUICIDE
295
-      lv_label_set_text(label_MotorOff, set_menu.shutdown);
296
-    #else
297
-      lv_label_set_text(label_MotorOff, set_menu.motoroff);
298
-    #endif
347
+    lv_label_set_text(label_MotorOff, set_menu.TERN(HAS_SUICIDE, shutdown, motoroff));
299 348
     lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
300 349
 
350
+    lv_label_set_text(label_MachinePara, set_menu.machine_para);
351
+    lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
352
+
301 353
     #if HAS_LANG_SELECT_SCREEN
302 354
       lv_label_set_text(label_Language, set_menu.language);
303 355
       lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
304 356
     #endif
305
-    lv_label_set_text(label_MachinePara, set_menu.machine_para);
306
-    lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
307 357
 
308
-    lv_label_set_text(label_EepromSet, set_menu.eepromSet);
309
-    lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
358
+    #if ENABLED(USE_WIFI_FUNCTION)
359
+      lv_label_set_text(label_Wifi, set_menu.wifi);
360
+      lv_obj_align(label_Wifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
361
+    #endif
310 362
 
311 363
     lv_label_set_text(label_Back, common_menu.text_back);
312 364
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
313 365
   }
366
+  #if HAS_ROTARY_ENCODER
367
+    if (gCfgItems.encoder_enable) {
368
+      lv_group_add_obj(g, buttonEepromSet);
369
+      lv_group_add_obj(g, buttonFan);
370
+      lv_group_add_obj(g, buttonAbout);
371
+      lv_group_add_obj(g, buMotorOff);
372
+      lv_group_add_obj(g, buttonMachinePara);
373
+      lv_group_add_obj(g, buttonLanguage);
374
+      #if ENABLED(USE_WIFI_FUNCTION)
375
+        lv_group_add_obj(g, buttonWifi);
376
+      #endif
377
+      lv_group_add_obj(g, buttonBack);
378
+    }
379
+  #endif
314 380
 }
315 381
 
316
-void lv_clear_set() { lv_obj_del(scr); }
382
+void lv_clear_set() {
383
+  #if HAS_ROTARY_ENCODER
384
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
385
+  #endif
386
+  lv_obj_del(scr);
387
+}
317 388
 
318 389
 #endif // HAS_TFT_LVGL_UI

+ 93
- 123
Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp View File

@@ -29,6 +29,7 @@
29 29
 #include "../../../../MarlinCore.h"
30 30
 #include "../../../../module/planner.h"
31 31
 
32
+extern lv_group_t * g;
32 33
 static lv_obj_t * scr;
33 34
 
34 35
 #define ID_STEP_RETURN  1
@@ -127,11 +128,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
127 128
 
128 129
 void lv_draw_step_settings(void) {
129 130
   lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
130
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
131
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
132
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
133
-  lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
134
-  lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
131
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
132
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
133
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
134
+  lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
135
+  lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
135 136
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
136 137
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) {
137 138
     disp_state_stack._disp_index++;
@@ -152,166 +153,133 @@ void lv_draw_step_settings(void) {
152 153
 
153 154
   lv_refr_now(lv_refr_get_disp_refreshing());
154 155
 
155
-  LV_IMG_DECLARE(bmp_para_back);
156
-  // LV_IMG_DECLARE(bmp_para_arrow);
157
-  LV_IMG_DECLARE(bmp_para_bank);
158
-
159 156
   if (uiCfg.para_ui_page != 1) {
160
-    buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
161
-    lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
162
-    lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
163
-    lv_obj_set_event_cb(buttonXText, event_handler);
164
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
165
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
166
-    lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
167
-    labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
168
-
169
-    buttonXValue = lv_imgbtn_create(scr, NULL);
157
+    labelXText = lv_label_create(scr, NULL);
158
+    lv_obj_set_style(labelXText, &tft_style_label_rel);
159
+    lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
160
+    lv_label_set_text(labelXText, machine_menu.X_Steps);
161
+
162
+    buttonXValue = lv_btn_create(scr, NULL);
170 163
     lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
171
-    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, "bmp_value_blank.bin", 0);
172
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
173
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
174
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
175
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
176
-    lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
164
+    lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
165
+    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_STEP_X, NULL, 0);
166
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
167
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
177 168
     labelXValue = lv_label_create(buttonXValue, NULL);
178 169
 
179 170
     line1 = lv_line_create(scr, NULL);
180 171
     lv_ex_line(line1, line_points[0]);
181 172
 
182
-    buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
183
-    lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
184
-    lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
185
-    lv_obj_set_event_cb(buttonYText, event_handler);
186
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
187
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
188
-    lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
189
-    labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
173
+    labelYText = lv_label_create(scr, NULL);
174
+    lv_obj_set_style(labelYText, &tft_style_label_rel);
175
+    lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
176
+    lv_label_set_text(labelYText, machine_menu.Y_Steps);
190 177
 
191
-    buttonYValue = lv_imgbtn_create(scr, NULL);
178
+    buttonYValue = lv_btn_create(scr, NULL);
192 179
     lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
193
-    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, "bmp_value_blank.bin", 0);
194
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
195
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
196
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
197
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
198
-    lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
180
+    lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
181
+    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_STEP_Y, NULL, 0);
182
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
183
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
199 184
     labelYValue = lv_label_create(buttonYValue, NULL);
200 185
 
201 186
     line2 = lv_line_create(scr, NULL);
202 187
     lv_ex_line(line2, line_points[1]);
203 188
 
204
-    buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
205
-    lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
206
-    lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
207
-    lv_obj_set_event_cb(buttonZText, event_handler);
208
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
209
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
210
-    lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
211
-    labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
189
+    labelZText = lv_label_create(scr, NULL);
190
+    lv_obj_set_style(labelZText, &tft_style_label_rel);
191
+    lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
192
+    lv_label_set_text(labelZText, machine_menu.Z_Steps);
212 193
 
213
-    buttonZValue = lv_imgbtn_create(scr, NULL);
194
+    buttonZValue = lv_btn_create(scr, NULL);
214 195
     lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
215
-    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, "bmp_value_blank.bin", 0);
216
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
217
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
218
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
219
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
220
-    lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
196
+    lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
197
+    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_STEP_Z, NULL, 0);
198
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
199
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
221 200
     labelZValue = lv_label_create(buttonZValue, NULL);
222 201
 
223 202
     line3 = lv_line_create(scr, NULL);
224 203
     lv_ex_line(line3, line_points[2]);
225 204
 
226
-    buttonE0Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
227
-    lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4);         /*Set its position*/
228
-    lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
229
-    lv_obj_set_event_cb(buttonE0Text, event_handler);
230
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
231
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
232
-    lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
233
-    labelE0Text = lv_label_create(buttonE0Text, NULL);                      /*Add a label to the button*/
205
+    labelE0Text = lv_label_create(scr, NULL);
206
+    lv_obj_set_style(labelE0Text, &tft_style_label_rel);
207
+    lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
208
+    lv_label_set_text(labelE0Text, machine_menu.E0_Steps);
234 209
 
235
-    buttonE0Value = lv_imgbtn_create(scr, NULL);
210
+    buttonE0Value = lv_btn_create(scr, NULL);
236 211
     lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
237
-    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, "bmp_value_blank.bin", 0);
238
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
239
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
240
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
241
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
242
-    lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
212
+    lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
213
+    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_STEP_E0, NULL, 0);
214
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
215
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
243 216
     labelE0Value = lv_label_create(buttonE0Value, NULL);
244 217
 
245 218
     line4 = lv_line_create(scr, NULL);
246 219
     lv_ex_line(line4, line_points[3]);
247 220
 
248
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
249
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, "bmp_back70x40.bin", 0);
250
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
251
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
252
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
253
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
221
+    buttonTurnPage = lv_btn_create(scr, NULL);
222
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_DOWN, NULL, 0);
223
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
224
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
225
+
226
+    #if HAS_ROTARY_ENCODER
227
+      if (gCfgItems.encoder_enable) {
228
+        lv_group_add_obj(g, buttonXValue);
229
+        lv_group_add_obj(g, buttonYValue);
230
+        lv_group_add_obj(g, buttonZValue);
231
+        lv_group_add_obj(g, buttonE0Value);
232
+        lv_group_add_obj(g, buttonTurnPage);
233
+      }
234
+    #endif
254 235
   }
255 236
   else {
256
-    buttonE1Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
257
-    lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y);             /*Set its position*/
258
-    lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
259
-    lv_obj_set_event_cb(buttonE1Text, event_handler);
260
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
261
-    lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
262
-    lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
263
-    labelE1Text = lv_label_create(buttonE1Text, NULL);                      /*Add a label to the button*/
264
-
265
-    buttonE1Value = lv_imgbtn_create(scr, NULL);
237
+    labelE1Text = lv_label_create(scr, NULL);
238
+    lv_obj_set_style(labelE1Text, &tft_style_label_rel);
239
+    lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
240
+    lv_label_set_text(labelE1Text, machine_menu.E1_Steps);
241
+
242
+    buttonE1Value = lv_btn_create(scr, NULL);
266 243
     lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
267
-    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, "bmp_value_blank.bin", 0);
268
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
269
-    lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
270
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
271
-    lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
272
-    lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
244
+    lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
245
+    lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_STEP_E1, NULL, 0);
246
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
247
+    lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
273 248
     labelE1Value = lv_label_create(buttonE1Value, NULL);
274 249
 
275 250
     line1 = lv_line_create(scr, NULL);
276 251
     lv_ex_line(line1, line_points[0]);
277 252
 
278
-    buttonTurnPage = lv_imgbtn_create(scr, NULL);
279
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, "bmp_back70x40.bin", 0);
280
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
281
-    lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
282
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
283
-    lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
253
+    buttonTurnPage = lv_btn_create(scr, NULL);
254
+    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_STEP_UP, NULL, 0);
255
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
256
+    lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
257
+
258
+    #if HAS_ROTARY_ENCODER
259
+      if (gCfgItems.encoder_enable) {
260
+        lv_group_add_obj(g, buttonE1Value);
261
+        lv_group_add_obj(g, buttonTurnPage);
262
+      }
263
+    #endif
284 264
   }
285 265
 
286 266
   lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
287
-  lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
267
+  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
288 268
   labelTurnPage = lv_label_create(buttonTurnPage, NULL);
289 269
 
290
-  buttonBack = lv_imgbtn_create(scr, NULL);
291
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, "bmp_back70x40.bin", 0);
292
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
293
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
294
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
295
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
296
-
270
+  buttonBack = lv_btn_create(scr, NULL);
271
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
272
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
297 273
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
298
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
274
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
275
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, NULL, 0);
299 276
   label_Back = lv_label_create(buttonBack, NULL);
277
+  #if HAS_ROTARY_ENCODER
278
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
279
+  #endif
300 280
 
301 281
   if (gCfgItems.multiple_language != 0) {
302 282
     if (uiCfg.para_ui_page != 1) {
303
-      lv_label_set_text(labelXText, machine_menu.X_Steps);
304
-      lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
305
-
306
-      lv_label_set_text(labelYText, machine_menu.Y_Steps);
307
-      lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
308
-
309
-      lv_label_set_text(labelZText, machine_menu.Z_Steps);
310
-      lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
311
-
312
-      lv_label_set_text(labelE0Text, machine_menu.E0_Steps);
313
-      lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
314
-
315 283
       lv_label_set_text(labelTurnPage, machine_menu.next);
316 284
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
317 285
 
@@ -336,9 +304,6 @@ void lv_draw_step_settings(void) {
336 304
       lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
337 305
     }
338 306
     else {
339
-      lv_label_set_text(labelE1Text, machine_menu.E1_Steps);
340
-      lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
341
-
342 307
       lv_label_set_text(labelTurnPage, machine_menu.previous);
343 308
       lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
344 309
 
@@ -353,6 +318,11 @@ void lv_draw_step_settings(void) {
353 318
   }
354 319
 }
355 320
 
356
-void lv_clear_step_settings() { lv_obj_del(scr); }
321
+void lv_clear_step_settings() {
322
+  #if HAS_ROTARY_ENCODER
323
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
324
+  #endif
325
+  lv_obj_del(scr);
326
+}
357 327
 
358 328
 #endif // HAS_TFT_LVGL_UI

+ 195
- 194
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp View File

@@ -31,6 +31,7 @@
31 31
 #include "../../../../module/stepper/indirection.h"
32 32
 #include "../../../../feature/tmc_util.h"
33 33
 
34
+extern lv_group_t * g;
34 35
 static lv_obj_t * scr;
35 36
 
36 37
 #define ID_TMC_CURRENT_RETURN 1
@@ -54,94 +55,105 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
54 55
         draw_return_ui();
55 56
       }
56 57
       break;
57
-    case ID_TMC_CURRENT_X:
58
+    #if AXIS_IS_TMC(X)
59
+      case ID_TMC_CURRENT_X:
60
+        if (event == LV_EVENT_CLICKED) {
61
+
62
+        }
63
+        else if (event == LV_EVENT_RELEASED) {
64
+          value = Xcurrent;
65
+          lv_clear_tmc_current_settings();
66
+          lv_draw_number_key();
67
+        }
68
+        break;
69
+    #endif
70
+
71
+    #if AXIS_IS_TMC(Y)
72
+    case ID_TMC_CURRENT_Y:
58 73
       if (event == LV_EVENT_CLICKED) {
59 74
 
60 75
       }
61 76
       else if (event == LV_EVENT_RELEASED) {
62
-        value = Xcurrent;
77
+        value = Ycurrent;
63 78
         lv_clear_tmc_current_settings();
64 79
         lv_draw_number_key();
65 80
       }
66 81
       break;
67
-    case ID_TMC_CURRENT_Y:
82
+    #endif
83
+
84
+    #if AXIS_IS_TMC(Z)
85
+    case ID_TMC_CURRENT_Z:
68 86
       if (event == LV_EVENT_CLICKED) {
69 87
 
70 88
       }
71 89
       else if (event == LV_EVENT_RELEASED) {
72
-        value = Ycurrent;
90
+        value = Zcurrent;
73 91
         lv_clear_tmc_current_settings();
74 92
         lv_draw_number_key();
75 93
       }
76 94
       break;
77
-    case ID_TMC_CURRENT_Z:
95
+    #endif
96
+
97
+    #if AXIS_IS_TMC(E0)
98
+      case ID_TMC_CURRENT_E0:
99
+        if (event == LV_EVENT_CLICKED) {
100
+
101
+        }
102
+        else if (event == LV_EVENT_RELEASED) {
103
+          value = E0current;
104
+          lv_clear_tmc_current_settings();
105
+          lv_draw_number_key();
106
+        }
107
+        break;
108
+    #endif
109
+
110
+    #if AXIS_IS_TMC(E1)
111
+      case ID_TMC_CURRENT_E1:
112
+        if (event == LV_EVENT_CLICKED) {
113
+
114
+        }
115
+        else if (event == LV_EVENT_RELEASED) {
116
+          value = E1current;
117
+          lv_clear_tmc_current_settings();
118
+          lv_draw_number_key();
119
+        }
120
+        break;
121
+    #endif
122
+    case ID_TMC_CURRENT_UP:
78 123
       if (event == LV_EVENT_CLICKED) {
79 124
 
80 125
       }
81 126
       else if (event == LV_EVENT_RELEASED) {
82
-        value = Zcurrent;
127
+        uiCfg.para_ui_page = 0;
83 128
         lv_clear_tmc_current_settings();
84
-        lv_draw_number_key();
129
+        lv_draw_tmc_current_settings();
85 130
       }
86 131
       break;
87
-    case ID_TMC_CURRENT_E0:
132
+    case ID_TMC_CURRENT_DOWN:
88 133
       if (event == LV_EVENT_CLICKED) {
89 134
 
90 135
       }
91 136
       else if (event == LV_EVENT_RELEASED) {
92
-        value = E0current;
137
+        uiCfg.para_ui_page = 1;
93 138
         lv_clear_tmc_current_settings();
94
-        lv_draw_number_key();
139
+        lv_draw_tmc_current_settings();
95 140
       }
96 141
       break;
97
-      #if AXIS_IS_TMC(E1)
98
-        case ID_TMC_CURRENT_E1:
99
-          if (event == LV_EVENT_CLICKED) {
100
-
101
-          }
102
-          else if (event == LV_EVENT_RELEASED) {
103
-            value = E1current;
104
-            lv_clear_tmc_current_settings();
105
-            lv_draw_number_key();
106
-          }
107
-          break;
108
-
109
-        case ID_TMC_CURRENT_UP:
110
-          if (event == LV_EVENT_CLICKED) {
111
-
112
-          }
113
-          else if (event == LV_EVENT_RELEASED) {
114
-            uiCfg.para_ui_page = 0;
115
-            lv_clear_tmc_current_settings();
116
-            lv_draw_tmc_current_settings();
117
-          }
118
-          break;
119
-        case ID_TMC_CURRENT_DOWN:
120
-          if (event == LV_EVENT_CLICKED) {
121
-
122
-          }
123
-          else if (event == LV_EVENT_RELEASED) {
124
-            uiCfg.para_ui_page = 1;
125
-            lv_clear_tmc_current_settings();
126
-            lv_draw_tmc_current_settings();
127
-          }
128
-          break;
129
-      #endif
130 142
   }
131 143
 }
132 144
 
133 145
 void lv_draw_tmc_current_settings(void) {
134 146
   lv_obj_t *buttonBack = NULL, *label_Back = NULL;
135
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
136
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
137
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
138
-  lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
147
+  lv_obj_t *labelXText = NULL, *buttonXValue = NULL, *labelXValue = NULL;
148
+  lv_obj_t *labelYText = NULL, *buttonYValue = NULL, *labelYValue = NULL;
149
+  lv_obj_t *labelZText = NULL, *buttonZValue = NULL, *labelZValue = NULL;
150
+  lv_obj_t *labelE0Text = NULL, *buttonE0Value = NULL, *labelE0Value = NULL;
139 151
 
140 152
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
141
-  #if AXIS_IS_TMC(E1)
153
+  //#if AXIS_IS_TMC(E1)
142 154
     lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
143
-    lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
144
-  #endif
155
+    lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
156
+  //#endif
145 157
   float milliamps;
146 158
 
147 159
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) {
@@ -163,217 +175,201 @@ void lv_draw_tmc_current_settings(void) {
163 175
 
164 176
   lv_refr_now(lv_refr_get_disp_refreshing());
165 177
 
166
-  LV_IMG_DECLARE(bmp_para_back);
167
-  // LV_IMG_DECLARE(bmp_para_arrow);
168
-  LV_IMG_DECLARE(bmp_para_bank);
169
-
170 178
   if (uiCfg.para_ui_page != 1) {
171
-    buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
172
-    lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
173
-    lv_obj_set_size(buttonXText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
174
-    lv_obj_set_event_cb(buttonXText, event_handler);
175
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
176
-    lv_btn_set_style(buttonXText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
177
-    lv_btn_set_layout(buttonXText, LV_LAYOUT_OFF);
178
-    labelXText = lv_label_create(buttonXText, NULL);                        /*Add a label to the button*/
179
-
180
-    buttonXValue = lv_imgbtn_create(scr, NULL);
179
+    labelXText = lv_label_create(scr, NULL);
180
+    lv_obj_set_style(labelXText, &tft_style_label_rel);
181
+    lv_obj_set_pos(labelXText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
182
+    lv_label_set_text(labelXText, machine_menu.X_Current);
183
+
184
+    buttonXValue = lv_btn_create(scr, NULL);
181 185
     lv_obj_set_pos(buttonXValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
182
-    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, "bmp_value_blank.bin", 0);
183
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_REL, &bmp_para_bank);
184
-    lv_imgbtn_set_src(buttonXValue, LV_BTN_STATE_PR, &bmp_para_bank);
185
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_PR, &style_para_value_pre);
186
-    lv_imgbtn_set_style(buttonXValue, LV_BTN_STATE_REL, &style_para_value_rel);
187
-    lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
186
+    lv_obj_set_size(buttonXValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
187
+    lv_obj_set_event_cb_mks(buttonXValue, event_handler, ID_TMC_CURRENT_X, NULL, 0);
188
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_REL, &style_para_value);
189
+    lv_btn_set_style(buttonXValue, LV_BTN_STYLE_PR, &style_para_value);
188 190
     labelXValue = lv_label_create(buttonXValue, NULL);
189 191
 
190 192
     line1 = lv_line_create(scr, NULL);
191 193
     lv_ex_line(line1, line_points[0]);
192 194
 
193
-    buttonYText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
194
-    lv_obj_set_pos(buttonYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          /*Set its position*/
195
-    lv_obj_set_size(buttonYText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
196
-    lv_obj_set_event_cb(buttonYText, event_handler);
197
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
198
-    lv_btn_set_style(buttonYText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
199
-    lv_btn_set_layout(buttonYText, LV_LAYOUT_OFF);
200
-    labelYText = lv_label_create(buttonYText, NULL);                        /*Add a label to the button*/
195
+    labelYText = lv_label_create(scr, NULL);
196
+    lv_obj_set_style(labelYText, &tft_style_label_rel);
197
+    lv_obj_set_pos(labelYText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
198
+    lv_label_set_text(labelYText, machine_menu.Y_Current);
201 199
 
202
-    buttonYValue = lv_imgbtn_create(scr, NULL);
200
+    buttonYValue = lv_btn_create(scr, NULL);
203 201
     lv_obj_set_pos(buttonYValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V);
204
-    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, "bmp_value_blank.bin", 0);
205
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_REL, &bmp_para_bank);
206
-    lv_imgbtn_set_src(buttonYValue, LV_BTN_STATE_PR, &bmp_para_bank);
207
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_PR, &style_para_value_pre);
208
-    lv_imgbtn_set_style(buttonYValue, LV_BTN_STATE_REL, &style_para_value_rel);
209
-    lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
202
+    lv_obj_set_size(buttonYValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
203
+    lv_obj_set_event_cb_mks(buttonYValue, event_handler, ID_TMC_CURRENT_Y, NULL, 0);
204
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_REL, &style_para_value);
205
+    lv_btn_set_style(buttonYValue, LV_BTN_STYLE_PR, &style_para_value);
210 206
     labelYValue = lv_label_create(buttonYValue, NULL);
211 207
 
212 208
     line2 = lv_line_create(scr, NULL);
213 209
     lv_ex_line(line2, line_points[1]);
214 210
 
215
-    buttonZText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
216
-    lv_obj_set_pos(buttonZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3);          /*Set its position*/
217
-    lv_obj_set_size(buttonZText, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);     /*Set its size*/
218
-    lv_obj_set_event_cb(buttonZText, event_handler);
219
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_REL, &tft_style_label_rel);  /*Set the button's released style*/
220
-    lv_btn_set_style(buttonZText, LV_BTN_STYLE_PR, &tft_style_label_pre);   /*Set the button's pressed style*/
221
-    lv_btn_set_layout(buttonZText, LV_LAYOUT_OFF);
222
-    labelZText = lv_label_create(buttonZText, NULL);                        /*Add a label to the button*/
211
+    labelZText = lv_label_create(scr, NULL);
212
+    lv_obj_set_style(labelZText, &tft_style_label_rel);
213
+    lv_obj_set_pos(labelZText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
214
+    lv_label_set_text(labelZText, machine_menu.Z_Current);
223 215
 
224
-    buttonZValue = lv_imgbtn_create(scr, NULL);
216
+    buttonZValue = lv_btn_create(scr, NULL);
225 217
     lv_obj_set_pos(buttonZValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V);
226
-    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, "bmp_value_blank.bin", 0);
227
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_REL, &bmp_para_bank);
228
-    lv_imgbtn_set_src(buttonZValue, LV_BTN_STATE_PR, &bmp_para_bank);
229
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_PR, &style_para_value_pre);
230
-    lv_imgbtn_set_style(buttonZValue, LV_BTN_STATE_REL, &style_para_value_rel);
231
-    lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
218
+    lv_obj_set_size(buttonZValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
219
+    lv_obj_set_event_cb_mks(buttonZValue, event_handler, ID_TMC_CURRENT_Z, NULL, 0);
220
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_REL, &style_para_value);
221
+    lv_btn_set_style(buttonZValue, LV_BTN_STYLE_PR, &style_para_value);
232 222
     labelZValue = lv_label_create(buttonZValue, NULL);
233 223
 
234 224
     line3 = lv_line_create(scr, NULL);
235 225
     lv_ex_line(line3, line_points[2]);
236 226
 
237
-    buttonE0Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
238
-    lv_obj_set_pos(buttonE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4);         /*Set its position*/
239
-    lv_obj_set_size(buttonE0Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
240
-    lv_obj_set_event_cb(buttonE0Text, event_handler);
241
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
242
-    lv_btn_set_style(buttonE0Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
243
-    lv_btn_set_layout(buttonE0Text, LV_LAYOUT_OFF);
244
-    labelE0Text = lv_label_create(buttonE0Text, NULL);                      /*Add a label to the button*/
227
+    labelE0Text = lv_label_create(scr, NULL);
228
+    lv_obj_set_style(labelE0Text, &tft_style_label_rel);
229
+    lv_obj_set_pos(labelE0Text, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
230
+    lv_label_set_text(labelE0Text, machine_menu.E0_Current);
245 231
 
246
-    buttonE0Value = lv_imgbtn_create(scr, NULL);
232
+    buttonE0Value = lv_btn_create(scr, NULL);
247 233
     lv_obj_set_pos(buttonE0Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V);
248
-    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, "bmp_value_blank.bin", 0);
249
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_REL, &bmp_para_bank);
250
-    lv_imgbtn_set_src(buttonE0Value, LV_BTN_STATE_PR, &bmp_para_bank);
251
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_PR, &style_para_value_pre);
252
-    lv_imgbtn_set_style(buttonE0Value, LV_BTN_STATE_REL, &style_para_value_rel);
253
-    lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
234
+    lv_obj_set_size(buttonE0Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
235
+    lv_obj_set_event_cb_mks(buttonE0Value, event_handler, ID_TMC_CURRENT_E0, NULL, 0);
236
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_REL, &style_para_value);
237
+    lv_btn_set_style(buttonE0Value, LV_BTN_STYLE_PR, &style_para_value);
254 238
     labelE0Value = lv_label_create(buttonE0Value, NULL);
255 239
 
240
+    #if HAS_ROTARY_ENCODER
241
+      if (gCfgItems.encoder_enable) {
242
+        lv_group_add_obj(g, buttonXValue);
243
+        lv_group_add_obj(g, buttonYValue);
244
+        lv_group_add_obj(g, buttonZValue);
245
+        lv_group_add_obj(g, buttonE0Value);
246
+      }
247
+    #endif
248
+
256 249
     line4 = lv_line_create(scr, NULL);
257 250
     lv_ex_line(line4, line_points[3]);
258 251
 
259
-    #if AXIS_IS_TMC(E1)
260
-      buttonTurnPage = lv_imgbtn_create(scr, NULL);
261
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, "bmp_back70x40.bin", 0);
262
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
263
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
264
-      lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
265
-      lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
266
-    #endif
252
+    //#if AXIS_IS_TMC(E1)
253
+      buttonTurnPage = lv_btn_create(scr, NULL);
254
+      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, NULL, 0);
255
+      lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
256
+      lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
257
+
258
+      #if HAS_ROTARY_ENCODER
259
+        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
260
+      #endif
261
+    //#endif
267 262
   }
268 263
   else {
269
-    #if AXIS_IS_TMC(E1)
270
-      buttonE1Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
271
-      lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y);             /*Set its position*/
272
-      lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
273
-      lv_obj_set_event_cb(buttonE1Text, event_handler);
274
-      lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_REL, &tft_style_label_rel); /*Set the button's released style*/
275
-      lv_btn_set_style(buttonE1Text, LV_BTN_STYLE_PR, &tft_style_label_pre);  /*Set the button's pressed style*/
276
-      lv_btn_set_layout(buttonE1Text, LV_LAYOUT_OFF);
277
-      labelE1Text = lv_label_create(buttonE1Text, NULL);                      /*Add a label to the button*/
278
-
279
-      buttonE1Value = lv_imgbtn_create(scr, NULL);
264
+    //#if AXIS_IS_TMC(E1)
265
+      labelE1Text = lv_label_create(scr, NULL);
266
+      lv_obj_set_style(labelE1Text, &tft_style_label_rel);
267
+      lv_obj_set_pos(labelE1Text, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
268
+      lv_label_set_text(labelE1Text, machine_menu.E1_Current);
269
+
270
+      buttonE1Value = lv_btn_create(scr, NULL);
280 271
       lv_obj_set_pos(buttonE1Value, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
281
-      lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, "bmp_value_blank.bin", 0);
282
-      lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_REL, &bmp_para_bank);
283
-      lv_imgbtn_set_src(buttonE1Value, LV_BTN_STATE_PR, &bmp_para_bank);
284
-      lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_PR, &style_para_value_pre);
285
-      lv_imgbtn_set_style(buttonE1Value, LV_BTN_STATE_REL, &style_para_value_rel);
286
-      lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
272
+      lv_obj_set_size(buttonE1Value, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
273
+      lv_obj_set_event_cb_mks(buttonE1Value, event_handler, ID_TMC_CURRENT_E1, NULL, 0);
274
+      lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_REL, &style_para_value);
275
+      lv_btn_set_style(buttonE1Value, LV_BTN_STYLE_PR, &style_para_value);
287 276
       labelE1Value = lv_label_create(buttonE1Value, NULL);
288 277
 
289 278
       line1 = lv_line_create(scr, NULL);
290 279
       lv_ex_line(line1, line_points[0]);
291 280
 
292
-      buttonTurnPage = lv_imgbtn_create(scr, NULL);
293
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, "bmp_back70x40.bin", 0);
294
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
295
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
296
-      lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
297
-      lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
298
-    #endif
281
+      buttonTurnPage = lv_btn_create(scr, NULL);
282
+      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, NULL, 0);
283
+      lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_REL, &style_para_back);
284
+      lv_btn_set_style(buttonTurnPage, LV_BTN_STYLE_PR, &style_para_back);
285
+
286
+      #if HAS_ROTARY_ENCODER
287
+        if (gCfgItems.encoder_enable) {
288
+          lv_group_add_obj(g, buttonE1Value);
289
+          lv_group_add_obj(g, buttonTurnPage);
290
+        }
291
+      #endif
292
+    //#endif
299 293
   }
300
-  #if AXIS_IS_TMC(E1)
294
+  //#if AXIS_IS_TMC(E1)
301 295
     lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
302
-    lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
296
+    lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
303 297
     labelTurnPage = lv_label_create(buttonTurnPage, NULL);
304
-  #endif
298
+  //#endif
305 299
 
306
-  buttonBack = lv_imgbtn_create(scr, NULL);
307
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, "bmp_back70x40.bin", 0);
308
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
309
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
310
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
311
-  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
300
+  buttonBack = lv_btn_create(scr, NULL);
301
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, NULL, 0);
302
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_REL, &style_para_back);
303
+  lv_btn_set_style(buttonBack, LV_BTN_STYLE_PR, &style_para_back);
304
+
305
+  #if HAS_ROTARY_ENCODER
306
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
307
+  #endif
312 308
 
313 309
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
314
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
310
+  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
315 311
   label_Back = lv_label_create(buttonBack, NULL);
316 312
 
317 313
   if (gCfgItems.multiple_language != 0) {
318 314
     if (uiCfg.para_ui_page != 1) {
319
-      lv_label_set_text(labelXText, machine_menu.X_Current);
320
-      lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
321
-
322
-      lv_label_set_text(labelYText, machine_menu.Y_Current);
323
-      lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
324
-
325
-      lv_label_set_text(labelZText, machine_menu.Z_Current);
326
-      lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
327
-
328
-      lv_label_set_text(labelE0Text, machine_menu.E0_Current);
329
-      lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
330
-      #if AXIS_IS_TMC(E1)
315
+      //#if AXIS_IS_TMC(E1)
331 316
         lv_label_set_text(labelTurnPage, machine_menu.next);
332 317
         lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
333
-      #endif
318
+      //#endif
334 319
       #if AXIS_IS_TMC(X)
335 320
         milliamps = stepperX.getMilliamps();
336
-        ZERO(public_buf_l);
337
-        sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
338
-        lv_label_set_text(labelXValue, public_buf_l);
339
-        lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
321
+      #else
322
+        milliamps = -1;
340 323
       #endif
324
+      ZERO(public_buf_l);
325
+      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
326
+      lv_label_set_text(labelXValue, public_buf_l);
327
+      lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
328
+
341 329
       #if AXIS_IS_TMC(Y)
342 330
         milliamps = stepperY.getMilliamps();
343
-        ZERO(public_buf_l);
344
-        sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
345
-        lv_label_set_text(labelYValue, public_buf_l);
346
-        lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
331
+      #else
332
+        milliamps = -1;
347 333
       #endif
334
+      ZERO(public_buf_l);
335
+      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
336
+      lv_label_set_text(labelYValue, public_buf_l);
337
+      lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
338
+
348 339
       #if AXIS_IS_TMC(Z)
349 340
         milliamps = stepperZ.getMilliamps();
350
-        ZERO(public_buf_l);
351
-        sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
352
-        lv_label_set_text(labelZValue, public_buf_l);
353
-        lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
341
+      #else
342
+        milliamps = -1;
354 343
       #endif
344
+      ZERO(public_buf_l);
345
+      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
346
+      lv_label_set_text(labelZValue, public_buf_l);
347
+      lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
348
+
355 349
       #if AXIS_IS_TMC(E0)
356 350
         milliamps = stepperE0.getMilliamps();
357
-        ZERO(public_buf_l);
358
-        sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
359
-        lv_label_set_text(labelE0Value, public_buf_l);
360
-        lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
351
+      #else
352
+        milliamps = -1;
361 353
       #endif
354
+      ZERO(public_buf_l);
355
+      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
356
+      lv_label_set_text(labelE0Value, public_buf_l);
357
+      lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
362 358
     }
363 359
     else {
364
-      #if AXIS_IS_TMC(E1)
365
-        lv_label_set_text(labelE1Text, machine_menu.E1_Current);
366
-        lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
367
-
360
+      //#if AXIS_IS_TMC(E1)
368 361
         lv_label_set_text(labelTurnPage, machine_menu.previous);
369 362
         lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
370
-
371
-        milliamps = stepperE1.getMilliamps();
363
+        #if AXIS_IS_TMC(E1)
364
+          milliamps = stepperE1.getMilliamps();
365
+        #else
366
+          milliamps = -1;
367
+        #endif
372 368
         ZERO(public_buf_l);
373 369
         sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
374 370
         lv_label_set_text(labelE1Value, public_buf_l);
375 371
         lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
376
-      #endif
372
+      //#endif
377 373
     }
378 374
 
379 375
     lv_label_set_text(label_Back, common_menu.text_back);
@@ -381,6 +377,11 @@ void lv_draw_tmc_current_settings(void) {
381 377
   }
382 378
 }
383 379
 
384
-void lv_clear_tmc_current_settings() { lv_obj_del(scr); }
380
+void lv_clear_tmc_current_settings() {
381
+  #if HAS_ROTARY_ENCODER
382
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
383
+  #endif
384
+  lv_obj_del(scr);
385
+}
385 386
 
386 387
 #endif // HAS_TFT_LVGL_UI && HAS_TRINAMIC_CONFIG

+ 282
- 174
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp View File

@@ -33,6 +33,7 @@
33 33
 #include "../../../../gcode/gcode.h"
34 34
 #include "../../../../module/planner.h"
35 35
 
36
+extern lv_group_t * g;
36 37
 static lv_obj_t * scr;
37 38
 
38 39
 #define ID_TMC_MODE_RETURN 1
@@ -47,9 +48,9 @@ static lv_obj_t * scr;
47 48
 static lv_obj_t *labelXState = NULL, *labelYState = NULL, *labelZState = NULL, *labelE0State = NULL;
48 49
 static lv_obj_t *buttonXState = NULL, *buttonYState = NULL, *buttonZState = NULL, *buttonE0State = NULL;
49 50
 
50
-#if AXIS_HAS_STEALTHCHOP(E1)
51
+//#if AXIS_HAS_STEALTHCHOP(E1)
51 52
   static lv_obj_t *labelE1State = NULL, *buttonE1State = NULL;
52
-#endif
53
+//#endif
53 54
 
54 55
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
55 56
   switch (obj->mks_obj_id) {
@@ -63,136 +64,158 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
63 64
         draw_return_ui();
64 65
       }
65 66
       break;
66
-    case ID_TMC_MODE_X:
67
-      if (event == LV_EVENT_CLICKED) {
68 67
 
69
-      }
70
-      else if (event == LV_EVENT_RELEASED) {
71
-        if (stepperX.stored.stealthChop_enabled == true) {
72
-          stepperX.stored.stealthChop_enabled = false;
73
-          stepperX.refresh_stepping_mode();
74
-          lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0);
75
-          lv_label_set_text(labelXState, machine_menu.disable);
76
-          //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
77
-          // gcode.process_subcommands_now_P(PSTR("M500"));
78
-        }
79
-        else {
80
-          stepperX.stored.stealthChop_enabled = true;
81
-          stepperX.refresh_stepping_mode();
82
-          lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0);
83
-          lv_label_set_text(labelXState, machine_menu.enable);
84
-          // gcode.process_subcommands_now_P(PSTR("M500"));
85
-        }
86
-        gcode.process_subcommands_now_P(PSTR("M500"));
87
-      }
88
-      break;
89
-    case ID_TMC_MODE_Y:
90
-      if (event == LV_EVENT_CLICKED) {
68
+    #if AXIS_HAS_STEALTHCHOP(X)
69
+      case ID_TMC_MODE_X:
70
+        if (event == LV_EVENT_CLICKED) {
91 71
 
92
-      }
93
-      else if (event == LV_EVENT_RELEASED) {
94
-        if (stepperY.stored.stealthChop_enabled == true) {
95
-          stepperY.stored.stealthChop_enabled = false;
96
-          stepperY.refresh_stepping_mode();
97
-          lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0);
98
-          lv_label_set_text(labelYState, machine_menu.disable);
99
-          //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
100 72
         }
101
-        else {
102
-          stepperY.stored.stealthChop_enabled = true;
103
-          stepperY.refresh_stepping_mode();
104
-          lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0);
105
-          lv_label_set_text(labelYState, machine_menu.enable);
73
+        else if (event == LV_EVENT_RELEASED) {
74
+          if (stepperX.stored.stealthChop_enabled) {
75
+            stepperX.stored.stealthChop_enabled = false;
76
+            stepperX.refresh_stepping_mode();
77
+            lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
78
+            lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
79
+            lv_label_set_text(labelXState, machine_menu.disable);
80
+            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
81
+            // gcode.process_subcommands_now_P(PSTR("M500"));
82
+          }
83
+          else {
84
+            stepperX.stored.stealthChop_enabled = true;
85
+            stepperX.refresh_stepping_mode();
86
+            lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
87
+            lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
88
+            lv_label_set_text(labelXState, machine_menu.enable);
89
+            // gcode.process_subcommands_now_P(PSTR("M500"));
90
+          }
91
+          gcode.process_subcommands_now_P(PSTR("M500"));
106 92
         }
107
-        gcode.process_subcommands_now_P(PSTR("M500"));
108
-      }
109
-      break;
110
-    case ID_TMC_MODE_Z:
111
-      if (event == LV_EVENT_CLICKED) {
93
+        break;
94
+    #endif // if AXIS_HAS_STEALTHCHOP(X)
112 95
 
113
-      }
114
-      else if (event == LV_EVENT_RELEASED) {
115
-        if (stepperZ.stored.stealthChop_enabled == true) {
116
-          stepperZ.stored.stealthChop_enabled = false;
117
-          stepperZ.refresh_stepping_mode();
118
-          lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0);
119
-          lv_label_set_text(labelZState, machine_menu.disable);
120
-          //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
121
-        }
122
-        else {
123
-          stepperZ.stored.stealthChop_enabled = true;
124
-          stepperZ.refresh_stepping_mode();
125
-          lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0);
126
-          lv_label_set_text(labelZState, machine_menu.enable);
127
-        }
128
-        gcode.process_subcommands_now_P(PSTR("M500"));
129
-      }
130
-      break;
131
-    case ID_TMC_MODE_E0:
132
-      if (event == LV_EVENT_CLICKED) {
96
+    #if AXIS_HAS_STEALTHCHOP(Y)
97
+      case ID_TMC_MODE_Y:
98
+        if (event == LV_EVENT_CLICKED) {
133 99
 
134
-      }
135
-      else if (event == LV_EVENT_RELEASED) {
136
-        if (stepperE0.stored.stealthChop_enabled == true) {
137
-          stepperE0.stored.stealthChop_enabled = false;
138
-          stepperE0.refresh_stepping_mode();
139
-          lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0);
140
-          lv_label_set_text(labelE0State, machine_menu.disable);
141
-          //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
142 100
         }
143
-        else {
144
-          stepperE0.stored.stealthChop_enabled = true;
145
-          stepperE0.refresh_stepping_mode();
146
-          lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0);
147
-          lv_label_set_text(labelE0State, machine_menu.enable);
101
+        else if (event == LV_EVENT_RELEASED) {
102
+          if (stepperY.stored.stealthChop_enabled) {
103
+            stepperY.stored.stealthChop_enabled = false;
104
+            stepperY.refresh_stepping_mode();
105
+            lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
106
+            lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
107
+            lv_label_set_text(labelYState, machine_menu.disable);
108
+            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
109
+          }
110
+          else {
111
+            stepperY.stored.stealthChop_enabled = true;
112
+            stepperY.refresh_stepping_mode();
113
+            lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
114
+            lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
115
+            lv_label_set_text(labelYState, machine_menu.enable);
116
+          }
117
+          gcode.process_subcommands_now_P(PSTR("M500"));
148 118
         }
149
-        gcode.process_subcommands_now_P(PSTR("M500"));
150
-      }
151
-      break;
152
-      #if AXIS_HAS_STEALTHCHOP(E1)
153
-        case ID_TMC_MODE_E1:
154
-          if (event == LV_EVENT_CLICKED) {
119
+        break;
120
+    #endif // if AXIS_HAS_STEALTHCHOP(Y)
155 121
 
122
+    #if AXIS_HAS_STEALTHCHOP(Z)
123
+      case ID_TMC_MODE_Z:
124
+        if (event == LV_EVENT_CLICKED) {
125
+
126
+        }
127
+        else if (event == LV_EVENT_RELEASED) {
128
+          if (stepperZ.stored.stealthChop_enabled) {
129
+            stepperZ.stored.stealthChop_enabled = false;
130
+            stepperZ.refresh_stepping_mode();
131
+            lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
132
+            lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
133
+            lv_label_set_text(labelZState, machine_menu.disable);
134
+            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
156 135
           }
157
-          else if (event == LV_EVENT_RELEASED) {
158
-            if (stepperE1.stored.stealthChop_enabled == true) {
159
-              stepperE1.stored.stealthChop_enabled = false;
160
-              stepperE1.refresh_stepping_mode();
161
-              lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0);
162
-              lv_label_set_text(labelE1State, machine_menu.disable);
163
-              //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
164
-            }
165
-            else {
166
-              stepperE1.stored.stealthChop_enabled = true;
167
-              stepperE1.refresh_stepping_mode();
168
-              lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0);
169
-              lv_label_set_text(labelE1State, machine_menu.enable);
170
-            }
171
-            gcode.process_subcommands_now_P(PSTR("M500"));
136
+          else {
137
+            stepperZ.stored.stealthChop_enabled = true;
138
+            stepperZ.refresh_stepping_mode();
139
+            lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
140
+            lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
141
+            lv_label_set_text(labelZState, machine_menu.enable);
172 142
           }
173
-          break;
143
+          gcode.process_subcommands_now_P(PSTR("M500"));
144
+        }
145
+        break;
146
+    #endif // if AXIS_HAS_STEALTHCHOP(Z)
174 147
 
175
-        case ID_TMC_MODE_UP:
176
-          if (event == LV_EVENT_CLICKED) {
148
+    #if AXIS_HAS_STEALTHCHOP(E0)
149
+      case ID_TMC_MODE_E0:
150
+        if (event == LV_EVENT_CLICKED) {
177 151
 
152
+        }
153
+        else if (event == LV_EVENT_RELEASED) {
154
+          if (stepperE0.stored.stealthChop_enabled) {
155
+            stepperE0.stored.stealthChop_enabled = false;
156
+            stepperE0.refresh_stepping_mode();
157
+            lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
158
+            lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
159
+            lv_label_set_text(labelE0State, machine_menu.disable);
160
+            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
178 161
           }
179
-          else if (event == LV_EVENT_RELEASED) {
180
-            uiCfg.para_ui_page = 0;
181
-            lv_clear_tmc_step_mode_settings();
182
-            lv_draw_tmc_step_mode_settings();
162
+          else {
163
+            stepperE0.stored.stealthChop_enabled = true;
164
+            stepperE0.refresh_stepping_mode();
165
+            lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
166
+            lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
167
+            lv_label_set_text(labelE0State, machine_menu.enable);
183 168
           }
184
-          break;
185
-        case ID_TMC_MODE_DOWN:
186
-          if (event == LV_EVENT_CLICKED) {
169
+          gcode.process_subcommands_now_P(PSTR("M500"));
170
+        }
171
+        break;
172
+    #endif // if AXIS_HAS_STEALTHCHOP(E0)
173
+
174
+    #if AXIS_HAS_STEALTHCHOP(E1)
175
+      case ID_TMC_MODE_E1:
176
+        if (event == LV_EVENT_CLICKED) {
187 177
 
178
+        }
179
+        else if (event == LV_EVENT_RELEASED) {
180
+          if (stepperE1.stored.stealthChop_enabled) {
181
+            stepperE1.stored.stealthChop_enabled = false;
182
+            stepperE1.refresh_stepping_mode();
183
+            lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
184
+            lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
185
+            lv_label_set_text(labelE1State, machine_menu.disable);
186
+            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
188 187
           }
189
-          else if (event == LV_EVENT_RELEASED) {
190
-            uiCfg.para_ui_page = 1;
191
-            lv_clear_tmc_step_mode_settings();
192
-            lv_draw_tmc_step_mode_settings();
188
+          else {
189
+            stepperE1.stored.stealthChop_enabled = true;
190
+            stepperE1.refresh_stepping_mode();
191
+            lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
192
+            lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
193
+            lv_label_set_text(labelE1State, machine_menu.enable);
193 194
           }
194
-          break;
195
-      #endif // if AXIS_HAS_STEALTHCHOP(E1)
195
+          gcode.process_subcommands_now_P(PSTR("M500"));
196
+        }
197
+        break;
198
+    #endif // if AXIS_HAS_STEALTHCHOP(E1)
199
+    case ID_TMC_MODE_UP:
200
+      if (event == LV_EVENT_CLICKED) {
201
+
202
+      }
203
+      else if (event == LV_EVENT_RELEASED) {
204
+        uiCfg.para_ui_page = 0;
205
+        lv_clear_tmc_step_mode_settings();
206
+        lv_draw_tmc_step_mode_settings();
207
+      }
208
+      break;
209
+    case ID_TMC_MODE_DOWN:
210
+      if (event == LV_EVENT_CLICKED) {
211
+
212
+      }
213
+      else if (event == LV_EVENT_RELEASED) {
214
+        uiCfg.para_ui_page = 1;
215
+        lv_clear_tmc_step_mode_settings();
216
+        lv_draw_tmc_step_mode_settings();
217
+      }
218
+      break;
196 219
   }
197 220
 }
198 221
 
@@ -204,10 +227,10 @@ void lv_draw_tmc_step_mode_settings(void) {
204 227
   lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL;
205 228
 
206 229
   lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
207
-  #if AXIS_HAS_STEALTHCHOP(E1)
230
+  //#if AXIS_HAS_STEALTHCHOP(E1)
208 231
     lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
209 232
     lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL;
210
-  #endif
233
+  //#endif
211 234
 
212 235
 
213 236
   labelXState   = NULL;
@@ -218,10 +241,10 @@ void lv_draw_tmc_step_mode_settings(void) {
218 241
   buttonZState  = NULL;
219 242
   labelE0State  = NULL;
220 243
   buttonE0State = NULL;
221
-  #if AXIS_HAS_STEALTHCHOP(E1)
244
+  //#if AXIS_HAS_STEALTHCHOP(E1)
222 245
     labelE1State  = NULL;
223 246
     buttonE1State = NULL;
224
-  #endif
247
+  //#endif
225 248
 
226 249
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) {
227 250
     disp_state_stack._disp_index++;
@@ -242,10 +265,6 @@ void lv_draw_tmc_step_mode_settings(void) {
242 265
 
243 266
   lv_refr_now(lv_refr_get_disp_refreshing());
244 267
 
245
-  LV_IMG_DECLARE(bmp_para_back);
246
-  LV_IMG_DECLARE(bmp_para_state);
247
-  // LV_IMG_DECLARE(bmp_para_bank);
248
-
249 268
   if (uiCfg.para_ui_page != 1) {
250 269
     buttonXText = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
251 270
     lv_obj_set_pos(buttonXText, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
@@ -258,16 +277,28 @@ void lv_draw_tmc_step_mode_settings(void) {
258 277
 
259 278
     buttonXState = lv_imgbtn_create(scr, NULL);
260 279
     lv_obj_set_pos(buttonXState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
261
-    if (stepperX.get_stealthChop_status())
262
-      lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_enable.bin", 0);
263
-    else
264
-      lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, "bmp_disable.bin", 0);
265
-    lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, &bmp_para_state);
266
-    lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, &bmp_para_state);
280
+    #if AXIS_HAS_STEALTHCHOP(X)
281
+    if (stepperX.get_stealthChop_status()) {
282
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
283
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
284
+    }
285
+    else {
286
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
287
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
288
+    }
289
+    #else
290
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
291
+      lv_imgbtn_set_src(buttonXState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
292
+    #endif
293
+    lv_obj_set_event_cb_mks(buttonXState, event_handler, ID_TMC_MODE_X, NULL, 0);
294
+
267 295
     lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_PR, &tft_style_label_pre);
268 296
     lv_imgbtn_set_style(buttonXState, LV_BTN_STATE_REL, &tft_style_label_rel);
269 297
     lv_btn_set_layout(buttonXState, LV_LAYOUT_OFF);
270 298
     labelXState = lv_label_create(buttonXState, NULL);
299
+    #if HAS_ROTARY_ENCODER
300
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXState);
301
+    #endif
271 302
 
272 303
     line1 = lv_line_create(scr, NULL);
273 304
     lv_ex_line(line1, line_points[0]);
@@ -283,16 +314,28 @@ void lv_draw_tmc_step_mode_settings(void) {
283 314
 
284 315
     buttonYState = lv_imgbtn_create(scr, NULL);
285 316
     lv_obj_set_pos(buttonYState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_STATE_V);
286
-    if (stepperY.get_stealthChop_status())
287
-      lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_enable.bin", 0);
288
-    else
289
-      lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, "bmp_disable.bin", 0);
290
-    lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, &bmp_para_state);
291
-    lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, &bmp_para_state);
317
+    #if AXIS_HAS_STEALTHCHOP(Y)
318
+      if (stepperY.get_stealthChop_status()) {
319
+        lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
320
+        lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
321
+      }
322
+      else {
323
+        lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
324
+        lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
325
+      }
326
+    #else
327
+      lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
328
+      lv_imgbtn_set_src(buttonYState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
329
+    #endif
330
+    lv_obj_set_event_cb_mks(buttonYState, event_handler, ID_TMC_MODE_Y, NULL, 0);
331
+
292 332
     lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_PR, &tft_style_label_pre);
293 333
     lv_imgbtn_set_style(buttonYState, LV_BTN_STATE_REL, &tft_style_label_rel);
294 334
     lv_btn_set_layout(buttonYState, LV_LAYOUT_OFF);
295 335
     labelYState = lv_label_create(buttonYState, NULL);
336
+    #if HAS_ROTARY_ENCODER
337
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYState);
338
+    #endif
296 339
 
297 340
     line2 = lv_line_create(scr, NULL);
298 341
     lv_ex_line(line2, line_points[1]);
@@ -308,16 +351,27 @@ void lv_draw_tmc_step_mode_settings(void) {
308 351
 
309 352
     buttonZState = lv_imgbtn_create(scr, NULL);
310 353
     lv_obj_set_pos(buttonZState, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_STATE_V);
311
-    if (stepperZ.get_stealthChop_status())
312
-      lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_enable.bin", 0);
313
-    else
314
-      lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, "bmp_disable.bin", 0);
315
-    lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, &bmp_para_state);
316
-    lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, &bmp_para_state);
354
+    #if AXIS_HAS_STEALTHCHOP(Z)
355
+      if (stepperZ.get_stealthChop_status()) {
356
+        lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
357
+        lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
358
+      }
359
+      else {
360
+        lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
361
+        lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
362
+      }
363
+    #else
364
+      lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
365
+      lv_imgbtn_set_src(buttonZState, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
366
+    #endif
367
+    lv_obj_set_event_cb_mks(buttonZState, event_handler, ID_TMC_MODE_Z, NULL, 0);
317 368
     lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_PR, &tft_style_label_pre);
318 369
     lv_imgbtn_set_style(buttonZState, LV_BTN_STATE_REL, &tft_style_label_rel);
319 370
     lv_btn_set_layout(buttonZState, LV_LAYOUT_OFF);
320 371
     labelZState = lv_label_create(buttonZState, NULL);
372
+    #if HAS_ROTARY_ENCODER
373
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZState);
374
+    #endif
321 375
 
322 376
     line3 = lv_line_create(scr, NULL);
323 377
     lv_ex_line(line3, line_points[2]);
@@ -333,31 +387,48 @@ void lv_draw_tmc_step_mode_settings(void) {
333 387
 
334 388
     buttonE0State = lv_imgbtn_create(scr, NULL);
335 389
     lv_obj_set_pos(buttonE0State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V);
336
-    if (stepperE0.get_stealthChop_status())
337
-      lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_enable.bin", 0);
338
-    else
339
-      lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, "bmp_disable.bin", 0);
340
-    lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, &bmp_para_state);
341
-    lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, &bmp_para_state);
390
+    #if AXIS_HAS_STEALTHCHOP(E0)
391
+      if (stepperE0.get_stealthChop_status()) {
392
+        lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
393
+        lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
394
+      }
395
+      else {
396
+        lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
397
+        lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
398
+      }
399
+    #else
400
+      lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
401
+      lv_imgbtn_set_src(buttonE0State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
402
+    #endif
403
+
404
+    lv_obj_set_event_cb_mks(buttonE0State, event_handler, ID_TMC_MODE_E0, NULL, 0);
405
+
342 406
     lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_PR, &tft_style_label_pre);
343 407
     lv_imgbtn_set_style(buttonE0State, LV_BTN_STATE_REL, &tft_style_label_rel);
344 408
     lv_btn_set_layout(buttonE0State, LV_LAYOUT_OFF);
345 409
     labelE0State = lv_label_create(buttonE0State, NULL);
410
+    #if HAS_ROTARY_ENCODER
411
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE0State);
412
+    #endif
413
+
346 414
 
347 415
     line4 = lv_line_create(scr, NULL);
348 416
     lv_ex_line(line4, line_points[3]);
349 417
 
350
-    #if AXIS_HAS_STEALTHCHOP(E1)
418
+    //#if AXIS_HAS_STEALTHCHOP(E1)
351 419
       buttonTurnPage = lv_imgbtn_create(scr, NULL);
352
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, "bmp_back70x40.bin", 0);
353
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
354
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
420
+      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_DOWN, NULL, 0);
421
+      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
422
+      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
355 423
       lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
356 424
       lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
357
-    #endif
425
+      #if HAS_ROTARY_ENCODER
426
+        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
427
+      #endif
428
+    //#endif
358 429
   }
359 430
   else {
360
-    #if AXIS_HAS_STEALTHCHOP(E1)
431
+    //#if AXIS_HAS_STEALTHCHOP(E1)
361 432
       buttonE1Text = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
362 433
       lv_obj_set_pos(buttonE1Text, PARA_UI_POS_X, PARA_UI_POS_Y);             /*Set its position*/
363 434
       lv_obj_set_size(buttonE1Text, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y);    /*Set its size*/
@@ -369,40 +440,54 @@ void lv_draw_tmc_step_mode_settings(void) {
369 440
 
370 441
       buttonE1State = lv_imgbtn_create(scr, NULL);
371 442
       lv_obj_set_pos(buttonE1State, PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V);
372
-      if (stepperE1.get_stealthChop_status())
373
-        lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_enable.bin", 0);
374
-      else
375
-        lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, "bmp_disable.bin", 0);
376
-      lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, &bmp_para_state);
377
-      lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, &bmp_para_state);
443
+      #if AXIS_HAS_STEALTHCHOP(E1)
444
+        if (stepperE1.get_stealthChop_status()) {
445
+          lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
446
+          lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
447
+          }
448
+        else {
449
+          lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
450
+          lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
451
+        }
452
+      #else
453
+        lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
454
+        lv_imgbtn_set_src(buttonE1State, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
455
+      #endif
456
+      lv_obj_set_event_cb_mks(buttonE1State, event_handler, ID_TMC_MODE_E1, NULL, 0);
378 457
       lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_PR, &tft_style_label_pre);
379 458
       lv_imgbtn_set_style(buttonE1State, LV_BTN_STATE_REL, &tft_style_label_rel);
380 459
       lv_btn_set_layout(buttonE1State, LV_LAYOUT_OFF);
381 460
       labelE1State = lv_label_create(buttonE1State, NULL);
461
+      #if HAS_ROTARY_ENCODER
462
+        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE1State);
463
+      #endif
382 464
 
383 465
       line1 = lv_line_create(scr, NULL);
384 466
       lv_ex_line(line1, line_points[0]);
385 467
 
386 468
       buttonTurnPage = lv_imgbtn_create(scr, NULL);
387
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, "bmp_back70x40.bin", 0);
388
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, &bmp_para_back);
389
-      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, &bmp_para_back);
469
+      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_MODE_UP, NULL, 0);
470
+      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
471
+      lv_imgbtn_set_src(buttonTurnPage, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
390 472
       lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_PR, &tft_style_label_pre);
391 473
       lv_imgbtn_set_style(buttonTurnPage, LV_BTN_STATE_REL, &tft_style_label_rel);
392
-    #endif
474
+    //#endif
393 475
   }
394
-  #if AXIS_HAS_STEALTHCHOP(E1)
476
+  //#if AXIS_HAS_STEALTHCHOP(E1)
395 477
     lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
396 478
     lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
397 479
     labelTurnPage = lv_label_create(buttonTurnPage, NULL);
398
-  #endif
480
+  //#endif
399 481
 
400 482
   buttonBack = lv_imgbtn_create(scr, NULL);
401
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, "bmp_back70x40.bin", 0);
402
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_para_back);
403
-  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_para_back);
483
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_MODE_RETURN, NULL, 0);
484
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
485
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
404 486
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
405 487
   lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
488
+  #if HAS_ROTARY_ENCODER
489
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
490
+  #endif
406 491
 
407 492
   lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
408 493
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
@@ -422,50 +507,68 @@ void lv_draw_tmc_step_mode_settings(void) {
422 507
       lv_label_set_text(labelE0Text, machine_menu.E0_StepMode);
423 508
       lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
424 509
 
510
+      #if AXIS_HAS_STEALTHCHOP(X)
425 511
       if (stepperX.get_stealthChop_status())
426 512
         lv_label_set_text(labelXState, machine_menu.enable);
427 513
       else
428 514
         lv_label_set_text(labelXState, machine_menu.disable);
515
+      #else
516
+        lv_label_set_text(labelXState, machine_menu.disable);
517
+      #endif
429 518
       lv_obj_align(labelXState, buttonXState, LV_ALIGN_CENTER, 0, 0);
430 519
 
520
+      #if AXIS_HAS_STEALTHCHOP(Y)
431 521
       if (stepperY.get_stealthChop_status())
432 522
         lv_label_set_text(labelYState, machine_menu.enable);
433 523
       else
434 524
         lv_label_set_text(labelYState, machine_menu.disable);
525
+      #else
526
+        lv_label_set_text(labelYState, machine_menu.disable);
527
+      #endif
435 528
       lv_obj_align(labelYState, buttonYState, LV_ALIGN_CENTER, 0, 0);
436 529
 
530
+      #if AXIS_HAS_STEALTHCHOP(Z)
437 531
       if (stepperZ.get_stealthChop_status())
438 532
         lv_label_set_text(labelZState, machine_menu.enable);
439 533
       else
440 534
         lv_label_set_text(labelZState, machine_menu.disable);
535
+      #else
536
+        lv_label_set_text(labelZState, machine_menu.disable);
537
+      #endif
441 538
       lv_obj_align(labelZState, buttonZState, LV_ALIGN_CENTER, 0, 0);
442 539
 
540
+      #if AXIS_HAS_STEALTHCHOP(E0)
443 541
       if (stepperE0.get_stealthChop_status())
444 542
         lv_label_set_text(labelE0State, machine_menu.enable);
445 543
       else
446 544
         lv_label_set_text(labelE0State, machine_menu.disable);
545
+      #else
546
+        lv_label_set_text(labelE0State, machine_menu.disable);
547
+      #endif
447 548
       lv_obj_align(labelE0State, buttonE0State, LV_ALIGN_CENTER, 0, 0);
448 549
 
449
-      #if AXIS_HAS_STEALTHCHOP(E1)
550
+      //#if AXIS_HAS_STEALTHCHOP(E1)
450 551
         lv_label_set_text(labelTurnPage, machine_menu.next);
451 552
         lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
452
-      #endif
553
+      //#endif
453 554
     }
454 555
     else {
455
-      #if AXIS_HAS_STEALTHCHOP(E1)
556
+      //#if AXIS_HAS_STEALTHCHOP(E1)
456 557
         lv_label_set_text(labelE1Text, machine_menu.E1_StepMode);
457 558
         lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
458
-
559
+        #if AXIS_HAS_STEALTHCHOP(E1)
459 560
         if (stepperE1.get_stealthChop_status())
460 561
           lv_label_set_text(labelE1State, machine_menu.enable);
461 562
         else
462 563
           lv_label_set_text(labelE1State, machine_menu.disable);
564
+        #else
565
+          lv_label_set_text(labelE1State, machine_menu.disable);
566
+        #endif
463 567
         lv_obj_align(labelE1State, buttonE1State, LV_ALIGN_CENTER, 0, 0);
464 568
 
465 569
         lv_label_set_text(labelTurnPage, machine_menu.previous);
466 570
         lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
467
-
468
-      #endif
571
+      //#endif
469 572
     }
470 573
 
471 574
     lv_label_set_text(label_Back, common_menu.text_back);
@@ -473,6 +576,11 @@ void lv_draw_tmc_step_mode_settings(void) {
473 576
   }
474 577
 }
475 578
 
476
-void lv_clear_tmc_step_mode_settings() { lv_obj_del(scr); }
579
+void lv_clear_tmc_step_mode_settings() {
580
+  #if HAS_ROTARY_ENCODER
581
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
582
+  #endif
583
+  lv_obj_del(scr);
584
+}
477 585
 
478 586
 #endif // HAS_TFT_LVGL_UI && HAS_STEALTHCHOP

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

@@ -32,8 +32,9 @@
32 32
 
33 33
 #include "../../../../MarlinCore.h"
34 34
 #include "../../../../gcode/queue.h"
35
+#include "../../../../module/temperature.h"
35 36
 
36
-// static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn;
37
+extern lv_group_t * g;
37 38
 static lv_obj_t * scr;
38 39
 
39 40
 #define ID_T_PRE_HEAT   1
@@ -45,6 +46,10 @@ static lv_obj_t * scr;
45 46
 #define ID_T_MORE       7
46 47
 #define ID_T_RETURN     8
47 48
 
49
+#if ENABLED(MKS_TEST)
50
+  extern uint8_t curent_disp_ui;
51
+#endif
52
+
48 53
 static void event_handler(lv_obj_t * obj, lv_event_t event) {
49 54
   switch (obj->mks_obj_id) {
50 55
     case ID_T_PRE_HEAT:
@@ -89,8 +94,11 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
89 94
       }
90 95
       else if (event == LV_EVENT_RELEASED) {
91 96
         #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
92
-          queue.enqueue_one_P(PSTR("G28"));
93
-          queue.enqueue_one_P(PSTR("G29"));
97
+          //queue.enqueue_one_P(PSTR("G28"));
98
+          //queue.enqueue_one_P(PSTR("G29"));
99
+          get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
100
+          public_buf_m[sizeof(public_buf_m)-1] = 0;
101
+          queue.inject_P(PSTR(public_buf_m));
94 102
         #else
95 103
           uiCfg.leveling_first_time = 1;
96 104
           lv_clear_tool();
@@ -98,7 +106,16 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
98 106
         #endif
99 107
       }
100 108
       break;
101
-    case ID_T_FILAMENT: break;
109
+    case ID_T_FILAMENT:
110
+      if (event == LV_EVENT_CLICKED) {
111
+        // nothing to do
112
+      }
113
+      else if (event == LV_EVENT_RELEASED) {
114
+        uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
115
+        lv_clear_tool();
116
+        lv_draw_filament_change();
117
+      }
118
+      break;
102 119
     case ID_T_MORE: break;
103 120
     case ID_T_RETURN:
104 121
       if (event == LV_EVENT_CLICKED) {
@@ -106,7 +123,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
106 123
       }
107 124
       else if (event == LV_EVENT_RELEASED) {
108 125
         TERN_(MKS_TEST, curent_disp_ui = 1);
109
-        lv_obj_del(scr);
126
+        lv_clear_tool();
110 127
         lv_draw_ready_print();
111 128
       }
112 129
       break;
@@ -115,6 +132,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
115 132
 
116 133
 void lv_draw_tool(void) {
117 134
   lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonMove, *buttonHome, *buttonLevel;
135
+  lv_obj_t *buttonFilament;
118 136
   lv_obj_t *buttonBack;
119 137
 
120 138
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) {
@@ -138,75 +156,64 @@ void lv_draw_tool(void) {
138 156
 
139 157
   lv_refr_now(lv_refr_get_disp_refreshing());
140 158
 
141
-  LV_IMG_DECLARE(bmp_pic);
142
-
143 159
   // Create image buttons
144 160
   buttonPreHeat   = lv_imgbtn_create(scr, NULL);
145 161
   buttonExtrusion = lv_imgbtn_create(scr, NULL);
146 162
   buttonMove      = lv_imgbtn_create(scr, NULL);
147 163
   buttonHome      = lv_imgbtn_create(scr, NULL);
148 164
   buttonLevel     = lv_imgbtn_create(scr, NULL);
149
-  // buttonFilament = lv_imgbtn_create(scr, NULL);
150
-  // buttonMore = lv_imgbtn_create(scr, NULL);
151
-  buttonBack = lv_imgbtn_create(scr, NULL);
165
+  buttonFilament  = lv_imgbtn_create(scr, NULL);
166
+  //buttonMore    = lv_imgbtn_create(scr, NULL);
167
+  buttonBack      = lv_imgbtn_create(scr, NULL);
152 168
 
153
-  lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, "bmp_preHeat.bin", 0);
154
-  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, &bmp_pic);
155
-  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, &bmp_pic);
169
+  lv_obj_set_event_cb_mks(buttonPreHeat, event_handler, ID_T_PRE_HEAT, NULL, 0);
170
+  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_REL, "F:/bmp_preHeat.bin");
171
+  lv_imgbtn_set_src(buttonPreHeat, LV_BTN_STATE_PR, "F:/bmp_preHeat.bin");
156 172
   lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_PR, &tft_style_label_pre);
157 173
   lv_imgbtn_set_style(buttonPreHeat, LV_BTN_STATE_REL, &tft_style_label_rel);
158
-  lv_obj_clear_protect(buttonPreHeat, LV_PROTECT_FOLLOW);
159
-
160
-  #if 1
161
-    lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, "bmp_extruct.bin", 0);
162
-    lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, &bmp_pic);
163
-    lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, &bmp_pic);
164
-    lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
165
-    lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
166
-
167
-    lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, "bmp_mov.bin", 0);
168
-    lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, &bmp_pic);
169
-    lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, &bmp_pic);
170
-    lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
171
-    lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
172
-
173
-    lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, "bmp_zero.bin", 0);
174
-    lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, &bmp_pic);
175
-    lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, &bmp_pic);
176
-    lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre);
177
-    lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel);
178
-
179
-    lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, "bmp_leveling.bin", 0);
180
-    lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, &bmp_pic);
181
-    lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, &bmp_pic);
182
-    lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre);
183
-    lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel);
184
-
185
-    //lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,"bmp_Filamentchange.bin",0);
186
-    //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, &bmp_pic);
187
-    //lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, &bmp_pic);
188
-    //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
189
-    //lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
190
-
191
-    //lv_obj_set_event_cb_mks(buttonMore, event_handler,ID_T_MORE,"bmp_More.bin",0);
192
-    //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_REL, &bmp_pic);
193
-    //lv_imgbtn_set_src(buttonMore, LV_BTN_STATE_PR, &bmp_pic);
194
-    //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_PR, &tft_style_label_pre);
195
-    //lv_imgbtn_set_style(buttonMore, LV_BTN_STATE_REL, &tft_style_label_rel);
196
-
197
-    lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, "bmp_return.bin", 0);
198
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, &bmp_pic);
199
-    lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, &bmp_pic);
200
-    lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
201
-    lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
202
-  #endif // if 1
174
+
175
+  lv_obj_set_event_cb_mks(buttonExtrusion, event_handler, ID_T_EXTRUCT, NULL, 0);
176
+  lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_REL, "F:/bmp_extruct.bin");
177
+  lv_imgbtn_set_src(buttonExtrusion, LV_BTN_STATE_PR, "F:/bmp_extruct.bin");
178
+  lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_PR, &tft_style_label_pre);
179
+  lv_imgbtn_set_style(buttonExtrusion, LV_BTN_STATE_REL, &tft_style_label_rel);
180
+
181
+  lv_obj_set_event_cb_mks(buttonMove, event_handler, ID_T_MOV, NULL, 0);
182
+  lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_REL, "F:/bmp_mov.bin");
183
+  lv_imgbtn_set_src(buttonMove, LV_BTN_STATE_PR, "F:/bmp_mov.bin");
184
+  lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_PR, &tft_style_label_pre);
185
+  lv_imgbtn_set_style(buttonMove, LV_BTN_STATE_REL, &tft_style_label_rel);
186
+
187
+  lv_obj_set_event_cb_mks(buttonHome, event_handler, ID_T_HOME, NULL, 0);
188
+  lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_REL, "F:/bmp_zero.bin");
189
+  lv_imgbtn_set_src(buttonHome, LV_BTN_STATE_PR, "F:/bmp_zero.bin");
190
+  lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_PR, &tft_style_label_pre);
191
+  lv_imgbtn_set_style(buttonHome, LV_BTN_STATE_REL, &tft_style_label_rel);
192
+
193
+  lv_obj_set_event_cb_mks(buttonLevel, event_handler, ID_T_LEVELING, NULL, 0);
194
+  lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_REL, "F:/bmp_leveling.bin");
195
+  lv_imgbtn_set_src(buttonLevel, LV_BTN_STATE_PR, "F:/bmp_leveling.bin");
196
+  lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_PR, &tft_style_label_pre);
197
+  lv_imgbtn_set_style(buttonLevel, LV_BTN_STATE_REL, &tft_style_label_rel);
198
+
199
+  lv_obj_set_event_cb_mks(buttonFilament, event_handler,ID_T_FILAMENT,NULL,0);
200
+  lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_REL, "F:/bmp_filamentchange.bin");
201
+  lv_imgbtn_set_src(buttonFilament, LV_BTN_STATE_PR, "F:/bmp_filamentchange.bin");
202
+  lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_PR, &tft_style_label_pre);
203
+  lv_imgbtn_set_style(buttonFilament, LV_BTN_STATE_REL, &tft_style_label_rel);
204
+
205
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_T_RETURN, NULL, 0);
206
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
207
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
208
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
209
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
203 210
 
204 211
   lv_obj_set_pos(buttonPreHeat, INTERVAL_V, titleHeight);
205 212
   lv_obj_set_pos(buttonExtrusion, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight);
206 213
   lv_obj_set_pos(buttonMove, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight);
207 214
   lv_obj_set_pos(buttonHome, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight);
208 215
   lv_obj_set_pos(buttonLevel, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
209
-  //lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
216
+  lv_obj_set_pos(buttonFilament,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
210 217
   //lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
211 218
   lv_obj_set_pos(buttonBack, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
212 219
 
@@ -216,18 +223,18 @@ void lv_draw_tool(void) {
216 223
   lv_btn_set_layout(buttonMove, LV_LAYOUT_OFF);
217 224
   lv_btn_set_layout(buttonHome, LV_LAYOUT_OFF);
218 225
   lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
219
-  //lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
226
+  lv_btn_set_layout(buttonFilament, LV_LAYOUT_OFF);
220 227
   //lv_btn_set_layout(buttonMore, LV_LAYOUT_OFF);
221 228
   lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
222 229
 
223
-  lv_obj_t * labelPreHeat   = lv_label_create(buttonPreHeat, NULL);
224
-  lv_obj_t * labelExtrusion = lv_label_create(buttonExtrusion, NULL);
225
-  lv_obj_t * label_Move     = lv_label_create(buttonMove, NULL);
226
-  lv_obj_t * label_Home     = lv_label_create(buttonHome, NULL);
227
-  lv_obj_t * label_Level    = lv_label_create(buttonLevel, NULL);
228
-  //lv_obj_t * label_Filament = lv_label_create(buttonFilament, NULL);
229
-  //lv_obj_t * label_More = lv_label_create(buttonMore, NULL);
230
-  lv_obj_t * label_Back = lv_label_create(buttonBack, NULL);
230
+  lv_obj_t *labelPreHeat   = lv_label_create(buttonPreHeat, NULL);
231
+  lv_obj_t *labelExtrusion = lv_label_create(buttonExtrusion, NULL);
232
+  lv_obj_t *label_Move     = lv_label_create(buttonMove, NULL);
233
+  lv_obj_t *label_Home     = lv_label_create(buttonHome, NULL);
234
+  lv_obj_t *label_Level    = lv_label_create(buttonLevel, NULL);
235
+  lv_obj_t *label_Filament = lv_label_create(buttonFilament, NULL);
236
+  //lv_obj_t *label_More   = lv_label_create(buttonMore, NULL);
237
+  lv_obj_t *label_Back     = lv_label_create(buttonBack, NULL);
231 238
 
232 239
   if (gCfgItems.multiple_language != 0) {
233 240
     lv_label_set_text(labelPreHeat, tool_menu.preheat);
@@ -242,17 +249,11 @@ void lv_draw_tool(void) {
242 249
     lv_label_set_text(label_Home, tool_menu.home);
243 250
     lv_obj_align(label_Home, buttonHome, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
244 251
 
245
-    /*
246
-    if (gCfgItems.leveling_mode != 2) {
247
-      lv_label_set_text(label_Level, gCfgItems.leveling_mode == 1 ? tool_menu.autoleveling : tool_menu.leveling);
248
-      lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
249
-    }
250
-    */
251 252
     lv_label_set_text(label_Level, tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling));
252 253
     lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
253 254
 
254
-    //lv_label_set_text(label_Filament, tool_menu.filament);
255
-    //lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
255
+    lv_label_set_text(label_Filament, tool_menu.filament);
256
+    lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
256 257
 
257 258
     //lv_label_set_text(label_More, tool_menu.more);
258 259
     //lv_obj_align(label_More, buttonMore, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
@@ -260,8 +261,24 @@ void lv_draw_tool(void) {
260 261
     lv_label_set_text(label_Back, common_menu.text_back);
261 262
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
262 263
   }
264
+  #if HAS_ROTARY_ENCODER
265
+    if (gCfgItems.encoder_enable) {
266
+      lv_group_add_obj(g, buttonPreHeat);
267
+      lv_group_add_obj(g, buttonExtrusion);
268
+      lv_group_add_obj(g, buttonMove);
269
+      lv_group_add_obj(g, buttonHome);
270
+      lv_group_add_obj(g, buttonLevel);
271
+      lv_group_add_obj(g, buttonFilament);
272
+      lv_group_add_obj(g, buttonBack);
273
+    }
274
+  #endif
263 275
 }
264 276
 
265
-void lv_clear_tool() { lv_obj_del(scr); }
277
+void lv_clear_tool() {
278
+  #if HAS_ROTARY_ENCODER
279
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
280
+  #endif
281
+  lv_obj_del(scr);
282
+}
266 283
 
267 284
 #endif // HAS_TFT_LVGL_UI

+ 350
- 145
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp View File

@@ -55,7 +55,8 @@ DISP_STATE_STACK disp_state_stack;
55 55
 DISP_STATE disp_state = MAIN_UI;
56 56
 DISP_STATE last_disp_state;
57 57
 PRINT_TIME print_time;
58
-value_state value;
58
+num_key_value_state value;
59
+keyboard_value_state keyboard_value;
59 60
 
60 61
 uint32_t To_pre_view;
61 62
 uint8_t gcode_preview_over;
@@ -73,6 +74,14 @@ extern uint8_t bmp_public_buf[17 * 1024];
73 74
 
74 75
 extern void LCD_IO_WriteData(uint16_t RegValue);
75 76
 
77
+static const char custom_gcode_command[][100] = {
78
+  "G28\nG29\nM500",
79
+  "G28",
80
+  "G28",
81
+  "G28",
82
+  "G28"
83
+};
84
+
76 85
 lv_point_t line_points[4][2] = {
77 86
   {{PARA_UI_POS_X, PARA_UI_POS_Y + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y + PARA_UI_SIZE_Y}},
78 87
   {{PARA_UI_POS_X, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}, {TFT_WIDTH, PARA_UI_POS_Y*2 + PARA_UI_SIZE_Y}},
@@ -108,22 +117,58 @@ void gCfgItems_init() {
108 117
   #elif LCD_LANGUAGE == pt
109 118
     gCfgItems.language = LANG_PORTUGUESE;
110 119
   #endif
111
-  gCfgItems.leveling_mode    = 0;
112
-  gCfgItems.from_flash_pic   = 0;
113
-  gCfgItems.curFilesize      = 0;
114
-  gCfgItems.finish_power_off = 0;
115
-  gCfgItems.pause_reprint    = 0;
116
-  gCfgItems.pausePosX        = -1;
117
-  gCfgItems.pausePosY        = -1;
118
-  gCfgItems.pausePosZ        = 5;
120
+  gCfgItems.leveling_mode     = 0;
121
+  gCfgItems.from_flash_pic    = 0;
122
+  gCfgItems.curFilesize       = 0;
123
+  gCfgItems.finish_power_off  = 0;
124
+  gCfgItems.pause_reprint     = 0;
125
+  gCfgItems.pausePosX         = -1;
126
+  gCfgItems.pausePosY         = -1;
127
+  gCfgItems.pausePosZ         = 5;
128
+  gCfgItems.levelingPos[0][0] = X_MIN_POS + 30;
129
+  gCfgItems.levelingPos[0][1] = Y_MIN_POS + 30;
130
+  gCfgItems.levelingPos[1][0] = X_MAX_POS - 30;
131
+  gCfgItems.levelingPos[1][1] = Y_MIN_POS + 30;
132
+  gCfgItems.levelingPos[2][0] = X_MAX_POS - 30;
133
+  gCfgItems.levelingPos[2][1] = Y_MAX_POS - 30;
134
+  gCfgItems.levelingPos[3][0] = X_MIN_POS + 30;
135
+  gCfgItems.levelingPos[3][1] = Y_MAX_POS - 30;
136
+  gCfgItems.levelingPos[4][0] = X_BED_SIZE / 2;
137
+  gCfgItems.levelingPos[4][1] = Y_BED_SIZE / 2;
138
+  gCfgItems.cloud_enable  = true;
139
+  #if ENABLED(USE_WIFI_FUNCTION)
140
+    gCfgItems.wifi_mode_sel = STA_MODEL;
141
+    gCfgItems.fileSysType   = FILE_SYS_SD;
142
+    gCfgItems.wifi_type     = ESP_WIFI;
143
+  #endif
144
+  gCfgItems.filamentchange_load_length   = 200;
145
+  gCfgItems.filamentchange_load_speed    = 1000;
146
+  gCfgItems.filamentchange_unload_length = 200;
147
+  gCfgItems.filamentchange_unload_speed  = 1000;
148
+  gCfgItems.filament_limit_temper        = 200;
149
+
150
+  gCfgItems.encoder_enable = true;
151
+
119 152
   W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems.spi_flash_flag, VAR_INF_ADDR, sizeof(gCfgItems.spi_flash_flag));
120
-  if (gCfgItems.spi_flash_flag == GCFG_FLAG_VALUE) {
153
+  if (gCfgItems.spi_flash_flag == FLASH_INF_VALID_FLAG) {
121 154
     W25QXX.SPI_FLASH_BufferRead((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
122 155
   }
123 156
   else {
124
-    gCfgItems.spi_flash_flag = GCFG_FLAG_VALUE;
157
+    gCfgItems.spi_flash_flag = FLASH_INF_VALID_FLAG;
125 158
     W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
126 159
     W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
160
+    //init gcode command
161
+    W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[0], AUTO_LEVELING_COMMAND_ADDR, 100);
162
+    W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[1], OTHERS_COMMAND_ADDR_1, 100);
163
+    W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[2], OTHERS_COMMAND_ADDR_2, 100);
164
+    W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[3], OTHERS_COMMAND_ADDR_3, 100);
165
+    W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&custom_gcode_command[4], OTHERS_COMMAND_ADDR_4, 100);
166
+  }
167
+
168
+  const byte rot = TERN0(GRAPHICAL_TFT_ROTATE_180, 0xEE);
169
+  if (gCfgItems.disp_rotation_180 != rot) {
170
+    gCfgItems.disp_rotation_180 = rot;
171
+    update_spi_flash();
127 172
   }
128 173
 
129 174
   uiCfg.F[0] = 'N';
@@ -134,11 +179,6 @@ void gCfgItems_init() {
134 179
   W25QXX.SPI_FLASH_BufferWrite(uiCfg.F,REFLSHE_FLGA_ADD,4);
135 180
 }
136 181
 
137
-void gCfg_to_spiFlah() {
138
-  W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
139
-  W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
140
-}
141
-
142 182
 void ui_cfg_init() {
143 183
   uiCfg.curTempType         = 0;
144 184
   uiCfg.curSprayerChoose    = 0;
@@ -150,12 +190,81 @@ void ui_cfg_init() {
150 190
   uiCfg.move_dist           = 1;
151 191
   uiCfg.moveSpeed           = 3000;
152 192
   uiCfg.stepPrintSpeed      = 10;
193
+  uiCfg.command_send        = 0;
194
+  uiCfg.dialogType          = 0;
195
+  uiCfg.filament_heat_completed_load = 0;
196
+  uiCfg.filament_rate                = 0;
197
+  uiCfg.filament_loading_completed   = 0;
198
+  uiCfg.filament_unloading_completed = 0;
199
+  uiCfg.filament_loading_time_flg    = 0;
200
+  uiCfg.filament_loading_time_cnt    = 0;
201
+  uiCfg.filament_unloading_time_flg  = 0;
202
+  uiCfg.filament_unloading_time_cnt  = 0;
203
+
204
+  #if ENABLED(USE_WIFI_FUNCTION)
205
+    memset(&wifiPara, 0, sizeof(wifiPara));
206
+    memset(&ipPara, 0, sizeof(ipPara));
207
+    strcpy(wifiPara.ap_name, WIFI_AP_NAME);
208
+    strcpy(wifiPara.keyCode, WIFI_KEY_CODE);
209
+    //client
210
+    strcpy(ipPara.ip_addr, IP_ADDR);
211
+    strcpy(ipPara.mask, IP_MASK);
212
+    strcpy(ipPara.gate, IP_GATE);
213
+    strcpy(ipPara.dns, IP_DNS);
214
+
215
+    ipPara.dhcp_flag = IP_DHCP_FLAG;
216
+
217
+    //AP
218
+    strcpy(ipPara.dhcpd_ip, AP_IP_ADDR);
219
+    strcpy(ipPara.dhcpd_mask, AP_IP_MASK);
220
+    strcpy(ipPara.dhcpd_gate, AP_IP_GATE);
221
+    strcpy(ipPara.dhcpd_dns, AP_IP_DNS);
222
+    strcpy(ipPara.start_ip_addr, IP_START_IP);
223
+    strcpy(ipPara.end_ip_addr, IP_END_IP);
224
+
225
+    ipPara.dhcpd_flag = AP_IP_DHCP_FLAG;
226
+
227
+    strcpy((char*)uiCfg.cloud_hostUrl, "baizhongyun.cn");
228
+    uiCfg.cloud_port = 10086;
229
+  #endif
230
+
231
+  uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5);
232
+  uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5);
153 233
 }
154 234
 
155 235
 void update_spi_flash() {
236
+  uint8_t command_buf[512];
237
+
238
+  W25QXX.init(SPI_QUARTER_SPEED);
239
+  //read back the gcode command befor erase spi flash
240
+  W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
241
+  W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
242
+  W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
243
+  W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
244
+}
245
+
246
+void update_gcode_command(int addr,uint8_t *s) {
247
+  uint8_t command_buf[512];
248
+
156 249
   W25QXX.init(SPI_QUARTER_SPEED);
250
+  //read back the gcode command befor erase spi flash
251
+  W25QXX.SPI_FLASH_BufferRead((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
157 252
   W25QXX.SPI_FLASH_SectorErase(VAR_INF_ADDR);
158 253
   W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&gCfgItems, VAR_INF_ADDR, sizeof(gCfgItems));
254
+  switch (addr) {
255
+    case AUTO_LEVELING_COMMAND_ADDR: memcpy(&command_buf[0*100], s, 100); break;
256
+    case OTHERS_COMMAND_ADDR_1: memcpy(&command_buf[1*100], s, 100); break;
257
+    case OTHERS_COMMAND_ADDR_2: memcpy(&command_buf[2*100], s, 100); break;
258
+    case OTHERS_COMMAND_ADDR_3: memcpy(&command_buf[3*100], s, 100); break;
259
+    case OTHERS_COMMAND_ADDR_4: memcpy(&command_buf[4*100], s, 100); break;
260
+    default: break;
261
+  }
262
+  W25QXX.SPI_FLASH_BufferWrite((uint8_t *)&command_buf, GCODE_COMMAND_ADDR, sizeof(command_buf));
263
+}
264
+
265
+void get_gcode_command(int addr,uint8_t *d) {
266
+  W25QXX.init(SPI_QUARTER_SPEED);
267
+  W25QXX.SPI_FLASH_BufferRead((uint8_t *)d, addr, 100);
159 268
 }
160 269
 
161 270
 lv_style_t tft_style_scr;
@@ -169,6 +278,13 @@ lv_style_t style_num_key_pre;
169 278
 lv_style_t style_num_key_rel;
170 279
 
171 280
 lv_style_t style_num_text;
281
+lv_style_t style_sel_text;
282
+
283
+lv_style_t style_para_value;
284
+lv_style_t style_para_back;
285
+
286
+lv_style_t lv_bar_style_indic;
287
+
172 288
 void tft_style_init() {
173 289
   lv_style_copy(&tft_style_scr, &lv_style_scr);
174 290
   tft_style_scr.body.main_color   = LV_COLOR_BACKGROUND;
@@ -197,12 +313,13 @@ void tft_style_init() {
197 313
   tft_style_label_rel.text.letter_space = 0;
198 314
   tft_style_label_pre.text.line_space   = -5;
199 315
   tft_style_label_rel.text.line_space   = -5;
316
+
200 317
   lv_style_copy(&style_para_value_pre, &lv_style_scr);
201 318
   lv_style_copy(&style_para_value_rel, &lv_style_scr);
202 319
   style_para_value_pre.body.main_color = LV_COLOR_BACKGROUND;
203 320
   style_para_value_pre.body.grad_color = LV_COLOR_BACKGROUND;
204
-  style_para_value_pre.text.color      = LV_COLOR_BLACK;
205
-  style_para_value_pre.text.sel_color  = LV_COLOR_BLACK;
321
+  style_para_value_pre.text.color      = LV_COLOR_TEXT;
322
+  style_para_value_pre.text.sel_color  = LV_COLOR_TEXT;
206 323
   style_para_value_rel.body.main_color = LV_COLOR_BACKGROUND;
207 324
   style_para_value_rel.body.grad_color = LV_COLOR_BACKGROUND;
208 325
   style_para_value_rel.text.color      = LV_COLOR_BLACK;
@@ -215,6 +332,7 @@ void tft_style_init() {
215 332
   style_para_value_rel.text.letter_space = 0;
216 333
   style_para_value_pre.text.line_space   = -5;
217 334
   style_para_value_rel.text.line_space   = -5;
335
+
218 336
   lv_style_copy(&style_num_key_pre, &lv_style_scr);
219 337
   lv_style_copy(&style_num_key_rel, &lv_style_scr);
220 338
   style_num_key_pre.body.main_color = LV_COLOR_KEY_BACKGROUND;
@@ -250,10 +368,48 @@ void tft_style_init() {
250 368
   style_num_text.text.letter_space = 0;
251 369
   style_num_text.text.line_space   = -5;
252 370
 
371
+  lv_style_copy(&style_sel_text, &lv_style_scr);
372
+  style_sel_text.body.main_color  = LV_COLOR_BACKGROUND;
373
+  style_sel_text.body.grad_color  = LV_COLOR_BACKGROUND;
374
+  style_sel_text.text.color       = LV_COLOR_YELLOW;
375
+  style_sel_text.text.sel_color   = LV_COLOR_YELLOW;
376
+  style_sel_text.text.font        = &gb2312_puhui32;
377
+  style_sel_text.line.width       = 0;
378
+  style_sel_text.text.letter_space  = 0;
379
+  style_sel_text.text.line_space    = -5;
253 380
   lv_style_copy(&style_line, &lv_style_plain);
254 381
   style_line.line.color   = LV_COLOR_MAKE(0x49, 0x54, 0xff);
255 382
   style_line.line.width   = 1;
256 383
   style_line.line.rounded = 1;
384
+
385
+  lv_style_copy(&style_para_value, &lv_style_plain);
386
+  style_para_value.body.border.color = LV_COLOR_BACKGROUND;
387
+  style_para_value.body.border.width = 1;
388
+  style_para_value.body.main_color   = LV_COLOR_WHITE;
389
+  style_para_value.body.grad_color   = LV_COLOR_WHITE;
390
+  style_para_value.body.shadow.width = 0;
391
+  style_para_value.body.radius       = 3;
392
+  style_para_value.text.color        = LV_COLOR_BLACK;
393
+  style_para_value.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
394
+
395
+  lv_style_copy(&style_para_back, &lv_style_plain);
396
+  style_para_back.body.border.color = LV_COLOR_BACKGROUND;
397
+  style_para_back.body.border.width = 1;
398
+  style_para_back.body.main_color   = TFT_LV_PARA_BACK_BODY_COLOR;
399
+  style_para_back.body.grad_color   = TFT_LV_PARA_BACK_BODY_COLOR;
400
+  style_para_back.body.shadow.width = 0;
401
+  style_para_back.body.radius       = 3;
402
+  style_para_back.text.color        = LV_COLOR_WHITE;
403
+  style_para_back.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
404
+
405
+  lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
406
+  lv_bar_style_indic.text.color        = lv_color_hex3(0xADF);
407
+  lv_bar_style_indic.image.color       = lv_color_hex3(0xADF);
408
+  lv_bar_style_indic.line.color        = lv_color_hex3(0xADF);
409
+  lv_bar_style_indic.body.main_color   = lv_color_hex3(0xADF);
410
+  lv_bar_style_indic.body.grad_color   = lv_color_hex3(0xADF);
411
+  lv_bar_style_indic.body.border.color = lv_color_hex3(0xADF);
412
+
257 413
 }
258 414
 
259 415
 #define MAX_TITLE_LEN 28
@@ -360,15 +516,14 @@ char *getDispText(int index) {
360 516
     case BIND_UI:
361 517
       strcpy(public_buf_l, cloud_menu.title);
362 518
       break;
363
-    case ZOFFSET_UI:
364
-      strcpy(public_buf_l, zoffset_menu.title);
365
-      break;
366 519
     case TOOL_UI:
367 520
       strcpy(public_buf_l, tool_menu.title);
368 521
       break;
369 522
     case WIFI_LIST_UI:
370
-      //strcpy(public_buf_l, list_menu.title);
371
-      break;
523
+      #if ENABLED(USE_WIFI_FUNCTION)
524
+        strcpy(public_buf_l, list_menu.title);
525
+        break;
526
+      #endif
372 527
     case MACHINE_PARA_UI:
373 528
       strcpy(public_buf_l, MachinePara_menu.title);
374 529
       break;
@@ -503,7 +658,7 @@ char *creat_title_text() {
503 658
         #if ENABLED(TFT_LVGL_UI_SPI)
504 659
           SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
505 660
         #else
506
-          ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
661
+          LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
507 662
           LCD_WriteRAM_Prepare();
508 663
         #endif
509 664
 
@@ -582,10 +737,10 @@ char *creat_title_text() {
582 737
             //saved_feedrate_percentage = feedrate_percentage;
583 738
             planner.flow_percentage[0] = 100;
584 739
             planner.e_factor[0]        = planner.flow_percentage[0] * 0.01;
585
-            if (EXTRUDERS == 2) {
740
+            #if HAS_MULTI_EXTRUDER
586 741
               planner.flow_percentage[1] = 100;
587 742
               planner.e_factor[1]        = planner.flow_percentage[1] * 0.01;
588
-            }
743
+            #endif
589 744
             card.startFileprint();
590 745
             TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
591 746
             once_flag = 0;
@@ -615,7 +770,7 @@ char *creat_title_text() {
615 770
         #if ENABLED(TFT_LVGL_UI_SPI)
616 771
           SPI_TFT.SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
617 772
         #else
618
-          ili9320_SetWindows(xpos_pixel, ypos_pixel + row, 200, 1);
773
+          LCD_setWindowArea(xpos_pixel, ypos_pixel + row, 200, 1);
619 774
           LCD_WriteRAM_Prepare();
620 775
         #endif
621 776
 
@@ -714,10 +869,10 @@ char *creat_title_text() {
714 869
             //saved_feedrate_percentage = feedrate_percentage;
715 870
             planner.flow_percentage[0] = 100;
716 871
             planner.e_factor[0]        = planner.flow_percentage[0] * 0.01;
717
-            if (EXTRUDERS == 2) {
872
+            #if HAS_MULTI_EXTRUDER
718 873
               planner.flow_percentage[1] = 100;
719 874
               planner.e_factor[1]        = planner.flow_percentage[1] * 0.01;
720
-            }
875
+            #endif
721 876
             card.startFileprint();
722 877
             TERN_(POWER_LOSS_RECOVERY, recovery.prepare());
723 878
             once_flag = 0;
@@ -733,17 +888,17 @@ char *creat_title_text() {
733 888
   void Draw_default_preview(int xpos_pixel, int ypos_pixel, uint8_t sel) {
734 889
     int index;
735 890
     int y_off = 0;
736
-
891
+    W25QXX.init(SPI_QUARTER_SPEED);
737 892
     for (index = 0; index < 10; index++) { // 200*200
738 893
       #if HAS_BAK_VIEW_IN_FLASH
739 894
         if (sel == 1) {
740 895
           flash_view_Read(bmp_public_buf, 8000); // 20k
741 896
         }
742 897
         else {
743
-          default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
898
+          default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
744 899
         }
745 900
       #else
746
-        default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 20k
901
+        default_view_Read(bmp_public_buf, DEFAULT_VIEW_MAX_SIZE / 10); // 8k
747 902
       #endif
748 903
 
749 904
       #if ENABLED(TFT_LVGL_UI_SPI)
@@ -754,7 +909,7 @@ char *creat_title_text() {
754 909
         uint16_t temp_p;
755 910
         int i = 0;
756 911
         uint16_t *p_index;
757
-        ili9320_SetWindows(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
912
+        LCD_setWindowArea(xpos_pixel, y_off * 20 + ypos_pixel, 200, 20); // 200*200
758 913
 
759 914
         LCD_WriteRAM_Prepare();
760 915
 
@@ -904,29 +1059,28 @@ void GUI_RefreshPage() {
904 1059
       */
905 1060
       break;
906 1061
 
907
-    case WIFI_UI:
908
-      /*
909
-      if (wifi_refresh_flg == 1) {
910
-        disp_wifi_state();
911
-        wifi_refresh_flg = 0;
912
-      }
913
-      */
914
-      break;
1062
+    #if ENABLED(USE_WIFI_FUNCTION)
1063
+      case WIFI_UI:
1064
+        if (temperature_change_frequency == 1) {
1065
+          disp_wifi_state();
1066
+          temperature_change_frequency = 0;
1067
+        }
1068
+        break;
1069
+    #endif
1070
+
915 1071
     case BIND_UI:
916 1072
       /*refresh_bind_ui();*/
917 1073
       break;
918 1074
 
919 1075
     case FILAMENTCHANGE_UI:
920
-      /*
921 1076
       if (temperature_change_frequency) {
922 1077
         temperature_change_frequency = 0;
923
-        disp_filament_sprayer_temp();
1078
+        disp_filament_temp();
924 1079
       }
925
-      */
926 1080
       break;
927 1081
     case DIALOG_UI:
928
-      /*filament_dialog_handle();
929
-      wifi_scan_handle();*/
1082
+      filament_dialog_handle();
1083
+      TERN_(USE_WIFI_FUNCTION, wifi_scan_handle());
930 1084
       break;
931 1085
     case MESHLEVELING_UI:
932 1086
       /*disp_zpos();*/
@@ -934,66 +1088,68 @@ void GUI_RefreshPage() {
934 1088
     case HARDWARE_TEST_UI:
935 1089
       break;
936 1090
     case WIFI_LIST_UI:
937
-      /*
938
-      if (wifi_refresh_flg == 1) {
939
-        disp_wifi_list();
940
-        wifi_refresh_flg = 0;
941
-      }
942
-      */
1091
+      #if ENABLED(USE_WIFI_FUNCTION)
1092
+        if (printing_rate_update_flag == 1) {
1093
+          disp_wifi_list();
1094
+          printing_rate_update_flag = 0;
1095
+        }
1096
+      #endif
943 1097
       break;
944 1098
     case KEY_BOARD_UI:
945 1099
       /*update_password_disp();
946 1100
       update_join_state_disp();*/
947 1101
       break;
948
-    case TIPS_UI:
949
-      /*
950
-      switch (tips_type) {
951
-        case TIPS_TYPE_JOINING:
952
-          if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) {
953
-            tips_disp.timer = TIPS_TIMER_STOP;
954
-            tips_disp.timer_count = 0;
955
-            Clear_Tips();
956
-            tips_type = TIPS_TYPE_WIFI_CONECTED;
957
-            draw_Tips();
958
-          }
959
-          if (tips_disp.timer_count >= 30) {
960
-            tips_disp.timer = TIPS_TIMER_STOP;
961
-            tips_disp.timer_count = 0;
962
-            Clear_Tips();
963
-            tips_type = TIPS_TYPE_TAILED_JOIN;
964
-            draw_Tips();
965
-          }
966
-          break;
967
-        case TIPS_TYPE_TAILED_JOIN:
968
-          if (tips_disp.timer_count >= 3) {
969
-            tips_disp.timer = TIPS_TIMER_STOP;
970
-            tips_disp.timer_count = 0;
971
-            last_disp_state = TIPS_UI;
972
-            Clear_Tips();
973
-            draw_Wifi_list();
974
-          }
975
-          break;
976
-        case TIPS_TYPE_WIFI_CONECTED:
977
-          if (tips_disp.timer_count >= 3) {
978
-            tips_disp.timer = TIPS_TIMER_STOP;
979
-            tips_disp.timer_count = 0;
980
-
981
-            last_disp_state = TIPS_UI;
982
-            Clear_Tips();
983
-            draw_Wifi();
984
-          }
985
-          break;
986
-        default: break;
987
-      }
988
-      */
989
-      break;
1102
+    #if ENABLED(USE_WIFI_FUNCTION)
1103
+      case WIFI_TIPS_UI:
1104
+        switch (wifi_tips_type) {
1105
+          case TIPS_TYPE_JOINING:
1106
+            if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName,(const char *)wifi_list.wifiName[wifi_list.nameIndex]) == 0) {
1107
+              tips_disp.timer = TIPS_TIMER_STOP;
1108
+              tips_disp.timer_count = 0;
1109
+
1110
+              lv_clear_wifi_tips();
1111
+              wifi_tips_type = TIPS_TYPE_WIFI_CONECTED;
1112
+              lv_draw_wifi_tips();
1113
+
1114
+            }
1115
+            if (tips_disp.timer_count >= 30 * 1000) {
1116
+              tips_disp.timer = TIPS_TIMER_STOP;
1117
+              tips_disp.timer_count = 0;
1118
+              lv_clear_wifi_tips();
1119
+              wifi_tips_type = TIPS_TYPE_TAILED_JOIN;
1120
+              lv_draw_wifi_tips();
1121
+            }
1122
+            break;
1123
+          case TIPS_TYPE_TAILED_JOIN:
1124
+            if (tips_disp.timer_count >= 3 * 1000) {
1125
+              tips_disp.timer = TIPS_TIMER_STOP;
1126
+              tips_disp.timer_count = 0;
1127
+
1128
+              last_disp_state = WIFI_TIPS_UI;
1129
+              lv_clear_wifi_tips();
1130
+              lv_draw_wifi_list();
1131
+            }
1132
+            break;
1133
+          case TIPS_TYPE_WIFI_CONECTED:
1134
+            if (tips_disp.timer_count >= 3 * 1000) {
1135
+              tips_disp.timer = TIPS_TIMER_STOP;
1136
+              tips_disp.timer_count = 0;
1137
+
1138
+              last_disp_state = WIFI_TIPS_UI;
1139
+              lv_clear_wifi_tips();
1140
+              lv_draw_wifi();
1141
+            }
1142
+            break;
1143
+          default: break;
1144
+        }
1145
+        break;
1146
+    #endif
1147
+
990 1148
     case BABY_STEP_UI:
991
-      /*
992 1149
       if (temperature_change_frequency == 1) {
993 1150
         temperature_change_frequency = 0;
994 1151
         disp_z_offset_value();
995 1152
       }
996
-      */
997 1153
       break;
998 1154
     default: break;
999 1155
   }
@@ -1060,9 +1216,11 @@ void clear_cur_ui() {
1060 1216
     case DISK_UI:
1061 1217
       //Clear_Disk();
1062 1218
       break;
1063
-    case WIFI_UI:
1064
-      //Clear_Wifi();
1065
-      break;
1219
+    #if ENABLED(USE_WIFI_FUNCTION)
1220
+      case WIFI_UI:
1221
+        lv_clear_wifi();
1222
+        break;
1223
+    #endif
1066 1224
     case MORE_UI:
1067 1225
       //Clear_more();
1068 1226
       break;
@@ -1078,15 +1236,20 @@ void clear_cur_ui() {
1078 1236
     case PRINT_MORE_UI:
1079 1237
       //Clear_Printmore();
1080 1238
       break;
1239
+    case FILAMENTCHANGE_UI:
1240
+      lv_clear_filament_change();
1241
+      break;
1081 1242
     case LEVELING_UI:
1082 1243
       lv_clear_manualLevel();
1083 1244
       break;
1084 1245
     case BIND_UI:
1085 1246
       //Clear_Bind();
1086 1247
       break;
1087
-    case ZOFFSET_UI:
1088
-      //Clear_Zoffset();
1089
-      break;
1248
+    #if HAS_BED_PROBE
1249
+      case NOZZLE_PROBE_OFFSET_UI:
1250
+        lv_clear_auto_level_offset_settings();
1251
+        break;
1252
+    #endif
1090 1253
     case TOOL_UI:
1091 1254
       lv_clear_tool();
1092 1255
       break;
@@ -1096,15 +1259,19 @@ void clear_cur_ui() {
1096 1259
     case HARDWARE_TEST_UI:
1097 1260
       //Clear_Hardwaretest();
1098 1261
       break;
1099
-    case WIFI_LIST_UI:
1100
-      //Clear_Wifi_list();
1101
-      break;
1262
+    #if ENABLED(USE_WIFI_FUNCTION)
1263
+      case WIFI_LIST_UI:
1264
+          lv_clear_wifi_list();
1265
+        break;
1266
+    #endif
1102 1267
     case KEY_BOARD_UI:
1103
-      //Clear_Keyboard();
1104
-      break;
1105
-    case TIPS_UI:
1106
-      //Clear_Tips();
1268
+      lv_clear_keyboard();
1107 1269
       break;
1270
+    #if ENABLED(USE_WIFI_FUNCTION)
1271
+      case WIFI_TIPS_UI:
1272
+        lv_clear_wifi_tips();
1273
+        break;
1274
+    #endif
1108 1275
     case MACHINE_PARA_UI:
1109 1276
       lv_clear_machine_para();
1110 1277
       break;
@@ -1130,19 +1297,19 @@ void clear_cur_ui() {
1130 1297
       //Clear_EndstopType();
1131 1298
       break;
1132 1299
     case FILAMENT_SETTINGS_UI:
1133
-      //Clear_FilamentSettings();
1300
+      lv_clear_filament_settings();
1134 1301
       break;
1135 1302
     case LEVELING_SETTIGNS_UI:
1136 1303
       //Clear_LevelingSettings();
1137 1304
       break;
1138 1305
     case LEVELING_PARA_UI:
1139
-      //Clear_LevelingPara();
1306
+      lv_clear_level_settings();
1140 1307
       break;
1141 1308
     case DELTA_LEVELING_PARA_UI:
1142 1309
       //Clear_DeltaLevelPara();
1143 1310
       break;
1144
-    case XYZ_LEVELING_PARA_UI:
1145
-      //Clear_XYZLevelPara();
1311
+    case MANUAL_LEVELING_POSIGION_UI:
1312
+      lv_clear_manual_level_pos_settings();
1146 1313
       break;
1147 1314
     case MAXFEEDRATE_UI:
1148 1315
       lv_clear_max_feedrate_settings();
@@ -1183,7 +1350,7 @@ void clear_cur_ui() {
1183 1350
       lv_clear_number_key();
1184 1351
       break;
1185 1352
     case BABY_STEP_UI:
1186
-      //Clear_babyStep();
1353
+      lv_clear_baby_stepping();
1187 1354
       break;
1188 1355
     case PAUSE_POS_UI:
1189 1356
       lv_clear_pause_position();
@@ -1201,8 +1368,22 @@ void clear_cur_ui() {
1201 1368
           lv_clear_tmc_step_mode_settings();
1202 1369
           break;
1203 1370
       #endif
1204
-    default:
1371
+    #if ENABLED(USE_WIFI_FUNCTION)
1372
+    case WIFI_SETTINGS_UI:
1373
+      lv_clear_wifi_settings();
1205 1374
       break;
1375
+    #endif
1376
+    #if USE_SENSORLESS
1377
+      case HOMING_SENSITIVITY_UI:
1378
+        lv_clear_homing_sensitivity_settings();
1379
+        break;
1380
+    #endif
1381
+    #if HAS_ROTARY_ENCODER
1382
+      case ENCODER_SETTINGS_UI:
1383
+        lv_clear_encoder_settings();
1384
+        break;
1385
+    #endif
1386
+    default: break;
1206 1387
   }
1207 1388
   //GUI_Clear();
1208 1389
 }
@@ -1267,21 +1448,17 @@ void draw_return_ui() {
1267 1448
         lv_draw_about();
1268 1449
         break;
1269 1450
 
1270
-        #if tan_mask
1271
-          case LOG_UI:
1272
-            //draw_Connect();
1273
-            break;
1274
-        #endif
1275
-
1276 1451
       case CALIBRATE_UI:
1277 1452
         //draw_calibrate();
1278 1453
         break;
1279 1454
       case DISK_UI:
1280 1455
         //draw_Disk();
1281 1456
         break;
1282
-      case WIFI_UI:
1283
-        //draw_Wifi();
1284
-        break;
1457
+      #if ENABLED(USE_WIFI_FUNCTION)
1458
+        case WIFI_UI:
1459
+          lv_draw_wifi();
1460
+          break;
1461
+      #endif
1285 1462
       case MORE_UI:
1286 1463
         //draw_More();
1287 1464
         break;
@@ -1289,7 +1466,7 @@ void draw_return_ui() {
1289 1466
         //draw_printmore();
1290 1467
         break;
1291 1468
       case FILAMENTCHANGE_UI:
1292
-        //draw_FilamentChange();
1469
+        lv_draw_filament_change();
1293 1470
         break;
1294 1471
       case LEVELING_UI:
1295 1472
         lv_draw_manualLevel();
@@ -1297,13 +1474,11 @@ void draw_return_ui() {
1297 1474
       case BIND_UI:
1298 1475
         //draw_bind();
1299 1476
         break;
1300
-
1301
-        #if tan_mask
1302
-          case ZOFFSET_UI:
1303
-            //draw_Zoffset();
1304
-            break;
1305
-        #endif
1306
-
1477
+      #if HAS_BED_PROBE
1478
+        case NOZZLE_PROBE_OFFSET_UI:
1479
+          lv_draw_auto_level_offset_settings();
1480
+          break;
1481
+      #endif
1307 1482
       case TOOL_UI:
1308 1483
         lv_draw_tool();
1309 1484
         break;
@@ -1314,13 +1489,17 @@ void draw_return_ui() {
1314 1489
         //draw_Hardwaretest();
1315 1490
         break;
1316 1491
       case WIFI_LIST_UI:
1317
-        //draw_Wifi_list();
1492
+        #if ENABLED(USE_WIFI_FUNCTION)
1493
+          lv_draw_wifi_list();
1494
+        #endif
1318 1495
         break;
1319 1496
       case KEY_BOARD_UI:
1320
-        //draw_Keyboard();
1497
+        lv_draw_keyboard();
1321 1498
         break;
1322
-      case TIPS_UI:
1323
-        //draw_Tips();
1499
+      case WIFI_TIPS_UI:
1500
+        #if ENABLED(USE_WIFI_FUNCTION)
1501
+          lv_draw_wifi_tips();
1502
+        #endif
1324 1503
         break;
1325 1504
       case MACHINE_PARA_UI:
1326 1505
         lv_draw_machine_para();
@@ -1347,19 +1526,19 @@ void draw_return_ui() {
1347 1526
         //draw_EndstopType();
1348 1527
         break;
1349 1528
       case FILAMENT_SETTINGS_UI:
1350
-        //draw_FilamentSettings();
1529
+        lv_draw_filament_settings();
1351 1530
         break;
1352 1531
       case LEVELING_SETTIGNS_UI:
1353 1532
         //draw_LevelingSettings();
1354 1533
         break;
1355 1534
       case LEVELING_PARA_UI:
1356
-        //draw_LevelingPara();
1535
+        lv_draw_level_settings();
1357 1536
         break;
1358 1537
       case DELTA_LEVELING_PARA_UI:
1359 1538
         //draw_DeltaLevelPara();
1360 1539
         break;
1361
-      case XYZ_LEVELING_PARA_UI:
1362
-        //draw_XYZLevelPara();
1540
+      case MANUAL_LEVELING_POSIGION_UI:
1541
+        lv_draw_manual_level_pos_settings();
1363 1542
         break;
1364 1543
       case MAXFEEDRATE_UI:
1365 1544
         lv_draw_max_feedrate_settings();
@@ -1400,10 +1579,10 @@ void draw_return_ui() {
1400 1579
         lv_draw_number_key();
1401 1580
         break;
1402 1581
       case DIALOG_UI:
1403
-        //draw_dialog(DialogType);
1582
+        //draw_dialog(uiCfg.dialogType);
1404 1583
         break;
1405 1584
       case BABY_STEP_UI:
1406
-        //draw_babyStep();
1585
+        lv_draw_baby_stepping();
1407 1586
         break;
1408 1587
       case PAUSE_POS_UI:
1409 1588
         lv_draw_pause_position();
@@ -1421,6 +1600,21 @@ void draw_return_ui() {
1421 1600
             lv_draw_tmc_step_mode_settings();
1422 1601
             break;
1423 1602
         #endif
1603
+      #if ENABLED(USE_WIFI_FUNCTION)
1604
+        case WIFI_SETTINGS_UI:
1605
+        lv_draw_wifi_settings();
1606
+        break;
1607
+      #endif
1608
+      #if USE_SENSORLESS
1609
+        case HOMING_SENSITIVITY_UI:
1610
+          lv_draw_homing_sensitivity_settings();
1611
+          break;
1612
+      #endif
1613
+      #if HAS_ROTARY_ENCODER
1614
+        case ENCODER_SETTINGS_UI:
1615
+          lv_draw_encoder_settings();
1616
+          break;
1617
+      #endif
1424 1618
       default: break;
1425 1619
     }
1426 1620
   }
@@ -1440,8 +1634,8 @@ void draw_return_ui() {
1440 1634
 #endif
1441 1635
 
1442 1636
 void lv_ex_line(lv_obj_t * line, lv_point_t *points) {
1443
-  /*Copy the previous line and apply the new style*/
1444
-  lv_line_set_points(line, points, 2);     /*Set the points*/
1637
+  // Copy the previous line and apply the new style
1638
+  lv_line_set_points(line, points, 2);     // Set the points
1445 1639
   lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line);
1446 1640
   lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
1447 1641
 }
@@ -1450,18 +1644,29 @@ extern volatile uint32_t systick_uptime_millis;
1450 1644
 
1451 1645
 void print_time_count() {
1452 1646
   if ((systick_uptime_millis % 1000) == 0)
1453
-    if (print_time.start == 1) print_time.seconds++;
1647
+  if (print_time.start == 1) print_time.seconds++;
1454 1648
 }
1455 1649
 
1456 1650
 void LV_TASK_HANDLER() {
1457 1651
   //lv_tick_inc(1);
1458 1652
   lv_task_handler();
1459 1653
   if (mks_test_flag == 0x1e) mks_hardware_test();
1654
+
1460 1655
   #if HAS_GCODE_PREVIEW
1461 1656
     disp_pre_gcode(2, 36);
1462 1657
   #endif
1658
+
1463 1659
   GUI_RefreshPage();
1660
+
1661
+  #if ENABLED(USE_WIFI_FUNCTION)
1662
+    get_wifi_commands();
1663
+  #endif
1664
+
1464 1665
   //sd_detection();
1666
+
1667
+  #if HAS_ROTARY_ENCODER
1668
+    if (gCfgItems.encoder_enable) lv_update_encoder();
1669
+  #endif
1465 1670
 }
1466 1671
 
1467 1672
 #endif // HAS_TFT_LVGL_UI

+ 145
- 23
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h View File

@@ -34,7 +34,11 @@
34 34
 #undef LV_COLOR_BACKGROUND
35 35
 #define LV_COLOR_BACKGROUND LV_COLOR_MAKE(0x1A, 0x1A, 0x1A) // LV_COLOR_MAKE(0x00, 0x00, 0x00)
36 36
 
37
+#define TFT_LV_PARA_BACK_BODY_COLOR  LV_COLOR_MAKE(0x4A, 0x52, 0xFF)
38
+
39
+#include "tft_lvgl_configuration.h"
37 40
 #include "tft_multi_language.h"
41
+#include "pic_manager.h"
38 42
 #include "draw_ready_print.h"
39 43
 #include "draw_language.h"
40 44
 #include "draw_set.h"
@@ -66,8 +70,33 @@
66 70
 #include "draw_eeprom_settings.h"
67 71
 #include "draw_max_feedrate_settings.h"
68 72
 #include "draw_tmc_step_mode_settings.h"
73
+#include "draw_level_settings.h"
74
+#include "draw_manual_level_pos_settings.h"
75
+#include "draw_auto_level_offset_settings.h"
76
+#include "draw_filament_change.h"
77
+#include "draw_filament_settings.h"
78
+#include "draw_homing_sensitivity_settings.h"
79
+#include "draw_baby_stepping.h"
80
+#include "draw_keyboard.h"
81
+#include "draw_encoder_settings.h"
82
+
83
+#if ENABLED(USE_WIFI_FUNCTION)
84
+  #include "wifiSerial.h"
85
+  #include "wifi_module.h"
86
+  #include "wifi_upload.h"
87
+  #include "draw_wifi_settings.h"
88
+  #include "draw_wifi.h"
89
+  #include "draw_wifi_list.h"
90
+  #include "draw_wifi_tips.h"
91
+#endif
69 92
 
70 93
 #include "../../inc/MarlinConfigPre.h"
94
+#define FILE_SYS_USB  0
95
+#define FILE_SYS_SD 1
96
+
97
+#define TICK_CYCLE 1
98
+
99
+#define PARA_SEL_ICON_TEXT_COLOR  LV_COLOR_MAKE(0x4a, 0x52, 0xff);
71 100
 
72 101
 #define TFT35
73 102
 
@@ -100,30 +129,38 @@
100 129
   #define PREVIEW_LITTLE_PIC_SIZE  40910  // 400*100+9*101+1
101 130
   #define PREVIEW_SIZE      202720        // (PREVIEW_LITTLE_PIC_SIZE+800*200+201*9+1)
102 131
 
103
-  #define GCFG_FLAG_VALUE   0xEE
104
-
105 132
   // machine parameter ui
106
-  #define PARA_UI_POS_X            10
107
-  #define PARA_UI_POS_Y            50
133
+  #define PARA_UI_POS_X             10
134
+  #define PARA_UI_POS_Y             50
108 135
 
109
-  #define PARA_UI_SIZE_X          450
110
-  #define PARA_UI_SIZE_Y           40
136
+  #define PARA_UI_SIZE_X            450
137
+  #define PARA_UI_SIZE_Y            40
111 138
 
112 139
   #define PARA_UI_ARROW_V          12
113 140
 
114
-  #define PARA_UI_BACL_POS_X      400
115
-  #define PARA_UI_BACL_POS_Y      270
141
+  #define PARA_UI_BACL_POS_X        400
142
+  #define PARA_UI_BACL_POS_Y        270
116 143
 
117
-  #define PARA_UI_TURN_PAGE_POS_X 320
118
-  #define PARA_UI_TURN_PAGE_POS_Y 270
144
+  #define PARA_UI_TURN_PAGE_POS_X   320
145
+  #define PARA_UI_TURN_PAGE_POS_Y   270
119 146
 
120
-  #define PARA_UI_VALUE_SIZE_X    370
121
-  #define PARA_UI_VALUE_POS_X     400
147
+  #define PARA_UI_VALUE_SIZE_X      370
148
+  #define PARA_UI_VALUE_POS_X       400
122 149
   #define PARA_UI_VALUE_V           5
123 150
 
124
-  #define PARA_UI_STATE_POS_X     380
151
+  #define PARA_UI_STATE_POS_X       380
125 152
   #define PARA_UI_STATE_V           2
126 153
 
154
+  #define PARA_UI_VALUE_SIZE_X_2    200
155
+  #define PARA_UI_VALUE_POS_X_2     320
156
+  #define PARA_UI_VALUE_V_2         5
157
+
158
+  #define PARA_UI_VALUE_BTN_X_SIZE  70
159
+  #define PARA_UI_VALUE_BTN_Y_SIZE  28
160
+
161
+  #define PARA_UI_BACK_BTN_X_SIZE   70
162
+  #define PARA_UI_BACK_BTN_Y_SIZE   40
163
+
127 164
 #else // ifdef TFT35
128 165
 
129 166
   #define TFT_WIDTH     320
@@ -135,13 +172,25 @@ extern char public_buf_m[100];
135 172
 extern char public_buf_l[30];
136 173
 
137 174
 typedef struct {
138
-  uint8_t spi_flash_flag;
175
+  uint32_t spi_flash_flag;
176
+  uint8_t disp_rotation_180;
139 177
   uint8_t multiple_language;
140 178
   uint8_t language;
141 179
   uint8_t leveling_mode;
142 180
   uint8_t from_flash_pic;
143 181
   uint8_t finish_power_off;
144 182
   uint8_t pause_reprint;
183
+  uint8_t wifi_mode_sel;
184
+  uint8_t fileSysType;
185
+  uint8_t wifi_type;
186
+  bool  cloud_enable;
187
+  bool  encoder_enable;
188
+  int   levelingPos[5][2];
189
+  int   filamentchange_load_length;
190
+  int   filamentchange_load_speed;
191
+  int   filamentchange_unload_length;
192
+  int   filamentchange_unload_speed;
193
+  int   filament_limit_temper;
145 194
   float pausePosX;
146 195
   float pausePosY;
147 196
   float pausePosZ;
@@ -153,15 +202,42 @@ typedef struct {
153 202
           curSprayerChoose : 3,
154 203
           stepHeat : 4;
155 204
   uint8_t leveling_first_time : 1,
156
-          para_ui_page : 1;
205
+          para_ui_page:1,
206
+          configWifi:1,
207
+          command_send:1,
208
+          filament_load_heat_flg:1,
209
+          filament_heat_completed_load:1,
210
+          filament_unload_heat_flg:1,
211
+          filament_heat_completed_unload:1;
212
+  uint8_t filament_loading_completed:1,
213
+          filament_unloading_completed:1,
214
+          filament_loading_time_flg:1,
215
+          filament_unloading_time_flg:1,
216
+          curSprayerChoose_bak:4;
217
+  uint8_t wifi_name[32];
218
+  uint8_t wifi_key[64];
219
+  uint8_t cloud_hostUrl[96];
157 220
   uint8_t extruStep;
158 221
   uint8_t extruSpeed;
159 222
   uint8_t print_state;
160 223
   uint8_t stepPrintSpeed;
161 224
   uint8_t waitEndMoves;
225
+  uint8_t dialogType;
226
+  uint8_t F[4];
227
+  uint8_t filament_rate;
162 228
   uint16_t moveSpeed;
229
+  uint16_t cloud_port;
230
+  uint16_t moveSpeed_bak;
231
+  uint32_t totalSend;
232
+  uint32_t filament_loading_time;
233
+  uint32_t filament_unloading_time;
234
+  uint32_t filament_loading_time_cnt;
235
+  uint32_t filament_unloading_time_cnt;
163 236
   float move_dist;
164
-  uint8_t F[4];
237
+  float desireSprayerTempBak;
238
+  float current_x_position_bak;
239
+  float current_y_position_bak;
240
+  float current_e_position_bak;
165 241
 } UI_CFG;
166 242
 
167 243
 typedef enum {
@@ -196,12 +272,14 @@ typedef enum {
196 272
   LEVELING_UI,
197 273
   MESHLEVELING_UI,
198 274
   BIND_UI,
199
-  ZOFFSET_UI,
275
+  #if HAS_BED_PROBE
276
+    NOZZLE_PROBE_OFFSET_UI,
277
+  #endif
200 278
   TOOL_UI,
201 279
   HARDWARE_TEST_UI,
202 280
   WIFI_LIST_UI,
203 281
   KEY_BOARD_UI,
204
-  TIPS_UI,
282
+  WIFI_TIPS_UI,
205 283
   MACHINE_PARA_UI,
206 284
   MACHINE_SETTINGS_UI,
207 285
   TEMPERATURE_SETTINGS_UI,
@@ -214,7 +292,7 @@ typedef enum {
214 292
   LEVELING_SETTIGNS_UI,
215 293
   LEVELING_PARA_UI,
216 294
   DELTA_LEVELING_PARA_UI,
217
-  XYZ_LEVELING_PARA_UI,
295
+  MANUAL_LEVELING_POSIGION_UI,
218 296
   MAXFEEDRATE_UI,
219 297
   STEPS_UI,
220 298
   ACCELERATION_UI,
@@ -232,7 +310,10 @@ typedef enum {
232 310
   PAUSE_POS_UI,
233 311
   TMC_CURRENT_UI,
234 312
   TMC_MODE_UI,
235
-  EEPROM_SETTINGS_UI
313
+  EEPROM_SETTINGS_UI,
314
+  WIFI_SETTINGS_UI,
315
+  HOMING_SENSITIVITY_UI,
316
+  ENCODER_SETTINGS_UI
236 317
 } DISP_STATE;
237 318
 
238 319
 typedef struct {
@@ -285,10 +366,45 @@ typedef enum {
285 366
 
286 367
   pause_pos_x,
287 368
   pause_pos_y,
288
-  pause_pos_z
369
+  pause_pos_z,
370
+
371
+  level_pos_x1,
372
+  level_pos_y1,
373
+  level_pos_x2,
374
+  level_pos_y2,
375
+  level_pos_x3,
376
+  level_pos_y3,
377
+  level_pos_x4,
378
+  level_pos_y4,
379
+  level_pos_x5,
380
+  level_pos_y5
381
+  #if HAS_BED_PROBE
382
+    ,
383
+    x_offset,
384
+    y_offset,
385
+    z_offset
386
+  #endif
387
+  ,
388
+  load_length,
389
+  load_speed,
390
+  unload_length,
391
+  unload_speed,
392
+  filament_temp,
393
+
394
+  x_sensitivity,
395
+  y_sensitivity,
396
+  z_sensitivity,
397
+  z2_sensitivity
398
+} num_key_value_state;
399
+extern num_key_value_state value;
289 400
 
290
-}value_state;
291
-extern value_state value;
401
+typedef enum {
402
+  wifiName,
403
+  wifiPassWord,
404
+  wifiConfig,
405
+  gcodeCommand
406
+} keyboard_value_state;
407
+extern keyboard_value_state keyboard_value;
292 408
 
293 409
 extern CFG_ITMES gCfgItems;
294 410
 extern UI_CFG uiCfg;
@@ -305,6 +421,10 @@ extern lv_style_t style_para_value_rel;
305 421
 extern lv_style_t style_num_key_pre;
306 422
 extern lv_style_t style_num_key_rel;
307 423
 extern lv_style_t style_num_text;
424
+extern lv_style_t style_sel_text;
425
+extern lv_style_t style_para_value;
426
+extern lv_style_t style_para_back;
427
+extern lv_style_t lv_bar_style_indic;
308 428
 
309 429
 extern lv_point_t line_points[4][2];
310 430
 
@@ -314,6 +434,8 @@ extern void tft_style_init();
314 434
 extern char *creat_title_text(void);
315 435
 extern void preview_gcode_prehandle(char *path);
316 436
 extern void update_spi_flash();
437
+extern void update_gcode_command(int addr,uint8_t *s);
438
+extern void get_gcode_command(int addr,uint8_t *d);
317 439
 #if HAS_GCODE_PREVIEW
318 440
   extern void disp_pre_gcode(int xpos_pixel, int ypos_pixel);
319 441
 #endif

+ 222
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp View File

@@ -0,0 +1,222 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#if ENABLED(USE_WIFI_FUNCTION)
30
+
31
+#include "../../../../../Configuration.h"
32
+#include "../../../../module/temperature.h"
33
+
34
+extern lv_group_t * g;
35
+static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text;
36
+
37
+#define ID_W_RETURN     1
38
+#define ID_W_CLOUD      2
39
+#define ID_W_RECONNECT  3
40
+
41
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
42
+  switch (obj->mks_obj_id) {
43
+    case ID_W_RETURN:
44
+      if (event == LV_EVENT_CLICKED) {
45
+
46
+      }
47
+      else if (event == LV_EVENT_RELEASED) {
48
+        clear_cur_ui();
49
+        lv_draw_set();
50
+      }
51
+    break;
52
+    case ID_W_CLOUD:
53
+      if (event == LV_EVENT_CLICKED) {
54
+
55
+      }
56
+      else if (event == LV_EVENT_RELEASED) {
57
+        //clear_cur_ui();
58
+        //draw_return_ui();
59
+      }
60
+    break;
61
+    case ID_W_RECONNECT:
62
+      if (event == LV_EVENT_CLICKED) {
63
+
64
+      }
65
+      else if (event == LV_EVENT_RELEASED) {
66
+        clear_cur_ui();
67
+        lv_draw_wifi_list();
68
+      }
69
+    break;
70
+  }
71
+}
72
+
73
+void lv_draw_wifi(void) {
74
+  lv_obj_t *buttonBack=NULL,*label_Back=NULL;
75
+  lv_obj_t *buttonCloud=NULL,*label_Cloud=NULL;
76
+  lv_obj_t *buttonReconnect=NULL,*label_Reconnect=NULL;
77
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) {
78
+    disp_state_stack._disp_index++;
79
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI;
80
+  }
81
+  disp_state = WIFI_UI;
82
+
83
+  scr = lv_obj_create(NULL, NULL);
84
+
85
+  lv_obj_set_style(scr, &tft_style_scr);
86
+  lv_scr_load(scr);
87
+  lv_obj_clean(scr);
88
+
89
+  lv_obj_t * title = lv_label_create(scr, NULL);
90
+  lv_obj_set_style(title, &tft_style_label_rel);
91
+  lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
92
+  lv_label_set_text(title, creat_title_text());
93
+
94
+  lv_refr_now(lv_refr_get_disp_refreshing());
95
+
96
+  // Create an Image button
97
+  buttonBack = lv_imgbtn_create(scr, NULL);
98
+  if (gCfgItems.wifi_mode_sel == STA_MODEL) {
99
+    //buttonCloud = lv_imgbtn_create(scr, NULL);
100
+    buttonReconnect = lv_imgbtn_create(scr, NULL);
101
+  }
102
+
103
+  lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_W_RETURN, NULL,0);
104
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_return.bin");
105
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_return.bin");
106
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
107
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
108
+  #if HAS_ROTARY_ENCODER
109
+    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
110
+  #endif
111
+
112
+  lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4,  BTN_Y_PIXEL+INTERVAL_H+titleHeight);
113
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
114
+
115
+  if (gCfgItems.wifi_mode_sel == STA_MODEL) {
116
+
117
+    lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL,0);
118
+    lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_REL, "F:/bmp_wifi.bin");
119
+    lv_imgbtn_set_src(buttonReconnect, LV_BTN_STATE_PR, "F:/bmp_wifi.bin");
120
+    lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_PR, &tft_style_label_pre);
121
+    lv_imgbtn_set_style(buttonReconnect, LV_BTN_STATE_REL, &tft_style_label_rel);
122
+
123
+    #if HAS_ROTARY_ENCODER
124
+      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonReconnect);
125
+    #endif
126
+
127
+    lv_obj_set_pos(buttonReconnect,BTN_X_PIXEL*2+INTERVAL_V*3,  BTN_Y_PIXEL+INTERVAL_H+titleHeight);
128
+    lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
129
+  }
130
+
131
+  label_Back = lv_label_create(buttonBack, NULL);
132
+
133
+  if (gCfgItems.wifi_mode_sel == STA_MODEL) {
134
+    //label_Cloud = lv_label_create(buttonCloud, NULL);
135
+    label_Reconnect = lv_label_create(buttonReconnect, NULL);
136
+  }
137
+
138
+  if (gCfgItems.multiple_language !=0) {
139
+    lv_label_set_text(label_Back, common_menu.text_back);
140
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
141
+
142
+    if (gCfgItems.wifi_mode_sel == STA_MODEL) {
143
+      //lv_label_set_text(label_Cloud, common_menu.text_back);
144
+      //lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
145
+
146
+      lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
147
+      lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
148
+    }
149
+  }
150
+
151
+  wifi_ip_text = lv_label_create(scr, NULL);
152
+  lv_obj_set_style(wifi_ip_text, &tft_style_label_rel);
153
+
154
+  wifi_name_text = lv_label_create(scr, NULL);
155
+  lv_obj_set_style(wifi_name_text, &tft_style_label_rel);
156
+
157
+  wifi_key_text = lv_label_create(scr, NULL);
158
+  lv_obj_set_style(wifi_key_text, &tft_style_label_rel);
159
+
160
+  wifi_state_text = lv_label_create(scr, NULL);
161
+  lv_obj_set_style(wifi_state_text, &tft_style_label_rel);
162
+
163
+  disp_wifi_state();
164
+}
165
+
166
+void disp_wifi_state() {
167
+  memset(public_buf_m, 0, sizeof(public_buf_m));
168
+  strcpy(public_buf_m,wifi_menu.ip);
169
+  strcat(public_buf_m,ipPara.ip_addr);
170
+  lv_label_set_text(wifi_ip_text, public_buf_m);
171
+  lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER,0, -100);
172
+
173
+  memset(public_buf_m, 0, sizeof(public_buf_m));
174
+  strcpy(public_buf_m,wifi_menu.wifi);
175
+  strcat(public_buf_m,wifiPara.ap_name);
176
+  lv_label_set_text(wifi_name_text, public_buf_m);
177
+  lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER,0, -70);
178
+
179
+  if (wifiPara.mode == AP_MODEL) {
180
+    memset(public_buf_m, 0, sizeof(public_buf_m));
181
+    strcpy(public_buf_m,wifi_menu.key);
182
+    strcat(public_buf_m,wifiPara.keyCode);
183
+    lv_label_set_text(wifi_key_text, public_buf_m);
184
+    lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -40);
185
+
186
+    memset(public_buf_m, 0, sizeof(public_buf_m));
187
+    strcpy(public_buf_m,wifi_menu.state_ap);
188
+    if (wifi_link_state == WIFI_CONNECTED)
189
+      strcat(public_buf_m,wifi_menu.connected);
190
+    else if (wifi_link_state == WIFI_NOT_CONFIG)
191
+      strcat(public_buf_m,wifi_menu.disconnected);
192
+    else
193
+      strcat(public_buf_m,wifi_menu.exception);
194
+    lv_label_set_text(wifi_state_text, public_buf_m);
195
+    lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -10);
196
+  }
197
+  else {
198
+    ZERO(public_buf_m);
199
+    strcpy(public_buf_m, wifi_menu.state_sta);
200
+    if (wifi_link_state == WIFI_CONNECTED)
201
+      strcat(public_buf_m, wifi_menu.connected);
202
+    else if (wifi_link_state == WIFI_NOT_CONFIG)
203
+      strcat(public_buf_m, wifi_menu.disconnected);
204
+    else
205
+      strcat(public_buf_m, wifi_menu.exception);
206
+    lv_label_set_text(wifi_state_text, public_buf_m);
207
+    lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER,0, -40);
208
+
209
+    lv_label_set_text(wifi_key_text, "");
210
+    lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER,0, -10);
211
+  }
212
+}
213
+
214
+void lv_clear_wifi() {
215
+  #if HAS_ROTARY_ENCODER
216
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
217
+  #endif
218
+  lv_obj_del(scr);
219
+}
220
+
221
+#endif // USE_WIFI_FUNCTION
222
+#endif // HAS_TFT_LVGL_UI

+ 38
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.h View File

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

+ 235
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp View File

@@ -0,0 +1,235 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#if ENABLED(USE_WIFI_FUNCTION)
30
+
31
+#include "../../../../../Configuration.h"
32
+#include "../../../../module/temperature.h"
33
+
34
+#define NAME_BTN_X 330
35
+#define NAME_BTN_Y 48
36
+
37
+#define MARK_BTN_X 0
38
+#define MARK_BTN_Y 68
39
+
40
+WIFI_LIST wifi_list;
41
+list_menu_def list_menu;
42
+
43
+extern lv_group_t * g;
44
+static lv_obj_t * scr;
45
+static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE];
46
+static lv_obj_t *lableWifiText[NUMBER_OF_PAGE];
47
+static lv_obj_t *lablePageText;
48
+
49
+#define ID_WL_RETURN      11
50
+#define ID_WL_DOWN        12
51
+
52
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
53
+  if (obj->mks_obj_id == ID_WL_RETURN) {
54
+    if (event == LV_EVENT_CLICKED) {
55
+
56
+    }
57
+    else if (event == LV_EVENT_RELEASED) {
58
+      clear_cur_ui();
59
+      lv_draw_set();
60
+    }
61
+  }
62
+  else if (obj->mks_obj_id == ID_WL_DOWN) {
63
+    if (event == LV_EVENT_CLICKED) {
64
+
65
+    }
66
+    else if (event == LV_EVENT_RELEASED) {
67
+      if (wifi_list.getNameNum > 0) {
68
+        if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
69
+          wifi_list.nameIndex = 0;
70
+          wifi_list.currentWifipage = 1;
71
+        }
72
+        else {
73
+          wifi_list.nameIndex += NUMBER_OF_PAGE;
74
+          wifi_list.currentWifipage++;
75
+        }
76
+        disp_wifi_list();
77
+      }
78
+    }
79
+  }
80
+  else {
81
+    for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
82
+      if (obj->mks_obj_id == i + 1) {
83
+        if (event == LV_EVENT_CLICKED) {
84
+
85
+        }
86
+        else if (event == LV_EVENT_RELEASED) {
87
+          if (wifi_list.getNameNum != 0) {
88
+            const bool do_wifi = wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[wifi_list.nameIndex + i]) == 0;
89
+            wifi_list.nameIndex += i;
90
+            last_disp_state = WIFI_LIST_UI;
91
+            lv_clear_wifi_list();
92
+            if (do_wifi)
93
+              lv_draw_wifi();
94
+            else {
95
+              keyboard_value = wifiConfig;
96
+              lv_draw_keyboard();
97
+            }
98
+          }
99
+        }
100
+      }
101
+    }
102
+  }
103
+}
104
+
105
+void lv_draw_wifi_list(void) {
106
+  lv_obj_t *buttonBack = NULL, *buttonDown = NULL;
107
+
108
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) {
109
+    disp_state_stack._disp_index++;
110
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI;
111
+  }
112
+  disp_state = WIFI_LIST_UI;
113
+
114
+  scr = lv_obj_create(NULL, NULL);
115
+
116
+  lv_obj_set_style(scr, &tft_style_scr);
117
+  lv_scr_load(scr);
118
+  lv_obj_clean(scr);
119
+
120
+  lv_obj_t * title = lv_label_create(scr, NULL);
121
+  lv_obj_set_style(title, &tft_style_label_rel);
122
+  lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
123
+  lv_label_set_text(title, creat_title_text());
124
+
125
+  lv_refr_now(lv_refr_get_disp_refreshing());
126
+
127
+  buttonDown = lv_imgbtn_create(scr, NULL);
128
+  buttonBack = lv_imgbtn_create(scr, NULL);
129
+
130
+  lv_obj_set_event_cb_mks(buttonDown, event_handler,ID_WL_DOWN,NULL,0);
131
+  lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_REL, "F:/bmp_pageDown.bin");
132
+  lv_imgbtn_set_src(buttonDown, LV_BTN_STATE_PR, "F:/bmp_pageDown.bin");
133
+  lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_PR, &tft_style_label_pre);
134
+  lv_imgbtn_set_style(buttonDown, LV_BTN_STATE_REL, &tft_style_label_rel);
135
+
136
+  lv_obj_set_event_cb_mks(buttonBack, event_handler,ID_WL_RETURN,NULL,0);
137
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back.bin");
138
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back.bin");
139
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
140
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
141
+
142
+  lv_obj_set_pos(buttonDown,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL+INTERVAL_H);
143
+  lv_obj_set_pos(buttonBack,OTHER_BTN_XPIEL*3+INTERVAL_V*4,titleHeight+OTHER_BTN_YPIEL*2+INTERVAL_H*2);
144
+
145
+  lv_btn_set_layout(buttonDown, LV_LAYOUT_OFF);
146
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
147
+
148
+  for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
149
+    buttonWifiN[i] = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
150
+    lv_obj_set_pos(buttonWifiN[i], 0,NAME_BTN_Y*i+10+titleHeight);                            /*Set its position*/
151
+    lv_obj_set_size(buttonWifiN[i], NAME_BTN_X,NAME_BTN_Y);                          /*Set its size*/
152
+    lv_obj_set_event_cb_mks(buttonWifiN[i], event_handler,(i+1),NULL,0);
153
+    lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel);    /*Set the button's released style*/
154
+    lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_PR, &tft_style_label_pre);      /*Set the button's pressed style*/
155
+    lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF);
156
+    lableWifiText[i] = lv_label_create(buttonWifiN[i], NULL);
157
+    #if HAS_ROTARY_ENCODER
158
+      uint8_t j = 0;
159
+      if (gCfgItems.encoder_enable) {
160
+        j = wifi_list.nameIndex + i;
161
+        if (j < wifi_list.getNameNum) lv_group_add_obj(g, buttonWifiN[i]);
162
+      }
163
+    #endif
164
+  }
165
+
166
+  lablePageText = lv_label_create(scr, NULL);
167
+  lv_obj_set_style(lablePageText, &tft_style_label_rel);
168
+
169
+  wifi_list.nameIndex = 0;
170
+  wifi_list.currentWifipage = 1;
171
+
172
+  if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) {
173
+    memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName));
174
+    memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName));
175
+  }
176
+  #if HAS_ROTARY_ENCODER
177
+    if (gCfgItems.encoder_enable) {
178
+      lv_group_add_obj(g, buttonDown);
179
+      lv_group_add_obj(g, buttonBack);
180
+    }
181
+  #endif
182
+
183
+  disp_wifi_list();
184
+}
185
+
186
+void disp_wifi_list(void) {
187
+  int8_t tmpStr[WIFI_NAME_BUFFER_SIZE] = { 0 };
188
+  uint8_t i, j;
189
+
190
+  sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage);
191
+  lv_label_set_text(lablePageText, (const char *)tmpStr);
192
+  lv_obj_align(lablePageText, NULL, LV_ALIGN_CENTER, 50, -100);
193
+
194
+  for (i = 0; i < NUMBER_OF_PAGE; i++) {
195
+    memset(tmpStr, 0, sizeof(tmpStr));
196
+
197
+    j = wifi_list.nameIndex + i;
198
+    if (j >= wifi_list.getNameNum) {
199
+      lv_label_set_text(lableWifiText[i], (const char *)tmpStr);
200
+      lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
201
+    }
202
+    else {
203
+      lv_label_set_text(lableWifiText[i], (char const *)wifi_list.wifiName[j]);
204
+      lv_obj_align(lableWifiText[i], buttonWifiN[i], LV_ALIGN_IN_LEFT_MID, 20, 0);
205
+
206
+      if (wifi_link_state == WIFI_CONNECTED && strcmp((const char *)wifi_list.wifiConnectedName, (const char *)wifi_list.wifiName[j]) == 0) {
207
+        lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &style_sel_text);
208
+      }
209
+      else {
210
+        lv_btn_set_style(buttonWifiN[i], LV_BTN_STYLE_REL, &tft_style_label_rel);
211
+      }
212
+    }
213
+  }
214
+}
215
+
216
+void wifi_scan_handle() {
217
+  if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return;
218
+  last_disp_state = DIALOG_UI;
219
+  lv_clear_dialog();
220
+  if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL)
221
+    lv_draw_wifi();
222
+  else
223
+    lv_draw_wifi_list();
224
+}
225
+
226
+void lv_clear_wifi_list() {
227
+  #if HAS_ROTARY_ENCODER
228
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
229
+  #endif
230
+  lv_obj_del(scr);
231
+}
232
+
233
+#endif // USE_WIFI_FUNCTION
234
+
235
+#endif // HAS_TFT_LVGL_UI

+ 76
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.h View File

@@ -0,0 +1,76 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+  extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+extern void lv_draw_wifi_list();
29
+extern void lv_clear_wifi_list();
30
+extern void disp_wifi_list(void);
31
+extern void cutWifiName(char *name, int len,char *outStr);
32
+extern void wifi_scan_handle();
33
+
34
+#define NUMBER_OF_PAGE 5
35
+
36
+#define WIFI_TOTAL_NUMBER 20
37
+#define WIFI_NAME_BUFFER_SIZE 33
38
+
39
+typedef struct {
40
+  int8_t getNameNum;
41
+  int8_t nameIndex;
42
+  int8_t currentWifipage;
43
+  int8_t getPage;
44
+  int8_t RSSI[WIFI_TOTAL_NUMBER];
45
+  uint8_t wifiName[WIFI_TOTAL_NUMBER][WIFI_NAME_BUFFER_SIZE];
46
+  uint8_t wifiConnectedName[WIFI_NAME_BUFFER_SIZE];
47
+} WIFI_LIST;
48
+extern WIFI_LIST wifi_list;
49
+
50
+typedef struct list_menu_disp {
51
+  const char *title;
52
+  const char *file_pages;
53
+} list_menu_def;
54
+extern list_menu_def list_menu;
55
+
56
+typedef struct keyboard_menu_disp {
57
+  const char *title;
58
+  const char *apply;
59
+  const char *password;
60
+  const char *letter;
61
+  const char *digital;
62
+  const char *symbol;
63
+  const char *space;
64
+} keyboard_menu_def;
65
+extern keyboard_menu_def keyboard_menu;
66
+
67
+typedef struct tips_menu_disp {
68
+  const char *joining;
69
+  const char *failedJoin;
70
+  const char *wifiConected;
71
+} tips_menu_def;
72
+extern tips_menu_def tips_menu;
73
+
74
+#ifdef __cplusplus
75
+  } /* C-declarations for C++ */
76
+#endif

+ 299
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp View File

@@ -0,0 +1,299 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#if ENABLED(USE_WIFI_FUNCTION)
30
+
31
+#include "../../../../../Configuration.h"
32
+#include "../../../../module/planner.h"
33
+
34
+extern lv_group_t * g;
35
+static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL;
36
+
37
+#define ID_WIFI_RETURN    1
38
+#define ID_WIFI_MODEL     2
39
+#define ID_WIFI_NAME      3
40
+#define ID_WIFI_PASSWORD  4
41
+#define ID_WIFI_CLOUD     5
42
+#define ID_WIFI_CONFIG    6
43
+
44
+static void event_handler(lv_obj_t * obj, lv_event_t event) {
45
+  switch (obj->mks_obj_id) {
46
+    case ID_WIFI_RETURN:
47
+      if (event == LV_EVENT_CLICKED) {
48
+
49
+      }
50
+      else if (event == LV_EVENT_RELEASED) {
51
+      lv_clear_wifi_settings();
52
+            draw_return_ui();
53
+      }
54
+    break;
55
+    case ID_WIFI_MODEL:
56
+      if (event == LV_EVENT_CLICKED) {
57
+
58
+      }
59
+      else if (event == LV_EVENT_RELEASED) {
60
+      if (gCfgItems.wifi_mode_sel == AP_MODEL) {
61
+        gCfgItems.wifi_mode_sel = STA_MODEL;
62
+        lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
63
+        lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
64
+        update_spi_flash();
65
+      }
66
+      else{
67
+        gCfgItems.wifi_mode_sel = AP_MODEL;
68
+        lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
69
+        lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
70
+        update_spi_flash();
71
+      }
72
+      }
73
+    break;
74
+    case ID_WIFI_NAME:
75
+      if (event == LV_EVENT_CLICKED) {
76
+
77
+      }
78
+      else if (event == LV_EVENT_RELEASED) {
79
+      keyboard_value=wifiName;
80
+      lv_clear_wifi_settings();
81
+          lv_draw_keyboard();
82
+      }
83
+    break;
84
+    case ID_WIFI_PASSWORD:
85
+      if (event == LV_EVENT_CLICKED) {
86
+
87
+      }
88
+      else if (event == LV_EVENT_RELEASED) {
89
+      keyboard_value=wifiPassWord;
90
+      lv_clear_wifi_settings();
91
+          lv_draw_keyboard();
92
+      }
93
+    break;
94
+    case ID_WIFI_CLOUD:
95
+      if (event == LV_EVENT_CLICKED) {
96
+
97
+      }
98
+      else if (event == LV_EVENT_RELEASED) {
99
+      if (gCfgItems.cloud_enable) {
100
+        gCfgItems.cloud_enable = false;
101
+        lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_disable.bin",0);
102
+        lv_label_set_text(labelCloudValue, machine_menu.disable);
103
+        update_spi_flash();
104
+      }
105
+      else {
106
+        gCfgItems.cloud_enable = true;
107
+        lv_obj_set_event_cb_mks(obj, event_handler,ID_WIFI_CLOUD,"bmp_enable.bin",0);
108
+        lv_label_set_text(labelCloudValue, machine_menu.enable);
109
+        update_spi_flash();
110
+      }
111
+    }
112
+    break;
113
+    case ID_WIFI_CONFIG:
114
+      if (event == LV_EVENT_CLICKED) {
115
+
116
+      }
117
+      else if (event == LV_EVENT_RELEASED) {
118
+      lv_clear_wifi_settings();
119
+          lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
120
+      }
121
+    break;
122
+  }
123
+}
124
+
125
+void lv_draw_wifi_settings(void) {
126
+  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonConfig = NULL, *labelConfig = NULL;
127
+  lv_obj_t *labelModelText = NULL;
128
+  lv_obj_t *labelNameText = NULL, *buttonNameValue = NULL, *labelNameValue = NULL;
129
+  lv_obj_t *labelPassWordText = NULL, *buttonPassWordValue = NULL, *labelPassWordValue = NULL;
130
+  lv_obj_t *labelCloudText = NULL, *buttonCloudValue = NULL;
131
+  lv_obj_t * line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
132
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) {
133
+    disp_state_stack._disp_index++;
134
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI;
135
+  }
136
+  disp_state = WIFI_SETTINGS_UI;
137
+
138
+  scr = lv_obj_create(NULL, NULL);
139
+
140
+  lv_obj_set_style(scr, &tft_style_scr);
141
+  lv_scr_load(scr);
142
+  lv_obj_clean(scr);
143
+
144
+  lv_obj_t * title = lv_label_create(scr, NULL);
145
+  lv_obj_set_style(title, &tft_style_label_rel);
146
+  lv_obj_set_pos(title,TITLE_XPOS,TITLE_YPOS);
147
+  lv_label_set_text(title, machine_menu.WifiConfTitle);
148
+
149
+  lv_refr_now(lv_refr_get_disp_refreshing());
150
+
151
+  labelModelText = lv_label_create(scr, NULL);
152
+  lv_obj_set_style(labelModelText, &tft_style_label_rel);
153
+  lv_obj_set_pos(labelModelText, PARA_UI_POS_X, PARA_UI_POS_Y + 10);
154
+  lv_label_set_text(labelModelText, machine_menu.wifiMode);
155
+
156
+  buttonModelValue = lv_imgbtn_create(scr, NULL);
157
+  lv_obj_set_pos(buttonModelValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y+PARA_UI_VALUE_V);
158
+  lv_obj_set_event_cb_mks(buttonModelValue, event_handler,ID_WIFI_MODEL, NULL,0);
159
+  lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_REL, "F:/bmp_blank_sel.bin");
160
+  lv_imgbtn_set_src(buttonModelValue, LV_BTN_STATE_PR, "F:/bmp_blank_sel.bin");
161
+  lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_PR, &style_para_value_pre);
162
+  lv_imgbtn_set_style(buttonModelValue, LV_BTN_STATE_REL, &style_para_value_pre);
163
+  lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF);
164
+  labelModelValue = lv_label_create(buttonModelValue, NULL);
165
+
166
+  line1 = lv_line_create(scr, NULL);
167
+  lv_ex_line(line1,line_points[0]);
168
+
169
+  labelNameText = lv_label_create(scr, NULL);
170
+  lv_obj_set_style(labelNameText, &tft_style_label_rel);
171
+  lv_obj_set_pos(labelNameText, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10);
172
+
173
+  buttonNameValue = lv_btn_create(scr, NULL);
174
+  lv_obj_set_pos(buttonNameValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*2+PARA_UI_VALUE_V);
175
+  lv_obj_set_size(buttonNameValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
176
+  lv_obj_set_event_cb_mks(buttonNameValue, event_handler,ID_WIFI_NAME, NULL,0);
177
+  lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_REL, &style_para_value);
178
+  lv_btn_set_style(buttonNameValue, LV_BTN_STYLE_PR, &style_para_value);
179
+  labelNameValue = lv_label_create(buttonNameValue, NULL);
180
+
181
+  line2 = lv_line_create(scr, NULL);
182
+  lv_ex_line(line2,line_points[1]);
183
+
184
+  labelPassWordText = lv_label_create(scr, NULL);
185
+  lv_obj_set_style(labelPassWordText, &tft_style_label_rel);
186
+  lv_obj_set_pos(labelPassWordText, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10);
187
+
188
+  buttonPassWordValue = lv_btn_create(scr, NULL);
189
+  lv_obj_set_pos(buttonPassWordValue,PARA_UI_VALUE_POS_X,PARA_UI_POS_Y*3+PARA_UI_VALUE_V);
190
+  lv_obj_set_size(buttonPassWordValue, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE);
191
+  lv_obj_set_event_cb_mks(buttonPassWordValue, event_handler,ID_WIFI_PASSWORD, NULL,0);
192
+  lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_REL, &style_para_value);
193
+  lv_btn_set_style(buttonPassWordValue, LV_BTN_STYLE_PR, &style_para_value);
194
+  labelPassWordValue = lv_label_create(buttonPassWordValue, NULL);
195
+
196
+  line3 = lv_line_create(scr, NULL);
197
+  lv_ex_line(line3,line_points[2]);
198
+
199
+  labelCloudText = lv_label_create(scr, NULL);
200
+  lv_obj_set_style(labelCloudText, &tft_style_label_rel);
201
+  lv_obj_set_pos(labelCloudText, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10);
202
+  lv_label_set_text(labelCloudText, machine_menu.wifiCloud);
203
+
204
+  buttonCloudValue = lv_imgbtn_create(scr, NULL);
205
+  lv_obj_set_pos(buttonCloudValue,PARA_UI_STATE_POS_X,PARA_UI_POS_Y*4+PARA_UI_STATE_V);
206
+  if (gCfgItems.cloud_enable) {
207
+    lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_enable.bin");
208
+    lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_enable.bin");
209
+  }
210
+  else {
211
+    lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_REL, "F:/bmp_disable.bin");
212
+    lv_imgbtn_set_src(buttonCloudValue, LV_BTN_STATE_PR, "F:/bmp_disable.bin");
213
+  }
214
+    lv_obj_set_event_cb_mks(buttonCloudValue, event_handler,ID_WIFI_CLOUD, NULL,0);
215
+  lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_PR, &tft_style_label_pre);
216
+  lv_imgbtn_set_style(buttonCloudValue, LV_BTN_STATE_REL, &tft_style_label_rel);
217
+  lv_btn_set_layout(buttonCloudValue, LV_LAYOUT_OFF);
218
+  labelCloudValue = lv_label_create(buttonCloudValue, NULL);
219
+
220
+  line4 = lv_line_create(scr, NULL);
221
+  lv_ex_line(line4,line_points[3]);
222
+
223
+  buttonConfig = lv_imgbtn_create(scr, NULL);
224
+  lv_obj_set_event_cb_mks(buttonConfig, event_handler,ID_WIFI_CONFIG, NULL,0);
225
+    lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
226
+  lv_imgbtn_set_src(buttonConfig, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
227
+  lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_PR, &tft_style_label_pre);
228
+  lv_imgbtn_set_style(buttonConfig, LV_BTN_STATE_REL, &tft_style_label_rel);
229
+  lv_obj_set_pos(buttonConfig, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
230
+  lv_btn_set_layout(buttonConfig, LV_LAYOUT_OFF);
231
+  labelConfig = lv_label_create(buttonConfig, NULL);
232
+
233
+  buttonBack = lv_imgbtn_create(scr, NULL);
234
+  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_WIFI_RETURN, NULL, 0);
235
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_REL, "F:/bmp_back70x40.bin");
236
+  lv_imgbtn_set_src(buttonBack, LV_BTN_STATE_PR, "F:/bmp_back70x40.bin");
237
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_PR, &tft_style_label_pre);
238
+  lv_imgbtn_set_style(buttonBack, LV_BTN_STATE_REL, &tft_style_label_rel);
239
+  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
240
+  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
241
+  label_Back = lv_label_create(buttonBack, NULL);
242
+
243
+  if (gCfgItems.multiple_language !=0) {
244
+    if (gCfgItems.wifi_mode_sel == AP_MODEL) {
245
+      lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
246
+      lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
247
+    }
248
+    else {
249
+      lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
250
+      lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER,0, 0);
251
+    }
252
+    memset(public_buf_m,0,sizeof(public_buf_m));
253
+    strcat(public_buf_m,machine_menu.wifiName);
254
+    strcat(public_buf_m,(const char *)uiCfg.wifi_name);
255
+    lv_label_set_text(labelNameText,public_buf_m);
256
+
257
+    lv_label_set_text(labelNameValue,machine_menu.wifiEdit);
258
+    lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER,0, 0);
259
+
260
+    memset(public_buf_m,0,sizeof(public_buf_m));
261
+    strcat(public_buf_m,machine_menu.wifiPassWord);
262
+    strcat(public_buf_m,(const char *)uiCfg.wifi_key);
263
+    lv_label_set_text(labelPassWordText,public_buf_m);
264
+
265
+    lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit);
266
+    lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER,0, 0);
267
+
268
+    lv_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable);
269
+    lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER,0, 0);
270
+
271
+    lv_label_set_text(labelConfig,machine_menu.wifiConfig);
272
+    lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER,0, 0);
273
+
274
+    lv_label_set_text(label_Back, common_menu.text_back);
275
+    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER,0, 0);
276
+  }
277
+
278
+  #if HAS_ROTARY_ENCODER
279
+    if (gCfgItems.encoder_enable) {
280
+      lv_group_add_obj(g, buttonModelValue);
281
+      lv_group_add_obj(g, buttonNameValue);
282
+      lv_group_add_obj(g, buttonPassWordValue);
283
+      lv_group_add_obj(g, buttonCloudValue);
284
+      lv_group_add_obj(g, buttonConfig);
285
+      lv_group_add_obj(g, buttonBack);
286
+    }
287
+  #endif
288
+}
289
+
290
+void lv_clear_wifi_settings() {
291
+  #if HAS_ROTARY_ENCODER
292
+    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
293
+  #endif
294
+  lv_obj_del(scr);
295
+}
296
+
297
+#endif // USE_WIFI_FUNCTION
298
+
299
+#endif // HAS_TFT_LVGL_UI

+ 36
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.h View File

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

+ 85
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp View File

@@ -0,0 +1,85 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "lv_conf.h"
27
+#include "draw_ui.h"
28
+
29
+#if ENABLED(USE_WIFI_FUNCTION)
30
+
31
+#include "../../../../../Configuration.h"
32
+#include "../../../../module/temperature.h"
33
+
34
+static lv_obj_t * scr;
35
+
36
+TIPS_TYPE wifi_tips_type;
37
+TIPS_DISP tips_disp;
38
+tips_menu_def tips_menu;
39
+
40
+void lv_draw_wifi_tips(void) {
41
+  static lv_obj_t * text_tips,*wifi_name;
42
+
43
+  if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) {
44
+    disp_state_stack._disp_index++;
45
+    disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_TIPS_UI;
46
+  }
47
+  disp_state = WIFI_TIPS_UI;
48
+
49
+  scr = lv_obj_create(NULL, NULL);
50
+
51
+  lv_obj_set_style(scr, &tft_style_scr);
52
+  lv_scr_load(scr);
53
+  lv_obj_clean(scr);
54
+  lv_refr_now(lv_refr_get_disp_refreshing());
55
+
56
+  text_tips = lv_label_create(scr, NULL);
57
+  lv_obj_set_style(text_tips, &tft_style_label_rel);
58
+
59
+  wifi_name = lv_label_create(scr, NULL);
60
+  lv_obj_set_style(wifi_name, &tft_style_label_rel);
61
+
62
+  if (wifi_tips_type == TIPS_TYPE_JOINING) {
63
+    lv_label_set_text(text_tips, tips_menu.joining);
64
+    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
65
+  }
66
+  else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) {
67
+    lv_label_set_text(text_tips, tips_menu.failedJoin);
68
+    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
69
+  }
70
+  else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) {
71
+    lv_label_set_text(text_tips, tips_menu.wifiConected);
72
+    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER,0, -60);
73
+  }
74
+
75
+  lv_label_set_text(wifi_name, (const char *)wifi_list.wifiName[wifi_list.nameIndex]);
76
+  lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER,0, -20);
77
+
78
+  tips_disp.timer = TIPS_TIMER_START;
79
+  tips_disp.timer_count = 0;
80
+}
81
+
82
+void lv_clear_wifi_tips() { lv_obj_del(scr); }
83
+
84
+#endif // USE_WIFI_FUNCTION
85
+#endif // HAS_TFT_LVGL_UI

+ 51
- 0
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.h View File

@@ -0,0 +1,51 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+  extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+
29
+extern void lv_draw_wifi_tips(void);
30
+extern void lv_clear_wifi_tips();
31
+
32
+typedef enum {
33
+  TIPS_TYPE_JOINING,
34
+  TIPS_TYPE_TAILED_JOIN,
35
+  TIPS_TYPE_WIFI_CONECTED
36
+} TIPS_TYPE;
37
+extern TIPS_TYPE wifi_tips_type;
38
+
39
+typedef struct {
40
+  unsigned char timer;
41
+  unsigned int timer_count;
42
+} TIPS_DISP;
43
+extern TIPS_DISP tips_disp;
44
+
45
+#define TIPS_TIMER_START 1
46
+#define TIPS_TIMER_STOP 0
47
+
48
+#ifdef __cplusplus
49
+  } /* C-declarations for C++ */
50
+#endif
51
+

+ 69
- 0
Marlin/src/lcd/extui/lib/mks_ui/irq_overrid.cpp View File

@@ -0,0 +1,69 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "draw_ui.h"
27
+
28
+#if ENABLED(USE_WIFI_FUNCTION)
29
+
30
+#include "wifiSerial.h"
31
+
32
+#include <libmaple/libmaple.h>
33
+#include <libmaple/gpio.h>
34
+#include <libmaple/timer.h>
35
+#include <libmaple/usart.h>
36
+#include <libmaple/ring_buffer.h>
37
+
38
+#include "../../../../inc/MarlinConfig.h"
39
+
40
+#ifdef __cplusplus
41
+  extern "C" { /* C-declarations for C++ */
42
+#endif
43
+
44
+#define WIFI_IO1_SET()    WRITE(WIFI_IO1_PIN, HIGH);
45
+#define WIFI_IO1_RESET()  WRITE(WIFI_IO1_PIN, LOW);
46
+
47
+void __irq_usart1(void) {
48
+  WIFISERIAL.wifi_usart_irq(USART1_BASE);
49
+  if (wifi_link_state == WIFI_TRANS_FILE) {
50
+    if (WIFISERIAL.available() == (400)) WIFI_IO1_SET();
51
+    if (WIFISERIAL.wifi_rb_is_full()) {
52
+      if (esp_state == TRANSFER_IDLE) esp_state = TRANSFERING;
53
+      if (storeRcvData(UART_RX_BUFFER_SIZE)) {
54
+        if (wifiTransError.flag != 0x1) WIFI_IO1_RESET();
55
+      }
56
+      else {
57
+        WIFI_IO1_SET();
58
+        esp_state = TRANSFER_STORE;
59
+      }
60
+    }
61
+  }
62
+}
63
+
64
+#ifdef __cplusplus
65
+  } /* C-declarations for C++ */
66
+#endif
67
+
68
+#endif // USE_WIFI_FUNCTION
69
+#endif // HAS_TFT_LVGL_UI

+ 73
- 27
Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp View File

@@ -38,7 +38,10 @@
38 38
 #include "../../../../module/temperature.h"
39 39
 #include "../../../../sd/cardreader.h"
40 40
 
41
-uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det2_sta, mt_det3_sta;
41
+uint8_t pw_det_sta, pw_off_sta, mt_det_sta, mt_det3_sta;
42
+#if PIN_EXISTS(MT_DET_2)
43
+  uint8_t mt_det2_sta;
44
+#endif
42 45
 uint8_t endstopx1_sta, endstopx2_sta, endstopy1_sta, endstopy2_sta, endstopz1_sta, endstopz2_sta;
43 46
 void test_gpio_readlevel_L() {
44 47
   #if ENABLED(MKS_TEST)
@@ -46,15 +49,17 @@ void test_gpio_readlevel_L() {
46 49
     WRITE(WIFI_IO0_PIN, HIGH);
47 50
     itest = 10000;
48 51
     while (itest--);
49
-    pw_det_sta = (READ(POWER_LOSS_PIN) == 0);
50
-    pw_off_sta = (READ(PS_ON_PIN) == 0);
52
+    pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 0);
53
+    pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 0);
51 54
     mt_det_sta = (READ(MT_DET_1_PIN) == 0);
52
-    mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
55
+    #if PIN_EXISTS(MT_DET_2)
56
+      mt_det2_sta = (READ(MT_DET_2_PIN) == 0);
57
+    #endif
53 58
     //mt_det3_sta = (READ(FIL_RUNOUT_3_PIN) == 0);
54 59
     endstopx1_sta = (READ(X_MIN_PIN) == 0);
55
-    endstopx2_sta = (READ(X_MAX_PIN) == 0);
60
+    //endstopx2_sta = (READ(X_MAX_PIN) == 0);
56 61
     endstopy1_sta = (READ(Y_MIN_PIN) == 0);
57
-    endstopy2_sta = (READ(Y_MAX_PIN) == 0);
62
+    //endstopy2_sta = (READ(Y_MAX_PIN) == 0);
58 63
     endstopz1_sta = (READ(Z_MIN_PIN) == 0);
59 64
     endstopz2_sta = (READ(Z_MAX_PIN) == 0);
60 65
   #endif
@@ -66,15 +71,17 @@ void test_gpio_readlevel_H() {
66 71
     WRITE(WIFI_IO0_PIN, LOW);
67 72
     itest = 10000;
68 73
     while (itest--);
69
-    pw_det_sta = (READ(POWER_LOSS_PIN) == 1);
70
-    pw_off_sta = (READ(PS_ON_PIN) == 1);
74
+    pw_det_sta = (READ(MKS_TEST_POWER_LOSS_PIN) == 1);
75
+    pw_off_sta = (READ(MKS_TEST_PS_ON_PIN) == 1);
71 76
     mt_det_sta = (READ(MT_DET_1_PIN) == 1);
72
-    mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
77
+    #if PIN_EXISTS(MT_DET_2)
78
+      mt_det2_sta = (READ(MT_DET_2_PIN) == 1);
79
+    #endif
73 80
     //mt_det3_sta = (READ(MT_DET_3_PIN) == 1);
74 81
     endstopx1_sta = (READ(X_MIN_PIN) == 1);
75
-    endstopx2_sta = (READ(X_MAX_PIN) == 1);
82
+    //endstopx2_sta = (READ(X_MAX_PIN) == 1);
76 83
     endstopy1_sta = (READ(Y_MIN_PIN) == 1);
77
-    endstopy2_sta = (READ(Y_MAX_PIN) == 1);
84
+    //endstopy2_sta = (READ(Y_MAX_PIN) == 1);
78 85
     endstopz1_sta = (READ(Z_MIN_PIN) == 1);
79 86
     endstopz2_sta = (READ(Z_MAX_PIN) == 1);
80 87
   #endif
@@ -83,20 +90,22 @@ void test_gpio_readlevel_H() {
83 90
 void init_test_gpio() {
84 91
   #ifdef MKS_TEST
85 92
     SET_INPUT_PULLUP(X_MIN_PIN);
86
-    SET_INPUT_PULLUP(X_MAX_PIN);
93
+    //SET_INPUT_PULLUP(X_MAX_PIN);
87 94
     SET_INPUT_PULLUP(Y_MIN_PIN);
88
-    SET_INPUT_PULLUP(Y_MAX_PIN);
95
+    //SET_INPUT_PULLUP(Y_MAX_PIN);
89 96
     SET_INPUT_PULLUP(Z_MIN_PIN);
90 97
     SET_INPUT_PULLUP(Z_MAX_PIN);
91 98
 
92 99
     SET_OUTPUT(WIFI_IO0_PIN);
93 100
 
94 101
     SET_INPUT_PULLUP(MT_DET_1_PIN);
95
-    SET_INPUT_PULLUP(MT_DET_2_PIN);
102
+    #if PIN_EXISTS(MT_DET_2)
103
+      SET_INPUT_PULLUP(MT_DET_2_PIN);
104
+    #endif
96 105
     //SET_INPUT_PULLUP(MT_DET_3_PIN);
97 106
 
98
-    SET_INPUT_PULLUP(POWER_LOSS_PIN);
99
-    SET_INPUT_PULLUP(PS_ON_PIN);
107
+    SET_INPUT_PULLUP(MKS_TEST_POWER_LOSS_PIN);
108
+    SET_INPUT_PULLUP(MKS_TEST_PS_ON_PIN);
100 109
 
101 110
     SET_INPUT_PULLUP(SERVO0_PIN);
102 111
 
@@ -104,14 +113,28 @@ void init_test_gpio() {
104 113
     SET_OUTPUT(Y_ENABLE_PIN);
105 114
     SET_OUTPUT(Z_ENABLE_PIN);
106 115
     SET_OUTPUT(E0_ENABLE_PIN);
107
-    SET_OUTPUT(E1_ENABLE_PIN);
116
+    #if !MB(MKS_ROBIN_E3P)
117
+      SET_OUTPUT(E1_ENABLE_PIN);
118
+    #endif
108 119
 
109 120
     WRITE(X_ENABLE_PIN, LOW);
110 121
     WRITE(Y_ENABLE_PIN, LOW);
111 122
     WRITE(Z_ENABLE_PIN, LOW);
112 123
     WRITE(E0_ENABLE_PIN, LOW);
113
-    WRITE(E1_ENABLE_PIN, LOW);
124
+    #if !MB(MKS_ROBIN_E3P)
125
+      WRITE(E1_ENABLE_PIN, LOW);
126
+    #endif
114 127
     //WRITE(E2_ENABLE_PIN, LOW);
128
+
129
+    #if MB(MKS_ROBIN_E3P)
130
+      SET_INPUT_PULLUP(PA1);
131
+      SET_INPUT_PULLUP(PA3);
132
+      SET_INPUT_PULLUP(PC2);
133
+      SET_INPUT_PULLUP(PD8);
134
+      SET_INPUT_PULLUP(PE5);
135
+      SET_INPUT_PULLUP(PE6);
136
+      SET_INPUT_PULLUP(PE7);
137
+    #endif
115 138
   #endif
116 139
 }
117 140
 
@@ -124,22 +147,37 @@ void mks_test_beeper() {
124 147
   #endif
125 148
 }
126 149
 
127
-void mks_gpio_test(){
150
+void mks_gpio_test() {
128 151
   #if ENABLED(MKS_TEST)
129 152
     init_test_gpio();
130 153
 
131 154
     test_gpio_readlevel_L();
132 155
     test_gpio_readlevel_H();
133 156
     test_gpio_readlevel_L();
134
-    if ((pw_det_sta == 1) && (mt_det_sta == 1) && (mt_det2_sta == 1)) // &&(mt_det3_sta == 1))
157
+    if ((pw_det_sta == 1)
158
+        && (pw_off_sta == 1)
159
+        && (mt_det_sta == 1)
160
+      #if PIN_EXISTS(MT_DET_2)
161
+        && (mt_det2_sta == 1)
162
+      #endif
163
+      #if MB(MKS_ROBIN_E3P)
164
+        && (READ(PA1) == 0)
165
+        && (READ(PA3) == 0)
166
+        && (READ(PC2) == 0)
167
+        && (READ(PD8) == 0)
168
+        && (READ(PE5) == 0)
169
+        && (READ(PE6) == 0)
170
+        && (READ(PE7) == 0)
171
+      #endif
172
+    ) // &&(mt_det3_sta == 1))
135 173
       disp_det_ok();
136 174
     else
137 175
       disp_det_error();
138 176
 
139 177
     if ( (endstopx1_sta == 1)
140
-      && (endstopx2_sta == 1)
178
+      //&& (endstopx2_sta == 1)
141 179
       && (endstopy1_sta == 1)
142
-      && (endstopy2_sta == 1)
180
+      //&& (endstopy2_sta == 1)
143 181
       && (endstopz1_sta == 1)
144 182
       && (endstopz2_sta == 1)
145 183
     )
@@ -149,18 +187,22 @@ void mks_gpio_test(){
149 187
     #endif
150 188
 }
151 189
 
152
-void mks_hardware_test(){
190
+void mks_hardware_test() {
153 191
   #if ENABLED(MKS_TEST)
154 192
     if (millis() % 2000 < 1000) {
155 193
       WRITE(X_DIR_PIN, LOW);
156 194
       WRITE(Y_DIR_PIN, LOW);
157 195
       WRITE(Z_DIR_PIN, LOW);
158 196
       WRITE(E0_DIR_PIN, LOW);
159
-      WRITE(E1_DIR_PIN, LOW);
197
+      #if !MB(MKS_ROBIN_E3P)
198
+        WRITE(E1_DIR_PIN, LOW);
199
+      #endif
160 200
       //WRITE(E2_DIR_PIN, LOW);
161 201
       thermalManager.fan_speed[0] = 255;
162 202
       //WRITE(HEATER_2_PIN, HIGH); // HE2
163
-      WRITE(HEATER_1_PIN, HIGH); // HE1
203
+      #if !MB(MKS_ROBIN_E3P)
204
+        WRITE(HEATER_1_PIN, HIGH); // HE1
205
+      #endif
164 206
       WRITE(HEATER_0_PIN, HIGH); // HE0
165 207
       WRITE(HEATER_BED_PIN, HIGH); // HOT-BED
166 208
     }
@@ -169,11 +211,15 @@ void mks_hardware_test(){
169 211
       WRITE(Y_DIR_PIN, HIGH);
170 212
       WRITE(Z_DIR_PIN, HIGH);
171 213
       WRITE(E0_DIR_PIN, HIGH);
172
-      WRITE(E1_DIR_PIN, HIGH);
214
+      #if !MB(MKS_ROBIN_E3P)
215
+        WRITE(E1_DIR_PIN, HIGH);
216
+      #endif
173 217
       //WRITE(E2_DIR_PIN, HIGH);
174 218
       thermalManager.fan_speed[0] = 0;
175 219
       //WRITE(HEATER_2_PIN, LOW); // HE2
176
-      WRITE(HEATER_1_PIN, LOW); // HE1
220
+      #if !MB(MKS_ROBIN_E3P)
221
+        WRITE(HEATER_1_PIN, LOW); // HE1
222
+      #endif
177 223
       WRITE(HEATER_0_PIN, LOW); // HE0
178 224
       WRITE(HEATER_BED_PIN, LOW); // HOT-BED
179 225
     }

+ 95
- 79
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.cpp View File

@@ -24,6 +24,7 @@
24 24
 #if HAS_TFT_LVGL_UI
25 25
 
26 26
 #include "string.h"
27
+#include "draw_ui.h"
27 28
 #include "pic_manager.h"
28 29
 #include "draw_ready_print.h"
29 30
 #include "mks_hardware_test.h"
@@ -41,59 +42,61 @@ extern unsigned char bmp_public_buf[17 * 1024];
41 42
   extern char *createFilename(char * const buffer, const dir_t &p);
42 43
 #endif
43 44
 
44
-static char assets[][LONG_FILENAME_LENGTH] = {
45
+static const char assets[][LONG_FILENAME_LENGTH] = {
45 46
   //homing screen
46
-  "bmp_Zero.bin",
47
+  "bmp_zeroAll.bin",
48
+  "bmp_zero.bin",
47 49
   "bmp_zeroX.bin",
48 50
   "bmp_zeroY.bin",
49 51
   "bmp_zeroZ.bin",
50 52
   "bmp_manual_off.bin",
51 53
 
52 54
   //tool screen
53
-  "bmp_PreHeat.bin",
54
-  "bmp_Extruct.bin",
55
-  "bmp_Mov.bin",
55
+  "bmp_preHeat.bin",
56
+  "bmp_extruct.bin",
57
+  "bmp_mov.bin",
56 58
   // "bmp_Zero.bin",
57
-  "bmp_Leveling.bin",
59
+  "bmp_leveling.bin",
60
+  "bmp_filamentchange.bin",
58 61
 
59 62
   //fan screen
60 63
   "bmp_Add.bin",
61 64
   "bmp_Dec.bin",
62
-  "bmp_Speed255.bin",
63
-  "bmp_Speed127.bin",
64
-  "bmp_Speed0.bin",
65
+  "bmp_speed255.bin",
66
+  "bmp_speed127.bin",
67
+  "bmp_speed0.bin",
65 68
 
66 69
   //preheat screen
67 70
   // "bmp_Add.bin",
68 71
   // "bmp_Dec.bin",
69
-  "bmp_Speed0.bin",
72
+  "bmp_speed0.bin",
70 73
   // "bmp_Extru2.bin",
71 74
   // "bmp_Extru1.bin",
72
-  "bmp_Bed.bin",
73
-  "bmp_Step1_degree.bin",
74
-  "bmp_Step5_degree.bin",
75
-  "bmp_Step10_degree.bin",
75
+  "bmp_bed.bin",
76
+  "bmp_step1_degree.bin",
77
+  "bmp_step5_degree.bin",
78
+  "bmp_step10_degree.bin",
76 79
 
77 80
   //extrusion screen
78
-  "bmp_In.bin",
79
-  "bmp_Out.bin",
80
-  "bmp_Extru1.bin",
81
-  #if EXTRUDERS > 1
82
-    "bmp_Extru2.bin",
81
+  "bmp_in.bin",
82
+  "bmp_out.bin",
83
+  "bmp_extru1.bin",
84
+  #if HAS_MULTI_EXTRUDER
85
+    "bmp_extru2.bin",
83 86
   #endif
84
-  "bmp_Speed_high.bin",
85
-  "bmp_Speed_slow.bin",
86
-  "bmp_Speed_normal.bin",
87
-  "bmp_Step1_mm.bin",
88
-  "bmp_Step5_mm.bin",
89
-  "bmp_Step10_mm.bin",
87
+  "bmp_speed_high.bin",
88
+  "bmp_speed_slow.bin",
89
+  "bmp_speed_normal.bin",
90
+  "bmp_step1_mm.bin",
91
+  "bmp_step5_mm.bin",
92
+  "bmp_step10_mm.bin",
90 93
 
91 94
   //select file screen
92 95
   "bmp_pageUp.bin",
93 96
   "bmp_pageDown.bin",
94
-  "bmp_Back.bin", //TODO: why two back buttons? Why not just one? (return / back)
95
-  "bmp_Dir.bin",
96
-  "bmp_File.bin",
97
+  "bmp_back.bin", //TODO: why two back buttons? Why not just one? (return / back)
98
+  "bmp_dir.bin",
99
+  "bmp_file.bin",
97 100
 
98 101
   //move motor screen
99 102
   //TODO: 6 equal icons, just in diffenct rotation... it may be optimized too
@@ -103,68 +106,69 @@ static char assets[][LONG_FILENAME_LENGTH] = {
103 106
   "bmp_yDec.bin",
104 107
   "bmp_zAdd.bin",
105 108
   "bmp_zDec.bin",
106
-  "bmp_Step_move0_1.bin",
107
-  "bmp_Step_move1.bin",
108
-  "bmp_Step_move10.bin",
109
+  "bmp_step_move0_1.bin",
110
+  "bmp_step_move1.bin",
111
+  "bmp_step_move10.bin",
109 112
 
110 113
   //operation screen
111 114
   "bmp_auto_off.bin",
112
-  "bmp_Speed.bin",
115
+  "bmp_speed.bin",
113 116
   //"bmp_Mamual.bin", //TODO: didn't find it.. changed to bmp_manual_off.bin
114
-  "bmp_Fan.bin",
115
-  //"bmp_PreHeat.bin",
116
-  //"bmp_Extruct.bin",
117
-  // "bmp_Mov.bin",
117
+  "bmp_fan.bin",
118
+  "bmp_temp.bin",
119
+  "bmp_extrude_opr.bin",
120
+  "bmp_move_opr.bin",
118 121
 
119 122
   //change speed screen
120
-  "bmp_Step1_percent.bin",
121
-  "bmp_Step5_percent.bin",
122
-  "bmp_Step10_percent.bin",
123
+  "bmp_step1_percent.bin",
124
+  "bmp_step5_percent.bin",
125
+  "bmp_step10_percent.bin",
123 126
   "bmp_extruct_sel.bin",
124 127
   "bmp_mov_changespeed.bin",
125 128
   // "bmp_extrude_opr.bin", equal to "bmp_Extruct.bin"
126 129
   "bmp_mov_sel.bin",
130
+  "bmp_speed_extruct.bin",
127 131
 
128 132
   //printing screen
129
-  "bmp_Pause.bin",
130
-  "bmp_Resume.bin",
131
-  "bmp_Stop.bin",
132
-  "bmp_Ext1_state.bin",
133
-  #if EXTRUDERS > 1
134
-    "bmp_Ext2_state.bin",
133
+  "bmp_pause.bin",
134
+  "bmp_resume.bin",
135
+  "bmp_stop.bin",
136
+  "bmp_ext1_state.bin",
137
+  #if HAS_MULTI_EXTRUDER
138
+    "bmp_ext2_state.bin",
135 139
   #endif
136
-  "bmp_Bed_state.bin",
137
-  "bmp_Fan_state.bin",
138
-  "bmp_Time_state.bin",
139
-  "bmp_Zpos_state.bin",
140
-  "bmp_Operate.bin",
140
+  "bmp_bed_state.bin",
141
+  "bmp_fan_state.bin",
142
+  "bmp_time_state.bin",
143
+  "bmp_zpos_state.bin",
144
+  "bmp_operate.bin",
141 145
 
142 146
   //manual leval screen (only if disabled auto level)
143 147
   #if DISABLED(AUTO_BED_LEVELING_BILINEAR)
144
-    "bmp_Leveling1.bin",
145
-    "bmp_Leveling2.bin",
146
-    "bmp_Leveling3.bin",
147
-    "bmp_Leveling4.bin",
148
-    "bmp_Leveling5.bin",
148
+    "bmp_leveling1.bin",
149
+    "bmp_leveling2.bin",
150
+    "bmp_leveling3.bin",
151
+    "bmp_leveling4.bin",
152
+    "bmp_leveling5.bin",
149 153
   #endif
150 154
 
151 155
   //lang select screen
152 156
   #if HAS_LANG_SELECT_SCREEN
153
-    "bmp_Language.bin",
157
+    "bmp_language.bin",
154 158
     "bmp_simplified_cn.bin",
155 159
     "bmp_simplified_cn_sel.bin",
156 160
     "bmp_traditional_cn.bin",
157 161
     "bmp_traditional_cn_sel.bin",
158
-    "bmp_English.bin",
159
-    "bmp_English_sel.bin",
160
-    "bmp_Russian.bin",
161
-    "bmp_Russian_sel.bin",
162
-    "bmp_Spanish.bin",
163
-    "bmp_Spanish_sel.bin",
164
-    "bmp_French.bin",
165
-    "bmp_French_sel.bin",
166
-    "bmp_Italy.bin",
167
-    "bmp_Italy_sel.bin",
162
+    "bmp_english.bin",
163
+    "bmp_english_sel.bin",
164
+    "bmp_russian.bin",
165
+    "bmp_russian_sel.bin",
166
+    "bmp_spanish.bin",
167
+    "bmp_spanish_sel.bin",
168
+    "bmp_french.bin",
169
+    "bmp_french_sel.bin",
170
+    "bmp_italy.bin",
171
+    "bmp_italy_sel.bin",
168 172
   #endif // HAS_LANG_SELECT_SCREEN
169 173
 
170 174
   // gcode preview
@@ -177,21 +181,15 @@ static char assets[][LONG_FILENAME_LENGTH] = {
177 181
   #endif
178 182
 
179 183
   // settings screen
180
-  "bmp_About.bin",
184
+  "bmp_about.bin",
181 185
   //"bmp_Language.bin",
182 186
   //"bmp_Fan.bin",
183 187
   //"bmp_manual_off.bin",
184 188
 
185 189
   //start screen
186 190
   "bmp_printing.bin",
187
-  "bmp_Set.bin",
188
-  "bmp_Tool.bin",
189
-
190
-  #if ENABLED(HAS_STEALTHCHOP)
191
-    //"bmp_back70x40.bin",
192
-    "bmp_disable.bin",
193
-    "bmp_enable.bin",
194
-  #endif
191
+  "bmp_set.bin",
192
+  "bmp_tool.bin",
195 193
 
196 194
   // settings screen
197 195
   "bmp_eeprom_settings.bin",
@@ -202,14 +200,27 @@ static char assets[][LONG_FILENAME_LENGTH] = {
202 200
   "bmp_arrow.bin",
203 201
   "bmp_back70x40.bin",
204 202
   "bmp_value_blank.bin",
205
-  "bmp_Return.bin"
203
+  "bmp_blank_sel.bin",
204
+  "bmp_disable.bin",
205
+  "bmp_enable.bin",
206
+  "bmp_return.bin",
207
+
208
+  #if ENABLED(USE_WIFI_FUNCTION)
209
+    //wifi screen
210
+    "bmp_wifi.bin",
211
+  #endif
212
+
213
+  //babystep screen
214
+  "bmp_baby_move0_01.bin",
215
+  "bmp_baby_move0_05.bin",
216
+  "bmp_baby_move0_1.bin"
206 217
 };
207 218
 
208 219
 #if HAS_SPI_FLASH_FONT
209 220
   static char fonts[][LONG_FILENAME_LENGTH] = { "FontUNIGBK.bin" };
210 221
 #endif
211 222
 
212
-static uint8_t currentFlashPage = 0;
223
+uint8_t currentFlashPage = 0;
213 224
 
214 225
 uint32_t lv_get_pic_addr(uint8_t *Pname) {
215 226
   uint8_t Pic_cnt;
@@ -253,8 +264,13 @@ const char *bakPath = "_assets";
253 264
 void spiFlashErase_PIC() {
254 265
   volatile uint32_t pic_sectorcnt = 0;
255 266
   W25QXX.init(SPI_QUARTER_SPEED);
256
-  for (pic_sectorcnt = 0; pic_sectorcnt < PIC_SIZE_xM * 1024 / 64; pic_sectorcnt++)
257
-    W25QXX.SPI_FLASH_BlockErase(PICINFOADDR + pic_sectorcnt * 64 * 1024);
267
+  //erase 0x001000 -64K
268
+  for (pic_sectorcnt = 0; pic_sectorcnt < (64 - 4) / 4; pic_sectorcnt++) {
269
+    W25QXX.SPI_FLASH_SectorErase(PICINFOADDR + pic_sectorcnt * 4 * 1024);
270
+  }
271
+  //erase 64K -- 6M
272
+  for (pic_sectorcnt = 0; pic_sectorcnt < (PIC_SIZE_xM * 1024 / 64 - 1); pic_sectorcnt++)
273
+    W25QXX.SPI_FLASH_BlockErase((pic_sectorcnt + 1) * 64 * 1024);
258 274
 }
259 275
 
260 276
 #if HAS_SPI_FLASH_FONT

+ 11
- 2
Marlin/src/lcd/extui/lib/mks_ui/pic_manager.h View File

@@ -21,7 +21,7 @@
21 21
  */
22 22
 #pragma once
23 23
 
24
-#include "../../../../inc/MarlinConfig.h"
24
+#include "../../../../inc/MarlinConfigPre.h"
25 25
 
26 26
 #include "../../../../libs/W25Qxx.h"
27 27
 
@@ -119,9 +119,18 @@
119 119
 
120 120
 // Flash flag
121 121
 #define REFLSHE_FLGA_ADD                (0X800000-32)
122
-#define FLASH_INF_VALID_FLAG            0xAA558761
122
+
123 123
 // SD card information first addr
124 124
 #define VAR_INF_ADDR                    0x000000
125
+#define FLASH_INF_VALID_FLAG            0x20200831
126
+
127
+//Store some gcode commands, such as auto leveling commands
128
+#define GCODE_COMMAND_ADDR              VAR_INF_ADDR + 3*1024
129
+#define AUTO_LEVELING_COMMAND_ADDR      GCODE_COMMAND_ADDR
130
+#define OTHERS_COMMAND_ADDR_1           AUTO_LEVELING_COMMAND_ADDR + 100
131
+#define OTHERS_COMMAND_ADDR_2           OTHERS_COMMAND_ADDR_1 + 100
132
+#define OTHERS_COMMAND_ADDR_3           OTHERS_COMMAND_ADDR_2 + 100
133
+#define OTHERS_COMMAND_ADDR_4           OTHERS_COMMAND_ADDR_3 + 100
125 134
 
126 135
 #ifdef __cplusplus
127 136
   extern "C" { /* C-declarations for C++ */

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

@@ -53,6 +53,11 @@ void printer_state_polling() {
53 53
         planner.synchronize();
54 54
 
55 55
         gcode.process_subcommands_now_P(PSTR("M25"));
56
+
57
+        //save the positon
58
+        uiCfg.current_x_position_bak = current_position.x;
59
+        uiCfg.current_y_position_bak = current_position.y;
60
+
56 61
         if (gCfgItems.pausePosZ != (float)-1) {
57 62
           gcode.process_subcommands_now_P(PSTR("G91"));
58 63
           ZERO(public_buf_l);
@@ -66,6 +71,7 @@ void printer_state_polling() {
66 71
           gcode.process_subcommands_now(public_buf_l);
67 72
         }
68 73
         uiCfg.print_state = PAUSED;
74
+        uiCfg.current_e_position_bak = current_position.e;
69 75
 
70 76
         // #if ENABLED(POWER_LOSS_RECOVERY)
71 77
         //  if (recovery.enabled) recovery.save(true);
@@ -83,7 +89,19 @@ void printer_state_polling() {
83 89
 
84 90
   if (uiCfg.print_state == RESUMING) {
85 91
     if (IS_SD_PAUSED()) {
86
-      gcode.process_subcommands_now_P(PSTR("M24\nG91\nG1 Z-5\nG90"));
92
+      if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) {
93
+        ZERO(public_buf_m);
94
+        sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak);
95
+        gcode.process_subcommands_now(public_buf_m);
96
+      }
97
+      if (gCfgItems.pausePosZ != (float)-1) {
98
+        gcode.process_subcommands_now_P(PSTR("G91"));
99
+        ZERO(public_buf_l);
100
+        sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
101
+        gcode.process_subcommands_now(public_buf_l);
102
+        gcode.process_subcommands_now_P(PSTR("G90"));
103
+      }
104
+      gcode.process_subcommands_now_P(PSTR("M24"));
87 105
       uiCfg.print_state = WORKING;
88 106
       start_print_time();
89 107
 
@@ -108,11 +126,25 @@ void printer_state_polling() {
108 126
         }
109 127
       #endif
110 128
 
111
-      if (gCfgItems.pause_reprint == 1) {
112
-        gcode.process_subcommands_now_P(PSTR("G91\nG1 Z-5\nG90"));
113
-      }
114 129
       recovery.resume();
115
-
130
+      #if 0
131
+        // Move back to the saved XY
132
+        char str_1[16], str_2[16];
133
+        ZERO(public_buf_m);
134
+        sprintf_P(public_buf_m, PSTR("G1 X%s Y%s F2000"),
135
+          dtostrf(recovery.info.current_position.x, 1, 3, str_1),
136
+          dtostrf(recovery.info.current_position.y, 1, 3, str_2)
137
+        );
138
+        gcode.process_subcommands_now(public_buf_m);
139
+
140
+        if ((gCfgItems.pause_reprint) == 1 && (gCfgItems.pausePosZ != (float)-1)) {
141
+          gcode.process_subcommands_now_P(PSTR("G91"));
142
+          ZERO(public_buf_l);
143
+          sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
144
+          gcode.process_subcommands_now(public_buf_l);
145
+          gcode.process_subcommands_now_P(PSTR("G90"));
146
+        }
147
+      #endif
116 148
       uiCfg.print_state = WORKING;
117 149
       start_print_time();
118 150
 
@@ -123,6 +155,8 @@ void printer_state_polling() {
123 155
 
124 156
   if (uiCfg.print_state == WORKING)
125 157
     filament_check();
158
+
159
+  TERN_(USE_WIFI_FUNCTION, wifi_looping());
126 160
 }
127 161
 
128 162
 void filament_pin_setup() {

+ 36
- 18
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_en.h View File

@@ -46,8 +46,8 @@
46 46
 
47 47
 #define MACHINE_PARA_TITLE_EN       "Config"
48 48
 #define MACHINE_TYPE_CNOFIG_EN      "Machine settings"
49
-#define TEMPERATURE_CONFIG_EN       "Temperature settings"
50 49
 #define MOTOR_CONFIG_EN             "Motor settings"
50
+#define MACHINE_LEVELING_CONFIG_EN  "Leveling settings"
51 51
 #define ADVANCE_CONFIG_EN           "Adavance settings"
52 52
 
53 53
 #define MACHINE_CONFIG_TITLE_EN     "Machine Settings"
@@ -56,7 +56,6 @@
56 56
 #define MACHINE_HOMEDIR_EN          "Home direction"
57 57
 #define MACHINE_ENDSTOP_TYPE_EN     "Endstop type"
58 58
 #define MACHINE_FILAMENT_CONFIG_EN  "Filament settings"
59
-#define MACHINE_LEVELING_CONFIG_EN  "Leveling settings"
60 59
 
61 60
 #define MACHINE_TYPE_CONFIG_TITLE_EN    "Machine Settings>Machine type"
62 61
 #define MACHINE_TYPE_XYZ_EN             "XYZ Machine"
@@ -91,18 +90,18 @@
91 90
 #define ENDSTOP_OPENED_EN               "Open"
92 91
 #define ENDSTOP_CLOSED_EN               "Close"
93 92
 
94
-#define FILAMENT_CONF_TITLE_EN          "Filament settings"
95
-#define FILAMENT_IN_TEMPERATURE_EN      "Load temperature"
93
+#define FILAMENT_CONF_TITLE_EN          "Machine Settings>Filament settings"
96 94
 #define FILAMENT_IN_LENGTH_EN           "Load length"
97 95
 #define FILAMENT_IN_SPEED_EN            "Load speed"
98
-#define FILAMENT_OUT_TEMPERATURE_EN     "Unload temperature"
96
+#define FILAMENT_TEMPERATURE_EN         "Filament temperature"
99 97
 #define FILAMENT_OUT_LENGTH_EN          "Unload length"
100 98
 #define FILAMENT_OUT_SPEED_EN           "Unload speed"
101 99
 
102
-#define LEVELING_CONF_TITLE_EN          "Leveling settings"
100
+#define LEVELING_CONF_TITLE_EN          "Machine Settings>Leveling settings"
103 101
 #define LEVELING_PARA_CONF_EN           "Leveling settings"
104
-#define LEVELING_DELTA_EN               "delta machine leveling"
105
-#define LEVELING_XYZ_EN                 "Manual leveling coordinate settings"
102
+#define LEVELING_MANUAL_POS_EN          "Manual leveling coordinate settings"
103
+#define LEVELING_AUTO_COMMAND_EN        "AutoLeveling command settings"
104
+#define LEVELING_AUTO_ZOFFSET_EN        "Nozzle-to-probe offsets settings"
106 105
 
107 106
 #define LEVELING_PARA_CONF_TITLE_EN     "leveling setting"
108 107
 #define AUTO_LEVELING_ENABLE_EN         "Enable auto leveling"
@@ -226,6 +225,9 @@
226 225
 #define HAVE_UPS_EN                     "Has UPS power supply"
227 226
 #define Z2_AND_Z2ENDSTOP_CONF_EN        "Z2 Settings"
228 227
 #define ENABLE_PINS_CONF_EN             "Enable pins level settings"
228
+#define WIFI_SETTINGS_EN                "Wi-Fi parameter settings"
229
+#define HOMING_SENSITIVITY_CONF_EN      "Homing sensitivity settings"
230
+#define ENCODER_SETTINGS_EN             "Rotary encoder settings"
229 231
 
230 232
 #define Z2_AND_Z2ENDSTOP_CONF_TITLE_EN  "Z2 Settings"
231 233
 #define Z2_ENABLE_EN                    "Z2 Enable"
@@ -243,6 +245,29 @@
243 245
 #define PAUSE_POSITION_Y_EN  "Y axis position (Absolute position,-1 invalid)"
244 246
 #define PAUSE_POSITION_Z_EN  "Z axis position (Relative position,-1 invalid)"
245 247
 
248
+#define WIFI_SETTINGS_TITLE_EN    "Machine Settings>Wi-Fi Parameter"
249
+#define WIFI_SETTINGS_MODE_EN     "Wi-Fi Mode"
250
+#define WIFI_SETTINGS_NAME_EN     "Wi-Fi Name: "
251
+#define WIFI_SETTINGS_PASSWORD_EN "Wi-Fi Password: "
252
+#define WIFI_SETTINGS_CLOUD_EN    "Do you use cloud services?"
253
+#define WIFI_SETTINGS_CONFIG_EN   "Config"
254
+#define WIFI_SETTINGS_EDIT_EN     "Edit"
255
+#define WIFI_CONFIG_TIPS_EN       "Wi-Fi configuration?"
256
+
257
+#define OFFSET_TITLE_EN  "Machine Settings>Offset"
258
+#define OFFSET_X_EN      "X offset"
259
+#define OFFSET_Y_EN      "Y offset"
260
+#define OFFSET_Z_EN      "Z offset"
261
+
262
+#define HOMING_SENSITIVITY_CONF_TITLE_EN      "Machine Settings>Sensitivity"
263
+#define X_SENSITIVITY_EN                      "X Axis Sensitivity"
264
+#define Y_SENSITIVITY_EN                      "Y Axis Sensitivity"
265
+#define Z_SENSITIVITY_EN                      "Z Axis Sensitivity"
266
+#define Z2_SENSITIVITY_EN                     "Z2 Axis Sensitivity"
267
+
268
+#define ENCODER_CONF_TITLE_EN                 "Machine Settings>Rotary encoder settings"
269
+#define ENCODER_CONF_TEXT_EN                  "Is the encoder function used?"
270
+
246 271
 #define TOOL_TEXT_EN            "Tool"
247 272
 #define PREHEAT_TEXT_EN         "Preheat"
248 273
 #define MOVE_TEXT_EN            "Move"
@@ -429,10 +454,6 @@
429 454
 #define STEP_5PERCENT_EN                    "5%"
430 455
 #define STEP_10PERCENT_EN                   "10%"
431 456
 
432
-#define ZOFFSET_EN                          "Z Offset"
433
-#define ZOFFSET_INC_EN                      "Add"
434
-#define ZOFFSET_DEC_EN                      "Dec"
435
-
436 457
 #define TITLE_READYPRINT_EN                 "ReadyPrint"
437 458
 #define TITLE_PREHEAT_EN                    "Preheat"
438 459
 #define TITLE_MOVE_EN                       "Move"
@@ -455,7 +476,6 @@
455 476
 #define TITLE_CLOUD_TEXT_EN                 "Cloud"
456 477
 #define TITLE_DIALOG_CONFIRM_EN             "Confirm"
457 478
 #define TITLE_FILESYS_EN                    "FileSys"
458
-#define TITLE_ZOFFSET_EN                    "Z Offset"
459 479
 
460 480
 #define AUTO_SHUTDOWN_EN                    "Auto"
461 481
 #define MANUAL_SHUTDOWN_EN                  "Manual"
@@ -494,11 +514,9 @@
494 514
 #define TEXT_WIFI_SYMBOL_EN     "#+="
495 515
 #define TEXT_WIFI_PASSWORD_EN   "Password"
496 516
 
497
-#define TEXT_WIFI_POINT_BOLD_EN "`"
498
-
499
-#define TEXT_WIFI_JOINING_EN        "Joining\nNetwork..."
500
-#define TEXT_WIFI_FAILED_JOIN_EN    "Failed to\nJoin Wi-Fi"
501
-#define TEXT_WIFI_WIFI_CONECTED_EN  "Wi-Fi\nConnected"
517
+#define TEXT_WIFI_JOINING_EN  "Joining Network..."
518
+#define TEXT_WIFI_FAILED_JOIN_EN  "Failed to Join Wi-Fi"
519
+#define TEXT_WIFI_WIFI_CONECTED_EN "Wi-Fi Connected"
502 520
 
503 521
 #define TEXT_BUTTON_DISCONECTED_EN  "Disconnect"
504 522
 #define TEXT_WIFI_FORGET_EN         "Forget Network"

+ 0
- 5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_fr.h View File

@@ -208,10 +208,6 @@
208 208
 #define STEP_5PERCENT_FR              "5%"
209 209
 #define STEP_10PERCENT_FR             "10%"
210 210
 
211
-#define ZOFFSET_FR                    "Z Offset"
212
-#define ZOFFSET_INC_FR                "Ajouter"
213
-#define ZOFFSET_DEC_FR                "Réduire"
214
-
215 211
 #define TITLE_READYPRINT_FR           "Prête"
216 212
 #define TITLE_PREHEAT_FR              "Préchauffe"
217 213
 #define TITLE_MOVE_FR                 "Déplace"
@@ -234,7 +230,6 @@
234 230
 #define TITLE_CLOUD_TEXT_FR           "Cloud"
235 231
 #define TITLE_DIALOG_CONFIRM_FR       "Confirm"
236 232
 #define TITLE_FILESYS_FR              "FileSys"
237
-#define TITLE_ZOFFSET_FR              "Z Offset"
238 233
 
239 234
 #define DIALOG_CLOSE_MACHINE_FR       "Closing machine......"
240 235
 

+ 0
- 5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_it.h View File

@@ -205,10 +205,6 @@
205 205
 #define STEP_5PERCENT_IT                  "5%"
206 206
 #define STEP_10PERCENT_IT                 "10%"
207 207
 
208
-#define ZOFFSET_IT                        "Z Offset"
209
-#define ZOFFSET_INC_IT                    "Add"
210
-#define ZOFFSET_DEC_IT                    "Dec"
211
-
212 208
 #define TITLE_READYPRINT_IT               "Pronto"
213 209
 #define TITLE_PREHEAT_IT                  "Preris"
214 210
 #define TITLE_MOVE_IT                     "Muovi"
@@ -231,7 +227,6 @@
231 227
 #define TITLE_CLOUD_TEXT_IT               "Cloud"
232 228
 #define TITLE_DIALOG_CONFIRM_IT           "Confirm"
233 229
 #define TITLE_FILESYS_IT                  "FileSys"
234
-#define TITLE_ZOFFSET_IT                  "Z Offset"
235 230
 
236 231
 #define AUTO_SHUTDOWN_IT                  "Auto"
237 232
 #define MANUAL_SHUTDOWN_IT                "Manuale"

+ 0
- 5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_ru.h View File

@@ -205,10 +205,6 @@
205 205
 #define STEP_5PERCENT_RU                    "5%"
206 206
 #define STEP_10PERCENT_RU                   "10%"
207 207
 
208
-#define ZOFFSET_RU                          "Z Offset"
209
-#define ZOFFSET_INC_RU                      "добавить"
210
-#define ZOFFSET_DEC_RU                      "уменьшить"
211
-
212 208
 #define TITLE_READYPRINT_RU                 "готов к"
213 209
 #define TITLE_PREHEAT_RU                    "движение"
214 210
 #define TITLE_MOVE_RU                       "движение"
@@ -232,7 +228,6 @@
232 228
 #define TITLE_CLOUD_TEXT_RU                 "Cloud"
233 229
 #define TITLE_DIALOG_CONFIRM_RU             "Confirm"
234 230
 #define TITLE_FILESYS_RU                    "FileSys"
235
-#define TITLE_ZOFFSET_RU                    "Z Offset"
236 231
 
237 232
 #define AUTO_SHUTDOWN_RU                    "авто-откл"
238 233
 #define MANUAL_SHUTDOWN_RU                  "ручн-откл"

+ 36
- 16
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_s_cn.h View File

@@ -31,8 +31,8 @@
31 31
 
32 32
 #define MACHINE_PARA_TITLE_CN         "机器参数"
33 33
 #define MACHINE_TYPE_CNOFIG_CN        "机器设置"
34
-#define TEMPERATURE_CONFIG_CN         "温度设置"
35 34
 #define MOTOR_CONFIG_CN               "电机设置"
35
+#define MACHINE_LEVELING_CONFIG_CN    "调平设置"
36 36
 #define ADVANCE_CONFIG_CN             "高级设置"
37 37
 
38 38
 #define MACHINE_CONFIG_TITLE_CN       "机器参数>机器配置"
@@ -41,7 +41,6 @@
41 41
 #define MACHINE_HOMEDIR_CN            "归零方向"
42 42
 #define MACHINE_ENDSTOP_TYPE_CN       "限位开关类型"
43 43
 #define MACHINE_FILAMENT_CONFIG_CN    "换料设置"
44
-#define MACHINE_LEVELING_CONFIG_CN    "调平设置"
45 44
 
46 45
 #define MACHINE_TYPE_CONFIG_TITLE_CN  "机器参数>机型选择"
47 46
 #define MACHINE_TYPE_XYZ_CN           "XYZ机型"
@@ -77,17 +76,17 @@
77 76
 #define ENDSTOP_CLOSED_CN             "常闭"
78 77
 
79 78
 #define FILAMENT_CONF_TITLE_CN        "换料设置"
80
-#define FILAMENT_IN_TEMPERATURE_CN    "进料温度"
81 79
 #define FILAMENT_IN_LENGTH_CN         "进料长度"
82 80
 #define FILAMENT_IN_SPEED_CN          "进料速度"
83
-#define FILAMENT_OUT_TEMPERATURE_CN   "退料温度"
81
+#define FILAMENT_TEMPERATURE_CN       "换料温度"
84 82
 #define FILAMENT_OUT_LENGTH_CN        "退料长度"
85 83
 #define FILAMENT_OUT_SPEED_CN         "退料速度"
86 84
 
87
-#define LEVELING_CONF_TITLE_CN        "调平设置"
85
+#define LEVELING_CONF_TITLE_CN        "机器参数>调平设置"
88 86
 #define LEVELING_PARA_CONF_CN         "调平设置"
89
-#define LEVELING_DELTA_CN             "delta机型设置"
90
-#define LEVELING_XYZ_CN               "手动调平坐标设置"
87
+#define LEVELING_MANUAL_POS_CN        "手动调平坐标设置"
88
+#define LEVELING_AUTO_COMMAND_CN      "自动调平指令设置"
89
+#define LEVELING_AUTO_ZOFFSET_CN      "挤出头与调平开关偏移设置"
91 90
 
92 91
 #define LEVELING_PARA_CONF_TITLE_CN   "调平参数"
93 92
 #define AUTO_LEVELING_ENABLE_CN       "自动调平"
@@ -146,6 +145,7 @@
146 145
 #define TMC_STEP_MODE_CN              "TMC 驱动模式设置"
147 146
 #define MOTORDIRCONF_CN               "电机方向设置"
148 147
 #define HOMEFEEDRATECONF_CN           "归零速度设置"
148
+#define HOMING_SENSITIVITY_CONF_CN    "无限位回零灵敏度调节"
149 149
 
150 150
 #define MAXFEEDRATE_CONF_TITLE_CN     "机器参数>最大速度"
151 151
 #define X_MAXFEEDRATE_CN              "X轴最大速度"
@@ -211,6 +211,8 @@
211 211
 #define HAVE_UPS_CN                     "机器配备UPS电源"
212 212
 #define Z2_AND_Z2ENDSTOP_CONF_CN        "双Z轴双限位功能设置"
213 213
 #define ENABLE_PINS_CONF_CN             "电机使能脚电平设置"
214
+#define WIFI_SETTINGS_CN                "Wi-Fi参数设置"
215
+#define ENCODER_SETTINGS_CN             "旋钮设置"
214 216
 
215 217
 #define Z2_AND_Z2ENDSTOP_CONF_TITLE_CN  "双z双限位设置"
216 218
 #define Z2_ENABLE_CN                    "启用Z2轴"
@@ -223,10 +225,33 @@
223 225
 #define Z_ENABLE_PINS_INVERT_CN         "Z轴电机使能电平"
224 226
 #define E_ENABLE_PINS_INVERT_CN         "E轴电机使能电平"
225 227
 
226
-#define PAUSE_POSITION_CN    "打印暂停位置设置"
227
-#define PAUSE_POSITION_X_CN  "X轴暂停位置(绝对位置,-1无效)"
228
-#define PAUSE_POSITION_Y_CN  "Y轴暂停位置(绝对位置,-1无效)"
229
-#define PAUSE_POSITION_Z_CN  "Z轴暂停位置(相对位置,-1无效)"
228
+#define PAUSE_POSITION_CN         "打印暂停位置设置"
229
+#define PAUSE_POSITION_X_CN       "X轴暂停位置(绝对位置,-1无效)"
230
+#define PAUSE_POSITION_Y_CN       "Y轴暂停位置(绝对位置,-1无效)"
231
+#define PAUSE_POSITION_Z_CN       "Z轴暂停位置(相对位置,-1无效)"
232
+#define WIFI_SETTINGS_TITLE_CN    "机器参数>Wi-Fi设置"
233
+#define WIFI_SETTINGS_MODE_CN     "Wi-Fi 模式"
234
+#define WIFI_SETTINGS_NAME_CN     "Wi-Fi 名称: "
235
+#define WIFI_SETTINGS_PASSWORD_CN "Wi-Fi 密码: "
236
+#define WIFI_SETTINGS_CLOUD_CN    "是否使用云服务?"
237
+#define WIFI_SETTINGS_CONFIG_CN   "配置"
238
+#define WIFI_SETTINGS_EDIT_CN     "编辑"
239
+#define WIFI_CONFIG_TIPS_CN       "进行Wi-Fi配置?"
240
+
241
+#define OFFSET_TITLE_CN  "机器参数>偏移设置"
242
+#define OFFSET_X_CN      "X轴与调平开关偏移"
243
+#define OFFSET_Y_CN      "Y轴与调平开关偏移"
244
+#define OFFSET_Z_CN      "Z轴与调平开关偏移"
245
+
246
+#define HOMING_SENSITIVITY_CONF_TITLE_CN      "机器参数>灵敏度调节"
247
+#define X_SENSITIVITY_CN                      "X轴灵敏度"
248
+#define Y_SENSITIVITY_CN                      "Y轴灵敏度"
249
+#define Z_SENSITIVITY_CN                      "Z轴灵敏度"
250
+#define Z2_SENSITIVITY_CN                     "Z2轴灵敏度"
251
+
252
+#define ENCODER_CONF_TITLE_CN                 "机器参数>旋钮设置"
253
+#define ENCODER_CONF_TEXT_CN                  "是否使用旋钮功能?"
254
+
230 255
 #define TOOL_TEXT_CN                "工具"
231 256
 #define PREHEAT_TEXT_CN             "预热"
232 257
 #define MOVE_TEXT_CN                "移动"
@@ -395,10 +420,6 @@
395 420
 #define STEP_5PERCENT_CN            "5%"
396 421
 #define STEP_10PERCENT_CN           "10%"
397 422
 
398
-#define ZOFFSET_CN                  "Z Offset"
399
-#define ZOFFSET_INC_CN              "增加"
400
-#define ZOFFSET_DEC_CN              "减少"
401
-
402 423
 #define TITLE_READYPRINT_CN         "准备打印"
403 424
 #define TITLE_PREHEAT_CN            "预热"
404 425
 #define TITLE_MOVE_CN               "移动"
@@ -421,7 +442,6 @@
421 442
 #define TITLE_CLOUD_TEXT_CN         "云服务"
422 443
 #define TITLE_DIALOG_CONFIRM_CN     "确认"
423 444
 #define TITLE_FILESYS_CN            "文件系统"
424
-#define TITLE_ZOFFSET_CN            "Z Offset"
425 445
 
426 446
 #define AUTO_SHUTDOWN_CN            "自动关机"
427 447
 #define MANUAL_SHUTDOWN_CN          "手动关机"

+ 0
- 5
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_sp.h View File

@@ -206,10 +206,6 @@
206 206
 #define STEP_5PERCENT_SP            "5%"
207 207
 #define STEP_10PERCENT_SP           "10%"
208 208
 
209
-#define ZOFFSET_SP                  "Z Offset"
210
-#define ZOFFSET_INC_SP              "Más"
211
-#define ZOFFSET_DEC_SP              "Menos"
212
-
213 209
 #define TITLE_READYPRINT_SP         "Inicio"
214 210
 #define TITLE_PREHEAT_SP            "Precalentar"
215 211
 #define TITLE_MOVE_SP               "Mover"
@@ -233,7 +229,6 @@
233 229
 #define TITLE_CLOUD_TEXT_SP         "Cloud"
234 230
 #define TITLE_DIALOG_CONFIRM_SP     "Confirmar"
235 231
 #define TITLE_FILESYS_SP            "Puerto"
236
-#define TITLE_ZOFFSET_SP            "Z Offset"
237 232
 
238 233
 #define AUTO_SHUTDOWN_SP            "Auto"
239 234
 #define MANUAL_SHUTDOWN_SP          "manual"

+ 35
- 16
Marlin/src/lcd/extui/lib/mks_ui/tft_Language_t_cn.h View File

@@ -31,8 +31,8 @@
31 31
 
32 32
 #define MACHINE_PARA_TITLE_T_CN         "機器參數"
33 33
 #define MACHINE_TYPE_CNOFIG_T_CN        "機器設置"
34
-#define TEMPERATURE_CONFIG_T_CN         "溫度設置"
35 34
 #define MOTOR_CONFIG_T_CN               "電機設置"
35
+#define MACHINE_LEVELING_CONFIG_T_CN    "調平設置"
36 36
 #define ADVANCE_CONFIG_T_CN             "高級設置"
37 37
 
38 38
 #define MACHINE_CONFIG_TITLE_T_CN       "機器參數>機器配置"
@@ -41,7 +41,6 @@
41 41
 #define MACHINE_HOMEDIR_T_CN            "歸零方向"
42 42
 #define MACHINE_ENDSTOP_TYPE_T_CN       "限位開關類型"
43 43
 #define MACHINE_FILAMENT_CONFIG_T_CN    "換料設置"
44
-#define MACHINE_LEVELING_CONFIG_T_CN    "調平設置"
45 44
 
46 45
 #define MACHINE_TYPE_CONFIG_TITLE_T_CN  "機器參數>機型選擇"
47 46
 #define MACHINE_TYPE_XYZ_T_CN           "XYZ機型"
@@ -77,17 +76,17 @@
77 76
 #define ENDSTOP_CLOSED_T_CN             "常閉"
78 77
 
79 78
 #define FILAMENT_CONF_TITLE_T_CN        "換料設置"
80
-#define FILAMENT_IN_TEMPERATURE_T_CN    "進料溫度"
81 79
 #define FILAMENT_IN_LENGTH_T_CN         "進料長度"
82 80
 #define FILAMENT_IN_SPEED_T_CN          "進料速度"
83
-#define FILAMENT_OUT_TEMPERATURE_T_CN   "退料溫度"
81
+#define FILAMENT_TEMPERATURE_T_CN       "換料溫度"
84 82
 #define FILAMENT_OUT_LENGTH_T_CN        "退料長度"
85 83
 #define FILAMENT_OUT_SPEED_T_CN         "退料速度"
86 84
 
87
-#define LEVELING_CONF_TITLE_T_CN        "調平設置"
85
+#define LEVELING_CONF_TITLE_T_CN        "機器參數>調平設置"
88 86
 #define LEVELING_PARA_CONF_T_CN         "調平設置"
89
-#define LEVELING_DELTA_T_CN             "delta機型設置"
90
-#define LEVELING_XYZ_T_CN               "手動調平坐標設置"
87
+#define LEVELING_MANUAL_POS_T_CN        "手動調平坐標設置"
88
+#define LEVELING_AUTO_COMMAND_T_CN      "自動調平指令設置"
89
+#define LEVELING_AUTO_ZOFFSET_T_CN      "擠出頭與調平開關偏移設置"
91 90
 
92 91
 #define LEVELING_PARA_CONF_TITLE_T_CN   "調平參數"
93 92
 #define AUTO_LEVELING_ENABLE_T_CN       "自動調平"
@@ -146,6 +145,7 @@
146 145
 #define TMC_STEP_MODE_T_CN              "TMC 驅動模式設置"
147 146
 #define MOTORDIRCONF_T_CN               "電機方向設置"
148 147
 #define HOMEFEEDRATECONF_T_CN           "歸零速度設置"
148
+#define HOMING_SENSITIVITY_CONF_T_CN    "無限位回零靈敏度調節"
149 149
 
150 150
 #define MAXFEEDRATE_CONF_TITLE_T_CN     "機器參數>最大速度"
151 151
 #define X_MAXFEEDRATE_T_CN              "X軸最大速度"
@@ -211,6 +211,8 @@
211 211
 #define HAVE_UPS_T_CN                   "機器配備UPS電壓"
212 212
 #define Z2_AND_Z2ENDSTOP_CONF_T_CN      "雙z軸雙限位功能設置"
213 213
 #define ENABLE_PINS_CONF_T_CN           "電機使能腳電平設置"
214
+#define WIFI_SETTINGS_T_CN              "Wi-Fi參數設置"
215
+#define ENCODER_SETTINGS_T_CN           "旋鈕設置"
214 216
 
215 217
 #define Z2_AND_Z2ENDSTOP_CONF_TITLE_T_CN  "雙z軸雙限位設置"
216 218
 #define Z2_ENABLE_T_CN                    "啟用Z2軸"
@@ -223,10 +225,32 @@
223 225
 #define Z_ENABLE_PINS_INVERT_T_CN       "Z軸電機使能電平"
224 226
 #define E_ENABLE_PINS_INVERT_T_CN       "E軸電機使能電平"
225 227
 
226
-#define PAUSE_POSITION_T_CN             "打印暫停位置設置"
227
-#define PAUSE_POSITION_X_T_CN           "X軸暫停位置(絕對位置,-1無效)"
228
-#define PAUSE_POSITION_Y_T_CN           "Y軸暫停位置(絕對位置,-1無效)"
229
-#define PAUSE_POSITION_Z_T_CN           "Z軸暫停位置(相對位置,-1無效)"
228
+#define PAUSE_POSITION_T_CN         "打印暫停位置設置"
229
+#define PAUSE_POSITION_X_T_CN       "X軸暫停位置(絕對位置,-1無效)"
230
+#define PAUSE_POSITION_Y_T_CN       "Y軸暫停位置(絕對位置,-1無效)"
231
+#define PAUSE_POSITION_Z_T_CN       "Z軸暫停位置(相對位置,-1無效)"
232
+#define WIFI_SETTINGS_TITLE_T_CN    "機器參數>Wi-Fi設置"
233
+#define WIFI_SETTINGS_MODE_T_CN     "Wi-Fi 模式"
234
+#define WIFI_SETTINGS_NAME_T_CN     "Wi-Fi 名稱: "
235
+#define WIFI_SETTINGS_PASSWORD_T_CN "Wi-Fi 密碼: "
236
+#define WIFI_SETTINGS_CLOUD_T_CN    "是否使用雲服務?"
237
+#define WIFI_SETTINGS_CONFIG_T_CN   "配置"
238
+#define WIFI_SETTINGS_EDIT_T_CN     "編輯"
239
+#define WIFI_CONFIG_TIPS_T_CN       "進行Wi-Fi配置?"
240
+
241
+#define OFFSET_TITLE_T_CN               "機器參數>偏移設置"
242
+#define OFFSET_X_T_CN                   "X軸與調平開關偏移"
243
+#define OFFSET_Y_T_CN                   "Y軸與調平開關偏移"
244
+#define OFFSET_Z_T_CN                   "Z軸與調平開關偏移"
245
+
246
+#define HOMING_SENSITIVITY_CONF_TITLE_T_CN      "機器參數>靈敏度調節"
247
+#define X_SENSITIVITY_T_CN                      "X軸靈敏度"
248
+#define Y_SENSITIVITY_T_CN                      "Y軸靈敏度"
249
+#define Z_SENSITIVITY_T_CN                      "Z軸靈敏度"
250
+#define Z2_SENSITIVITY_T_CN                     "Z2軸靈敏度"
251
+
252
+#define ENCODER_CONF_TITLE_T_CN                 "機器參數>旋鈕設置"
253
+#define ENCODER_CONF_TEXT_T_CN                  "是否使用旋鈕功能?"
230 254
 
231 255
 #define TOOL_TEXT_T_CN                  "工具"
232 256
 #define PREHEAT_TEXT_T_CN               "預熱"
@@ -398,10 +422,6 @@
398 422
 #define STEP_5PERCENT_T_CN            "5%%"
399 423
 #define STEP_10PERCENT_T_CN           "10%%"
400 424
 
401
-#define ZOFFSET_T_CN                  "Z Offset"
402
-#define ZOFFSET_INC_T_CN              "增加"
403
-#define ZOFFSET_DEC_T_CN              "減少"
404
-
405 425
 #define TITLE_READYPRINT_T_CN         "準備打印"
406 426
 #define TITLE_PREHEAT_T_CN            "預熱"
407 427
 #define TITLE_MOVE_T_CN               "移動"
@@ -424,7 +444,6 @@
424 444
 #define TITLE_CLOUD_TEXT_T_CN         "雲服務"
425 445
 #define TITLE_DIALOG_CONFIRM_T_CN     "確認"
426 446
 #define TITLE_FILESYS_T_CN            "文件系統"
427
-#define TITLE_ZOFFSET_T_CN            "Z Offset"
428 447
 
429 448
 #define AUTO_SHUTDOWN_T_CN            "自動關機"
430 449
 #define MANUAL_SHUTDOWN_T_CN          "手動關機"

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


+ 35
- 16
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.h View File

@@ -22,25 +22,44 @@
22 22
 #pragma once
23 23
 
24 24
 /**
25
- * @file tft_lvgl_configuration.h
26
- * @date    2020-02-21
27
- * */
25
+ * @file lcd/extui/lib/mks_ui/tft_lvgl_configuration.h
26
+ * @date 2020-02-21
27
+ */
28 28
 
29
-//#ifdef __cplusplus
30
-//extern "C" {
31
-//#endif
29
+#ifdef __cplusplus
30
+  extern "C" { /* C-declarations for C++ */
31
+#endif
32 32
 
33 33
 #include <lvgl.h>
34 34
 
35
-void tft_lvgl_init();
36
-void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
37
-bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
35
+//#define GRAPHICAL_TFT_ROTATE_180
36
+#define USE_WIFI_FUNCTION 0
37
+
38
+extern void tft_lvgl_init();
39
+extern void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
40
+extern bool my_touchpad_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data);
41
+extern bool my_mousewheel_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data);
42
+
43
+extern void LCD_Clear(uint16_t Color);
44
+extern void tft_set_point(uint16_t x, uint16_t y, uint16_t point);
45
+extern void LCD_setWindowArea(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh);
46
+extern void LCD_WriteRAM_Prepare(void);
47
+extern void lcd_draw_logo();
48
+extern void lv_encoder_pin_init();
49
+extern void lv_update_encoder();
50
+
51
+extern lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode);
52
+extern lv_fs_res_t spi_flash_close_cb (lv_fs_drv_t * drv, void * file_p);
53
+extern lv_fs_res_t spi_flash_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
54
+extern lv_fs_res_t spi_flash_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
55
+extern lv_fs_res_t spi_flash_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
38 56
 
39
-void LCD_Clear(uint16_t Color);
40
-void tft_set_point(uint16_t x, uint16_t y, uint16_t point);
41
-void ili9320_SetWindows(uint16_t StartX, uint16_t StartY, uint16_t width, uint16_t heigh);
42
-void LCD_WriteRAM_Prepare(void);
57
+extern lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode);
58
+extern lv_fs_res_t sd_close_cb (lv_fs_drv_t * drv, void * file_p);
59
+extern lv_fs_res_t sd_read_cb (lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
60
+extern lv_fs_res_t sd_seek_cb(lv_fs_drv_t * drv, void * file_p, uint32_t pos);
61
+extern lv_fs_res_t sd_tell_cb(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
43 62
 
44
-//#ifdef __cplusplus
45
-//} /* extern "C" */
46
-//#endif
63
+#ifdef __cplusplus
64
+  } /* C-declarations for C++ */
65
+#endif

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

@@ -54,11 +54,8 @@ dialog_menu_def              dialog_menu;
54 54
 language_menu_def            language_menu;
55 55
 print_file_dialog_menu_def   print_file_dialog_menu;
56 56
 filesys_menu_def             filesys_menu;
57
-zoffset_menu_def             zoffset_menu;
58 57
 tool_menu_def                tool_menu;
59 58
 MachinePara_menu_def         MachinePara_menu;
60
-MachineSettings_menu_def     MachineSettings_menu;
61
-TemperatureSettings_menu_def TemperatureSettings_menu;
62 59
 pause_msg_def                pause_msg_menu;
63 60
 eeprom_def                   eeprom_menu;
64 61
 
@@ -67,8 +64,8 @@ void machine_setting_disp() {
67 64
   if (gCfgItems.language == LANG_SIMPLE_CHINESE) {
68 65
     MachinePara_menu.title              = MACHINE_PARA_TITLE_CN;
69 66
     MachinePara_menu.MachineSetting     = MACHINE_TYPE_CNOFIG_CN;
70
-    MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_CN;
71 67
     MachinePara_menu.MotorSetting       = MOTOR_CONFIG_CN;
68
+    MachinePara_menu.leveling           = MACHINE_LEVELING_CONFIG_CN;
72 69
     MachinePara_menu.AdvanceSetting     = ADVANCE_CONFIG_CN;
73 70
 
74 71
     machine_menu.default_value = DEFAULT_CN;
@@ -81,7 +78,6 @@ void machine_setting_disp() {
81 78
     machine_menu.HomeDir            = MACHINE_HOMEDIR_CN;
82 79
     machine_menu.EndStopType        = MACHINE_ENDSTOP_TYPE_CN;
83 80
     machine_menu.FilamentConf       = MACHINE_FILAMENT_CONFIG_CN;
84
-    machine_menu.LevelingConf       = MACHINE_LEVELING_CONFIG_CN;
85 81
 
86 82
     machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_CN;
87 83
     machine_menu.xyz                  = MACHINE_TYPE_XYZ_CN;
@@ -116,18 +112,18 @@ void machine_setting_disp() {
116 112
     machine_menu.opened           = ENDSTOP_OPENED_CN;
117 113
     machine_menu.closed           = ENDSTOP_CLOSED_CN;
118 114
 
119
-    machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_CN;
120
-    machine_menu.InTemperature     = FILAMENT_IN_TEMPERATURE_CN;
121
-    machine_menu.InLength          = FILAMENT_IN_LENGTH_CN;
122
-    machine_menu.InSpeed           = FILAMENT_IN_SPEED_CN;
123
-    machine_menu.OutTemperature    = FILAMENT_OUT_TEMPERATURE_CN;
124
-    machine_menu.OutLength         = FILAMENT_OUT_LENGTH_CN;
125
-    machine_menu.OutSpeed          = FILAMENT_OUT_SPEED_CN;
115
+    machine_menu.FilamentConfTitle   = FILAMENT_CONF_TITLE_CN;
116
+    machine_menu.InLength            = FILAMENT_IN_LENGTH_CN;
117
+    machine_menu.InSpeed             = FILAMENT_IN_SPEED_CN;
118
+    machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_CN;
119
+    machine_menu.OutLength           = FILAMENT_OUT_LENGTH_CN;
120
+    machine_menu.OutSpeed            = FILAMENT_OUT_SPEED_CN;
126 121
 
127
-    machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_CN;
128
-    machine_menu.LevelingParaConf      = LEVELING_PARA_CONF_CN;
129
-    machine_menu.DeltaLevelConf        = LEVELING_DELTA_CN;
130
-    machine_menu.XYZLevelconf          = LEVELING_XYZ_CN;
122
+    machine_menu.LevelingParaConfTitle   = LEVELING_CONF_TITLE_CN;
123
+    machine_menu.LevelingParaConf        = LEVELING_PARA_CONF_CN;
124
+    machine_menu.LevelingManuPosConf     = LEVELING_MANUAL_POS_CN;
125
+    machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_CN;
126
+    machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_CN;
131 127
 
132 128
     machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_CN;
133 129
     machine_menu.AutoLevelEnable      = AUTO_LEVELING_ENABLE_CN;
@@ -177,16 +173,19 @@ void machine_setting_disp() {
177 173
     machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_CN;
178 174
     machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_CN;
179 175
 
180
-    machine_menu.MotorConfTitle   = MOTOR_CONF_TITLE_CN;
181
-    machine_menu.MaxFeedRateConf  = MAXFEEDRATE_CONF_CN;
182
-    machine_menu.AccelerationConf = ACCELERATION_CONF_CN;
183
-    machine_menu.JerkConf         = JERKCONF_CN;
184
-    machine_menu.StepsConf        = STEPSCONF_CN;
185
-    machine_menu.TMCcurrentConf   = TMC_CURRENT_CN;
186
-    machine_menu.TMCStepModeConf  = TMC_STEP_MODE_CN;
187
-    machine_menu.MotorDirConf     = MOTORDIRCONF_CN;
188
-    machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_CN;
189
-    machine_menu.PausePosition    = PAUSE_POSITION_CN;
176
+    machine_menu.MotorConfTitle        = MOTOR_CONF_TITLE_CN;
177
+    machine_menu.MaxFeedRateConf       = MAXFEEDRATE_CONF_CN;
178
+    machine_menu.AccelerationConf      = ACCELERATION_CONF_CN;
179
+    machine_menu.JerkConf              = JERKCONF_CN;
180
+    machine_menu.StepsConf             = STEPSCONF_CN;
181
+    machine_menu.TMCcurrentConf        = TMC_CURRENT_CN;
182
+    machine_menu.TMCStepModeConf       = TMC_STEP_MODE_CN;
183
+    machine_menu.MotorDirConf          = MOTORDIRCONF_CN;
184
+    machine_menu.HomeFeedRateConf      = HOMEFEEDRATECONF_CN;
185
+    machine_menu.PausePosition         = PAUSE_POSITION_CN;
186
+    machine_menu.WifiSettings          = WIFI_SETTINGS_CN;
187
+    machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_CN;
188
+    machine_menu.EncoderSettings         = ENCODER_SETTINGS_CN;
190 189
 
191 190
     machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_CN;
192 191
     machine_menu.XMaxFeedRate         = X_MAXFEEDRATE_CN;
@@ -268,16 +267,38 @@ void machine_setting_disp() {
268 267
     machine_menu.key_reset   = KEY_REST_CN;
269 268
     machine_menu.key_confirm = KEY_CONFIRM_CN;
270 269
 
271
-    machine_menu.PausePosText = PAUSE_POSITION_CN;
272
-    machine_menu.xPos         = PAUSE_POSITION_X_CN;
273
-    machine_menu.yPos         = PAUSE_POSITION_Y_CN;
274
-    machine_menu.zPos         = PAUSE_POSITION_Z_CN;
270
+    machine_menu.PausePosText   = PAUSE_POSITION_CN;
271
+    machine_menu.xPos           = PAUSE_POSITION_X_CN;
272
+    machine_menu.yPos           = PAUSE_POSITION_Y_CN;
273
+    machine_menu.zPos           = PAUSE_POSITION_Z_CN;
274
+    machine_menu.WifiConfTitle  = WIFI_SETTINGS_TITLE_CN;
275
+    machine_menu.wifiMode       = WIFI_SETTINGS_MODE_CN;
276
+    machine_menu.wifiName       = WIFI_SETTINGS_NAME_CN;
277
+    machine_menu.wifiPassWord   = WIFI_SETTINGS_PASSWORD_CN;
278
+    machine_menu.wifiCloud      = WIFI_SETTINGS_CLOUD_CN;
279
+    machine_menu.wifiConfig     = WIFI_SETTINGS_CONFIG_CN;
280
+    machine_menu.wifiEdit       = WIFI_SETTINGS_EDIT_CN;
281
+    machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_CN;
282
+
283
+    machine_menu.OffsetConfTitle = OFFSET_TITLE_CN;
284
+    machine_menu.Xoffset         = OFFSET_X_CN;
285
+    machine_menu.Yoffset         = OFFSET_Y_CN;
286
+    machine_menu.Zoffset         = OFFSET_Z_CN;
287
+
288
+    machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_CN;
289
+    machine_menu.X_Sensitivity              = X_SENSITIVITY_CN;
290
+    machine_menu.Y_Sensitivity              = Y_SENSITIVITY_CN;
291
+    machine_menu.Z_Sensitivity              = Z_SENSITIVITY_CN;
292
+    machine_menu.Z2_Sensitivity             = Z2_SENSITIVITY_CN;
293
+
294
+    machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_CN;
295
+    machine_menu.EncoderConfText              = ENCODER_CONF_TEXT_CN;
275 296
   }
276 297
   else if (gCfgItems.language == LANG_COMPLEX_CHINESE) {
277 298
     MachinePara_menu.title              = MACHINE_PARA_TITLE_T_CN;
278 299
     MachinePara_menu.MachineSetting     = MACHINE_TYPE_CNOFIG_T_CN;
279
-    MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_T_CN;
280 300
     MachinePara_menu.MotorSetting       = MOTOR_CONFIG_T_CN;
301
+    MachinePara_menu.leveling           = MACHINE_LEVELING_CONFIG_T_CN;
281 302
     MachinePara_menu.AdvanceSetting     = ADVANCE_CONFIG_T_CN;
282 303
 
283 304
     machine_menu.default_value = DEFAULT_T_CN;
@@ -290,7 +311,6 @@ void machine_setting_disp() {
290 311
     machine_menu.HomeDir            = MACHINE_HOMEDIR_T_CN;
291 312
     machine_menu.EndStopType        = MACHINE_ENDSTOP_TYPE_T_CN;
292 313
     machine_menu.FilamentConf       = MACHINE_FILAMENT_CONFIG_T_CN;
293
-    machine_menu.LevelingConf       = MACHINE_LEVELING_CONFIG_T_CN;
294 314
 
295 315
     machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_T_CN;
296 316
     machine_menu.xyz                  = MACHINE_TYPE_XYZ_T_CN;
@@ -325,18 +345,18 @@ void machine_setting_disp() {
325 345
     machine_menu.opened           = ENDSTOP_OPENED_T_CN;
326 346
     machine_menu.closed           = ENDSTOP_CLOSED_T_CN;
327 347
 
328
-    machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_T_CN;
329
-    machine_menu.InTemperature     = FILAMENT_IN_TEMPERATURE_T_CN;
330
-    machine_menu.InLength          = FILAMENT_IN_LENGTH_T_CN;
331
-    machine_menu.InSpeed           = FILAMENT_IN_SPEED_T_CN;
332
-    machine_menu.OutTemperature    = FILAMENT_OUT_TEMPERATURE_T_CN;
333
-    machine_menu.OutLength         = FILAMENT_OUT_LENGTH_T_CN;
334
-    machine_menu.OutSpeed          = FILAMENT_OUT_SPEED_T_CN;
348
+    machine_menu.FilamentConfTitle   = FILAMENT_CONF_TITLE_T_CN;
349
+    machine_menu.InLength            = FILAMENT_IN_LENGTH_T_CN;
350
+    machine_menu.InSpeed             = FILAMENT_IN_SPEED_T_CN;
351
+    machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_T_CN;
352
+    machine_menu.OutLength           = FILAMENT_OUT_LENGTH_T_CN;
353
+    machine_menu.OutSpeed            = FILAMENT_OUT_SPEED_T_CN;
335 354
 
336
-    machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_T_CN;
337
-    machine_menu.LevelingParaConf      = LEVELING_PARA_CONF_T_CN;
338
-    machine_menu.DeltaLevelConf        = LEVELING_DELTA_T_CN;
339
-    machine_menu.XYZLevelconf          = LEVELING_XYZ_T_CN;
355
+    machine_menu.LevelingParaConfTitle   = LEVELING_CONF_TITLE_T_CN;
356
+    machine_menu.LevelingParaConf        = LEVELING_PARA_CONF_T_CN;
357
+    machine_menu.LevelingManuPosConf     = LEVELING_MANUAL_POS_T_CN;
358
+    machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_T_CN;
359
+    machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_T_CN;
340 360
 
341 361
     machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_T_CN;
342 362
     machine_menu.AutoLevelEnable      = AUTO_LEVELING_ENABLE_T_CN;
@@ -386,16 +406,19 @@ void machine_setting_disp() {
386 406
     machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_T_CN;
387 407
     machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_T_CN;
388 408
 
389
-    machine_menu.MotorConfTitle   = MOTOR_CONF_TITLE_T_CN;
390
-    machine_menu.MaxFeedRateConf  = MAXFEEDRATE_CONF_T_CN;
391
-    machine_menu.AccelerationConf = ACCELERATION_CONF_T_CN;
392
-    machine_menu.JerkConf         = JERKCONF_T_CN;
393
-    machine_menu.StepsConf        = STEPSCONF_T_CN;
394
-    machine_menu.TMCcurrentConf   = TMC_CURRENT_T_CN;
395
-    machine_menu.TMCStepModeConf  = TMC_STEP_MODE_T_CN;
396
-    machine_menu.MotorDirConf     = MOTORDIRCONF_T_CN;
397
-    machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_T_CN;
398
-    machine_menu.PausePosition    = PAUSE_POSITION_T_CN;
409
+    machine_menu.MotorConfTitle        = MOTOR_CONF_TITLE_T_CN;
410
+    machine_menu.MaxFeedRateConf       = MAXFEEDRATE_CONF_T_CN;
411
+    machine_menu.AccelerationConf      = ACCELERATION_CONF_T_CN;
412
+    machine_menu.JerkConf              = JERKCONF_T_CN;
413
+    machine_menu.StepsConf             = STEPSCONF_T_CN;
414
+    machine_menu.TMCcurrentConf        = TMC_CURRENT_T_CN;
415
+    machine_menu.TMCStepModeConf       = TMC_STEP_MODE_T_CN;
416
+    machine_menu.MotorDirConf          = MOTORDIRCONF_T_CN;
417
+    machine_menu.HomeFeedRateConf      = HOMEFEEDRATECONF_T_CN;
418
+    machine_menu.PausePosition         = PAUSE_POSITION_T_CN;
419
+    machine_menu.WifiSettings          = WIFI_SETTINGS_T_CN;
420
+    machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_T_CN;
421
+    machine_menu.EncoderSettings         = ENCODER_SETTINGS_T_CN;
399 422
 
400 423
     machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_T_CN;
401 424
     machine_menu.XMaxFeedRate         = X_MAXFEEDRATE_T_CN;
@@ -484,12 +507,34 @@ void machine_setting_disp() {
484 507
     machine_menu.yPos         = PAUSE_POSITION_Y_T_CN;
485 508
     machine_menu.zPos         = PAUSE_POSITION_Z_T_CN;
486 509
 
510
+    machine_menu.WifiConfTitle  = WIFI_SETTINGS_TITLE_T_CN;
511
+    machine_menu.wifiMode       = WIFI_SETTINGS_MODE_T_CN;
512
+    machine_menu.wifiName       = WIFI_SETTINGS_NAME_T_CN;
513
+    machine_menu.wifiPassWord   = WIFI_SETTINGS_PASSWORD_T_CN;
514
+    machine_menu.wifiCloud      = WIFI_SETTINGS_CLOUD_T_CN;
515
+    machine_menu.wifiConfig     = WIFI_SETTINGS_CONFIG_T_CN;
516
+    machine_menu.wifiEdit       = WIFI_SETTINGS_EDIT_T_CN;
517
+    machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_T_CN;
518
+
519
+    machine_menu.OffsetConfTitle = OFFSET_TITLE_T_CN;
520
+    machine_menu.Xoffset         = OFFSET_X_T_CN;
521
+    machine_menu.Yoffset         = OFFSET_Y_T_CN;
522
+    machine_menu.Zoffset         = OFFSET_Z_T_CN;
523
+
524
+    machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_T_CN;
525
+    machine_menu.X_Sensitivity              = X_SENSITIVITY_T_CN;
526
+    machine_menu.Y_Sensitivity              = Y_SENSITIVITY_T_CN;
527
+    machine_menu.Z_Sensitivity              = Z_SENSITIVITY_T_CN;
528
+    machine_menu.Z2_Sensitivity             = Z2_SENSITIVITY_T_CN;
529
+
530
+    machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_T_CN;
531
+    machine_menu.EncoderConfText              = ENCODER_CONF_TEXT_T_CN;
487 532
   }
488 533
   else {
489 534
     MachinePara_menu.title              = MACHINE_PARA_TITLE_EN;
490 535
     MachinePara_menu.MachineSetting     = MACHINE_TYPE_CNOFIG_EN;
491
-    MachinePara_menu.TemperatureSetting = TEMPERATURE_CONFIG_EN;
492 536
     MachinePara_menu.MotorSetting       = MOTOR_CONFIG_EN;
537
+    MachinePara_menu.leveling           = MACHINE_LEVELING_CONFIG_EN;
493 538
     MachinePara_menu.AdvanceSetting     = ADVANCE_CONFIG_EN;
494 539
 
495 540
     machine_menu.default_value = DEFAULT_EN;
@@ -502,7 +547,6 @@ void machine_setting_disp() {
502 547
     machine_menu.HomeDir            = MACHINE_HOMEDIR_EN;
503 548
     machine_menu.EndStopType        = MACHINE_ENDSTOP_TYPE_EN;
504 549
     machine_menu.FilamentConf       = MACHINE_FILAMENT_CONFIG_EN;
505
-    machine_menu.LevelingConf       = MACHINE_LEVELING_CONFIG_EN;
506 550
 
507 551
     machine_menu.MachineTypeConfTitle = MACHINE_TYPE_CONFIG_TITLE_EN;
508 552
     machine_menu.xyz                  = MACHINE_TYPE_XYZ_EN;
@@ -537,18 +581,18 @@ void machine_setting_disp() {
537 581
     machine_menu.opened           = ENDSTOP_OPENED_EN;
538 582
     machine_menu.closed           = ENDSTOP_CLOSED_EN;
539 583
 
540
-    machine_menu.FilamentConfTitle = FILAMENT_CONF_TITLE_EN;
541
-    machine_menu.InTemperature     = FILAMENT_IN_TEMPERATURE_EN;
542
-    machine_menu.InLength          = FILAMENT_IN_LENGTH_EN;
543
-    machine_menu.InSpeed           = FILAMENT_IN_SPEED_EN;
544
-    machine_menu.OutTemperature    = FILAMENT_OUT_TEMPERATURE_EN;
545
-    machine_menu.OutLength         = FILAMENT_OUT_LENGTH_EN;
546
-    machine_menu.OutSpeed          = FILAMENT_OUT_SPEED_EN;
584
+    machine_menu.FilamentConfTitle   = FILAMENT_CONF_TITLE_EN;
585
+    machine_menu.InLength            = FILAMENT_IN_LENGTH_EN;
586
+    machine_menu.InSpeed             = FILAMENT_IN_SPEED_EN;
587
+    machine_menu.FilamentTemperature = FILAMENT_TEMPERATURE_EN;
588
+    machine_menu.OutLength           = FILAMENT_OUT_LENGTH_EN;
589
+    machine_menu.OutSpeed            = FILAMENT_OUT_SPEED_EN;
547 590
 
548
-    machine_menu.LevelingParaConfTitle = LEVELING_CONF_TITLE_EN;
549
-    machine_menu.LevelingParaConf      = LEVELING_PARA_CONF_EN;
550
-    machine_menu.DeltaLevelConf        = LEVELING_DELTA_EN;
551
-    machine_menu.XYZLevelconf          = LEVELING_XYZ_EN;
591
+    machine_menu.LevelingParaConfTitle   = LEVELING_CONF_TITLE_EN;
592
+    machine_menu.LevelingParaConf        = LEVELING_PARA_CONF_EN;
593
+    machine_menu.LevelingManuPosConf     = LEVELING_MANUAL_POS_EN;
594
+    machine_menu.LevelingAutoCommandConf = LEVELING_AUTO_COMMAND_EN;
595
+    machine_menu.LevelingAutoZoffsetConf = LEVELING_AUTO_ZOFFSET_EN;
552 596
 
553 597
     machine_menu.LevelingSubConfTitle = LEVELING_PARA_CONF_TITLE_EN;
554 598
     machine_menu.AutoLevelEnable      = AUTO_LEVELING_ENABLE_EN;
@@ -598,16 +642,19 @@ void machine_setting_disp() {
598 642
     machine_menu.HotbedMinTemperature = HOTBED_MIN_TEMPERATURE_EN;
599 643
     machine_menu.HotbedMaxTemperature = HOTBED_MAX_TEMPERATURE_EN;
600 644
 
601
-    machine_menu.MotorConfTitle   = MOTOR_CONF_TITLE_EN;
602
-    machine_menu.MaxFeedRateConf  = MAXFEEDRATE_CONF_EN;
603
-    machine_menu.AccelerationConf = ACCELERATION_CONF_EN;
604
-    machine_menu.JerkConf         = JERKCONF_EN;
605
-    machine_menu.StepsConf        = STEPSCONF_EN;
606
-    machine_menu.TMCcurrentConf   = TMC_CURRENT_EN;
607
-    machine_menu.TMCStepModeConf  = TMC_STEP_MODE_EN;
608
-    machine_menu.MotorDirConf     = MOTORDIRCONF_EN;
609
-    machine_menu.HomeFeedRateConf = HOMEFEEDRATECONF_EN;
610
-    machine_menu.PausePosition    = PAUSE_POSITION_EN;
645
+    machine_menu.MotorConfTitle        = MOTOR_CONF_TITLE_EN;
646
+    machine_menu.MaxFeedRateConf       = MAXFEEDRATE_CONF_EN;
647
+    machine_menu.AccelerationConf      = ACCELERATION_CONF_EN;
648
+    machine_menu.JerkConf              = JERKCONF_EN;
649
+    machine_menu.StepsConf             = STEPSCONF_EN;
650
+    machine_menu.TMCcurrentConf        = TMC_CURRENT_EN;
651
+    machine_menu.TMCStepModeConf       = TMC_STEP_MODE_EN;
652
+    machine_menu.MotorDirConf          = MOTORDIRCONF_EN;
653
+    machine_menu.HomeFeedRateConf      = HOMEFEEDRATECONF_EN;
654
+    machine_menu.PausePosition         = PAUSE_POSITION_EN;
655
+    machine_menu.WifiSettings          = WIFI_SETTINGS_EN;
656
+    machine_menu.HomingSensitivityConf = HOMING_SENSITIVITY_CONF_EN;
657
+    machine_menu.EncoderSettings         = ENCODER_SETTINGS_EN;
611 658
 
612 659
     machine_menu.MaxFeedRateConfTitle = MAXFEEDRATE_CONF_TITLE_EN;
613 660
     machine_menu.XMaxFeedRate         = X_MAXFEEDRATE_EN;
@@ -692,10 +739,32 @@ void machine_setting_disp() {
692 739
     machine_menu.high_level = MOTOR_EN_HIGH_LEVEL_EN;
693 740
     machine_menu.low_level  = MOTOR_EN_LOW_LEVEL_EN;
694 741
 
695
-    machine_menu.PausePosText = PAUSE_POSITION_EN;
696
-    machine_menu.xPos         = PAUSE_POSITION_X_EN;
697
-    machine_menu.yPos         = PAUSE_POSITION_Y_EN;
698
-    machine_menu.zPos         = PAUSE_POSITION_Z_EN;
742
+    machine_menu.PausePosText   = PAUSE_POSITION_EN;
743
+    machine_menu.xPos           = PAUSE_POSITION_X_EN;
744
+    machine_menu.yPos           = PAUSE_POSITION_Y_EN;
745
+    machine_menu.zPos           = PAUSE_POSITION_Z_EN;
746
+    machine_menu.WifiConfTitle  = WIFI_SETTINGS_TITLE_EN;
747
+    machine_menu.wifiMode       = WIFI_SETTINGS_MODE_EN;
748
+    machine_menu.wifiName       = WIFI_SETTINGS_NAME_EN;
749
+    machine_menu.wifiPassWord   = WIFI_SETTINGS_PASSWORD_EN;
750
+    machine_menu.wifiCloud      = WIFI_SETTINGS_CLOUD_EN;
751
+    machine_menu.wifiConfig     = WIFI_SETTINGS_CONFIG_EN;
752
+    machine_menu.wifiEdit       = WIFI_SETTINGS_EDIT_EN;
753
+    machine_menu.wifiConfigTips = WIFI_CONFIG_TIPS_EN;
754
+
755
+    machine_menu.OffsetConfTitle = OFFSET_TITLE_EN;
756
+    machine_menu.Xoffset         = OFFSET_X_EN;
757
+    machine_menu.Yoffset         = OFFSET_Y_EN;
758
+    machine_menu.Zoffset         = OFFSET_Z_EN;
759
+
760
+    machine_menu.HomingSensitivityConfTitle = HOMING_SENSITIVITY_CONF_TITLE_EN;
761
+    machine_menu.X_Sensitivity              = X_SENSITIVITY_EN;
762
+    machine_menu.Y_Sensitivity              = Y_SENSITIVITY_EN;
763
+    machine_menu.Z_Sensitivity              = Z_SENSITIVITY_EN;
764
+    machine_menu.Z2_Sensitivity             = Z2_SENSITIVITY_EN;
765
+
766
+    machine_menu.EncoderConfTitle = ENCODER_CONF_TITLE_EN;
767
+    machine_menu.EncoderConfText              = ENCODER_CONF_TEXT_EN;
699 768
   }
700 769
 }
701 770
 
@@ -771,10 +840,6 @@ void disp_language_init() {
771 840
 
772 841
   filament_menu.stat_temp = TEXT_VALUE;
773 842
 
774
-  zoffset_menu.step001 = ZOFFSET_STEP001;
775
-  zoffset_menu.step01  = ZOFFSET_STEP01;
776
-  zoffset_menu.step1   = ZOFFSET_STEP1;
777
-
778 843
   machine_menu.key_0     = KEYBOARD_KEY0_EN;
779 844
   machine_menu.key_1     = KEYBOARD_KEY1_EN;
780 845
   machine_menu.key_2     = KEYBOARD_KEY2_EN;
@@ -788,22 +853,15 @@ void disp_language_init() {
788 853
   machine_menu.key_point = KEYBOARD_KEY_POINT_EN;
789 854
   machine_menu.negative  = KEYBOARD_KEY_NEGATIVE_EN;
790 855
   // wifi-list
791
-  #if 0
792
-    list_menu.title      = TEXT_WIFI_MENU_TITLE_EN;
793
-    list_menu.file_pages = FILE_PAGES_EN;
794
-    // keyboard
795
-    keyboard_menu.apply    = MANUAL_IP_APPLY_EN;
796
-    keyboard_menu.password = TEXT_WIFI_PASSWORD_EN;
797
-    keyboard_menu.space    = TEXT_WIFI_SAPCE_EN;
798
-    keyboard_menu.letter   = TEXT_WIFI_LETTER_EN;
799
-    keyboard_menu.digital  = TEXT_WIFI_DIGITAL_EN;
800
-    keyboard_menu.symbol   = TEXT_WIFI_SYMBOL_EN;
856
+  #if ENABLED(USE_WIFI_FUNCTION)
857
+    list_menu.title        = TEXT_WIFI_MENU_TITLE_EN;
858
+    list_menu.file_pages   = FILE_PAGES_EN;
859
+
801 860
     // tips
802
-    tips_menu.pointBold    = TEXT_WIFI_POINT_BOLD_EN;
803 861
     tips_menu.joining      = TEXT_WIFI_JOINING_EN;
804 862
     tips_menu.failedJoin   = TEXT_WIFI_FAILED_JOIN_EN;
805 863
     tips_menu.wifiConected = TEXT_WIFI_WIFI_CONECTED_EN;
806
-  #endif
864
+  #endif  //USE_WIFI_FUNCTION
807 865
   machine_setting_disp();
808 866
 
809 867
   operation_menu.babystep = TEXT_BABY_STEP_EN;
@@ -904,7 +962,6 @@ void disp_language_init() {
904 962
       filesys_menu.usb_sys = U_DISK_TEXT_CN;
905 963
       //
906 964
       more_menu.title   = TITLE_MORE_CN;
907
-      more_menu.zoffset = ZOFFSET_CN;
908 965
       // WIFI
909 966
       wifi_menu.title = WIFI_TEXT;
910 967
       // wifi_menu.key = WIFI_KEY_TEXT_CN;
@@ -1016,11 +1073,6 @@ void disp_language_init() {
1016 1073
       print_file_dialog_menu.reprint          = DIALOG_REPRINT_CN;
1017 1074
       print_file_dialog_menu.wifi_enable_tips = DIALOG_WIFI_ENABLE_TIPS_CN;
1018 1075
 
1019
-      // ZOFFSET
1020
-      zoffset_menu.title = TITLE_ZOFFSET_CN;
1021
-      zoffset_menu.inc   = ZOFFSET_INC_CN;
1022
-      zoffset_menu.dec   = ZOFFSET_DEC_CN;
1023
-
1024 1076
       pause_msg_menu.pausing       = MESSAGE_PAUSING_CN;
1025 1077
       pause_msg_menu.changing      = MESSAGE_CHANGING_CN;
1026 1078
       pause_msg_menu.unload        = MESSAGE_UNLOAD_CN;
@@ -1092,7 +1144,6 @@ void disp_language_init() {
1092 1144
             preheat_menu.step_10c     = TEXT_10C_T_CN;
1093 1145
             //
1094 1146
             move_menu.title   = MOVE_TEXT_T_CN;
1095
-            more_menu.zoffset = ZOFFSET_T_CN;
1096 1147
             //
1097 1148
             home_menu.title    = TITLE_HOME_T_CN;
1098 1149
             home_menu.stopmove = HOME_STOPMOVE_T_CN;
@@ -1249,10 +1300,6 @@ void disp_language_init() {
1249 1300
             print_file_dialog_menu.print_time          = DIALOG_PRINT_TIME_T_CN;
1250 1301
             print_file_dialog_menu.reprint             = DIALOG_REPRINT_T_CN;
1251 1302
             print_file_dialog_menu.wifi_enable_tips    = DIALOG_WIFI_ENABLE_TIPS_T_CN;
1252
-            // ZOFFSET
1253
-            zoffset_menu.title = TITLE_ZOFFSET_T_CN;
1254
-            zoffset_menu.inc   = ZOFFSET_INC_T_CN;
1255
-            zoffset_menu.dec   = ZOFFSET_DEC_T_CN;
1256 1303
 
1257 1304
             pause_msg_menu.pausing       = MESSAGE_PAUSING_T_CN;
1258 1305
             pause_msg_menu.changing      = MESSAGE_CHANGING_T_CN;
@@ -1359,7 +1406,6 @@ void disp_language_init() {
1359 1406
             set_menu.machine_para = MACHINE_PARA_EN;
1360 1407
             set_menu.eepromSet    = EEPROM_SETTINGS_EN;
1361 1408
             more_menu.title       = TITLE_MORE_EN;
1362
-            more_menu.zoffset     = ZOFFSET_EN;
1363 1409
             //
1364 1410
             filesys_menu.title   = TITLE_FILESYS_EN;
1365 1411
             filesys_menu.sd_sys  = SD_CARD_TEXT_EN;
@@ -1469,10 +1515,6 @@ void disp_language_init() {
1469 1515
             print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_EN;
1470 1516
             print_file_dialog_menu.reprint               = DIALOG_REPRINT_EN;
1471 1517
             print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_EN;
1472
-            // ZOFFSET
1473
-            zoffset_menu.title = TITLE_ZOFFSET_EN;
1474
-            zoffset_menu.inc   = ZOFFSET_INC_EN;
1475
-            zoffset_menu.dec   = ZOFFSET_DEC_EN;
1476 1518
 
1477 1519
             pause_msg_menu.pausing       = MESSAGE_PAUSING_EN;
1478 1520
             pause_msg_menu.changing      = MESSAGE_CHANGING_EN;
@@ -1579,7 +1621,6 @@ void disp_language_init() {
1579 1621
             set_menu.machine_para = MACHINE_PARA_RU;
1580 1622
             set_menu.eepromSet    = EEPROM_SETTINGS_RU;
1581 1623
             more_menu.title       = TITLE_MORE_RU;
1582
-            more_menu.zoffset     = ZOFFSET_RU;
1583 1624
             //
1584 1625
             filesys_menu.title   = TITLE_FILESYS_RU;
1585 1626
             filesys_menu.sd_sys  = SD_CARD_TEXT_RU;
@@ -1689,10 +1730,6 @@ void disp_language_init() {
1689 1730
             print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_RU;
1690 1731
             print_file_dialog_menu.reprint               = DIALOG_REPRINT_RU;
1691 1732
             print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_RU;
1692
-            // ZOFFSET
1693
-            zoffset_menu.title = TITLE_ZOFFSET_RU;
1694
-            zoffset_menu.inc   = ZOFFSET_INC_RU;
1695
-            zoffset_menu.dec   = ZOFFSET_DEC_RU;
1696 1733
 
1697 1734
             pause_msg_menu.pausing       = MESSAGE_PAUSING_RU;
1698 1735
             pause_msg_menu.changing      = MESSAGE_CHANGING_RU;
@@ -1803,7 +1840,6 @@ void disp_language_init() {
1803 1840
             set_menu.machine_para = MACHINE_PARA_SP;
1804 1841
             set_menu.eepromSet    = EEPROM_SETTINGS_SP;
1805 1842
             more_menu.title       = TITLE_MORE_SP;
1806
-            more_menu.zoffset     = ZOFFSET_SP;
1807 1843
             //
1808 1844
             filesys_menu.title   = TITLE_FILESYS_SP;
1809 1845
             filesys_menu.sd_sys  = SD_CARD_TEXT_SP;
@@ -1914,10 +1950,6 @@ void disp_language_init() {
1914 1950
             print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_SP;
1915 1951
             print_file_dialog_menu.reprint               = DIALOG_REPRINT_SP;
1916 1952
             print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_SP;
1917
-            // ZOFFSET
1918
-            zoffset_menu.title = TITLE_ZOFFSET_SP;
1919
-            zoffset_menu.inc   = ZOFFSET_INC_SP;
1920
-            zoffset_menu.dec   = ZOFFSET_DEC_SP;
1921 1953
 
1922 1954
             pause_msg_menu.pausing       = MESSAGE_PAUSING_SP;
1923 1955
             pause_msg_menu.changing      = MESSAGE_CHANGING_SP;
@@ -2025,7 +2057,6 @@ void disp_language_init() {
2025 2057
           set_menu.machine_para = MACHINE_PARA_FR;
2026 2058
           set_menu.eepromSet    = EEPROM_SETTINGS_FR;
2027 2059
           more_menu.title       = TITLE_MORE_FR;
2028
-          more_menu.zoffset     = ZOFFSET_FR;
2029 2060
           //
2030 2061
           filesys_menu.title          = TITLE_FILESYS_FR;
2031 2062
           filesys_menu.sd_sys         = SD_CARD_TEXT_FR;
@@ -2137,10 +2168,6 @@ void disp_language_init() {
2137 2168
           print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_FR;
2138 2169
           print_file_dialog_menu.reprint               = DIALOG_REPRINT_FR;
2139 2170
           print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_FR;
2140
-          // ZOFFSET
2141
-          zoffset_menu.title = TITLE_ZOFFSET_FR;
2142
-          zoffset_menu.inc   = ZOFFSET_INC_FR;
2143
-          zoffset_menu.dec   = ZOFFSET_DEC_FR;
2144 2171
 
2145 2172
           pause_msg_menu.pausing       = MESSAGE_PAUSING_FR;
2146 2173
           pause_msg_menu.changing      = MESSAGE_CHANGING_FR;
@@ -2249,7 +2276,6 @@ void disp_language_init() {
2249 2276
           set_menu.machine_para = MACHINE_PARA_IT;
2250 2277
           set_menu.eepromSet    = EEPROM_SETTINGS_IT;
2251 2278
           more_menu.title       = TITLE_MORE_IT;
2252
-          more_menu.zoffset     = ZOFFSET_IT;
2253 2279
           //
2254 2280
           filesys_menu.title   = TITLE_FILESYS_IT;
2255 2281
           filesys_menu.sd_sys  = SD_CARD_TEXT_IT;
@@ -2358,10 +2384,6 @@ void disp_language_init() {
2358 2384
           print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_IT;
2359 2385
           print_file_dialog_menu.reprint               = DIALOG_REPRINT_IT;
2360 2386
           print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_IT;
2361
-          // ZOFFSET
2362
-          zoffset_menu.title = TITLE_ZOFFSET_IT;
2363
-          zoffset_menu.inc   = ZOFFSET_INC_IT;
2364
-          zoffset_menu.dec   = ZOFFSET_DEC_IT;
2365 2387
 
2366 2388
           pause_msg_menu.pausing       = MESSAGE_PAUSING_IT;
2367 2389
           pause_msg_menu.changing      = MESSAGE_CHANGING_IT;
@@ -2472,7 +2494,6 @@ void disp_language_init() {
2472 2494
       set_menu.eepromSet    = EEPROM_SETTINGS_EN;
2473 2495
       //
2474 2496
       more_menu.title   = TITLE_MORE_EN;
2475
-      more_menu.zoffset = ZOFFSET_EN;
2476 2497
       //
2477 2498
       filesys_menu.title   = TITLE_FILESYS_EN;
2478 2499
       filesys_menu.sd_sys  = SD_CARD_TEXT_EN;
@@ -2582,10 +2603,6 @@ void disp_language_init() {
2582 2603
       print_file_dialog_menu.print_time            = DIALOG_PRINT_TIME_EN;
2583 2604
       print_file_dialog_menu.reprint               = DIALOG_REPRINT_EN;
2584 2605
       print_file_dialog_menu.wifi_enable_tips      = DIALOG_WIFI_ENABLE_TIPS_EN;
2585
-      // ZOFFSET
2586
-      zoffset_menu.title = TITLE_ZOFFSET_EN;
2587
-      zoffset_menu.inc   = ZOFFSET_INC_EN;
2588
-      zoffset_menu.dec   = ZOFFSET_DEC_EN;
2589 2606
 
2590 2607
       pause_msg_menu.pausing       = MESSAGE_PAUSING_EN;
2591 2608
       pause_msg_menu.changing      = MESSAGE_CHANGING_EN;

+ 32
- 43
Marlin/src/lcd/extui/lib/mks_ui/tft_multi_language.h View File

@@ -60,7 +60,6 @@ typedef struct machine_common_disp{
60 60
   const char *HomeDir;
61 61
   const char *EndStopType;
62 62
   const char *FilamentConf;
63
-  const char *LevelingConf;
64 63
 
65 64
   const char *MachineTypeConfTitle;
66 65
   const char *xyz;
@@ -96,17 +95,17 @@ typedef struct machine_common_disp{
96 95
   const char *closed;
97 96
 
98 97
   const char *FilamentConfTitle;
99
-  const char *InTemperature;
100 98
   const char *InLength;
101 99
   const char *InSpeed;
102
-  const char *OutTemperature;
100
+  const char *FilamentTemperature;
103 101
   const char *OutLength;
104 102
   const char *OutSpeed;
105 103
 
106 104
   const char *LevelingParaConfTitle;
107 105
   const char *LevelingParaConf;
108
-  const char *DeltaLevelConf;
109
-  const char *XYZLevelconf;
106
+  const char *LevelingManuPosConf;
107
+  const char *LevelingAutoCommandConf;
108
+  const char *LevelingAutoZoffsetConf;
110 109
 
111 110
   const char *LevelingSubConfTitle;
112 111
   const char *AutoLevelEnable;
@@ -165,6 +164,7 @@ typedef struct machine_common_disp{
165 164
   const char *HomeFeedRateConf;
166 165
   const char *TMCcurrentConf;
167 166
   const char *TMCStepModeConf;
167
+  const char *HomingSensitivityConf;
168 168
 
169 169
   const char *MaxFeedRateConfTitle;
170 170
   const char *XMaxFeedRate;
@@ -210,6 +210,12 @@ typedef struct machine_common_disp{
210 210
   const char *E0_StepMode;
211 211
   const char *E1_StepMode;
212 212
 
213
+  const char *HomingSensitivityConfTitle;
214
+  const char *X_Sensitivity;
215
+  const char *Y_Sensitivity;
216
+  const char *Z_Sensitivity;
217
+  const char *Z2_Sensitivity;
218
+
213 219
   const char *MotorDirConfTitle;
214 220
   const char *X_MotorDir;
215 221
   const char *Y_MotorDir;
@@ -231,6 +237,8 @@ typedef struct machine_common_disp{
231 237
   const char *Z2andZ2Endstop;
232 238
   const char *EnablePinsInvert;
233 239
   const char *PausePosition;
240
+  const char *WifiSettings;
241
+  const char *EncoderSettings;
234 242
 
235 243
   const char *Z2ConfTitle;
236 244
   const char *Z2Enable;
@@ -266,6 +274,23 @@ typedef struct machine_common_disp{
266 274
   const char *yPos;
267 275
   const char *zPos;
268 276
 
277
+  const char *WifiConfTitle;
278
+  const char *wifiMode;
279
+  const char *wifiName;
280
+  const char *wifiPassWord;
281
+  const char *wifiCloud;
282
+  const char *wifiConfig;
283
+  const char *wifiEdit;
284
+  const char *wifiConfigTips;
285
+
286
+  const char *OffsetConfTitle;
287
+  const char *Xoffset;
288
+  const char *Yoffset;
289
+  const char *Zoffset;
290
+
291
+  const char *EncoderConfTitle;
292
+  const char *EncoderConfText;
293
+
269 294
 } machine_common_def;
270 295
 
271 296
 extern machine_common_def machine_menu;
@@ -435,7 +460,6 @@ extern filesys_menu_def filesys_menu;
435 460
 
436 461
 typedef struct more_menu_disp {
437 462
   const char *title;
438
-  const char *zoffset;
439 463
   const char *back;
440 464
 } more_menu_def;
441 465
 
@@ -661,18 +685,6 @@ typedef struct print_file_dialog_disp {
661 685
 
662 686
 extern print_file_dialog_menu_def print_file_dialog_menu;
663 687
 
664
-typedef struct zoffset_menu_disp {
665
-  const char *title;
666
-  const char *inc;
667
-  const char *dec;
668
-  const char *step001;
669
-  const char *step01;
670
-  const char *step1;
671
-  const char *back;
672
-} zoffset_menu_def;
673
-
674
-extern zoffset_menu_def zoffset_menu;
675
-
676 688
 typedef struct tool_menu_disp {
677 689
   const char *title;
678 690
   const char *preheat;
@@ -691,37 +703,13 @@ extern tool_menu_def tool_menu;
691 703
 typedef struct MachinePara_menu_disp {
692 704
   const char *title;
693 705
   const char *MachineSetting;
694
-  const char *TemperatureSetting;
695 706
   const char *MotorSetting;
707
+  const char *leveling;
696 708
   const char *AdvanceSetting;
697
-  //const char *back;
698 709
 } MachinePara_menu_def;
699 710
 
700 711
 extern MachinePara_menu_def MachinePara_menu;
701 712
 
702
-typedef struct MachineSettings_menu_disp {
703
-  const char *title;
704
-  const char *Machine;
705
-  const char *Stroke;
706
-  const char *HomeDir;
707
-  const char *EndStopType;
708
-  const char *filamet;
709
-  const char *leveling;
710
-  const char *back;
711
-} MachineSettings_menu_def;
712
-
713
-extern MachineSettings_menu_def MachineSettings_menu;
714
-
715
-typedef struct TemperatureSettings_menu_disp {
716
-  const char *title;
717
-  const char *nozzle;
718
-  const char *hotbed;
719
-  const char *preheat;
720
-  const char *back;
721
-} TemperatureSettings_menu_def;
722
-
723
-extern TemperatureSettings_menu_def TemperatureSettings_menu;
724
-
725 713
 typedef struct pause_msg_disp {
726 714
   const char *pausing;
727 715
   const char *changing;
@@ -842,6 +830,7 @@ extern eeprom_def eeprom_menu;
842 830
 #define DIALOG_UPLOAD_SPEED_EN          "Speed"
843 831
 #define DIALOG_UPDATE_WIFI_FIRMWARE_EN  "Updating wifi model firmware"
844 832
 #define DIALOG_UPDATE_WIFI_WEB_EN       "Updating wifi model web data"
833
+#define DIALOG_UPDATE_NO_DEVICE_EN      "please check \nwether memory device insert!"
845 834
 
846 835
 #define ZOFFSET_STEP001                 "0.01mm"
847 836
 #define ZOFFSET_STEP01                  "0.1mm"

+ 120
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.cpp View File

@@ -0,0 +1,120 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "draw_ui.h"
27
+#include "wifiSerial.h"
28
+
29
+#if ENABLED(USE_WIFI_FUNCTION)
30
+
31
+#include <libmaple/libmaple.h>
32
+#include <libmaple/gpio.h>
33
+#include <libmaple/timer.h>
34
+#include <libmaple/usart.h>
35
+#include <libmaple/ring_buffer.h>
36
+
37
+#include "../../../../MarlinCore.h"
38
+
39
+DEFINE_WFSERIAL(WifiSerial1, 1);
40
+
41
+WifiSerial::WifiSerial(usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin) {
42
+  this->usart_device = usart_device;
43
+  this->tx_pin = tx_pin;
44
+  this->rx_pin = rx_pin;
45
+}
46
+
47
+/**
48
+ * Set up / tear down
49
+ */
50
+#if STM32_MCU_SERIES == STM32_SERIES_F1
51
+  /* F1 MCUs have no GPIO_AFR[HL], so turn off PWM if there's a conflict
52
+   * on this GPIO bit. */
53
+  static void disable_timer_if_necessary(timer_dev *dev, uint8 ch) {
54
+    if (dev != nullptr) timer_set_mode(dev, ch, TIMER_DISABLED);
55
+  }
56
+#elif STM32_MCU_SERIES == STM32_SERIES_F2 || STM32_MCU_SERIES == STM32_SERIES_F4
57
+  #define disable_timer_if_necessary(dev, ch) ((void)0)
58
+#else
59
+  #warning "Unsupported STM32 series; timer conflicts are possible"
60
+#endif
61
+
62
+void WifiSerial::begin(uint32 baud) { begin(baud, SERIAL_8N1); }
63
+
64
+/**
65
+ * Roger Clark.
66
+ * Note. The config parameter is not currently used. This is a work in progress.
67
+ * Code needs to be written to set the config of the hardware serial control register in question.
68
+ */
69
+
70
+void WifiSerial::begin(uint32 baud, uint8_t config) {
71
+  //ASSERT(baud <= this->usart_device->max_baud); // Roger Clark. Assert doesn't do anything useful, we may as well save the space in flash and ram etc
72
+
73
+  if (baud > this->usart_device->max_baud) return;
74
+
75
+  const stm32_pin_info *txi = &PIN_MAP[this->tx_pin],
76
+                       *rxi = &PIN_MAP[this->rx_pin];
77
+
78
+  disable_timer_if_necessary(txi->timer_device, txi->timer_channel);
79
+
80
+  usart_init(this->usart_device);
81
+
82
+  // Reinitialize the receive buffer, mks_esp8266 fixed data frame length is 1k bytes
83
+  rb_init(this->usart_device->rb, WIFI_RX_BUF_SIZE, wifiRxBuf);
84
+
85
+  usart_config_gpios_async(this->usart_device,
86
+                           rxi->gpio_device, rxi->gpio_bit,
87
+                           txi->gpio_device, txi->gpio_bit,
88
+                           config);
89
+  usart_set_baud_rate(this->usart_device, USART_USE_PCLK, baud);
90
+  usart_enable(this->usart_device);
91
+}
92
+
93
+void WifiSerial::end(void) {
94
+  usart_disable(this->usart_device);
95
+}
96
+
97
+int WifiSerial::available(void) {
98
+  return usart_data_available(this->usart_device);
99
+}
100
+
101
+//
102
+// I/O
103
+//
104
+
105
+int WifiSerial::read(void) {
106
+  if (usart_data_available(usart_device) <= 0) return -1;
107
+  return usart_getc(usart_device);
108
+}
109
+
110
+int WifiSerial::write(unsigned char ch) {
111
+  usart_putc(this->usart_device, ch);
112
+  return 1;
113
+}
114
+
115
+int WifiSerial::wifi_rb_is_full(void) {
116
+  return rb_is_full(this->usart_device->rb);
117
+}
118
+
119
+#endif // USE_WIFI_FUNCTION
120
+#endif // HAS_TFT_LVGL_UI

+ 102
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifiSerial.h View File

@@ -0,0 +1,102 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#include "tft_lvgl_configuration.h"
25
+
26
+#if ENABLED(USE_WIFI_FUNCTION)
27
+
28
+#if SERIAL_PORT_2 != -1
29
+  #error "SERIAL_PORT_2 must be set to -1 with HAS_TFT_LVGL_UI and USE_WIFI_FUNCTION."
30
+#endif
31
+
32
+#define WIFI_BAUDRATE          115200
33
+#define WIFI_UPLOAD_BAUDRATE  1958400
34
+#define USART_SAFE_INSERT
35
+
36
+#define WIFI_RX_BUF_SIZE  (1024+1)
37
+
38
+#include <libmaple/libmaple_types.h>
39
+#include <libmaple/usart.h>
40
+#include <libmaple/libmaple.h>
41
+#include <libmaple/gpio.h>
42
+#include <libmaple/timer.h>
43
+#include <libmaple/ring_buffer.h>
44
+
45
+#define DEFINE_WFSERIAL(name, n)\
46
+  WifiSerial name(USART##n, \
47
+  BOARD_USART##n##_TX_PIN,  \
48
+  BOARD_USART##n##_RX_PIN)
49
+
50
+class WifiSerial {
51
+  public:
52
+    uint8 wifiRxBuf[WIFI_RX_BUF_SIZE];
53
+
54
+  public:
55
+    WifiSerial(struct usart_dev *usart_device, uint8 tx_pin, uint8 rx_pin);
56
+
57
+    /* Set up/tear down */
58
+    void begin(uint32 baud);
59
+    void begin(uint32 baud,uint8_t config);
60
+    void end();
61
+    int available(void);
62
+    int read(void);
63
+    int write(uint8_t);
64
+    inline void wifi_usart_irq(usart_reg_map *regs) {
65
+      /* Handling RXNEIE and TXEIE interrupts.
66
+       * RXNE signifies availability of a byte in DR.
67
+       *
68
+       * See table 198 (sec 27.4, p809) in STM document RM0008 rev 15.
69
+       * We enable RXNEIE.
70
+       */
71
+      if ((regs->CR1 & USART_CR1_RXNEIE) && (regs->SR & USART_SR_RXNE)) {
72
+        #ifdef USART_SAFE_INSERT
73
+          /* If the buffer is full and the user defines USART_SAFE_INSERT,
74
+           * ignore new bytes. */
75
+          rb_safe_insert(this->usart_device->rb, (uint8)regs->DR);
76
+        #else
77
+          /* By default, push bytes around in the ring buffer. */
78
+          rb_push_insert(this->usart_device->rb, (uint8)regs->DR);
79
+        #endif
80
+      }
81
+      /* TXE signifies readiness to send a byte to DR. */
82
+      if ((regs->CR1 & USART_CR1_TXEIE) && (regs->SR & USART_SR_TXE)) {
83
+          if (!rb_is_empty(this->usart_device->wb))
84
+              regs->DR=rb_remove(this->usart_device->wb);
85
+          else
86
+              regs->CR1 &= ~((uint32)USART_CR1_TXEIE); // disable TXEIE
87
+      }
88
+    }
89
+
90
+    int wifi_rb_is_full(void);
91
+
92
+  private:
93
+    struct usart_dev *usart_device;
94
+    uint8 tx_pin;
95
+    uint8 rx_pin;
96
+};
97
+
98
+extern WifiSerial WifiSerial1;
99
+
100
+#define WIFISERIAL  WifiSerial1
101
+
102
+#endif // USE_WIFI_FUNCTION

+ 1927
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.cpp
File diff suppressed because it is too large
View File


+ 202
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifi_module.h View File

@@ -0,0 +1,202 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+  extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+#include "../../inc/MarlinConfigPre.h"
29
+
30
+#include <math.h>
31
+#include <stdio.h>
32
+#include <stdlib.h>
33
+
34
+#define UART_RX_BUFFER_SIZE   1024
35
+#define UART_FIFO_BUFFER_SIZE 1024
36
+
37
+#define ESP_WIFI              0x02
38
+
39
+#define AP_MODEL              0x01
40
+#define STA_MODEL             0x02
41
+
42
+#define WIFI_DECODE_TYPE      1
43
+
44
+#define IP_DHCP_FLAG          1
45
+
46
+#define WIFI_AP_NAME          "TP-LINK_MKS"
47
+#define WIFI_KEY_CODE         "makerbase"
48
+
49
+#define IP_ADDR               "192.168.3.100"
50
+#define IP_MASK               "255.255.255.0"
51
+#define IP_GATE               "192.168.3.1"
52
+#define IP_DNS                "192.168.3.1"
53
+
54
+#define AP_IP_DHCP_FLAG       1
55
+#define AP_IP_ADDR            "192.168.3.100"
56
+#define AP_IP_MASK            "255.255.255.0"
57
+#define AP_IP_GATE            "192.168.3.1"
58
+#define AP_IP_DNS             "192.168.3.1"
59
+#define IP_START_IP           "192.168.3.1"
60
+#define IP_END_IP             "192.168.3.255"
61
+
62
+#define UDISKBUFLEN           1024
63
+
64
+typedef enum{
65
+  udisk_buf_empty = 0,
66
+  udisk_buf_full,
67
+} UDISK_DATA_BUFFER_STATE;
68
+
69
+#define TRANS_RCV_FIFO_BLOCK_NUM    8
70
+
71
+typedef struct {
72
+  unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
73
+  unsigned char *p;
74
+  UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM];
75
+  unsigned char read_cur;
76
+  unsigned char write_cur;
77
+} WIFI_DMA_RCV_FIFO;
78
+
79
+typedef struct {
80
+  uint8_t flag; // 0x0: no error;  0x01: error
81
+  uint32_t start_tick; //error start time
82
+  uint32_t now_tick;
83
+} WIFI_TRANS_ERROR;
84
+
85
+extern volatile WIFI_TRANS_ERROR wifiTransError;
86
+
87
+typedef struct {
88
+  char ap_name[32];   //wifi-name
89
+  char keyCode[64]; //wifi password
90
+  int  decodeType;
91
+  int  baud;
92
+  int  mode;
93
+} WIFI_PARA;
94
+
95
+typedef struct {
96
+  char state;
97
+  char hostUrl[96];
98
+  int  port;
99
+  char id[21];
100
+} CLOUD_PARA;
101
+
102
+typedef struct {
103
+  char  dhcp_flag;
104
+  char  ip_addr[16];
105
+  char  mask[16];
106
+  char  gate[16];
107
+  char  dns[16];
108
+
109
+  char  dhcpd_flag;
110
+  char  dhcpd_ip[16];
111
+  char  dhcpd_mask[16];
112
+  char  dhcpd_gate[16];
113
+  char  dhcpd_dns[16];
114
+  char  start_ip_addr[16];
115
+  char  end_ip_addr[16];
116
+} IP_PARA;
117
+
118
+typedef enum {
119
+  WIFI_NOT_CONFIG,
120
+  WIFI_CONFIG_MODE,
121
+  WIFI_CONFIG_DHCP,
122
+  WIFI_CONFIG_AP,
123
+  WIFI_CONFIG_IP_INF,
124
+  WIFI_CONFIG_DNS,
125
+  WIFI_CONFIG_TCP,
126
+  WIFI_CONFIG_SERVER,
127
+  WIFI_CONFIG_REMOTE_PORT,
128
+  WIFI_CONFIG_BAUD,
129
+  WIFI_CONFIG_COMMINT,
130
+  WIFI_CONFIG_OK,
131
+  WIFI_GET_IP_OK,
132
+  WIFI_RECONN,
133
+  WIFI_CONNECTED,
134
+  WIFI_WAIT_TRANS_START,
135
+  WIFI_TRANS_FILE,
136
+  WIFI_CONFIG_DHCPD,
137
+  WIFI_COFIG_DHCPD_IP,
138
+  WIFI_COFIG_DHCPD_DNS,
139
+  WIFI_EXCEPTION,
140
+} WIFI_STATE;
141
+
142
+typedef enum {
143
+  TRANSFER_IDLE,
144
+  TRANSFERING,
145
+  TRANSFER_STORE,
146
+} TRANSFER_STATE;
147
+extern volatile TRANSFER_STATE esp_state;
148
+
149
+typedef struct {
150
+  char buf[20][80];
151
+  int  rd_index;
152
+  int  wt_index;
153
+} QUEUE;
154
+
155
+typedef enum {
156
+  WIFI_PARA_SET,      // 0x0:net parameter
157
+  WIFI_PRINT_INF,     // 0x1:print message
158
+  WIFI_TRANS_INF,     // 0x2:Pass through information
159
+  WIFI_EXCEP_INF,     // 0x3:Exception information
160
+  WIFI_CLOUD_CFG,     // 0x4:cloud config
161
+  WIFI_CLOUD_UNBIND,  // 0x5:Unbind ID
162
+} WIFI_RET_TYPE;
163
+
164
+typedef struct {
165
+  uint32_t uart_read_point;
166
+  uint32_t uart_write_point;
167
+  uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
168
+} SZ_USART_FIFO;
169
+
170
+#define WIFI_GCODE_BUFFER_LEAST_SIZE    96
171
+#define WIFI_GCODE_BUFFER_SIZE  (WIFI_GCODE_BUFFER_LEAST_SIZE * 3)
172
+typedef struct {
173
+    uint8_t wait_tick;
174
+    uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE];
175
+    uint32_t r;
176
+    uint32_t w;
177
+} WIFI_GCODE_BUFFER;
178
+
179
+extern volatile WIFI_STATE wifi_link_state;
180
+extern WIFI_PARA wifiPara;
181
+extern IP_PARA ipPara;
182
+extern CLOUD_PARA cloud_para;
183
+
184
+extern WIFI_GCODE_BUFFER espGcodeFifo;
185
+
186
+extern uint32_t  getWifiTick();
187
+extern uint32_t  getWifiTickDiff(int32_t lastTick, int32_t  curTick);
188
+
189
+extern void mks_esp_wifi_init();
190
+extern int  cfg_cloud_flag;
191
+extern int  send_to_wifi(char *buf, int len);
192
+extern void wifi_looping();
193
+extern int  raw_send_to_wifi(char *buf, int len);
194
+extern int  package_to_wifi(WIFI_RET_TYPE type,char *buf, int len);
195
+extern void get_wifi_list_command_send();
196
+extern void get_wifi_commands();
197
+extern int  readWifiBuf(int8_t *buf, int32_t len);
198
+extern int  storeRcvData(int32_t len);
199
+
200
+#ifdef __cplusplus
201
+  } /* C-declarations for C++ */
202
+#endif

+ 847
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp View File

@@ -0,0 +1,847 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#include "../../../../inc/MarlinConfigPre.h"
23
+
24
+#if HAS_TFT_LVGL_UI
25
+
26
+#include "draw_ui.h"
27
+#include "wifi_module.h"
28
+#include "wifi_upload.h"
29
+
30
+#include "../../../../MarlinCore.h"
31
+
32
+#define WIFI_SET()        WRITE(WIFI_RESET_PIN, HIGH);
33
+#define WIFI_RESET()      WRITE(WIFI_RESET_PIN, LOW);
34
+#define WIFI_IO1_SET()    WRITE(WIFI_IO1_PIN, HIGH);
35
+#define WIFI_IO1_RESET()  WRITE(WIFI_IO1_PIN, LOW);
36
+
37
+extern SZ_USART_FIFO  WifiRxFifo;
38
+
39
+extern int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
40
+extern int writeUsartFifo(SZ_USART_FIFO * fifo, int8_t * buf, int32_t len);
41
+extern void esp_port_begin(uint8_t interrupt);
42
+extern int usartFifoAvailable(SZ_USART_FIFO *fifo);
43
+extern void wifi_delay(int n);
44
+
45
+#define ARRAY_SIZE(a) sizeof(a) / sizeof((a)[0])
46
+
47
+//typedef signed char bool;
48
+
49
+// ESP8266 command codes
50
+const uint8_t ESP_FLASH_BEGIN = 0x02;
51
+const uint8_t ESP_FLASH_DATA = 0x03;
52
+const uint8_t ESP_FLASH_END = 0x04;
53
+const uint8_t ESP_MEM_BEGIN = 0x05;
54
+const uint8_t ESP_MEM_END = 0x06;
55
+const uint8_t ESP_MEM_DATA = 0x07;
56
+const uint8_t ESP_SYNC = 0x08;
57
+const uint8_t ESP_WRITE_REG = 0x09;
58
+const uint8_t ESP_READ_REG = 0x0a;
59
+
60
+// MAC address storage locations
61
+const uint32_t ESP_OTP_MAC0 = 0x3ff00050;
62
+const uint32_t ESP_OTP_MAC1 = 0x3ff00054;
63
+const uint32_t ESP_OTP_MAC2 = 0x3ff00058;
64
+const uint32_t ESP_OTP_MAC3 = 0x3ff0005c;
65
+
66
+const size_t EspFlashBlockSize = 0x0400;      // 1K byte blocks
67
+
68
+const uint8_t ESP_IMAGE_MAGIC = 0xe9;
69
+const uint8_t ESP_CHECKSUM_MAGIC = 0xef;
70
+
71
+const uint32_t ESP_ERASE_CHIP_ADDR = 0x40004984;  // &SPIEraseChip
72
+const uint32_t ESP_SEND_PACKET_ADDR = 0x40003c80; // &send_packet
73
+const uint32_t ESP_SPI_READ_ADDR = 0x40004b1c;    // &SPIRead
74
+const uint32_t ESP_UNKNOWN_ADDR = 0x40001121;   // not used
75
+const uint32_t ESP_USER_DATA_RAM_ADDR = 0x3ffe8000; // &user data ram
76
+const uint32_t ESP_IRAM_ADDR = 0x40100000;      // instruction RAM
77
+const uint32_t ESP_FLASH_ADDR = 0x40200000;     // address of start of Flash
78
+//const uint32_t ESP_FLASH_READ_STUB_BEGIN = IRAM_ADDR + 0x18;
79
+
80
+UPLOAD_STRUCT esp_upload;
81
+
82
+static const unsigned int retriesPerReset = 3;
83
+static const uint32_t connectAttemptInterval = 50;
84
+static const unsigned int percentToReportIncrement = 5; // how often we report % complete
85
+static const uint32_t defaultTimeout = 500;
86
+static const uint32_t eraseTimeout = 15000;
87
+static const uint32_t blockWriteTimeout = 200;
88
+static const uint32_t blockWriteInterval = 15;      // 15ms is long enough, 10ms is mostly too short
89
+
90
+// Messages corresponding to result codes, should make sense when followed by " error"
91
+const char *resultMessages[] = {
92
+  "no",
93
+  "timeout",
94
+  "comm write",
95
+  "connect",
96
+  "bad reply",
97
+  "file read",
98
+  "empty file",
99
+  "response header",
100
+  "slip frame",
101
+  "slip state",
102
+  "slip data"
103
+};
104
+
105
+// A note on baud rates.
106
+// The ESP8266 supports 921600, 460800, 230400, 115200, 74880 and some lower baud rates.
107
+// 921600b is not reliable because even though it sometimes succeeds in connecting, we get a bad response during uploading after a few blocks.
108
+// Probably our UART ISR cannot receive bytes fast enough, perhaps because of the latency of the system tick ISR.
109
+// 460800b doesn't always manage to connect, but if it does then uploading appears to be reliable.
110
+// 230400b always manages to connect.
111
+static const uint32_t uploadBaudRates[] = { 460800, 230400, 115200, 74880 };
112
+
113
+
114
+
115
+signed char IsReady() {
116
+  return esp_upload.state == upload_idle;
117
+}
118
+
119
+
120
+
121
+
122
+
123
+void uploadPort_write(const uint8_t *buf, size_t len) {
124
+  #if 0
125
+  int i;
126
+
127
+  for(i = 0; i < len; i++) {
128
+    while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
129
+
130
+      USART_SendData(USART1, *(buf + i));
131
+  }
132
+  #endif
133
+}
134
+
135
+char uploadPort_read() {
136
+  uint8_t retChar;
137
+  if (readUsartFifo(&WifiRxFifo, (int8_t *)&retChar, 1) == 1)
138
+    return retChar;
139
+  else
140
+    return 0;
141
+
142
+}
143
+
144
+int uploadPort_available() {
145
+  return usartFifoAvailable(&WifiRxFifo);
146
+}
147
+
148
+
149
+void uploadPort_begin() {
150
+  esp_port_begin(1);
151
+}
152
+
153
+void uploadPort_close() {
154
+
155
+  //WIFI_COM.end();
156
+  //WIFI_COM.begin(115200, true);
157
+
158
+  esp_port_begin(0);
159
+
160
+}
161
+
162
+
163
+void flushInput() {
164
+  while (uploadPort_available() != 0) {
165
+    (void)uploadPort_read();
166
+    //IWDG_ReloadCounter();
167
+  }
168
+}
169
+
170
+// Extract 1-4 bytes of a value in little-endian order from a buffer beginning at a specified offset
171
+uint32_t getData(unsigned byteCnt, const uint8_t *buf, int ofst) {
172
+  uint32_t val = 0;
173
+
174
+  if (buf && byteCnt) {
175
+    unsigned int shiftCnt = 0;
176
+    if (byteCnt > 4)
177
+      byteCnt = 4;
178
+    do{
179
+      val |= (uint32_t)buf[ofst++] << shiftCnt;
180
+      shiftCnt += 8;
181
+    } while (--byteCnt);
182
+  }
183
+  return(val);
184
+}
185
+
186
+// Put 1-4 bytes of a value in little-endian order into a buffer beginning at a specified offset.
187
+void putData(uint32_t val, unsigned byteCnt, uint8_t *buf, int ofst) {
188
+  if (buf && byteCnt) {
189
+    if (byteCnt > 4) {
190
+      byteCnt = 4;
191
+    }
192
+    do {
193
+      buf[ofst++] = (uint8_t)(val & 0xff);
194
+      val >>= 8;
195
+    } while (--byteCnt);
196
+  }
197
+}
198
+
199
+// Read a byte optionally performing SLIP decoding.  The return values are:
200
+//
201
+//  2 - an escaped byte was read successfully
202
+//  1 - a non-escaped byte was read successfully
203
+//  0 - no data was available
204
+//   -1 - the value 0xc0 was encountered (shouldn't happen)
205
+//   -2 - a SLIP escape byte was found but the following byte wasn't available
206
+//   -3 - a SLIP escape byte was followed by an invalid byte
207
+int ReadByte(uint8_t *data, signed char slipDecode) {
208
+  if (uploadPort_available() == 0) {
209
+    return(0);
210
+  }
211
+
212
+  // at least one byte is available
213
+  *data = uploadPort_read();
214
+  if (!slipDecode) {
215
+    return(1);
216
+  }
217
+
218
+  if (*data == 0xc0) {
219
+    // this shouldn't happen
220
+    return(-1);
221
+  }
222
+
223
+  // if not the SLIP escape, we're done
224
+  if (*data != 0xdb) {
225
+    return(1);
226
+  }
227
+
228
+  // SLIP escape, check availability of subsequent byte
229
+  if (uploadPort_available() == 0) {
230
+    return(-2);
231
+  }
232
+
233
+  // process the escaped byte
234
+  *data = uploadPort_read();
235
+  if (*data == 0xdc) {
236
+    *data = 0xc0;
237
+    return(2);
238
+  }
239
+
240
+  if (*data == 0xdd) {
241
+    *data = 0xdb;
242
+    return(2);
243
+  }
244
+  // invalid
245
+  return(-3);
246
+}
247
+// When we write a sync packet, there must be no gaps between most of the characters.
248
+// So use this function, which does a block write to the UART buffer in the latest CoreNG.
249
+void _writePacketRaw(const uint8_t *buf, size_t len) {
250
+  uploadPort_write(buf, len);
251
+}
252
+
253
+// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
254
+void WriteByteRaw(uint8_t b) {
255
+  uploadPort_write((const uint8_t *)&b, 1);
256
+}
257
+
258
+// Write a byte to the serial port optionally SLIP encoding. Return the number of bytes actually written.
259
+void WriteByteSlip(uint8_t b) {
260
+  if (b == 0xC0) {
261
+    WriteByteRaw(0xDB);
262
+    WriteByteRaw(0xDC);
263
+  }
264
+  else if (b == 0xDB) {
265
+    WriteByteRaw(0xDB);
266
+    WriteByteRaw(0xDD);
267
+  }
268
+  else {
269
+    uploadPort_write((const uint8_t *)&b, 1);
270
+  }
271
+}
272
+
273
+// Wait for a data packet to be returned.  If the body of the packet is
274
+// non-zero length, return an allocated buffer indirectly containing the
275
+// data and return the data length. Note that if the pointer for returning
276
+// the data buffer is NULL, the response is expected to be two bytes of zero.
277
+//
278
+// If an error occurs, return a negative value.  Otherwise, return the number
279
+// of bytes in the response (or zero if the response was not the standard "two bytes of zero").
280
+EspUploadResult readPacket(uint8_t op, uint32_t *valp, size_t *bodyLen, uint32_t msTimeout) {
281
+  typedef enum {
282
+    begin = 0,
283
+    header,
284
+    body,
285
+    end,
286
+    done
287
+  } PacketState;
288
+
289
+  uint8_t resp, opRet;
290
+
291
+  const size_t headerLength = 8;
292
+
293
+  uint32_t startTime = getWifiTick();
294
+  uint8_t hdr[headerLength];
295
+  uint16_t hdrIdx = 0;
296
+
297
+  uint16_t bodyIdx = 0;
298
+  uint8_t respBuf[2];
299
+
300
+  // wait for the response
301
+  uint16_t needBytes = 1;
302
+
303
+  PacketState state = begin;
304
+
305
+  *bodyLen = 0;
306
+
307
+
308
+  while (state != done) {
309
+    uint8_t c;
310
+    EspUploadResult stat;
311
+
312
+    //IWDG_ReloadCounter();
313
+
314
+    if (getWifiTickDiff(startTime, getWifiTick()) > msTimeout) {
315
+      return(timeout);
316
+    }
317
+
318
+    if (uploadPort_available() < needBytes) {
319
+      // insufficient data available
320
+      // preferably, return to Spin() here
321
+      continue;
322
+    }
323
+
324
+    // sufficient bytes have been received for the current state, process them
325
+    switch(state) {
326
+    case begin: // expecting frame start
327
+      c = uploadPort_read();
328
+      if (c != (uint8_t)0xc0) {
329
+        break;
330
+      }
331
+      state = header;
332
+      needBytes = 2;
333
+
334
+      break;
335
+    case end:   // expecting frame end
336
+      c = uploadPort_read();
337
+      if (c != (uint8_t)0xc0) {
338
+        return slipFrame;
339
+      }
340
+      state = done;
341
+
342
+      break;
343
+
344
+    case header:  // reading an 8-byte header
345
+    case body:    // reading the response body
346
+      {
347
+        int rslt;
348
+        // retrieve a byte with SLIP decoding
349
+        rslt = ReadByte(&c, 1);
350
+        if (rslt != 1 && rslt != 2) {
351
+          // some error occurred
352
+          stat = (rslt == 0 || rslt == -2) ? slipData : slipFrame;
353
+          return stat;
354
+        }
355
+        else if (state == header) {
356
+          //store the header byte
357
+          hdr[hdrIdx++] = c;
358
+          if (hdrIdx >= headerLength) {
359
+            // get the body length, prepare a buffer for it
360
+            *bodyLen = (uint16_t)getData(2, hdr, 2);
361
+
362
+            // extract the value, if requested
363
+            if (valp != 0) {
364
+              *valp = getData(4, hdr, 4);
365
+            }
366
+
367
+            if (*bodyLen != 0) {
368
+              state = body;
369
+            }
370
+            else {
371
+              needBytes = 1;
372
+              state = end;
373
+            }
374
+          }
375
+        }
376
+        else {
377
+          // Store the response body byte, check for completion
378
+          if (bodyIdx < ARRAY_SIZE(respBuf)) {
379
+            respBuf[bodyIdx] = c;
380
+          }
381
+          ++bodyIdx;
382
+          if (bodyIdx >= *bodyLen) {
383
+            needBytes = 1;
384
+            state = end;
385
+          }
386
+        }
387
+      }
388
+      break;
389
+
390
+    default:    // this shouldn't happen
391
+      return slipState;
392
+    }
393
+  }
394
+
395
+  // Extract elements from the header
396
+  resp = (uint8_t)getData(1, hdr, 0);
397
+  opRet = (uint8_t)getData(1, hdr, 1);
398
+  // Sync packets often provoke a response with a zero opcode instead of ESP_SYNC
399
+  if (resp != 0x01 || opRet != op) {
400
+//debug//printf("resp %02x %02x\n", resp, opRet);
401
+    return respHeader;
402
+  }
403
+
404
+  return success;
405
+}
406
+
407
+// Send a block of data performing SLIP encoding of the content.
408
+void _writePacket(const uint8_t *data, size_t len) {
409
+  unsigned char outBuf[2048] = {0};
410
+  unsigned int outIndex = 0;
411
+  while (len != 0) {
412
+    if (*data == 0xC0) {
413
+      outBuf[outIndex++] = 0xDB;
414
+      outBuf[outIndex++] = 0xDC;
415
+    }
416
+    else if (*data == 0xDB) {
417
+      outBuf[outIndex++] = 0xDB;
418
+      outBuf[outIndex++] = 0xDD;
419
+    }
420
+    else {
421
+      outBuf[outIndex++] = *data;
422
+
423
+    }
424
+    data++;
425
+    --len;
426
+  }
427
+  uploadPort_write((const uint8_t *)outBuf, outIndex);
428
+}
429
+
430
+// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
431
+// A SLIP packet begins and ends with 0xc0.  The data encapsulated has the bytes
432
+// 0xc0 and 0xdb replaced by the two-byte sequences {0xdb, 0xdc} and {0xdb, 0xdd} respectively.
433
+
434
+void writePacket(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) {
435
+
436
+  WriteByteRaw(0xc0);       // send the packet start character
437
+  _writePacket(hdr, hdrLen);    // send the header
438
+  _writePacket(data, dataLen);    // send the data block
439
+  WriteByteRaw(0xc0);       // send the packet end character
440
+}
441
+
442
+// Send a packet to the serial port while performing SLIP framing. The packet data comprises a header and an optional data block.
443
+// This is like writePacket except that it does a fast block write for both the header and the main data with no SLIP encoding. Used to send sync commands.
444
+void writePacketRaw(const uint8_t *hdr, size_t hdrLen, const uint8_t *data, size_t dataLen) {
445
+  WriteByteRaw(0xc0);       // send the packet start character
446
+  _writePacketRaw(hdr, hdrLen); // send the header
447
+  _writePacketRaw(data, dataLen); // send the data block in raw mode
448
+  WriteByteRaw(0xc0);       // send the packet end character
449
+}
450
+
451
+// Send a command to the attached device together with the supplied data, if any.
452
+// The data is supplied via a list of one or more segments.
453
+void sendCommand(uint8_t op, uint32_t checkVal, const uint8_t *data, size_t dataLen) {
454
+  // populate the header
455
+  uint8_t hdr[8];
456
+  putData(0, 1, hdr, 0);
457
+  putData(op, 1, hdr, 1);
458
+  putData(dataLen, 2, hdr, 2);
459
+  putData(checkVal, 4, hdr, 4);
460
+
461
+  // send the packet
462
+  //flushInput();
463
+  if (op == ESP_SYNC) {
464
+    writePacketRaw(hdr, sizeof(hdr), data, dataLen);
465
+  }
466
+  else {
467
+    writePacket(hdr, sizeof(hdr), data, dataLen);
468
+  }
469
+}
470
+
471
+// Send a command to the attached device together with the supplied data, if any, and get the response
472
+EspUploadResult doCommand(uint8_t op, const uint8_t *data, size_t dataLen, uint32_t checkVal, uint32_t *valp, uint32_t msTimeout) {
473
+  size_t bodyLen;
474
+  EspUploadResult stat;
475
+
476
+  sendCommand(op, checkVal, data, dataLen);
477
+
478
+  stat = readPacket(op, valp, &bodyLen, msTimeout);
479
+  if (stat == success && bodyLen != 2) {
480
+    stat = badReply;
481
+  }
482
+
483
+  return stat;
484
+}
485
+
486
+// Send a synchronising packet to the serial port in an attempt to induce
487
+// the ESP8266 to auto-baud lock on the baud rate.
488
+EspUploadResult Sync(uint16_t timeout) {
489
+  uint8_t buf[36];
490
+  EspUploadResult stat;
491
+  int i ;
492
+
493
+  // compose the data for the sync attempt
494
+  memset(buf, 0x55, sizeof(buf));
495
+  buf[0] = 0x07;
496
+  buf[1] = 0x07;
497
+  buf[2] = 0x12;
498
+  buf[3] = 0x20;
499
+
500
+  stat = doCommand(ESP_SYNC, buf, sizeof(buf), 0, 0, timeout);
501
+
502
+  // If we got a response other than sync, discard it and wait for a sync response. This happens at higher baud rates.
503
+  for (i = 0; i < 10 && stat == respHeader; ++i) {
504
+    size_t bodyLen;
505
+    stat = readPacket(ESP_SYNC, 0, &bodyLen, timeout);
506
+  }
507
+
508
+  if (stat == success) {
509
+    // Read and discard additional replies
510
+    for (;;) {
511
+      size_t bodyLen;
512
+      EspUploadResult rc = readPacket(ESP_SYNC, 0, &bodyLen, defaultTimeout);
513
+      if (rc != success || bodyLen != 2) {
514
+        break;
515
+      }
516
+    }
517
+  }
518
+  //DEBUG
519
+  //else debug//printf("stat=%d\n", (int)stat);
520
+  return stat;
521
+}
522
+
523
+// Send a command to the device to begin the Flash process.
524
+EspUploadResult flashBegin(uint32_t addr, uint32_t size) {
525
+  // determine the number of blocks represented by the size
526
+  uint32_t blkCnt;
527
+  uint8_t buf[16];
528
+  uint32_t timeout;
529
+
530
+  blkCnt = (size + EspFlashBlockSize - 1) / EspFlashBlockSize;
531
+
532
+  // ensure that the address is on a block boundary
533
+  addr &= ~(EspFlashBlockSize - 1);
534
+
535
+  // begin the Flash process
536
+  putData(size, 4, buf, 0);
537
+  putData(blkCnt, 4, buf, 4);
538
+  putData(EspFlashBlockSize, 4, buf, 8);
539
+  putData(addr, 4, buf, 12);
540
+
541
+  timeout = (size != 0) ? eraseTimeout : defaultTimeout;
542
+  return doCommand(ESP_FLASH_BEGIN, buf, sizeof(buf), 0, 0, timeout);
543
+}
544
+
545
+// Send a command to the device to terminate the Flash process
546
+EspUploadResult flashFinish(signed char reboot) {
547
+  uint8_t buf[4];
548
+  putData(reboot ? 0 : 1, 4, buf, 0);
549
+  return doCommand(ESP_FLASH_END, buf, sizeof(buf), 0, 0, defaultTimeout);
550
+}
551
+
552
+// Compute the checksum of a block of data
553
+uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
554
+  if (data != NULL) {
555
+    while (dataLen--) {
556
+      cksum ^= (uint16_t)*data++;
557
+    }
558
+  }
559
+  return(cksum);
560
+}
561
+
562
+EspUploadResult flashWriteBlock(uint16_t flashParmVal, uint16_t flashParmMask) {
563
+  #if 0
564
+  const uint32_t blkSize = EspFlashBlockSize;
565
+  int i;
566
+
567
+  // Allocate a data buffer for the combined header and block data
568
+  const uint16_t hdrOfst = 0;
569
+  const uint16_t dataOfst = 16;
570
+  const uint16_t blkBufSize = dataOfst + blkSize;
571
+  uint32_t blkBuf32[blkBufSize/4];
572
+  uint8_t * const blkBuf = (uint8_t*)(blkBuf32);
573
+  uint32_t cnt;
574
+  uint16_t cksum;
575
+  EspUploadResult stat;
576
+
577
+  // Prepare the header for the block
578
+  putData(blkSize, 4, blkBuf, hdrOfst + 0);
579
+  putData(esp_upload.uploadBlockNumber, 4, blkBuf, hdrOfst + 4);
580
+  putData(0, 4, blkBuf, hdrOfst + 8);
581
+  putData(0, 4, blkBuf, hdrOfst + 12);
582
+
583
+  // Get the data for the block
584
+  f_read(&esp_upload.uploadFile, blkBuf + dataOfst,  blkSize, &cnt );//->Read(reinterpret_cast<char *>(blkBuf + dataOfst), blkSize);
585
+  if (cnt != blkSize) {
586
+    if (f_tell(&esp_upload.uploadFile) == esp_upload.fileSize) {
587
+      // partial last block, fill the remainder
588
+      memset(blkBuf + dataOfst + cnt, 0xff, blkSize - cnt);
589
+    }
590
+    else {
591
+      return fileRead;
592
+    }
593
+  }
594
+
595
+  // Patch the flash parameters into the first block if it is loaded at address 0
596
+  if (esp_upload.uploadBlockNumber == 0 && esp_upload.uploadAddress == 0 && blkBuf[dataOfst] == ESP_IMAGE_MAGIC && flashParmMask != 0) {
597
+    // update the Flash parameters
598
+    uint32_t flashParm = getData(2, blkBuf + dataOfst + 2, 0) & ~(uint32_t)flashParmMask;
599
+    putData(flashParm | flashParmVal, 2, blkBuf + dataOfst + 2, 0);
600
+  }
601
+
602
+  // Calculate the block checksum
603
+  cksum = checksum(blkBuf + dataOfst, blkSize, ESP_CHECKSUM_MAGIC);
604
+
605
+  for (i = 0; i < 3; i++) {
606
+    if ((stat = doCommand(ESP_FLASH_DATA, blkBuf, blkBufSize, cksum, 0, blockWriteTimeout)) == success) {
607
+      break;
608
+    }
609
+  }
610
+
611
+  //printf("Upload %d\%\n", ftell(&esp_upload.uploadFile) * 100 / esp_upload.fileSize);
612
+
613
+  return stat;
614
+  #endif
615
+}
616
+
617
+void upload_spin() {
618
+  #if 0
619
+  switch (esp_upload.state) {
620
+  case resetting:
621
+
622
+    if (esp_upload.connectAttemptNumber == 9) {
623
+      // Time to give up
624
+      //Network::ResetWiFi();
625
+      esp_upload.uploadResult = connected;
626
+      esp_upload.state = done;
627
+    }
628
+    else{
629
+
630
+      // Reset the serial port at the new baud rate. Also reset the ESP8266.
631
+    //  const uint32_t baud = uploadBaudRates[esp_upload.connectAttemptNumber/esp_upload.retriesPerBaudRate];
632
+      if (esp_upload.connectAttemptNumber % esp_upload.retriesPerBaudRate == 0) {
633
+      }
634
+    //  uploadPort.begin(baud);
635
+    //  uploadPort_close();
636
+
637
+
638
+      uploadPort_begin();
639
+
640
+      wifi_delay(2000);
641
+
642
+      flushInput();
643
+
644
+      esp_upload.lastAttemptTime = esp_upload.lastResetTime = getWifiTick();
645
+      esp_upload.state = connecting;
646
+    }
647
+
648
+    break;
649
+
650
+  case connecting:
651
+    if ((getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= connectAttemptInterval) && (getWifiTickDiff(esp_upload.lastResetTime, getWifiTick()) >= 500)) {
652
+      // Attempt to establish a connection to the ESP8266.
653
+      EspUploadResult res = Sync(5000);
654
+      esp_upload.lastAttemptTime = getWifiTick();
655
+      if (res == success) {
656
+        // Successful connection
657
+//        //MessageF(" success on attempt %d\n", (connectAttemptNumber % retriesPerBaudRate) + 1);
658
+        //printf("connect success\n");
659
+        esp_upload.state = erasing;
660
+      }
661
+      else {
662
+        // This attempt failed
663
+        esp_upload.connectAttemptNumber++;
664
+        if (esp_upload.connectAttemptNumber % retriesPerReset == 0) {
665
+          esp_upload.state = resetting;   // try a reset and a lower baud rate
666
+        }
667
+      }
668
+    }
669
+    break;
670
+
671
+  case erasing:
672
+    if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= blockWriteInterval) {
673
+      uint32_t eraseSize;
674
+      const uint32_t sectorsPerBlock = 16;
675
+      const uint32_t sectorSize = 4096;
676
+      const uint32_t numSectors = (esp_upload.fileSize + sectorSize - 1)/sectorSize;
677
+      const uint32_t startSector = esp_upload.uploadAddress/sectorSize;
678
+      uint32_t headSectors = sectorsPerBlock - (startSector % sectorsPerBlock);
679
+
680
+      if (numSectors < headSectors) {
681
+        headSectors = numSectors;
682
+      }
683
+            eraseSize = (numSectors < 2 * headSectors)
684
+                      ? (numSectors + 1) / 2 * sectorSize
685
+                      : (numSectors - headSectors) * sectorSize;
686
+
687
+      //MessageF("Erasing %u bytes...\n", fileSize);
688
+      esp_upload.uploadResult = flashBegin(esp_upload.uploadAddress, eraseSize);
689
+      if (esp_upload.uploadResult == success) {
690
+        //MessageF("Uploading file...\n");
691
+        esp_upload.uploadBlockNumber = 0;
692
+        esp_upload.uploadNextPercentToReport = percentToReportIncrement;
693
+        esp_upload.lastAttemptTime = getWifiTick();
694
+        esp_upload.state = uploading;
695
+      }
696
+      else {
697
+        //MessageF("Erase failed\n");
698
+        esp_upload.state = done;
699
+      }
700
+    }
701
+    break;
702
+
703
+  case uploading:
704
+    // The ESP needs several milliseconds to recover from one packet before it will accept another
705
+    if (getWifiTickDiff(esp_upload.lastAttemptTime, getWifiTick()) >= 15) {
706
+      unsigned int percentComplete;
707
+      const uint32_t blkCnt = (esp_upload.fileSize + EspFlashBlockSize - 1) / EspFlashBlockSize;
708
+      if (esp_upload.uploadBlockNumber < blkCnt) {
709
+        esp_upload.uploadResult = flashWriteBlock(0, 0);
710
+        esp_upload.lastAttemptTime = getWifiTick();
711
+        if (esp_upload.uploadResult != success) {
712
+          //MessageF("Flash block upload failed\n");
713
+          esp_upload.state = done;
714
+        }
715
+        percentComplete = (100 * esp_upload.uploadBlockNumber)/blkCnt;
716
+        ++esp_upload.uploadBlockNumber;
717
+        if (percentComplete >= esp_upload.uploadNextPercentToReport) {
718
+          //MessageF("%u%% complete\n", percentComplete);
719
+          esp_upload.uploadNextPercentToReport += percentToReportIncrement;
720
+        }
721
+      }
722
+      else {
723
+        esp_upload.state = done;
724
+      }
725
+    }
726
+    break;
727
+
728
+  case done:
729
+    f_close(&esp_upload.uploadFile);
730
+    //uploadPort.end();
731
+    //uploadPort_close();
732
+
733
+    //WIFI_COM.begin(115200, true);
734
+    //wifi_init();
735
+
736
+    if (esp_upload.uploadResult == success) {
737
+      //printf("upload successfully\n");
738
+    }
739
+    else {
740
+      //printf("upload failed\n");
741
+    }
742
+    esp_upload.state = upload_idle;//idle;
743
+    break;
744
+
745
+  default:
746
+    break;
747
+  }
748
+  #endif
749
+}
750
+
751
+// Try to upload the given file at the given address
752
+void SendUpdateFile(const char *file, uint32_t address) {
753
+  #if 0
754
+  FRESULT res = f_open(&esp_upload.uploadFile, file,  FA_OPEN_EXISTING | FA_READ);
755
+
756
+  if (res !=  FR_OK) return;
757
+
758
+    esp_upload.fileSize = f_size(&esp_upload.uploadFile);
759
+  if (esp_upload.fileSize == 0) {
760
+    f_close(&esp_upload.uploadFile);
761
+    return;
762
+  }
763
+  f_lseek(&esp_upload.uploadFile, 0);
764
+
765
+  esp_upload.uploadAddress = address;
766
+  esp_upload.connectAttemptNumber = 0;
767
+  esp_upload.state = resetting;
768
+  #endif
769
+}
770
+
771
+static const uint32_t FirmwareAddress = 0x00000000, WebFilesAddress = 0x00100000;
772
+
773
+void ResetWiFiForUpload(int begin_or_end) {
774
+  #if 0
775
+    uint32_t start, now;
776
+
777
+    GPIO_InitTypeDef GPIO_InitStructure;
778
+
779
+    #if V1_0_V1_1
780
+      GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
781
+      GPIO_InitStructure.Pin = GPIO_Pin_8;
782
+      GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
783
+      HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
784
+    #else
785
+      GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
786
+      GPIO_InitStructure.Pin = GPIO_Pin_13;
787
+      GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
788
+      HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
789
+    #endif
790
+    start = getWifiTick();
791
+    now = start;
792
+
793
+    if (begin_or_end == 0) {
794
+      #if V1_0_V1_1
795
+        HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_RESET); //update mode
796
+      #else
797
+        HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_RESET); //update mode
798
+      #endif
799
+    }
800
+    else {
801
+      #if V1_0_V1_1
802
+        #if V1_0_V1_1
803
+          HAL_GPIO_WritePin(GPIOA,GPIO_Pin_8,GPIO_PIN_SET); //boot mode
804
+          GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH;
805
+          GPIO_InitStructure.Pin = GPIO_Pin_8;
806
+          GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
807
+          HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
808
+        #endif
809
+      #else
810
+        HAL_GPIO_WritePin(GPIOC,GPIO_Pin_13,GPIO_PIN_SET); //boot mode
811
+        GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
812
+        GPIO_InitStructure.Pin = GPIO_Pin_13;
813
+        GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
814
+        HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
815
+      #endif
816
+    }
817
+    WIFI_RESET();
818
+    while (getWifiTickDiff(start, now) < 500) now = getWifiTick();
819
+    WIFI_SET();
820
+  #endif
821
+}
822
+
823
+int32_t wifi_upload(int type) {
824
+  esp_upload.retriesPerBaudRate = 9;
825
+
826
+  ResetWiFiForUpload(0);
827
+
828
+  if (type == 0)
829
+    SendUpdateFile(ESP_FIRMWARE_FILE, FirmwareAddress);
830
+  else if (type == 1)
831
+    SendUpdateFile(ESP_WEB_FIRMWARE_FILE, FirmwareAddress);
832
+  else if (type == 2)
833
+    SendUpdateFile(ESP_WEB_FILE, WebFilesAddress);
834
+  else
835
+    return -1;
836
+
837
+  while (esp_upload.state != upload_idle) {
838
+    upload_spin();
839
+    //IWDG_ReloadCounter();
840
+  }
841
+
842
+  ResetWiFiForUpload(1);
843
+
844
+  return esp_upload.uploadResult == success ? 0 : -1;
845
+}
846
+
847
+#endif  // HAS_TFT_LVGL_UI

+ 74
- 0
Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.h View File

@@ -0,0 +1,74 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+#ifdef __cplusplus
25
+  extern "C" { /* C-declarations for C++ */
26
+#endif
27
+
28
+#define ESP_FIRMWARE_FILE     "1:/MksWifi.bin"
29
+#define ESP_WEB_FIRMWARE_FILE "1:/MksWifi_Web.bin"
30
+#define ESP_WEB_FILE          "1:/MksWifi_WebView.bin"
31
+
32
+typedef enum {
33
+  upload_idle,
34
+  resetting,
35
+  connecting,
36
+  erasing,
37
+  uploading,
38
+  done
39
+} UploadState;
40
+
41
+typedef enum {
42
+  success = 0,
43
+  timeout,
44
+  connected,
45
+  badReply,
46
+  fileRead,
47
+  emptyFile,
48
+  respHeader,
49
+  slipFrame,
50
+  slipState,
51
+  slipData,
52
+} EspUploadResult;
53
+
54
+typedef struct {
55
+  //FIL  uploadFile;
56
+  uint32_t fileSize;
57
+
58
+  uint32_t uploadAddress;
59
+  UploadState state;
60
+  uint32_t retriesPerBaudRate;
61
+  uint32_t connectAttemptNumber;
62
+  uint32_t lastAttemptTime;
63
+  uint32_t lastResetTime;
64
+  uint32_t uploadBlockNumber;
65
+  uint32_t uploadNextPercentToReport;
66
+  EspUploadResult uploadResult;
67
+} UPLOAD_STRUCT;
68
+
69
+extern UPLOAD_STRUCT esp_upload;
70
+int32_t wifi_upload(int type);
71
+
72
+#ifdef __cplusplus
73
+  } /* C-declarations for C++ */
74
+#endif

+ 7
- 7
Marlin/src/module/stepper.h View File

@@ -253,6 +253,13 @@ class Stepper {
253 253
       static bool initialized;
254 254
     #endif
255 255
 
256
+    // Last-moved extruder, as set when the last movement was fetched from planner
257
+    #if HAS_MULTI_EXTRUDER
258
+      static uint8_t last_moved_extruder;
259
+    #else
260
+      static constexpr uint8_t last_moved_extruder = 0;
261
+    #endif
262
+
256 263
   private:
257 264
 
258 265
     static block_t* current_block;          // A pointer to the block currently being traced
@@ -262,13 +269,6 @@ class Stepper {
262 269
 
263 270
     static bool abort_current_block;        // Signals to the stepper that current block should be aborted
264 271
 
265
-    // Last-moved extruder, as set when the last movement was fetched from planner
266
-    #if HAS_MULTI_EXTRUDER
267
-      static uint8_t last_moved_extruder;
268
-    #else
269
-      static constexpr uint8_t last_moved_extruder = 0;
270
-    #endif
271
-
272 272
     #if ENABLED(X_DUAL_ENDSTOPS)
273 273
       static bool locked_X_motor, locked_X2_motor;
274 274
     #endif

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

@@ -526,6 +526,8 @@
526 526
   #include "stm32f1/pins_MKS_ROBIN_E3.h"        // STM32F1                                env:mks_robin_e3
527 527
 #elif MB(MKS_ROBIN_E3D)
528 528
   #include "stm32f1/pins_MKS_ROBIN_E3D.h"       // STM32F1                                env:mks_robin_e3
529
+#elif MB(MKS_ROBIN_E3P)
530
+  #include "stm32f1/pins_MKS_ROBIN_E3P.h"       // STM32F1                                env:mks_robin_e3p
529 531
 #elif MB(BTT_SKR_MINI_V1_1)
530 532
   #include "stm32f1/pins_BTT_SKR_MINI_V1_1.h"   // STM32F1                                env:STM32F103RC_btt env:STM32F103RC_btt_512K env:STM32F103RC_btt_USB env:STM32F103RC_btt_512K_USB
531 533
 #elif MB(BTT_SKR_MINI_E3_V1_0)

+ 377
- 0
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h View File

@@ -0,0 +1,377 @@
1
+/**
2
+ * Marlin 3D Printer Firmware
3
+ * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4
+ *
5
+ * Based on Sprinter and grbl.
6
+ * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License as published by
10
+ * the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ * GNU General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
+ *
21
+ */
22
+#pragma once
23
+
24
+/**
25
+ * MKS Robin nano (STM32F130VET6) board pin assignments
26
+ */
27
+
28
+#ifndef __STM32F1__
29
+  #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
30
+#elif HOTENDS > 1 || E_STEPPERS > 1
31
+  #error "MKS Robin e3p supports up to 1 hotends / E-steppers. Comment out this line to continue."
32
+#elif HAS_FSMC_TFT
33
+  #error "MKS Robin e3p doesn't support FSMC-based TFT displays."
34
+#endif
35
+
36
+#define BOARD_INFO_NAME "MKS Robin e3p"
37
+
38
+//
39
+// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
40
+//
41
+
42
+#define DISABLE_DEBUG
43
+
44
+//
45
+// EEPROM
46
+//
47
+//#define FLASH_EEPROM_EMULATION
48
+//#define SDCARD_EEPROM_EMULATION
49
+
50
+#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM)
51
+  #define I2C_EEPROM                              // EEPROM on I2C-0
52
+  #define MARLIN_EEPROM_SIZE              0x1000  // 4KB
53
+#endif
54
+
55
+//
56
+// Note: MKS Robin board is using SPI2 interface.
57
+//
58
+//#define SPI_MODULE                           2
59
+#define ENABLE_SPI2
60
+
61
+//
62
+// Limit Switches
63
+//
64
+#define X_DIAG_PIN                          PA15
65
+#define Y_DIAG_PIN                          PA12
66
+#define Z_DIAG_PIN                          PA11
67
+#define E0_DIAG_PIN                         PC4
68
+
69
+#define X_STOP_PIN                          PA15
70
+#define Y_STOP_PIN                          PA12
71
+#define Z_MIN_PIN                           PA11
72
+#define Z_MAX_PIN                           PC4
73
+
74
+//
75
+// Steppers
76
+//
77
+#define X_ENABLE_PIN                        PE4
78
+#define X_STEP_PIN                          PE3
79
+#define X_DIR_PIN                           PE2
80
+#ifndef X_CS_PIN
81
+  #define X_CS_PIN                          PD5
82
+#endif
83
+
84
+#define Y_ENABLE_PIN                        PE1
85
+#define Y_STEP_PIN                          PE0
86
+#define Y_DIR_PIN                           PB9
87
+#ifndef Y_CS_PIN
88
+  #define Y_CS_PIN                          PD7
89
+#endif
90
+
91
+#define Z_ENABLE_PIN                        PB8
92
+#define Z_STEP_PIN                          PB5
93
+#define Z_DIR_PIN                           PB4
94
+#ifndef Z_CS_PIN
95
+  #define Z_CS_PIN                          PD4
96
+#endif
97
+
98
+#define E0_ENABLE_PIN                       PB3
99
+#define E0_STEP_PIN                         PD6
100
+#define E0_DIR_PIN                          PD3
101
+#ifndef E0_CS_PIN
102
+  #define E0_CS_PIN                         PD9
103
+#endif
104
+
105
+//
106
+// Software SPI pins for TMC2130 stepper drivers
107
+//
108
+#if ENABLED(TMC_USE_SW_SPI)
109
+  #ifndef TMC_SW_MOSI
110
+    #define TMC_SW_MOSI                     PD14
111
+  #endif
112
+  #ifndef TMC_SW_MISO
113
+    #define TMC_SW_MISO                     PD1
114
+  #endif
115
+  #ifndef TMC_SW_SCK
116
+    #define TMC_SW_SCK                      PD0
117
+  #endif
118
+#endif
119
+
120
+#if HAS_TMC_UART
121
+  /**
122
+   * TMC2208/TMC2209 stepper drivers
123
+   *
124
+   * Hardware serial communication ports.
125
+   * If undefined software serial is used according to the pins below
126
+   */
127
+  //#define X_HARDWARE_SERIAL  Serial
128
+  //#define X2_HARDWARE_SERIAL Serial1
129
+  //#define Y_HARDWARE_SERIAL  Serial1
130
+  //#define Y2_HARDWARE_SERIAL Serial1
131
+  //#define Z_HARDWARE_SERIAL  Serial1
132
+  //#define Z2_HARDWARE_SERIAL Serial1
133
+  //#define E0_HARDWARE_SERIAL Serial1
134
+  //#define E1_HARDWARE_SERIAL Serial1
135
+  //#define E2_HARDWARE_SERIAL Serial1
136
+  //#define E3_HARDWARE_SERIAL Serial1
137
+  //#define E4_HARDWARE_SERIAL Serial1
138
+
139
+  //
140
+  // Software serial
141
+  //
142
+
143
+  #define X_SERIAL_TX_PIN                   PD5
144
+  #define X_SERIAL_RX_PIN                   PD5
145
+
146
+  #define Y_SERIAL_TX_PIN                   PD7
147
+  #define Y_SERIAL_RX_PIN                   PD7
148
+
149
+  #define Z_SERIAL_TX_PIN                   PD4
150
+  #define Z_SERIAL_RX_PIN                   PD4
151
+
152
+  #define E0_SERIAL_TX_PIN                  PD9
153
+  #define E0_SERIAL_RX_PIN                  PD9
154
+
155
+  // Reduce baud rate to improve software serial reliability
156
+  #define TMC_BAUD_RATE                    19200
157
+#endif // TMC2208 || TMC2209
158
+
159
+//
160
+// Temperature Sensors
161
+//
162
+#define TEMP_0_PIN                          PC1   // TH1
163
+#define TEMP_BED_PIN                        PC0   // TB1
164
+
165
+//
166
+// Heaters / Fans
167
+//
168
+#define HEATER_0_PIN                        PC3   // HEATER1
169
+#define HEATER_BED_PIN                      PA0   // HOT BED
170
+
171
+#define FAN_PIN                             PB1   // FAN
172
+
173
+//
174
+// Misc. Functions
175
+//
176
+#if HAS_TFT_LVGL_UI
177
+  //#define MKSPWC
178
+  #ifdef MKSPWC
179
+    #define SUICIDE_PIN                     PB2   // Enable MKSPWC SUICIDE PIN
180
+    #define SUICIDE_PIN_INVERTING          false  // Enable MKSPWC PIN STATE
181
+    #define KILL_PIN                        PA2   // Enable MKSPWC DET PIN
182
+    #define KILL_PIN_STATE                  true  // Enable MKSPWC PIN STATE
183
+  #endif
184
+
185
+  #define MT_DET_1_PIN                      PA4   // LVGL UI FILAMENT RUNOUT1 PIN
186
+  #define MT_DET_PIN_INVERTING             false  // LVGL UI filament RUNOUT PIN STATE
187
+ 
188
+  #define WIFI_IO0_PIN                      PC13  // MKS ESP WIFI IO0 PIN
189
+  #define WIFI_IO1_PIN                      PC7   // MKS ESP WIFI IO1 PIN
190
+  #define WIFI_RESET_PIN                    PE9   // MKS ESP WIFI RESET PIN
191
+
192
+  #if ENABLED(MKS_TEST)
193
+    #define MKS_TEST_POWER_LOSS_PIN         PA2   // PW_DET
194
+    #define MKS_TEST_PS_ON_PIN              PB0   // PW_OFF
195
+  #endif
196
+#else
197
+  //#define POWER_LOSS_PIN                  PA2   // PW_DET
198
+  //#define PS_ON_PIN                       PB2   // PW_OFF
199
+  #define FIL_RUNOUT_PIN                    PA4
200
+#endif
201
+
202
+#define SERVO0_PIN                          PA8   // Enable BLTOUCH
203
+
204
+//#define LED_PIN                           PB2
205
+
206
+//
207
+// SD Card
208
+//
209
+#ifndef SDCARD_CONNECTION
210
+  #define SDCARD_CONNECTION              ONBOARD
211
+#endif
212
+
213
+#define SDIO_SUPPORT
214
+#define SDIO_CLOCK                       4500000  // 4.5 MHz
215
+#define SD_DETECT_PIN                       PD12
216
+#define ONBOARD_SD_CS_PIN                   PC11
217
+
218
+//
219
+// LCD / Controller
220
+//
221
+#ifndef BEEPER_PIN
222
+  #define BEEPER_PIN                        PC5
223
+#endif
224
+
225
+/**
226
+ * Note: MKS Robin TFT screens use various TFT controllers.
227
+ * If the screen stays white, disable 'LCD_RESET_PIN'
228
+ * to let the bootloader init the screen.
229
+ */
230
+
231
+#if HAS_SPI_TFT
232
+
233
+  // Shared SPI TFT
234
+
235
+  #define LCD_BACKLIGHT_PIN                 PD13
236
+
237
+  #define TOUCH_CS_PIN                      PE14  // SPI1_NSS
238
+  #define TOUCH_SCK_PIN                     PA5   // SPI1_SCK
239
+  #define TOUCH_MISO_PIN                    PA6   // SPI1_MISO
240
+  #define TOUCH_MOSI_PIN                    PA7   // SPI1_MOSI
241
+
242
+  #define BTN_EN1                           PE8
243
+  #define BTN_EN2                           PE11
244
+  #define BTN_ENC                           PE13
245
+
246
+  #define TFT_CS_PIN                        PD11
247
+  #define TFT_SCK_PIN                       PA5
248
+  #define TFT_MISO_PIN                      PA6
249
+  #define TFT_MOSI_PIN                      PA7
250
+  #define TFT_DC_PIN                        PD10
251
+  #define TFT_RST_PIN                       PC6
252
+  #define TFT_A0_PIN                  TFT_DC_PIN
253
+
254
+  #define TFT_RESET_PIN                     PC6
255
+  #define TFT_BACKLIGHT_PIN                 PD13
256
+
257
+  #define TOUCH_BUTTONS_HW_SPI
258
+  #define TOUCH_BUTTONS_HW_SPI_DEVICE          1
259
+
260
+  #ifndef TFT_WIDTH
261
+    #define TFT_WIDTH                        480
262
+  #endif
263
+  #ifndef TFT_HEIGHT
264
+    #define TFT_HEIGHT                       320
265
+  #endif
266
+
267
+  #define LCD_READ_ID                       0xD3
268
+  #define LCD_USE_DMA_SPI
269
+
270
+#endif
271
+
272
+#if ENABLED(TFT_LVGL_UI_SPI)
273
+
274
+  // LVGL
275
+
276
+  #define XPT2046_X_CALIBRATION           -17253
277
+  #define XPT2046_Y_CALIBRATION            11579
278
+  #define XPT2046_X_OFFSET                   514
279
+  #define XPT2046_Y_OFFSET                   -24
280
+
281
+#elif ENABLED(SPI_GRAPHICAL_TFT)
282
+
283
+  // Emulated DOGM SPI
284
+
285
+  #ifndef XPT2046_X_CALIBRATION
286
+    #define XPT2046_X_CALIBRATION         -11386
287
+  #endif
288
+  #ifndef XPT2046_Y_CALIBRATION
289
+    #define XPT2046_Y_CALIBRATION           8684
290
+  #endif
291
+  #ifndef XPT2046_X_OFFSET
292
+    #define XPT2046_X_OFFSET                 339
293
+  #endif
294
+  #ifndef XPT2046_Y_OFFSET
295
+    #define XPT2046_Y_OFFSET                 -18
296
+  #endif
297
+
298
+  #ifndef GRAPHICAL_TFT_UPSCALE
299
+    #define GRAPHICAL_TFT_UPSCALE              3
300
+  #endif
301
+  #ifndef TFT_PIXEL_OFFSET_Y
302
+    #define TFT_PIXEL_OFFSET_Y                32
303
+  #endif
304
+
305
+  #define BTN_ENC                           PE13
306
+  #define BTN_EN1                           PE8
307
+  #define BTN_EN2                           PE11
308
+
309
+  #define LCD_PINS_ENABLE                   PD13
310
+  #define LCD_PINS_RS                       PC6
311
+
312
+#elif ENABLED(TFT_480x320_SPI)
313
+    #define XPT2046_X_CALIBRATION         -17253
314
+    #define XPT2046_Y_CALIBRATION          11579
315
+    #define XPT2046_X_OFFSET                 514
316
+    #define XPT2046_Y_OFFSET                 -24
317
+
318
+    #define TFT_DRIVER                    ST7796
319
+    #define TFT_BUFFER_SIZE                14400
320
+
321
+#endif
322
+
323
+#if HAS_SPI_LCD && !HAS_SPI_TFT
324
+
325
+  // NON TFT Displays
326
+
327
+  #if ENABLED(MKS_MINI_12864)
328
+
329
+    // MKS MINI12864 and MKS LCD12864B
330
+    // If using MKS LCD12864A (Need to remove RPK2 resistor)
331
+
332
+    #define LCD_BACKLIGHT_PIN               -1
333
+    #define LCD_RESET_PIN                   -1
334
+    #define DOGLCD_A0                       PD11
335
+    #define DOGLCD_CS                       PE15
336
+    #define DOGLCD_SCK                      PA5
337
+    #define DOGLCD_MOSI                     PA7
338
+
339
+    // Required for MKS_MINI_12864 with this board
340
+    #define MKS_LCD12864B
341
+    #undef SHOW_BOOTSCREEN
342
+
343
+  #else                                           // !MKS_MINI_12864
344
+
345
+    #define LCD_PINS_D4                     PE14
346
+    #if ENABLED(ULTIPANEL)
347
+      #define LCD_PINS_D5                   PE15
348
+      #define LCD_PINS_D6                   PD11
349
+      #define LCD_PINS_D7                   PD10
350
+    #endif
351
+
352
+    #ifndef BOARD_ST7920_DELAY_1
353
+      #define BOARD_ST7920_DELAY_1 DELAY_NS(125)
354
+    #endif
355
+    #ifndef BOARD_ST7920_DELAY_2
356
+      #define BOARD_ST7920_DELAY_2 DELAY_NS(125)
357
+    #endif
358
+    #ifndef BOARD_ST7920_DELAY_3
359
+      #define BOARD_ST7920_DELAY_3 DELAY_NS(125)
360
+    #endif
361
+
362
+  #endif // !MKS_MINI_12864
363
+
364
+#endif // HAS_SPI_LCD && !HAS_SPI_TFT
365
+
366
+#define HAS_SPI_FLASH                          1
367
+#define SPI_FLASH_SIZE                 0x1000000  // 16MB
368
+#if HAS_SPI_FLASH
369
+  #define W25QXX_CS_PIN                     PB12
370
+  #define W25QXX_MOSI_PIN                   PB15
371
+  #define W25QXX_MISO_PIN                   PB14
372
+  #define W25QXX_SCK_PIN                    PB13
373
+#endif
374
+
375
+#if ENABLED(SPEAKER) && BEEPER_PIN == PC5
376
+  #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER."
377
+#endif

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

@@ -58,10 +58,6 @@
58 58
 #define Z_MIN_PIN                           PA11
59 59
 #define Z_MAX_PIN                           PC4
60 60
 
61
-#ifndef FIL_RUNOUT_PIN
62
-  #define FIL_RUNOUT_PIN                    PA4   // MT_DET
63
-#endif
64
-
65 61
 //
66 62
 // Steppers
67 63
 //
@@ -123,25 +119,33 @@
123 119
 //
124 120
 // Misc. Functions
125 121
 //
126
-#define POWER_LOSS_PIN                      PA2   // PW_DET
127
-#define PS_ON_PIN                           PA3   // PW_OFF
122
+#if HAS_TFT_LVGL_UI
123
+  //#define MKSPWC
124
+  #ifdef MKSPWC
125
+    #define SUICIDE_PIN                     PB2   // Enable MKSPWC SUICIDE PIN
126
+    #define SUICIDE_PIN_INVERTING          false  // Enable MKSPWC PIN STATE
127
+    #define KILL_PIN                        PA2   // Enable MKSPWC DET PIN
128
+    #define KILL_PIN_STATE                  true  // Enable MKSPWC PIN STATE
129
+  #endif
128 130
 
129
-//#define SUICIDE_PIN                       PB2   // Enable MKSPWC support ROBIN NANO v1.2 ONLY
130
-//#define SUICIDE_PIN_INVERTING            false
131
+  #define MT_DET_1_PIN                      PA4   // LVGL UI FILAMENT RUNOUT1 PIN
132
+  #define MT_DET_2_PIN                      PE6   // LVGL UI FILAMENT RUNOUT2 PIN
133
+  #define MT_DET_PIN_INVERTING             false  // LVGL UI filament RUNOUT PIN STATE
131 134
 
132
-//#define KILL_PIN                          PA2   // Enable MKSPWC support ROBIN NANO v1.2 ONLY
133
-//#define KILL_PIN_INVERTING                true  // Enable MKSPWC support ROBIN NANO v1.2 ONLY
135
+  #define WIFI_IO0_PIN                      PC13  // MKS ESP WIFI IO0 PIN
136
+  #define WIFI_IO1_PIN                      PC7   // MKS ESP WIFI IO1 PIN
137
+  #define WIFI_RESET_PIN                    PA5   // MKS ESP WIFI RESET PIN
138
+#else
139
+  //#define POWER_LOSS_PIN                  PA2   // PW_DET
140
+  //#define PS_ON_PIN                       PB2   // PW_OFF
141
+  #define FIL_RUNOUT_PIN                    PA4
142
+  #define FIL_RUNOUT2_PIN                   PE6
143
+#endif
134 144
 
135
-#define SERVO0_PIN                          PA8   // Enable BLTOUCH support ROBIN NANO v1.2 ONLY
145
+#define SERVO0_PIN                          PA8   // Enable BLTOUCH support
136 146
 
137 147
 //#define LED_PIN                           PB2
138 148
 
139
-#define MT_DET_1_PIN                        PA4
140
-#define MT_DET_2_PIN                        PE6
141
-#define MT_DET_PIN_INVERTING               false
142
-
143
-#define WIFI_IO0_PIN                        PC13
144
-
145 149
 //
146 150
 // SD Card
147 151
 //

+ 27
- 21
Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h View File

@@ -192,32 +192,38 @@
192 192
 //
193 193
 // Misc. Functions
194 194
 //
195
-#define POWER_LOSS_PIN                      PA2   // PW_DET
196
-#define PS_ON_PIN                           PA3   // PW_OFF
197
-
198
-//#define SUICIDE_PIN                       PB2   // Enable MKSPWC support ROBIN NANO v1.2 ONLY
199
-//#define SUICIDE_PIN_INVERTING            false
195
+#if HAS_TFT_LVGL_UI
196
+  //#define MKSPWC
197
+  #ifdef MKSPWC
198
+    #define SUICIDE_PIN                     PB2   // Enable MKSPWC SUICIDE PIN
199
+    #define SUICIDE_PIN_INVERTING          false  // Enable MKSPWC PIN STATE
200
+    #define KILL_PIN                        PA2   // Enable MKSPWC DET PIN
201
+    #define KILL_PIN_STATE                  true  // Enable MKSPWC PIN STATE
202
+  #endif
200 203
 
201
-//#define KILL_PIN                          PA2   // Enable MKSPWC support ROBIN NANO v1.2 ONLY
202
-//#define KILL_PIN_INVERTING                true  // Enable MKSPWC support ROBIN NANO v1.2 ONLY
204
+  #define MT_DET_1_PIN                      PA4   // LVGL UI FILAMENT RUNOUT1 PIN
205
+  #define MT_DET_2_PIN                      PE6   // LVGL UI FILAMENT RUNOUT2 PIN
206
+  #define MT_DET_PIN_INVERTING             false  // LVGL UI filament RUNOUT PIN STATE
207
+ 
208
+  #define WIFI_IO0_PIN                      PC13  // MKS ESP WIFI IO0 PIN
209
+  #define WIFI_IO1_PIN                      PC7   // MKS ESP WIFI IO1 PIN
210
+  #define WIFI_RESET_PIN                    PE9   // MKS ESP WIFI RESET PIN
211
+
212
+  #if ENABLED(MKS_TEST)
213
+    #define MKS_TEST_POWER_LOSS_PIN         PA2   // PW_DET
214
+    #define MKS_TEST_PS_ON_PIN              PB2   // PW_OFF
215
+  #endif
216
+#else
217
+  //#define POWER_LOSS_PIN                  PA2   // PW_DET
218
+  //#define PS_ON_PIN                       PB2   // PW_OFF
219
+  #define FIL_RUNOUT_PIN                    PA4
220
+  #define FIL_RUNOUT2_PIN                   PE6
221
+#endif
203 222
 
204
-#define SERVO0_PIN                          PA8   // Enable BLTOUCH support ROBIN NANO v1.2 ONLY
223
+#define SERVO0_PIN                          PA8   // Enable BLTOUCH
205 224
 
206 225
 //#define LED_PIN                           PB2
207 226
 
208
-#define MT_DET_1_PIN                        PA4
209
-#define MT_DET_2_PIN                        PE6
210
-#define MT_DET_PIN_INVERTING               false
211
-
212
-#ifndef FIL_RUNOUT_PIN
213
-  #define FIL_RUNOUT_PIN            MT_DET_1_PIN
214
-#endif
215
-#ifndef FIL_RUNOUT2_PIN
216
-  #define FIL_RUNOUT2_PIN           MT_DET_2_PIN
217
-#endif
218
-
219
-#define WIFI_IO0_PIN                        PC13
220
-
221 227
 //
222 228
 // SD Card
223 229
 //

+ 14
- 0
buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld View File

@@ -0,0 +1,14 @@
1
+MEMORY
2
+{
3
+  ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K - 40
4
+  rom (rx)  : ORIGIN = 0x08007000, LENGTH = 512K - 28K - 4K
5
+}
6
+
7
+/* Provide memory region aliases for common.inc */
8
+REGION_ALIAS("REGION_TEXT", rom);
9
+REGION_ALIAS("REGION_DATA", ram);
10
+REGION_ALIAS("REGION_BSS", ram);
11
+REGION_ALIAS("REGION_RODATA", rom);
12
+
13
+/* Let common.inc handle the real work. */
14
+INCLUDE common.inc

+ 40
- 0
buildroot/share/PlatformIO/scripts/mks_robin_e3p.py View File

@@ -0,0 +1,40 @@
1
+import os
2
+Import("env")
3
+
4
+# Relocate firmware from 0x08000000 to 0x08007000
5
+for define in env['CPPDEFINES']:
6
+    if define[0] == "VECT_TAB_ADDR":
7
+        env['CPPDEFINES'].remove(define)
8
+env['CPPDEFINES'].append(("VECT_TAB_ADDR", "0x08007000"))
9
+
10
+custom_ld_script = os.path.abspath("buildroot/share/PlatformIO/ldscripts/mks_robin_e3p.ld")
11
+for i, flag in enumerate(env["LINKFLAGS"]):
12
+    if "-Wl,-T" in flag:
13
+        env["LINKFLAGS"][i] = "-Wl,-T" + custom_ld_script
14
+    elif flag == "-T":
15
+        env["LINKFLAGS"][i + 1] = custom_ld_script
16
+
17
+
18
+# Encrypt ${PROGNAME}.bin and save it as 'mks_robin_e3p.bin'
19
+def encrypt(source, target, env):
20
+    import sys
21
+
22
+    key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
23
+
24
+    firmware = open(target[0].path, "rb")
25
+    robin = open(target[0].dir.path +'/Robin_e3p.bin', "wb")
26
+    length = os.path.getsize(target[0].path)
27
+    position = 0
28
+    try:
29
+        while position < length:
30
+            byte = firmware.read(1)
31
+            if position >= 320 and position < 31040:
32
+                byte = chr(ord(byte) ^ key[position & 31])
33
+                if sys.version_info[0] > 2:
34
+                    byte = bytes(byte, 'latin1')
35
+            robin.write(byte)
36
+            position += 1
37
+    finally:
38
+        firmware.close()
39
+        robin.close()
40
+env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", encrypt);

+ 17
- 1
platformio.ini View File

@@ -191,7 +191,7 @@ lib_deps           =
191 191
 # Feature Dependencies
192 192
 #
193 193
 [features]
194
-HAS_TFT_LVGL_UI         = lvgl=https://github.com/makerbase-mks/MKS-LittlevGL/archive/master.zip
194
+HAS_TFT_LVGL_UI         = lvgl=https://github.com/makerbase-mks/LVGL-6.1.1-MKS/archive/master.zip
195 195
                           src_filter=+<src/lcd/extui/lib/mks_ui>
196 196
                           extra_scripts=download_mks_assets.py
197 197
 HAS_TRINAMIC_CONFIG     = TMCStepper@~0.7.1
@@ -956,6 +956,22 @@ build_flags   = ${common_stm32f1.build_flags}
956 956
   -DDEBUG_LEVEL=0 -DSS_TIMER=4
957 957
 
958 958
 #
959
+# MKS Robin E3p (STM32F103VET6)
960
+#  - LVGL UI
961
+#
962
+[env:mks_robin_e3p]
963
+platform        = ${common_stm32f1.platform}
964
+extends         = common_stm32f1
965
+board           = genericSTM32F103VE
966
+platform_packages = tool-stm32duino
967
+extra_scripts   = ${common.extra_scripts}
968
+  buildroot/share/PlatformIO/scripts/mks_robin_e3p.py
969
+build_flags     = ${common_stm32f1.build_flags}
970
+  -DMCU_STM32F103VE -DSS_TIMER=4
971
+debug_tool      = jlink
972
+upload_protocol = jlink
973
+
974
+#
959 975
 # MKS Robin Lite/Lite2 (STM32F103RCT6)
960 976
 #
961 977
 [env:mks_robin_lite]

Loading…
Cancel
Save