Browse Source

More MKS UI cleanup, optimization (#19869)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Victor Oliveira 3 years ago
parent
commit
9630c2683c
No account linked to committer's email address
56 changed files with 2726 additions and 6604 deletions
  1. 15
    9
      Marlin/src/feature/tmc_util.h
  2. 1
    2
      Marlin/src/lcd/extui/lib/mks_ui/SPIFlashStorage.cpp
  3. 12
    20
      Marlin/src/lcd/extui/lib/mks_ui/draw_about.cpp
  4. 72
    275
      Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp
  5. 30
    207
      Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp
  6. 31
    102
      Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp
  7. 59
    141
      Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp
  8. 96
    146
      Marlin/src/lcd/extui/lib/mks_ui/draw_change_speed.cpp
  9. 229
    359
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp
  10. 40
    37
      Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h
  11. 27
    132
      Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp
  12. 17
    57
      Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp
  13. 6
    10
      Marlin/src/lcd/extui/lib/mks_ui/draw_error_message.cpp
  14. 79
    147
      Marlin/src/lcd/extui/lib/mks_ui/draw_extrusion.cpp
  15. 36
    110
      Marlin/src/lcd/extui/lib/mks_ui/draw_fan.cpp
  16. 63
    107
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp
  17. 54
    185
      Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp
  18. 31
    113
      Marlin/src/lcd/extui/lib/mks_ui/draw_home.cpp
  19. 37
    142
      Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp
  20. 37
    127
      Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp
  21. 15
    21
      Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp
  22. 77
    172
      Marlin/src/lcd/extui/lib/mks_ui/draw_language.cpp
  23. 23
    160
      Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp
  24. 29
    178
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp
  25. 28
    157
      Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp
  26. 62
    154
      Marlin/src/lcd/extui/lib/mks_ui/draw_manuaLevel.cpp
  27. 80
    297
      Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp
  28. 54
    208
      Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp
  29. 40
    220
      Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp
  30. 64
    155
      Marlin/src/lcd/extui/lib/mks_ui/draw_move_motor.cpp
  31. 141
    332
      Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp
  32. 66
    112
      Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp
  33. 31
    101
      Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp
  34. 100
    161
      Marlin/src/lcd/extui/lib/mks_ui/draw_preHeat.cpp
  35. 103
    146
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp
  36. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.h
  37. 55
    85
      Marlin/src/lcd/extui/lib/mks_ui/draw_printing.cpp
  38. 10
    8
      Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h
  39. 21
    67
      Marlin/src/lcd/extui/lib/mks_ui/draw_ready_print.cpp
  40. 41
    178
      Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp
  41. 54
    197
      Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp
  42. 79
    245
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp
  43. 55
    281
      Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp
  44. 50
    140
      Marlin/src/lcd/extui/lib/mks_ui/draw_tool.cpp
  45. 202
    52
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp
  46. 77
    47
      Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h
  47. 40
    73
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp
  48. 37
    60
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp
  49. 80
    126
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp
  50. 7
    11
      Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp
  51. 3
    3
      Marlin/src/lcd/extui/lib/mks_ui/gb2312_puhui16.cpp
  52. 1
    1
      Marlin/src/lcd/extui/lib/mks_ui/mks_hardware_test.cpp
  53. 0
    7
      Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp
  54. 13
    17
      Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp
  55. 2
    2
      Marlin/src/lcd/extui/lib/mks_ui/wifi_upload.cpp
  56. 12
    0
      buildroot/tests/mks_robin_nano35-tests

+ 15
- 9
Marlin/src/feature/tmc_util.h View File

@@ -103,9 +103,11 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
103 103
     inline uint16_t get_microstep_counter() { return TMC::MSCNT(); }
104 104
 
105 105
     #if HAS_STEALTHCHOP
106
-      inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
107
-      inline bool get_stealthChop() { return this->en_pwm_mode(); }
108
-      inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
106
+      inline bool get_stealthChop()                { return this->en_pwm_mode(); }
107
+      inline bool get_stored_stealthChop()         { return this->stored.stealthChop_enabled; }
108
+      inline void refresh_stepping_mode()          { this->en_pwm_mode(this->stored.stealthChop_enabled); }
109
+      inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
110
+      inline bool toggle_stepping_mode()           { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
109 111
     #endif
110 112
 
111 113
     #if ENABLED(HYBRID_THRESHOLD)
@@ -170,9 +172,11 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
170 172
     inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); }
171 173
 
172 174
     #if HAS_STEALTHCHOP
173
-      inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
174
-      inline bool get_stealthChop() { return !this->en_spreadCycle(); }
175
-      inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
175
+      inline bool get_stealthChop()                { return !this->en_spreadCycle(); }
176
+      inline bool get_stored_stealthChop()         { return this->stored.stealthChop_enabled; }
177
+      inline void refresh_stepping_mode()          { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
178
+      inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
179
+      inline bool toggle_stepping_mode()           { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
176 180
     #endif
177 181
 
178 182
     #if ENABLED(HYBRID_THRESHOLD)
@@ -216,9 +220,11 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
216 220
     inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); }
217 221
 
218 222
     #if HAS_STEALTHCHOP
219
-      inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
220
-      inline bool get_stealthChop() { return !this->en_spreadCycle(); }
221
-      inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
223
+      inline bool get_stealthChop()                { return !this->en_spreadCycle(); }
224
+      inline bool get_stored_stealthChop()         { return this->stored.stealthChop_enabled; }
225
+      inline void refresh_stepping_mode()          { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
226
+      inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
227
+      inline bool toggle_stepping_mode()           { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
222 228
     #endif
223 229
 
224 230
     #if ENABLED(HYBRID_THRESHOLD)

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

@@ -183,10 +183,9 @@ void SPIFlashStorage::loadPage(uint8_t* buffer) {
183 183
 
184 184
   // Test env
185 185
   // char fname[256];
186
-  // memset(buffer, 0, SPI_FLASH_PageSize);
187 186
   // snprintf(fname, sizeof(fname), "./pages/page-%03d.data", m_currentPage);
188 187
   // FILE *fp = fopen(fname, "rb");
189
-  // if (fp != NULL) {
188
+  // if (fp != nullptr) {
190 189
   //     fread(buffer, 1, SPI_FLASH_PageSize, fp);
191 190
   //     fclose(fp);
192 191
   // }

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

@@ -32,22 +32,18 @@
32 32
 
33 33
 #include "../../../../inc/MarlinConfig.h"
34 34
 
35
-extern lv_group_t * g;
36
-static lv_obj_t * scr;
37
-static lv_obj_t * fw_type, *board; //*fw_version;
35
+extern lv_group_t *g;
36
+static lv_obj_t *scr;
37
+static lv_obj_t *fw_type, *board; //*fw_version;
38 38
 
39
-#define ID_A_RETURN   1
39
+enum { ID_A_RETURN = 1 };
40 40
 
41
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
41
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
42
+  if (event != LV_EVENT_RELEASED) return;
42 43
   switch (obj->mks_obj_id) {
43 44
     case ID_A_RETURN:
44
-      if (event == LV_EVENT_CLICKED) {
45
-        // do nothing
46
-      }
47
-      else if (event == LV_EVENT_RELEASED) {
48
-        clear_cur_ui();
49
-        draw_return_ui();
50
-      }
45
+      clear_cur_ui();
46
+      draw_return_ui();
51 47
       break;
52 48
   }
53 49
 }
@@ -59,11 +55,7 @@ void lv_draw_about(void) {
59 55
   }
60 56
   disp_state = ABOUT_UI;
61 57
 
62
-  scr = lv_obj_create(NULL, NULL);
63
-
64
-  lv_obj_set_style(scr, &tft_style_scr);
65
-  lv_scr_load(scr);
66
-  lv_obj_clean(scr);
58
+  scr = lv_screen_create();
67 59
 
68 60
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
69 61
 
@@ -84,13 +76,13 @@ void lv_draw_about(void) {
84 76
   }
85 77
 
86 78
   //fw_version = lv_label_create(scr, SHORT_BUILD_VERSION);
87
-  //lv_obj_align(fw_version, NULL, LV_ALIGN_CENTER, 0, -60);
79
+  //lv_obj_align(fw_version, nullptr, LV_ALIGN_CENTER, 0, -60);
88 80
 
89 81
   fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION);
90
-  lv_obj_align(fw_type, NULL, LV_ALIGN_CENTER, 0, -20);
82
+  lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20);
91 83
 
92 84
   board = lv_label_create(scr, "Board: " BOARD_INFO_NAME);
93
-  lv_obj_align(board, NULL, LV_ALIGN_CENTER, 0, -60);
85
+  lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -60);
94 86
 }
95 87
 
96 88
 void lv_clear_about() {

+ 72
- 275
Marlin/src/lcd/extui/lib/mks_ui/draw_acceleration_settings.cpp View File

@@ -29,331 +29,128 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_ACCE_RETURN  1
36
-#define ID_ACCE_PRINT   2
37
-#define ID_ACCE_RETRA   3
38
-#define ID_ACCE_TRAVEL  4
39
-#define ID_ACCE_X       5
40
-#define ID_ACCE_Y       6
41
-#define ID_ACCE_Z       7
42
-#define ID_ACCE_E0      8
43
-#define ID_ACCE_E1      9
44
-#define ID_ACCE_UP     10
45
-#define ID_ACCE_DOWN   11
46
-
47
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_ACCE_RETURN = 1,
37
+  ID_ACCE_PRINT,
38
+  ID_ACCE_RETRA,
39
+  ID_ACCE_TRAVEL,
40
+  ID_ACCE_X,
41
+  ID_ACCE_Y,
42
+  ID_ACCE_Z,
43
+  ID_ACCE_E0,
44
+  ID_ACCE_E1,
45
+  ID_ACCE_UP,
46
+  ID_ACCE_DOWN
47
+};
48
+
49
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
50
+  if (event != LV_EVENT_RELEASED) return;
48 51
   switch (obj->mks_obj_id) {
49 52
     case ID_ACCE_RETURN:
50
-      if (event == LV_EVENT_CLICKED) {
51
-
52
-      }
53
-      else if (event == LV_EVENT_RELEASED) {
54
-        uiCfg.para_ui_page = 0;
55
-        lv_clear_acceleration_settings();
56
-        draw_return_ui();
57
-      }
53
+      uiCfg.para_ui_page = 0;
54
+      lv_clear_acceleration_settings();
55
+      draw_return_ui();
58 56
       break;
59 57
     case ID_ACCE_PRINT:
60
-      if (event == LV_EVENT_CLICKED) {
61
-
62
-      }
63
-      else if (event == LV_EVENT_RELEASED) {
64
-        value = PrintAcceleration;
65
-        lv_clear_acceleration_settings();
66
-        lv_draw_number_key();
67
-      }
58
+      value = PrintAcceleration;
59
+      lv_clear_acceleration_settings();
60
+      lv_draw_number_key();
68 61
       break;
69 62
     case ID_ACCE_RETRA:
70
-      if (event == LV_EVENT_CLICKED) {
71
-
72
-      }
73
-      else if (event == LV_EVENT_RELEASED) {
74
-        value = RetractAcceleration;
75
-        lv_clear_acceleration_settings();
76
-        lv_draw_number_key();
77
-      }
63
+      value = RetractAcceleration;
64
+      lv_clear_acceleration_settings();
65
+      lv_draw_number_key();
78 66
       break;
79 67
     case ID_ACCE_TRAVEL:
80
-      if (event == LV_EVENT_CLICKED) {
81
-
82
-      }
83
-      else if (event == LV_EVENT_RELEASED) {
84
-        value = TravelAcceleration;
85
-        lv_clear_acceleration_settings();
86
-        lv_draw_number_key();
87
-      }
68
+      value = TravelAcceleration;
69
+      lv_clear_acceleration_settings();
70
+      lv_draw_number_key();
88 71
       break;
89 72
     case ID_ACCE_X:
90
-      if (event == LV_EVENT_CLICKED) {
91
-
92
-      }
93
-      else if (event == LV_EVENT_RELEASED) {
94
-        value = XAcceleration;
95
-        lv_clear_acceleration_settings();
96
-        lv_draw_number_key();
97
-      }
73
+      value = XAcceleration;
74
+      lv_clear_acceleration_settings();
75
+      lv_draw_number_key();
98 76
       break;
99 77
     case ID_ACCE_Y:
100
-      if (event == LV_EVENT_CLICKED) {
101
-
102
-      }
103
-      else if (event == LV_EVENT_RELEASED) {
104
-        value = YAcceleration;
105
-        lv_clear_acceleration_settings();
106
-        lv_draw_number_key();
107
-      }
78
+      value = YAcceleration;
79
+      lv_clear_acceleration_settings();
80
+      lv_draw_number_key();
108 81
       break;
109 82
     case ID_ACCE_Z:
110
-      if (event == LV_EVENT_CLICKED) {
111
-
112
-      }
113
-      else if (event == LV_EVENT_RELEASED) {
114
-        value = ZAcceleration;
115
-        lv_clear_acceleration_settings();
116
-        lv_draw_number_key();
117
-      }
83
+      value = ZAcceleration;
84
+      lv_clear_acceleration_settings();
85
+      lv_draw_number_key();
118 86
       break;
119 87
     case ID_ACCE_E0:
120
-      if (event == LV_EVENT_CLICKED) {
121
-
122
-      }
123
-      else if (event == LV_EVENT_RELEASED) {
124
-        value = E0Acceleration;
125
-        lv_clear_acceleration_settings();
126
-        lv_draw_number_key();
127
-      }
88
+      value = E0Acceleration;
89
+      lv_clear_acceleration_settings();
90
+      lv_draw_number_key();
128 91
       break;
129 92
     case ID_ACCE_E1:
130
-      if (event == LV_EVENT_CLICKED) {
131
-
132
-      }
133
-      else if (event == LV_EVENT_RELEASED) {
134
-        value = E1Acceleration;
135
-        lv_clear_acceleration_settings();
136
-        lv_draw_number_key();
137
-      }
93
+      value = E1Acceleration;
94
+      lv_clear_acceleration_settings();
95
+      lv_draw_number_key();
138 96
       break;
139 97
     case ID_ACCE_UP:
140
-      if (event == LV_EVENT_CLICKED) {
141
-
142
-      }
143
-      else if (event == LV_EVENT_RELEASED) {
144
-        uiCfg.para_ui_page = 0;
145
-        lv_clear_acceleration_settings();
146
-        lv_draw_acceleration_settings();
147
-      }
98
+      uiCfg.para_ui_page = 0;
99
+      lv_clear_acceleration_settings();
100
+      lv_draw_acceleration_settings();
148 101
       break;
149 102
     case ID_ACCE_DOWN:
150
-      if (event == LV_EVENT_CLICKED) {
151
-
152
-      }
153
-      else if (event == LV_EVENT_RELEASED) {
154
-        uiCfg.para_ui_page = 1;
155
-        lv_clear_acceleration_settings();
156
-        lv_draw_acceleration_settings();
157
-      }
103
+      uiCfg.para_ui_page = 1;
104
+      lv_clear_acceleration_settings();
105
+      lv_draw_acceleration_settings();
158 106
       break;
159 107
   }
160 108
 }
161 109
 
162 110
 void lv_draw_acceleration_settings(void) {
163
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
164
-  lv_obj_t *buttonPrintValue = NULL, *labelPrintValue = NULL;
165
-  lv_obj_t *buttonRetraValue = NULL, *labelRetraValue = NULL;
166
-  lv_obj_t *buttonTravelValue = NULL, *labelTravelValue = NULL;
167
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
168
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
169
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
170
-  lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
171
-  lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
172
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
173 111
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ACCELERATION_UI) {
174 112
     disp_state_stack._disp_index++;
175 113
     disp_state_stack._disp_state[disp_state_stack._disp_index] = ACCELERATION_UI;
176 114
   }
177 115
   disp_state = ACCELERATION_UI;
178 116
 
179
-  scr = lv_obj_create(NULL, NULL);
180
-
181
-  lv_obj_set_style(scr, &tft_style_scr);
182
-  lv_scr_load(scr);
183
-  lv_obj_clean(scr);
117
+  scr = lv_screen_create();
184 118
 
185 119
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AccelerationConfTitle);
186
-
187 120
   lv_refr_now(lv_refr_get_disp_refreshing());
188 121
 
189 122
   if (uiCfg.para_ui_page != 1) {
123
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration);
124
+    lv_screen_menu_item_1_edit(scr, machine_menu.PrintAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_PRINT, 0, public_buf_l);
190 125
 
191
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.PrintAcceleration);
192
-
193
-    buttonPrintValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_PRINT);
194
-    labelPrintValue = lv_label_create_empty(buttonPrintValue);
195
-
196
-    line1 = lv_line_create(scr, NULL);
197
-    lv_ex_line(line1, line_points[0]);
198
-
199
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.RetractAcceleration);
200
-
201
-    buttonRetraValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_RETRA);
202
-    labelRetraValue = lv_label_create_empty(buttonRetraValue);
203
-
204
-    line2 = lv_line_create(scr, NULL);
205
-    lv_ex_line(line2, line_points[1]);
126
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.retract_acceleration);
127
+    lv_screen_menu_item_1_edit(scr, machine_menu.RetractAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_RETRA, 1, public_buf_l);
206 128
 
207
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.TravelAcceleration);
129
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.travel_acceleration);
130
+    lv_screen_menu_item_1_edit(scr, machine_menu.TravelAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_TRAVEL, 2, public_buf_l);
208 131
 
209
-    buttonTravelValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_TRAVEL);
210
-    labelTravelValue = lv_label_create_empty(buttonTravelValue);
132
+    sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
133
+    lv_screen_menu_item_1_edit(scr, machine_menu.X_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_X, 3, public_buf_l);
211 134
 
212
-    line3 = lv_line_create(scr, NULL);
213
-    lv_ex_line(line3, line_points[2]);
214
-
215
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.X_Acceleration);
216
-
217
-    buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_X);
218
-    labelXValue = lv_label_create_empty(buttonXValue);
219
-
220
-    line4 = lv_line_create(scr, NULL);
221
-    lv_ex_line(line4, line_points[3]);
222
-
223
-    buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_ACCE_DOWN);
224
-
225
-    #if HAS_ROTARY_ENCODER
226
-      if (gCfgItems.encoder_enable) {
227
-        lv_group_add_obj(g, buttonPrintValue);
228
-        lv_group_add_obj(g, buttonRetraValue);
229
-        lv_group_add_obj(g, buttonTravelValue);
230
-        lv_group_add_obj(g, buttonXValue);
231
-        lv_group_add_obj(g, buttonTurnPage);
232
-      }
233
-    #endif
135
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_DOWN, true);
234 136
   }
235 137
   else {
236
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.Y_Acceleration);
237
-
238
-    buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_Y);
239
-    labelYValue = lv_label_create_empty(buttonYValue);
138
+    sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
139
+    lv_screen_menu_item_1_edit(scr, machine_menu.Y_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ACCE_Y, 0, public_buf_l);
240 140
 
241
-    line1 = lv_line_create(scr, NULL);
242
-    lv_ex_line(line1, line_points[0]);
141
+    sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
142
+    lv_screen_menu_item_1_edit(scr, machine_menu.Z_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_ACCE_Z, 1, public_buf_l);
243 143
 
244
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Z_Acceleration);
144
+    sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
145
+    lv_screen_menu_item_1_edit(scr, machine_menu.E0_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_ACCE_E0, 2, public_buf_l);
245 146
 
246
-    buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_Z);
247
-    labelZValue = lv_label_create_empty(buttonZValue);
147
+    sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
148
+    lv_screen_menu_item_1_edit(scr, machine_menu.E1_Acceleration, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_ACCE_E1, 3, public_buf_l);
248 149
 
249
-
250
-    line2 = lv_line_create(scr, NULL);
251
-    lv_ex_line(line2, line_points[1]);
252
-
253
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.E0_Acceleration);
254
-
255
-    buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_E0);
256
-    labelE0Value = lv_label_create_empty(buttonE0Value);
257
-
258
-
259
-    line3 = lv_line_create(scr, NULL);
260
-    lv_ex_line(line3, line_points[2]);
261
-
262
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E1_Acceleration);
263
-
264
-    buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_ACCE_E1);
265
-    labelE1Value = lv_label_create_empty(buttonE1Value);
266
-
267
-    line4 = lv_line_create(scr, NULL);
268
-    lv_ex_line(line4, line_points[3]);
269
-
270
-    buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_ACCE_UP);
271
-    //lv_imgbtn_set_src_both(buttonTurnPage, "F:/bmp_back70x40.bin");
272
-    //lv_imgbtn_use_label_style(buttonTurnPage);
273
-
274
-    #if HAS_ROTARY_ENCODER
275
-      if (gCfgItems.encoder_enable) {
276
-        lv_group_add_obj(g, buttonYValue);
277
-        lv_group_add_obj(g, buttonZValue);
278
-        lv_group_add_obj(g, buttonE0Value);
279
-        lv_group_add_obj(g, buttonE1Value);
280
-        lv_group_add_obj(g, buttonTurnPage);
281
-      }
282
-    #endif
150
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_ACCE_UP, true);
283 151
   }
284 152
 
285
-  //lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
286
-  //lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
287
-  //labelTurnPage = lv_label_create_empty(buttonTurnPage);
288
-  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
289
-  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
290
-  labelTurnPage = lv_label_create_empty(buttonTurnPage);
291
-
292
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_ACCE_RETURN);
293
-  //lv_imgbtn_set_src_both(buttonBack, "F:/bmp_back70x40.bin");
294
-  //lv_imgbtn_use_label_style(buttonBack);
295
-  label_Back = lv_label_create_empty(buttonBack);
296
-  #if HAS_ROTARY_ENCODER
297
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
298
-  #endif
299
-
300
-  //lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
301
-  //lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
302
-
303
-  if (gCfgItems.multiple_language) {
304
-    if (uiCfg.para_ui_page != 1) {
305
-
306
-      lv_label_set_text(labelTurnPage, machine_menu.next);
307
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
308
-
309
-      ZERO(public_buf_l);
310
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.acceleration);
311
-      lv_label_set_text(labelPrintValue, public_buf_l);
312
-      lv_obj_align(labelPrintValue, buttonPrintValue, LV_ALIGN_CENTER, 0, 0);
313
-
314
-      ZERO(public_buf_l);
315
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.retract_acceleration);
316
-      lv_label_set_text(labelRetraValue, public_buf_l);
317
-      lv_obj_align(labelRetraValue, buttonRetraValue, LV_ALIGN_CENTER, 0, 0);
318
-
319
-      ZERO(public_buf_l);
320
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.travel_acceleration);
321
-      lv_label_set_text(labelTravelValue, public_buf_l);
322
-      lv_obj_align(labelTravelValue, buttonTravelValue, LV_ALIGN_CENTER, 0, 0);
323
-
324
-      ZERO(public_buf_l);
325
-      sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[X_AXIS]);
326
-      lv_label_set_text(labelXValue, public_buf_l);
327
-      lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
328
-    }
329
-    else {
330
-
331
-      lv_label_set_text(labelTurnPage, machine_menu.previous);
332
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
333
-      ZERO(public_buf_l);
334
-      sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Y_AXIS]);
335
-      lv_label_set_text(labelYValue, public_buf_l);
336
-      lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
337
-
338
-      ZERO(public_buf_l);
339
-      sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[Z_AXIS]);
340
-      lv_label_set_text(labelZValue, public_buf_l);
341
-      lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
342
-
343
-      ZERO(public_buf_l);
344
-      sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
345
-      lv_label_set_text(labelE0Value, public_buf_l);
346
-      lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
347
-
348
-      ZERO(public_buf_l);
349
-      sprintf_P(public_buf_l, PSTR("%d"), (int)planner.settings.max_acceleration_mm_per_s2[E_AXIS_N(1)]);
350
-      lv_label_set_text(labelE1Value, public_buf_l);
351
-      lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
352
-    }
353
-
354
-    lv_label_set_text(label_Back, common_menu.text_back);
355
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
356
-  }
153
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ACCE_RETURN, true);
357 154
 }
358 155
 
359 156
 void lv_clear_acceleration_settings() {

+ 30
- 207
Marlin/src/lcd/extui/lib/mks_ui/draw_advance_settings.cpp View File

@@ -28,248 +28,71 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
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
43
-
44
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_ADVANCE_RETURN = 1,
36
+  ID_PAUSE_POS,
37
+  ID_WIFI_PARA,
38
+  ID_FILAMENT_SETTINGS,
39
+  ID_ENCODER_SETTINGS
40
+};
41
+
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
45 43
   switch (obj->mks_obj_id) {
46 44
     case ID_ADVANCE_RETURN:
47
-      if (event == LV_EVENT_CLICKED) {
48
-
49
-      }
50
-      else if (event == LV_EVENT_RELEASED) {
51
-        lv_clear_advance_settings();
52
-        draw_return_ui();
53
-      }
45
+      lv_clear_advance_settings();
46
+      draw_return_ui();
54 47
       break;
55 48
     case ID_PAUSE_POS:
56
-      if (event == LV_EVENT_CLICKED) {
57
-
58
-      }
59
-      else if (event == LV_EVENT_RELEASED) {
60
-        lv_clear_advance_settings();
61
-        lv_draw_pause_position();
62
-      }
63
-      break;
64
-    case ID_PAUSE_POS_ARROW:
65
-      if (event == LV_EVENT_CLICKED) {
66
-
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        lv_clear_advance_settings();
70
-        lv_draw_pause_position();
71
-      }
49
+      lv_clear_advance_settings();
50
+      lv_draw_pause_position();
72 51
       break;
73 52
     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
-      }
53
+      lv_clear_advance_settings();
54
+      lv_draw_filament_settings();
90 55
       break;
91 56
     #if ENABLED(USE_WIFI_FUNCTION)
92 57
       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
-      }
58
+      lv_clear_advance_settings();
59
+      lv_draw_wifi_settings();
109 60
       break;
110 61
     #endif
111 62
     #if HAS_ROTARY_ENCODER
112 63
       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
-        }
64
+        lv_clear_advance_settings();
65
+        lv_draw_encoder_settings();
129 66
         break;
130 67
     #endif
131 68
   }
132 69
 }
133 70
 
134 71
 void lv_draw_advance_settings(void) {
135
-  lv_obj_t *buttonBack, *label_Back;
136
-  lv_obj_t *buttonPausePos, *labelPausePos;
137
-  lv_obj_t *buttonFilamentSettings, *labelFilamentSettings;
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 *buttonEncoder, *labelEncoder, *buttonEncoderNarrow;
144
-  #endif
145
-
146 72
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ADVANCED_UI) {
147 73
     disp_state_stack._disp_index++;
148 74
     disp_state_stack._disp_state[disp_state_stack._disp_index] = ADVANCED_UI;
149 75
   }
150 76
   disp_state = ADVANCED_UI;
151 77
 
152
-  scr = lv_obj_create(NULL, NULL);
153
-
154
-  lv_obj_set_style(scr, &tft_style_scr);
155
-  lv_scr_load(scr);
156
-  lv_obj_clean(scr);
78
+  scr = lv_screen_create();
157 79
 
158 80
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.AdvancedConfTitle);
159 81
 
160 82
   lv_refr_now(lv_refr_get_disp_refreshing());
161 83
 
162
-  buttonPausePos = lv_btn_create(scr, NULL);
163
-  lv_obj_set_pos(buttonPausePos, PARA_UI_POS_X, PARA_UI_POS_Y);
164
-  lv_obj_set_size(buttonPausePos, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
165
-  //lv_obj_set_event_cb(buttonMachine, event_handler);
166
-  lv_obj_set_event_cb_mks(buttonPausePos, event_handler, ID_PAUSE_POS, NULL, 0);
167
-  lv_btn_use_label_style(buttonPausePos);
168
-  lv_btn_set_layout(buttonPausePos, LV_LAYOUT_OFF);
169
-  labelPausePos = lv_label_create_empty(buttonPausePos);
170
-  #if HAS_ROTARY_ENCODER
171
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPausePos);
172
-  #endif
173
-
174
-  (void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_PAUSE_POS_ARROW);
175
-
176
-  line1 = lv_line_create(lv_scr_act(), NULL);
177
-  lv_ex_line(line1, line_points[0]);
178
-
179
-  buttonFilamentSettings = lv_btn_create(scr, NULL);
180
-  lv_obj_set_pos(buttonFilamentSettings, PARA_UI_POS_X, PARA_UI_POS_Y*2);
181
-  lv_obj_set_size(buttonFilamentSettings, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
182
-  lv_obj_set_event_cb_mks(buttonFilamentSettings, event_handler, ID_FILAMENT_SETTINGS, NULL, 0);
183
-  lv_btn_use_label_style(buttonFilamentSettings);
184
-  lv_btn_set_layout(buttonFilamentSettings, LV_LAYOUT_OFF);
185
-  labelFilamentSettings = lv_label_create_empty(buttonFilamentSettings);
186
-  #if HAS_ROTARY_ENCODER
187
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonFilamentSettings);
188
-  #endif
189
-
190
-  (void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y*2 + PARA_UI_ARROW_V, event_handler, ID_FILAMENT_SETTINGS_ARROW);
191
-
192
-  line2 = lv_line_create(lv_scr_act(), NULL);
193
-  lv_ex_line(line2, line_points[1]);
194
-
84
+  int index = 0;
85
+  lv_screen_menu_item(scr, machine_menu.PausePosition, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_POS, index++);
86
+  lv_screen_menu_item(scr, machine_menu.FilamentConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SETTINGS, index++);
195 87
   #if ENABLED(USE_WIFI_FUNCTION)
196
-
197
-    buttonWifiSet = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
198
-    lv_obj_set_pos(buttonWifiSet, PARA_UI_POS_X,PARA_UI_POS_Y*3);
199
-    lv_obj_set_size(buttonWifiSet, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
200
-    lv_obj_set_event_cb_mks(buttonWifiSet, event_handler,ID_WIFI_PARA,NULL, 0);
201
-    lv_btn_use_label_style(buttonWifiSet);
202
-    lv_btn_set_layout(buttonWifiSet, LV_LAYOUT_OFF);
203
-    labelWifiSet = lv_label_create_empty(buttonWifiSet);
204
-    #if HAS_ROTARY_ENCODER
205
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonWifiSet);
206
-    #endif
207
-
208
-    buttonWifiSetNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_WIFI_PARA_ARROW);
209
-
210
-    lv_obj_t * line3 = lv_line_create(scr, NULL);
211
-    lv_ex_line(line3,line_points[2]);
212
-
213
-    #if HAS_ROTARY_ENCODER
214
-      buttonEncoder = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
215
-      lv_obj_set_pos(buttonEncoder, PARA_UI_POS_X,PARA_UI_POS_Y*4);
216
-      lv_obj_set_size(buttonEncoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
217
-      lv_obj_set_event_cb_mks(buttonEncoder, event_handler,ID_ENCODER_SETTINGS,NULL, 0);
218
-      lv_btn_use_label_style(buttonEncoder);
219
-      lv_btn_set_layout(buttonEncoder, LV_LAYOUT_OFF);
220
-      labelEncoder = lv_label_create_empty(buttonEncoder);
221
-
222
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEncoder);
223
-
224
-      buttonEncoderNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V, event_handler, ID_ENCODER_SETTINGS_ARROW);
225
-
226
-      lv_obj_t * line4 = lv_line_create(scr, NULL);
227
-      lv_ex_line(line4,line_points[3]);
228
-    #endif
229
-
230
-  #elif HAS_ROTARY_ENCODER
231
-    buttonEncoder = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
232
-    lv_obj_set_pos(buttonEncoder, PARA_UI_POS_X,PARA_UI_POS_Y*3);
233
-    lv_obj_set_size(buttonEncoder, PARA_UI_SIZE_X,PARA_UI_SIZE_Y);
234
-    lv_obj_set_event_cb_mks(buttonEncoder, event_handler,ID_ENCODER_SETTINGS,NULL, 0);
235
-    lv_btn_use_label_style(buttonEncoder);
236
-    lv_btn_set_layout(buttonEncoder, LV_LAYOUT_OFF);
237
-    labelEncoder = lv_label_create_empty(buttonEncoder);
238
-
239
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonEncoder);
240
-
241
-    buttonEncoderNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_ENCODER_SETTINGS_ARROW);
242
-
243
-    lv_obj_t * line3 = lv_line_create(scr, NULL);
244
-    lv_ex_line(line3,line_points[2]);
88
+    lv_screen_menu_item(scr, machine_menu.WifiSettings, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_WIFI_PARA, index++);
245 89
   #endif
246
-
247
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ADVANCE_RETURN);
248 90
   #if HAS_ROTARY_ENCODER
249
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
91
+    lv_screen_menu_item(scr, machine_menu.EncoderSettings, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_ENCODER_SETTINGS, index);
92
+    index++;
250 93
   #endif
251
-  label_Back = lv_label_create_empty(buttonBack);
252
-
253
-  if (gCfgItems.multiple_language) {
254
-    lv_label_set_text(label_Back, common_menu.text_back);
255
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
256
-
257
-    lv_label_set_text(labelPausePos, machine_menu.PausePosition);
258
-    lv_obj_align(labelPausePos, buttonPausePos, LV_ALIGN_IN_LEFT_MID, 0, 0);
259
-
260
-    lv_label_set_text(labelFilamentSettings, machine_menu.FilamentConf);
261
-    lv_obj_align(labelFilamentSettings, buttonFilamentSettings, LV_ALIGN_IN_LEFT_MID, 0, 0);
262
-
263
-    #if ENABLED(USE_WIFI_FUNCTION)
264
-      lv_label_set_text(labelWifiSet, machine_menu.WifiSettings);
265
-      lv_obj_align(labelWifiSet, buttonWifiSet, LV_ALIGN_IN_LEFT_MID,0, 0);
266
-    #endif
267
-    #if HAS_ROTARY_ENCODER
268
-      lv_label_set_text(labelEncoder, machine_menu.EncoderSettings);
269
-      lv_obj_align(labelEncoder, buttonEncoder, LV_ALIGN_IN_LEFT_MID,0, 0);
270
-    #endif
271
-  }
272 94
 
95
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_ADVANCE_RETURN, true);
273 96
 }
274 97
 
275 98
 void lv_clear_advance_settings() {

+ 31
- 102
Marlin/src/lcd/extui/lib/mks_ui/draw_auto_level_offset_settings.cpp View File

@@ -29,135 +29,64 @@
29 29
 #include "../../../../module/probe.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_OFFSET_RETURN   1
36
-#define ID_OFFSET_X        2
37
-#define ID_OFFSET_Y        3
38
-#define ID_OFFSET_Z        4
39
-
40
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_OFFSET_RETURN = 1,
37
+  ID_OFFSET_X,
38
+  ID_OFFSET_Y,
39
+  ID_OFFSET_Z
40
+};
41
+
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
41 44
   switch (obj->mks_obj_id) {
42 45
     case ID_OFFSET_RETURN:
43
-      if (event == LV_EVENT_CLICKED) {
44
-
45
-      }
46
-      else if (event == LV_EVENT_RELEASED) {
47
-        lv_clear_auto_level_offset_settings();
48
-        draw_return_ui();
49
-      }
46
+      lv_clear_auto_level_offset_settings();
47
+      draw_return_ui();
50 48
       break;
51 49
     case ID_OFFSET_X:
52
-      if (event == LV_EVENT_CLICKED) {
53
-
54
-      }
55
-      else if (event == LV_EVENT_RELEASED) {
56
-        value = x_offset;
57
-        lv_clear_auto_level_offset_settings();
58
-        lv_draw_number_key();
59
-      }
50
+      value = x_offset;
51
+      lv_clear_auto_level_offset_settings();
52
+      lv_draw_number_key();
60 53
       break;
61 54
     case ID_OFFSET_Y:
62
-      if (event == LV_EVENT_CLICKED) {
63
-
64
-      }
65
-      else if (event == LV_EVENT_RELEASED) {
66
-        value = y_offset;
67
-        lv_clear_auto_level_offset_settings();
68
-        lv_draw_number_key();
69
-      }
55
+      value = y_offset;
56
+      lv_clear_auto_level_offset_settings();
57
+      lv_draw_number_key();
70 58
       break;
71 59
     case ID_OFFSET_Z:
72
-      if (event == LV_EVENT_CLICKED) {
73
-
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        value = z_offset;
77
-        lv_clear_auto_level_offset_settings();
78
-        lv_draw_number_key();
79
-      }
60
+      value = z_offset;
61
+      lv_clear_auto_level_offset_settings();
62
+      lv_draw_number_key();
80 63
       break;
81 64
   }
82 65
 }
83 66
 
84 67
 void lv_draw_auto_level_offset_settings(void) {
85
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
86
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
87
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
88
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
89
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
90 68
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NOZZLE_PROBE_OFFSET_UI) {
91 69
     disp_state_stack._disp_index++;
92 70
     disp_state_stack._disp_state[disp_state_stack._disp_index] = NOZZLE_PROBE_OFFSET_UI;
93 71
   }
94 72
   disp_state = NOZZLE_PROBE_OFFSET_UI;
95 73
 
96
-  scr = lv_obj_create(NULL, NULL);
97
-
98
-  lv_obj_set_style(scr, &tft_style_scr);
99
-  lv_scr_load(scr);
100
-  lv_obj_clean(scr);
74
+  scr = lv_screen_create();
101 75
 
102 76
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.OffsetConfTitle);
103 77
 
104 78
   lv_refr_now(lv_refr_get_disp_refreshing());
105 79
 
106
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.Xoffset);
107
-
108
-  buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_X);
109
-  labelXValue = lv_label_create_empty(buttonXValue);
110
-
111
-  line1 = lv_line_create(scr, NULL);
112
-  lv_ex_line(line1, line_points[0]);
113
-
114
-  lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Yoffset);
115
-
116
-  buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_Y);
117
-  labelYValue = lv_label_create_empty(buttonYValue);
118
-
119
-  line2 = lv_line_create(scr, NULL);
120
-  lv_ex_line(line2, line_points[1]);
80
+  sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
81
+  lv_screen_menu_item_1_edit(scr, machine_menu.Xoffset, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_OFFSET_X, 0, public_buf_l);
121 82
 
122
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Zoffset);
83
+  sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
84
+  lv_screen_menu_item_1_edit(scr, machine_menu.Yoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_OFFSET_Y, 1, public_buf_l);
123 85
 
124
-  buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_OFFSET_Z);
125
-  labelZValue = lv_label_create_empty(buttonZValue);
86
+  sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
87
+  lv_screen_menu_item_1_edit(scr, machine_menu.Zoffset, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_OFFSET_Z, 2, public_buf_l);
126 88
 
127
-  line3 = lv_line_create(scr, NULL);
128
-  lv_ex_line(line3, line_points[2]);
129
-
130
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_OFFSET_RETURN);
131
-  label_Back = lv_label_create_empty(buttonBack);
132
-
133
-  #if HAS_ROTARY_ENCODER
134
-    if (gCfgItems.encoder_enable) {
135
-      lv_group_add_obj(g, buttonXValue);
136
-      lv_group_add_obj(g, buttonYValue);
137
-      lv_group_add_obj(g, buttonZValue);
138
-      lv_group_add_obj(g, buttonBack);
139
-    }
140
-  #endif
141
-
142
-  if (gCfgItems.multiple_language) {
143
-    ZERO(public_buf_l);
144
-    sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.x, 0));
145
-    lv_label_set_text(labelXValue, public_buf_l);
146
-    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
147
-
148
-    ZERO(public_buf_l);
149
-    sprintf_P(public_buf_l, PSTR("%.1f"), TERN(HAS_PROBE_XY_OFFSET, probe.offset.y, 0));
150
-    lv_label_set_text(labelYValue, public_buf_l);
151
-    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
152
-
153
-    ZERO(public_buf_l);
154
-    sprintf_P(public_buf_l, PSTR("%.1f"), probe.offset.z);
155
-    lv_label_set_text(labelZValue, public_buf_l);
156
-    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
157
-
158
-    lv_label_set_text(label_Back, common_menu.text_back);
159
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
160
-  }
89
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_OFFSET_RETURN, true);
161 90
 }
162 91
 
163 92
 void lv_clear_auto_level_offset_settings() {

+ 59
- 141
Marlin/src/lcd/extui/lib/mks_ui/draw_baby_stepping.cpp View File

@@ -38,113 +38,75 @@
38 38
   #include "../../../../module/probe.h"
39 39
 #endif
40 40
 
41
-extern lv_group_t * g;
42
-static lv_obj_t * scr;
43
-
44
-static lv_obj_t *labelV, *buttonV, * zOffsetText;
45
-
46
-#define ID_BABY_STEP_X_P    1
47
-#define ID_BABY_STEP_X_N    2
48
-#define ID_BABY_STEP_Y_P    3
49
-#define ID_BABY_STEP_Y_N    4
50
-#define ID_BABY_STEP_Z_P    5
51
-#define ID_BABY_STEP_Z_N    6
52
-#define ID_BABY_STEP_DIST   7
53
-#define ID_BABY_STEP_RETURN 8
41
+extern lv_group_t *g;
42
+static lv_obj_t *scr;
43
+
44
+static lv_obj_t *labelV, *buttonV, *zOffsetText;
45
+
46
+enum {
47
+  ID_BABY_STEP_X_P = 1,
48
+  ID_BABY_STEP_X_N,
49
+  ID_BABY_STEP_Y_P,
50
+  ID_BABY_STEP_Y_N,
51
+  ID_BABY_STEP_Z_P,
52
+  ID_BABY_STEP_Z_N,
53
+  ID_BABY_STEP_DIST,
54
+  ID_BABY_STEP_RETURN
55
+};
54 56
 
55 57
 static float babystep_dist=0.01;
56 58
 static uint8_t has_adjust_z = 0;
57 59
 
58
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
60
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
61
+  if (event != LV_EVENT_RELEASED) return;
59 62
   char baby_buf[30] = { 0 };
60 63
   switch (obj->mks_obj_id) {
61 64
     case ID_BABY_STEP_X_P:
62
-      if (event == LV_EVENT_CLICKED) {
63
-        // nothing to do
64
-      }
65
-      else if (event == LV_EVENT_RELEASED) {
66
-        sprintf_P(baby_buf, PSTR("M290 X%.3f"),babystep_dist);
67
-        gcode.process_subcommands_now_P(PSTR(baby_buf));
68
-        has_adjust_z = 1;
69
-      }
65
+      sprintf_P(baby_buf, PSTR("M290 X%.3f"), babystep_dist);
66
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
67
+      has_adjust_z = 1;
70 68
       break;
71 69
     case ID_BABY_STEP_X_N:
72
-      if (event == LV_EVENT_CLICKED) {
73
-        // nothing to do
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        sprintf_P(baby_buf, PSTR("M290 X%.3f"),((float)0 - babystep_dist));
77
-        gcode.process_subcommands_now_P(PSTR(baby_buf));
78
-        has_adjust_z = 1;
79
-      }
70
+      sprintf_P(baby_buf, PSTR("M290 X%.3f"), -babystep_dist);
71
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
72
+      has_adjust_z = 1;
80 73
       break;
81 74
     case ID_BABY_STEP_Y_P:
82
-      if (event == LV_EVENT_CLICKED) {
83
-        // nothing to do
84
-      }
85
-      else if (event == LV_EVENT_RELEASED) {
86
-        sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
87
-        gcode.process_subcommands_now_P(PSTR(baby_buf));
88
-        has_adjust_z = 1;
89
-      }
75
+      sprintf_P(baby_buf, PSTR("M290 Y%.3f"), babystep_dist);
76
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
77
+      has_adjust_z = 1;
90 78
       break;
91 79
     case ID_BABY_STEP_Y_N:
92
-      if (event == LV_EVENT_CLICKED) {
93
-        // nothing to do
94
-      }
95
-      else if (event == LV_EVENT_RELEASED) {
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
-      }
80
+      sprintf_P(baby_buf, PSTR("M290 Y%.3f"), -babystep_dist);
81
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
82
+      has_adjust_z = 1;
100 83
       break;
101 84
     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
-        sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
107
-        gcode.process_subcommands_now_P(PSTR(baby_buf));
108
-        has_adjust_z = 1;
109
-      }
85
+      sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
86
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
87
+      has_adjust_z = 1;
110 88
       break;
111 89
     case ID_BABY_STEP_Z_N:
112
-      if (event == LV_EVENT_CLICKED) {
113
-        // nothing to do
114
-      }
115
-      else if (event == LV_EVENT_RELEASED) {
116
-        sprintf_P(baby_buf, PSTR("M290 Z%.3f"),((float)0 - babystep_dist));
117
-        gcode.process_subcommands_now_P(PSTR(baby_buf));
118
-        has_adjust_z = 1;
119
-      }
90
+      sprintf_P(baby_buf, PSTR("M290 Z%.3f"), babystep_dist);
91
+      gcode.process_subcommands_now_P(PSTR(baby_buf));
92
+      has_adjust_z = 1;
120 93
       break;
121 94
     case ID_BABY_STEP_DIST:
122
-      if (event == LV_EVENT_CLICKED) {
123
-        // nothing to do
124
-      }
125
-      else if (event == LV_EVENT_RELEASED) {
126
-        if (abs((int)(100 * babystep_dist)) == 1)
127
-          babystep_dist = 0.05;
128
-        else if (abs((int)(100 * babystep_dist)) == 5)
129
-          babystep_dist = 0.1;
130
-        else
131
-          babystep_dist = 0.01;
132
-        disp_baby_step_dist();
133
-      }
134
-
95
+      if (abs((int)(100 * babystep_dist)) == 1)
96
+        babystep_dist = 0.05;
97
+      else if (abs((int)(100 * babystep_dist)) == 5)
98
+        babystep_dist = 0.1;
99
+      else
100
+        babystep_dist = 0.01;
101
+      disp_baby_step_dist();
135 102
       break;
136 103
     case ID_BABY_STEP_RETURN:
137
-      if (event == LV_EVENT_CLICKED) {
138
-        // nothing to do
139
-      }
140
-      else if (event == LV_EVENT_RELEASED) {
141
-        if (has_adjust_z == 1) {
142
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
143
-          has_adjust_z = 0;
144
-        }
145
-        clear_cur_ui();
146
-        draw_return_ui();
104
+      if (has_adjust_z == 1) {
105
+        TERN_(EEPROM_SETTINGS, (void)settings.save());
106
+        has_adjust_z = 0;
147 107
       }
108
+      clear_cur_ui();
109
+      draw_return_ui();
148 110
       break;
149 111
   }
150 112
 }
@@ -156,75 +118,31 @@ void lv_draw_baby_stepping(void) {
156 118
   }
157 119
   disp_state = BABY_STEP_UI;
158 120
 
159
-  scr = lv_obj_create(NULL, NULL);
160
-
161
-  lv_obj_set_style(scr, &tft_style_scr);
162
-  lv_scr_load(scr);
163
-  lv_obj_clean(scr);
121
+  scr = lv_screen_create();
164 122
 
165 123
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
166 124
 
167 125
   lv_refr_now(lv_refr_get_disp_refreshing());
168 126
 
169
-  // Create an Image button
170
-  lv_obj_t *buttonXI = lv_imgbtn_create(scr, "F:/bmp_xAdd.bin", INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P);
171
-  lv_obj_t *buttonXD = lv_imgbtn_create(scr, "F:/bmp_xDec.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N);
172
-  lv_obj_t *buttonYI = lv_imgbtn_create(scr, "F:/bmp_yAdd.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P);
173
-  lv_obj_t *buttonYD = lv_imgbtn_create(scr, "F:/bmp_yDec.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Y_N);
174
-  lv_obj_t *buttonZI = lv_imgbtn_create(scr, "F:/bmp_zAdd.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_BABY_STEP_Z_P);
175
-  lv_obj_t *buttonZD = lv_imgbtn_create(scr, "F:/bmp_zDec.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Z_N);
176
-             buttonV = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_BABY_STEP_DIST);
177
-  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_RETURN);
178
-
179
-  // Create labels on the image buttons
180
-  lv_obj_t *labelXI = lv_label_create_empty(buttonXI);
181
-  lv_obj_t *labelXD = lv_label_create_empty(buttonXD);
182
-  lv_obj_t *labelYI = lv_label_create_empty(buttonYI);
183
-  lv_obj_t *labelYD = lv_label_create_empty(buttonYD);
184
-  lv_obj_t *labelZI = lv_label_create_empty(buttonZI);
185
-  lv_obj_t *labelZD = lv_label_create_empty(buttonZD);
127
+  lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_BABY_STEP_X_P);
128
+  lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_X_N);
129
+  lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_BABY_STEP_Y_P);
130
+  lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Y_N);
131
+  lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_BABY_STEP_Z_P);
132
+  lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_Z_N);
133
+  buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_BABY_STEP_DIST);
186 134
   labelV = lv_label_create_empty(buttonV);
187
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
188
-
189
-  if (gCfgItems.multiple_language) {
190
-    lv_label_set_text(labelXI, move_menu.x_add);
191
-    lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
192
-
193
-    lv_label_set_text(labelXD, move_menu.x_dec);
194
-    lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
195
-
196
-    lv_label_set_text(labelYI, move_menu.y_add);
197
-    lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
198
-
199
-    lv_label_set_text(labelYD, move_menu.y_dec);
200
-    lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
201
-
202
-    lv_label_set_text(labelZI, move_menu.z_add);
203
-    lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
204
-
205
-    lv_label_set_text(labelZD, move_menu.z_dec);
206
-    lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
207
-
208
-    lv_label_set_text(label_Back, common_menu.text_back);
209
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
210
-  }
211
-
212 135
   #if HAS_ROTARY_ENCODER
213 136
     if (gCfgItems.encoder_enable) {
214
-      lv_group_add_obj(g, buttonXI);
215
-      lv_group_add_obj(g, buttonXD);
216
-      lv_group_add_obj(g, buttonYI);
217
-      lv_group_add_obj(g, buttonYD);
218
-      lv_group_add_obj(g, buttonZI);
219
-      lv_group_add_obj(g, buttonZD);
220 137
       lv_group_add_obj(g, buttonV);
221
-      lv_group_add_obj(g, buttonBack);
222 138
     }
223 139
   #endif
224 140
 
141
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_BABY_STEP_RETURN);
142
+
225 143
   disp_baby_step_dist();
226 144
 
227
-  zOffsetText = lv_label_create(scr, 290, TITLE_YPOS, NULL);
145
+  zOffsetText = lv_label_create(scr, 290, TITLE_YPOS, nullptr);
228 146
   disp_z_offset_value();
229 147
 }
230 148
 
@@ -255,7 +173,7 @@ void disp_baby_step_dist() {
255 173
 
256 174
 void disp_z_offset_value() {
257 175
   char buf[20];
258
-  sprintf_P(buf, PSTR("offset Z: %.3f"), (double)TERN(HAS_BED_PROBE, probe.offset.z, 0));
176
+  sprintf_P(buf, PSTR("offset Z: %.3f"), (float)TERN(HAS_BED_PROBE, probe.offset.z, 0));
259 177
   lv_label_set_text(zOffsetText, buf);
260 178
 }
261 179
 

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

@@ -33,179 +33,136 @@
33 33
 #include "../../../../module/planner.h"
34 34
 #include "../../../../inc/MarlinConfig.h"
35 35
 
36
-extern lv_group_t * g;
37
-static lv_obj_t * scr;
36
+extern lv_group_t *g;
37
+static lv_obj_t *scr;
38 38
 static lv_obj_t *labelStep, *buttonStep, *buttonMov, *buttonExt;
39 39
 static lv_obj_t *labelMov, *labelExt;
40
-static lv_obj_t * printSpeedText;
40
+static lv_obj_t *printSpeedText;
41 41
 
42
-#define ID_C_ADD    1
43
-#define ID_C_DEC    2
44
-#define ID_C_MOVE   3
45
-#define ID_C_EXT    4
46
-#define ID_C_STEP   5
47
-#define ID_C_RETURN 6
42
+enum {
43
+  ID_C_ADD = 1,
44
+  ID_C_DEC,
45
+  ID_C_MOVE,
46
+  ID_C_EXT,
47
+  ID_C_STEP,
48
+  ID_C_RETURN
49
+};
48 50
 
49
-static uint8_t speedType;
51
+static bool editingFlowrate;
50 52
 
51
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
53
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
54
+  if (event != LV_EVENT_RELEASED) return;
52 55
   switch (obj->mks_obj_id) {
53 56
     case ID_C_ADD:
54
-      if (event == LV_EVENT_CLICKED) {
55
-        // nothing to do
57
+      if (!editingFlowrate) {
58
+        if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
59
+          feedrate_percentage += uiCfg.stepPrintSpeed;
60
+        else
61
+          feedrate_percentage = MAX_EXT_SPEED_PERCENT;
56 62
       }
57
-      else if (event == LV_EVENT_RELEASED) {
58
-        if (speedType == 0) {
59
-          if (feedrate_percentage < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
60
-            feedrate_percentage += uiCfg.stepPrintSpeed;
61
-          else
62
-            feedrate_percentage = MAX_EXT_SPEED_PERCENT;
63
-        }
64
-        else if (speedType == 1) {
65
-          if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
66
-            planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
67
-          else
68
-            planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
69
-          //planner.e_factor[0]= planner.flow_percentage[0]*0.01;
70
-          //planner.flow_percentage[1] = planner.flow_percentage[0];
71
-          //planner.e_factor[1]= planner.flow_percentage[1]*0.01;
72
-          planner.refresh_e_factor(0);
73
-          #if HAS_MULTI_EXTRUDER
74
-            planner.flow_percentage[1] = planner.flow_percentage[0];
75
-            planner.refresh_e_factor(1);
76
-          #endif
77
-        }
78
-        disp_print_speed();
63
+      else {
64
+        if (planner.flow_percentage[0] < MAX_EXT_SPEED_PERCENT - uiCfg.stepPrintSpeed)
65
+          planner.flow_percentage[0] += uiCfg.stepPrintSpeed;
66
+        else
67
+          planner.flow_percentage[0] = MAX_EXT_SPEED_PERCENT;
68
+        //planner.e_factor[0]= planner.flow_percentage[0]*0.01;
69
+        //planner.flow_percentage[1] = planner.flow_percentage[0];
70
+        //planner.e_factor[1]= planner.flow_percentage[1]*0.01;
71
+        planner.refresh_e_factor(0);
72
+        #if HAS_MULTI_EXTRUDER
73
+          planner.flow_percentage[1] = planner.flow_percentage[0];
74
+          planner.refresh_e_factor(1);
75
+        #endif
79 76
       }
77
+      disp_print_speed();
80 78
       break;
81 79
     case ID_C_DEC:
82
-      if (event == LV_EVENT_CLICKED) {
83
-        // nothing to do
80
+      if (!editingFlowrate) {
81
+        if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
82
+          feedrate_percentage -= uiCfg.stepPrintSpeed;
83
+        else
84
+          feedrate_percentage = MIN_EXT_SPEED_PERCENT;
84 85
       }
85
-      else if (event == LV_EVENT_RELEASED) {
86
-        if (speedType == 0) {
87
-          if (feedrate_percentage > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
88
-            feedrate_percentage -= uiCfg.stepPrintSpeed;
89
-          else
90
-            feedrate_percentage = MIN_EXT_SPEED_PERCENT;
91
-        }
92
-        else if (speedType == 1) {
93
-          if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
94
-            planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
95
-          else
96
-            planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
97
-          //planner.e_factor[0]= planner.flow_percentage[0] * 0.01;
98
-          //planner.flow_percentage[1] = planner.flow_percentage[0];
99
-          //planner.e_factor[1]= planner.flow_percentage[1] * 0.01;
100
-          planner.refresh_e_factor(0);
101
-          #if HAS_MULTI_EXTRUDER
102
-            planner.flow_percentage[1] = planner.flow_percentage[0];
103
-            planner.refresh_e_factor(1);
104
-          #endif
105
-        }
106
-        disp_print_speed();
86
+      else {
87
+        if (planner.flow_percentage[0] > MIN_EXT_SPEED_PERCENT + uiCfg.stepPrintSpeed)
88
+          planner.flow_percentage[0] -= uiCfg.stepPrintSpeed;
89
+        else
90
+          planner.flow_percentage[0] = MIN_EXT_SPEED_PERCENT;
91
+        //planner.e_factor[0]= planner.flow_percentage[0] * 0.01;
92
+        //planner.flow_percentage[1] = planner.flow_percentage[0];
93
+        //planner.e_factor[1]= planner.flow_percentage[1] * 0.01;
94
+        planner.refresh_e_factor(0);
95
+        #if HAS_MULTI_EXTRUDER
96
+          planner.flow_percentage[1] = planner.flow_percentage[0];
97
+          planner.refresh_e_factor(1);
98
+        #endif
107 99
       }
100
+      disp_print_speed();
108 101
       break;
109 102
     case ID_C_MOVE:
110
-      if (event == LV_EVENT_CLICKED) {
111
-        // nothing to do
112
-      }
113
-      else if (event == LV_EVENT_RELEASED) {
114
-        speedType = 0;
115
-        disp_speed_type();
116
-        disp_print_speed();
117
-      }
103
+      editingFlowrate = false;
104
+      disp_speed_type();
105
+      disp_print_speed();
118 106
       break;
119 107
     case ID_C_EXT:
120
-      if (event == LV_EVENT_CLICKED) {
121
-        // nothing to do
122
-      }
123
-      else if (event == LV_EVENT_RELEASED) {
124
-        speedType = 1;
125
-        disp_speed_type();
126
-        disp_print_speed();
127
-      }
108
+      editingFlowrate = true;
109
+      disp_speed_type();
110
+      disp_print_speed();
128 111
       break;
129 112
     case ID_C_STEP:
130
-      if (event == LV_EVENT_CLICKED) {
131
-
132
-      }
133
-      else if (event == LV_EVENT_RELEASED) {
134
-        if (uiCfg.stepPrintSpeed == 1)
135
-          uiCfg.stepPrintSpeed = 5;
136
-        else if (uiCfg.stepPrintSpeed == 5)
137
-          uiCfg.stepPrintSpeed = 10;
138
-        else
139
-          uiCfg.stepPrintSpeed = 1;
140
-        disp_speed_step();
141
-      }
113
+      if (uiCfg.stepPrintSpeed == 1)
114
+        uiCfg.stepPrintSpeed = 5;
115
+      else if (uiCfg.stepPrintSpeed == 5)
116
+        uiCfg.stepPrintSpeed = 10;
117
+      else
118
+        uiCfg.stepPrintSpeed = 1;
119
+      disp_speed_step();
142 120
       break;
143 121
     case ID_C_RETURN:
144
-      if (event == LV_EVENT_CLICKED) {
145
-        // nothing to do
146
-      }
147
-      else if (event == LV_EVENT_RELEASED) {
148
-        clear_cur_ui();
149
-        draw_return_ui();
150
-      }
122
+      clear_cur_ui();
123
+      draw_return_ui();
151 124
       break;
152 125
   }
153 126
 }
154 127
 
155 128
 void lv_draw_change_speed(void) {
156
-  lv_obj_t *buttonAdd, *buttonDec;
157
-  lv_obj_t *buttonBack;
158
-
159 129
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != CHANGE_SPEED_UI) {
160 130
     disp_state_stack._disp_index++;
161 131
     disp_state_stack._disp_state[disp_state_stack._disp_index] = CHANGE_SPEED_UI;
162 132
   }
163 133
   disp_state = CHANGE_SPEED_UI;
164 134
 
165
-  scr = lv_obj_create(NULL, NULL);
166
-
167
-  lv_obj_set_style(scr, &tft_style_scr);
168
-  lv_scr_load(scr);
169
-  lv_obj_clean(scr);
135
+  scr = lv_screen_create();
170 136
 
171 137
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
172 138
 
173 139
   lv_refr_now(lv_refr_get_disp_refreshing());
174 140
 
175 141
   // Create an Image button
176
-  buttonAdd  = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_C_ADD);
177
-  buttonDec  = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC);
178
-  buttonMov  = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_MOVE);
179
-  buttonExt  = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_EXT);
180
-  buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_STEP);
181
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN);
142
+  lv_big_button_create(scr, "F:/bmp_Add.bin", speed_menu.add, INTERVAL_V, titleHeight, event_handler, ID_C_ADD);
143
+  lv_big_button_create(scr, "F:/bmp_Dec.bin", speed_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_C_DEC);
144
+  buttonMov  = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_MOVE);
145
+  buttonExt  = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_EXT);
146
+  buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_STEP);
147
+  #if HAS_ROTARY_ENCODER
148
+    if (gCfgItems.encoder_enable) {
149
+      lv_group_add_obj(g, buttonMov);
150
+      lv_group_add_obj(g, buttonExt);
151
+      lv_group_add_obj(g, buttonStep);
152
+    }
153
+  #endif
154
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_C_RETURN);
182 155
 
183 156
   // Create labels on the image buttons
184
-  lv_obj_t *labelAdd    = lv_label_create_empty(buttonAdd);
185
-  lv_obj_t *labelDec    = lv_label_create_empty(buttonDec);
186 157
   labelMov              = lv_label_create_empty(buttonMov);
187 158
   labelExt              = lv_label_create_empty(buttonExt);
188 159
   labelStep             = lv_label_create_empty(buttonStep);
189
-  lv_obj_t *label_Back  = lv_label_create_empty(buttonBack);
190 160
 
191
-  if (gCfgItems.multiple_language) {
192
-    lv_label_set_text(labelAdd, speed_menu.add);
193
-    lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
194
-
195
-    lv_label_set_text(labelDec, speed_menu.dec);
196
-    lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
197
-
198
-    lv_label_set_text(label_Back, common_menu.text_back);
199
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
200
-  }
201 161
   #if HAS_ROTARY_ENCODER
202 162
     if (gCfgItems.encoder_enable) {
203
-      lv_group_add_obj(g, buttonAdd);
204
-      lv_group_add_obj(g, buttonDec);
205 163
       lv_group_add_obj(g, buttonMov);
206 164
       lv_group_add_obj(g, buttonExt);
207 165
       lv_group_add_obj(g, buttonStep);
208
-      lv_group_add_obj(g, buttonBack);
209 166
     }
210 167
   #endif
211 168
 
@@ -246,34 +203,27 @@ void disp_print_speed() {
246 203
 
247 204
   public_buf_l[0] = '\0';
248 205
 
249
-  if (speedType == 0) { // move
250
-    strcat(public_buf_l, speed_menu.move_speed);
251
-    strcat_P(public_buf_l, PSTR(": "));
252
-    sprintf_P(buf, PSTR("%d%%"), feedrate_percentage);
253
-    strcat(public_buf_l, buf);
206
+  int16_t val;
207
+  const char *lbl;
208
+  if (editingFlowrate) {
209
+    lbl = speed_menu.extrude_speed;
210
+    val = planner.flow_percentage[0];
254 211
   }
255
-  else if (speedType == 1) { // e1
256
-    strcat(public_buf_l, speed_menu.extrude_speed);
257
-    strcat_P(public_buf_l, PSTR(": "));
258
-    sprintf_P(buf, PSTR("%d%%"), planner.flow_percentage[0]);
259
-    strcat(public_buf_l, buf);
212
+  else {
213
+    lbl = speed_menu.move_speed;
214
+    val = feedrate_percentage;
260 215
   }
216
+  strcpy(public_buf_l, lbl);
217
+  strcat_P(public_buf_l, PSTR(": "));
218
+  sprintf_P(buf, PSTR("%d%%"), val);
219
+  strcat(public_buf_l, buf);
261 220
   lv_label_set_text(printSpeedText, public_buf_l);
262
-  lv_obj_align(printSpeedText, NULL, LV_ALIGN_CENTER, 0, -65);
221
+  lv_obj_align(printSpeedText, nullptr, LV_ALIGN_CENTER, 0, -65);
263 222
 }
264 223
 
265 224
 void disp_speed_type() {
266
-  switch (speedType) {
267
-    case 1:
268
-      lv_imgbtn_set_src_both(buttonMov, "F:/bmp_mov_changeSpeed.bin");
269
-      lv_imgbtn_set_src_both(buttonExt, "F:/bmp_extruct_sel.bin");
270
-      break;
271
-
272
-    default:
273
-      lv_imgbtn_set_src_both(buttonMov, "F:/bmp_mov_sel.bin");
274
-      lv_imgbtn_set_src_both(buttonExt, "F:/bmp_speed_extruct.bin");
275
-      break;
276
-  }
225
+  lv_imgbtn_set_src_both(buttonMov, editingFlowrate ? "F:/bmp_mov_changeSpeed.bin" : "F:/bmp_mov_sel.bin");
226
+  lv_imgbtn_set_src_both(buttonExt, editingFlowrate ? "F:/bmp_extruct_sel.bin" : "F:/bmp_speed_extruct.bin");
277 227
   lv_obj_refresh_ext_draw_pad(buttonExt);
278 228
   lv_obj_refresh_ext_draw_pad(buttonMov);
279 229
 

+ 229
- 359
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp View File

@@ -55,189 +55,162 @@
55 55
   #include "../../../../feature/pause.h"
56 56
 #endif
57 57
 
58
-extern lv_group_t * g;
59
-static lv_obj_t * scr;
60
-static lv_obj_t * tempText1;
61
-static lv_obj_t * filament_bar;
58
+extern lv_group_t *g;
59
+static lv_obj_t *scr, *tempText1, *filament_bar;
62 60
 
63 61
 extern uint8_t sel_id;
64 62
 extern bool once_flag, gcode_preview_over;
65
-extern int upload_result ;
63
+extern int upload_result;
66 64
 extern uint32_t upload_time;
67 65
 extern uint32_t upload_size;
68
-extern uint8_t temperature_change_frequency;
66
+extern bool temps_update_flag;
69 67
 
70
-static void btn_ok_event_cb(lv_obj_t * btn, lv_event_t event) {
71
-  if (event == LV_EVENT_CLICKED) {
72
-    // nothing to do
73
-  }
74
-  else if (event == LV_EVENT_RELEASED) {
75
-    if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) {
76
-      #if HAS_GCODE_PREVIEW
77
-        preview_gcode_prehandle(list_file.file_name[sel_id]);
78
-      #endif
79
-      reset_print_time();
80
-      start_print_time();
81
-
82
-      uiCfg.print_state = WORKING;
83
-      lv_clear_dialog();
84
-      lv_draw_printing();
85
-
86
-      #if ENABLED(SDSUPPORT)
87
-        if (!gcode_preview_over) {
88
-          char *cur_name;
89
-          cur_name = strrchr(list_file.file_name[sel_id], '/');
90
-
91
-          SdFile file, *curDir;
92
-          card.endFilePrint();
93
-          const char * const fname = card.diveToFile(true, curDir, cur_name);
94
-          if (!fname) return;
95
-          if (file.open(curDir, fname, O_READ)) {
96
-            gCfgItems.curFilesize = file.fileSize();
97
-            file.close();
98
-            update_spi_flash();
99
-          }
100
-          card.openFileRead(cur_name);
101
-          if (card.isFileOpen()) {
102
-            feedrate_percentage = 100;
103
-            //saved_feedrate_percentage = feedrate_percentage;
104
-            planner.flow_percentage[0] = 100;
105
-            planner.e_factor[0]        = planner.flow_percentage[0] * 0.01f;
106
-            #if HAS_MULTI_EXTRUDER
107
-              planner.flow_percentage[1] = 100;
108
-              planner.e_factor[1]        = planner.flow_percentage[1] * 0.01f;
109
-            #endif
110
-            card.startFileprint();
111
-            #if ENABLED(POWER_LOSS_RECOVERY)
112
-              recovery.prepare();
113
-            #endif
114
-            once_flag = false;
115
-          }
68
+static void btn_ok_event_cb(lv_obj_t *btn, lv_event_t event) {
69
+  if (event != LV_EVENT_RELEASED) return;
70
+  if (DIALOG_IS(TYPE_PRINT_FILE)) {
71
+    #if HAS_GCODE_PREVIEW
72
+      preview_gcode_prehandle(list_file.file_name[sel_id]);
73
+    #endif
74
+    reset_print_time();
75
+    start_print_time();
76
+
77
+    uiCfg.print_state = WORKING;
78
+    lv_clear_dialog();
79
+    lv_draw_printing();
80
+
81
+    #if ENABLED(SDSUPPORT)
82
+      if (!gcode_preview_over) {
83
+        char *cur_name;
84
+        cur_name = strrchr(list_file.file_name[sel_id], '/');
85
+
86
+        SdFile file, *curDir;
87
+        card.endFilePrint();
88
+        const char * const fname = card.diveToFile(true, curDir, cur_name);
89
+        if (!fname) return;
90
+        if (file.open(curDir, fname, O_READ)) {
91
+          gCfgItems.curFilesize = file.fileSize();
92
+          file.close();
93
+          update_spi_flash();
94
+        }
95
+        card.openFileRead(cur_name);
96
+        if (card.isFileOpen()) {
97
+          feedrate_percentage = 100;
98
+          //saved_feedrate_percentage = feedrate_percentage;
99
+          planner.flow_percentage[0] = 100;
100
+          planner.e_factor[0]        = planner.flow_percentage[0] * 0.01f;
101
+          #if HAS_MULTI_EXTRUDER
102
+            planner.flow_percentage[1] = 100;
103
+            planner.e_factor[1]        = planner.flow_percentage[1] * 0.01f;
104
+          #endif
105
+          card.startFileprint();
106
+          #if ENABLED(POWER_LOSS_RECOVERY)
107
+            recovery.prepare();
108
+          #endif
109
+          once_flag = false;
116 110
         }
117
-      #endif
118
-    }
119
-    else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
120
-      wait_for_heatup = false;
121
-      stop_print_time();
122
-      lv_clear_dialog();
123
-      lv_draw_ready_print();
124
-
125
-      #if ENABLED(SDSUPPORT)
126
-        //card.endFilePrint();
127
-        //wait_for_heatup = false;
128
-        uiCfg.print_state           = IDLE;
129
-        card.flag.abort_sd_printing = true;
130
-        //queue.clear();
131
-        //quickstop_stepper();
132
-        //print_job_timer.stop();
133
-        //thermalManager.disable_all_heaters();
134
-
135
-        //#if ENABLED(POWER_LOSS_RECOVERY)
136
-        //  recovery.purge();
137
-        //#endif
138
-        //queue.enqueue_now_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0"));
139
-        //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
140
-      #endif
141
-    }
142
-    else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
143
-      clear_cur_ui();
144
-      lv_draw_ready_print();
145
-    }
146
-    #if ENABLED(ADVANCED_PAUSE_FEATURE)
147
-      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
148
-            || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
149
-            || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
150
-      ) {
151
-        wait_for_user = false;
152
-      }
153
-      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
154
-        pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
155
-      }
156
-      else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
157
-        clear_cur_ui();
158
-        draw_return_ui();
159 111
       }
160 112
     #endif
161
-    else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
162
-      TERN_(EEPROM_SETTINGS, (void)settings.save());
163
-      clear_cur_ui();
164
-      draw_return_ui();
165
-    }
166
-    else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
167
-      TERN_(EEPROM_SETTINGS, (void)settings.load());
168
-      clear_cur_ui();
169
-      draw_return_ui();
170
-    }
171
-    else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
172
-      TERN_(EEPROM_SETTINGS, (void)settings.reset());
173
-      clear_cur_ui();
174
-      draw_return_ui();
175
-    }
176
-    else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
177
-      uiCfg.configWifi = 1;
178
-      clear_cur_ui();
179
-      draw_return_ui();
180
-    }
181
-    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
182
-      uiCfg.filament_heat_completed_load = 1;
183
-    }
184
-    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
185
-      uiCfg.filament_heat_completed_unload = 1;
186
-    }
187
-    else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
188
-          || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
189
-    ) {
113
+  }
114
+  else if (DIALOG_IS(TYPE_STOP)) {
115
+    wait_for_heatup = false;
116
+    stop_print_time();
117
+    lv_clear_dialog();
118
+    lv_draw_ready_print();
119
+
120
+    #if ENABLED(SDSUPPORT)
121
+      //card.endFilePrint();
122
+      //wait_for_heatup = false;
123
+      uiCfg.print_state           = IDLE;
124
+      card.flag.abort_sd_printing = true;
125
+      //queue.clear();
126
+      //quickstop_stepper();
127
+      //print_job_timer.stop();
128
+      //thermalManager.disable_all_heaters();
129
+
130
+      //#if ENABLED(POWER_LOSS_RECOVERY)
131
+      //  recovery.purge();
132
+      //#endif
133
+      //queue.enqueue_now_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0"));
134
+      //queue.inject_P(PSTR("G91\nG1 Z10\nG90\nG28 X0 Y0\nM84\nM107"));
135
+    #endif
136
+  }
137
+  else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
138
+    clear_cur_ui();
139
+    lv_draw_ready_print();
140
+  }
141
+  #if ENABLED(ADVANCED_PAUSE_FEATURE)
142
+    else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT))
143
+      wait_for_user = false;
144
+    else if (DIALOG_IS(PAUSE_MESSAGE_OPTION))
145
+      pause_menu_response = PAUSE_RESPONSE_EXTRUDE_MORE;
146
+    else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
190 147
       clear_cur_ui();
191 148
       draw_return_ui();
192 149
     }
150
+  #endif
151
+  else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
152
+    TERN_(EEPROM_SETTINGS, (void)settings.save());
153
+    clear_cur_ui();
154
+    draw_return_ui();
155
+  }
156
+  else if (DIALOG_IS(READ_EEPROM_TIPS)) {
157
+    TERN_(EEPROM_SETTINGS, (void)settings.load());
158
+    clear_cur_ui();
159
+    draw_return_ui();
160
+  }
161
+  else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
162
+    TERN_(EEPROM_SETTINGS, (void)settings.reset());
163
+    clear_cur_ui();
164
+    draw_return_ui();
165
+  }
166
+  else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
167
+    uiCfg.configWifi = 1;
168
+    clear_cur_ui();
169
+    draw_return_ui();
170
+  }
171
+  else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED))
172
+    uiCfg.filament_heat_completed_load = 1;
173
+  else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED))
174
+    uiCfg.filament_heat_completed_unload = 1;
175
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
176
+    clear_cur_ui();
177
+    draw_return_ui();
193 178
   }
194 179
 }
195 180
 
196
-static void btn_cancel_event_cb(lv_obj_t * btn, lv_event_t event) {
197
-  if (event == LV_EVENT_CLICKED) {
198
-    // nothing to do
181
+static void btn_cancel_event_cb(lv_obj_t *btn, lv_event_t event) {
182
+  if (event != LV_EVENT_RELEASED) return;
183
+  if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
184
+    #if ENABLED(ADVANCED_PAUSE_FEATURE)
185
+      pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
186
+    #endif
199 187
   }
200
-  else if (event == LV_EVENT_RELEASED) {
201
-    if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
202
-      #if ENABLED(ADVANCED_PAUSE_FEATURE)
203
-        pause_menu_response = PAUSE_RESPONSE_RESUME_PRINT;
204
-      #endif
205
-    }
206
-    else if ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
207
-          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT)
208
-          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED)
209
-          || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)
210
-    ) {
211
-      thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
212
-      clear_cur_ui();
213
-      draw_return_ui();
214
-    }
215
-    else if ((uiCfg.dialogType   == DIALOG_TYPE_FILAMENT_LOADING)
216
-       || (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING)
217
-    ) {
218
-      queue.enqueue_one_P(PSTR("M410"));
219
-      uiCfg.filament_rate                = 0;
220
-      uiCfg.filament_loading_completed   = 0;
221
-      uiCfg.filament_unloading_completed = 0;
222
-      uiCfg.filament_loading_time_flg    = 0;
223
-      uiCfg.filament_loading_time_cnt    = 0;
224
-      uiCfg.filament_unloading_time_flg  = 0;
225
-      uiCfg.filament_unloading_time_cnt  = 0;
226
-      thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
227
-      clear_cur_ui();
228
-      draw_return_ui();
229
-    }
230
-    else {
231
-      clear_cur_ui();
232
-      draw_return_ui();
233
-    }
188
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT, TYPE_FILAMENT_HEAT_LOAD_COMPLETED, TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
189
+    thermalManager.temp_hotend[uiCfg.curSprayerChoose].target= uiCfg.desireSprayerTempBak;
190
+    clear_cur_ui();
191
+    draw_return_ui();
192
+  }
193
+  else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
194
+    queue.enqueue_one_P(PSTR("M410"));
195
+    uiCfg.filament_rate                = 0;
196
+    uiCfg.filament_loading_completed   = 0;
197
+    uiCfg.filament_unloading_completed = 0;
198
+    uiCfg.filament_loading_time_flg    = 0;
199
+    uiCfg.filament_loading_time_cnt    = 0;
200
+    uiCfg.filament_unloading_time_flg  = 0;
201
+    uiCfg.filament_unloading_time_cnt  = 0;
202
+    thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
203
+    clear_cur_ui();
204
+    draw_return_ui();
205
+  }
206
+  else {
207
+    clear_cur_ui();
208
+    draw_return_ui();
234 209
   }
235 210
 }
236 211
 
237 212
 void lv_draw_dialog(uint8_t type) {
238
-
239
-  lv_obj_t * btnOk = NULL;
240
-  lv_obj_t * btnCancel = NULL;
213
+  lv_obj_t *btnOk = nullptr, *btnCancel = nullptr;
241 214
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != DIALOG_UI) {
242 215
     disp_state_stack._disp_index++;
243 216
     disp_state_stack._disp_state[disp_state_stack._disp_index] = DIALOG_UI;
@@ -246,153 +219,70 @@ void lv_draw_dialog(uint8_t type) {
246 219
 
247 220
   uiCfg.dialogType = type;
248 221
 
249
-  scr = lv_obj_create(NULL, NULL);
250
-
251
-  lv_obj_set_style(scr, &tft_style_scr);
252
-  lv_scr_load(scr);
253
-  lv_obj_clean(scr);
222
+  scr = lv_screen_create();
254 223
 
255 224
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
256 225
 
257 226
   lv_refr_now(lv_refr_get_disp_refreshing());
258 227
 
259
-  static lv_style_t style_btn_rel;                                 // A variable to store the released style
260
-  lv_style_copy(&style_btn_rel, &lv_style_plain);                  // Initialize from a built-in style
261
-  style_btn_rel.body.border.color = lv_color_hex3(0x269);
262
-  style_btn_rel.body.border.width = 1;
263
-  style_btn_rel.body.main_color   = lv_color_hex3(0xADF);
264
-  style_btn_rel.body.grad_color   = lv_color_hex3(0x46B);
265
-  style_btn_rel.body.shadow.width = 4;
266
-  style_btn_rel.body.shadow.type  = LV_SHADOW_BOTTOM;
267
-  style_btn_rel.body.radius       = LV_RADIUS_CIRCLE;
268
-  style_btn_rel.text.color        = lv_color_hex3(0xDEF);
269
-  style_btn_rel.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
270
-
271
-  static lv_style_t style_btn_pr;                                  // A variable to store the pressed style
272
-  lv_style_copy(&style_btn_pr, &style_btn_rel);                    // Initialize from the released style
273
-  style_btn_pr.body.border.color = lv_color_hex3(0x46B);
274
-  style_btn_pr.body.main_color   = lv_color_hex3(0x8BD);
275
-  style_btn_pr.body.grad_color   = lv_color_hex3(0x24A);
276
-  style_btn_pr.body.shadow.width = 2;
277
-  style_btn_pr.text.color        = lv_color_hex3(0xBCD);
278
-  style_btn_pr.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
279
-
280
-  // Set button styles for Released and Pressed
281
-  auto lv_btn_use_button_style = [&](lv_obj_t *btn) {
282
-    lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel);
283
-    lv_btn_set_style(btn, LV_BTN_STYLE_PR,  &style_btn_pr);
284
-  };
285
-
286 228
   lv_obj_t *labelDialog = lv_label_create_empty(scr);
287 229
 
288
-  if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
289
-      btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
290
-      lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);                // Set its position
291
-      lv_obj_set_size(btnOk, 100, 50);                               // Set its size
292
-      lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
293
-      lv_btn_use_button_style(btnOk);
230
+  if (DIALOG_IS(TYPE_FINISH_PRINT, PAUSE_MESSAGE_RESUME)) {
231
+      btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
294 232
       lv_obj_t *labelOk = lv_label_create_empty(btnOk);             // Add a label to the button
295 233
       lv_label_set_text(labelOk, print_file_dialog_menu.confirm);    // Set the labels text
296 234
   }
297
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING
298
-        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT
299
-        || uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT
300
-  ) {
301
-    btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
302
-    lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);                // Set its position
303
-    lv_obj_set_size(btnOk, 100, 50);                               // Set its size
304
-    lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
305
-    lv_btn_use_button_style(btnOk);
235
+  else if (DIALOG_IS(PAUSE_MESSAGE_WAITING, PAUSE_MESSAGE_INSERT, PAUSE_MESSAGE_HEAT)) {
236
+    btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
306 237
     lv_obj_t *labelOk = lv_label_create_empty(btnOk);             // Add a label to the button
307 238
     lv_label_set_text(labelOk, print_file_dialog_menu.confirm);    // Set the labels text
308 239
   }
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
316
-  ) {
240
+  else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING, PAUSE_MESSAGE_CHANGING, PAUSE_MESSAGE_UNLOAD, PAUSE_MESSAGE_LOAD, PAUSE_MESSAGE_PURGE, PAUSE_MESSAGE_RESUME, PAUSE_MESSAGE_HEATING)) {
317 241
     // nothing to do
318 242
   }
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_use_button_style(btnCancel);
243
+  else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
244
+    btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
325 245
     lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
326 246
     lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
327 247
   }
328
-  else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
329
-    btnCancel = lv_btn_create(scr, NULL);
330
-    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
331
-    lv_obj_set_size(btnCancel, 100, 50);
332
-    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
333
-    lv_btn_use_button_style(btnCancel);
248
+  else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
249
+    btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
334 250
     lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
335 251
     lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
336 252
   }
337 253
   #if ENABLED(USE_WIFI_FUNCTION)
338
-    else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
254
+    else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
339 255
       if (upload_result == 2) {
340
-        btnCancel = lv_btn_create(scr, NULL);
341
-        lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
342
-        lv_obj_set_size(btnCancel, 100, 50);
343
-        lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
344
-        lv_btn_use_button_style(btnCancel);
256
+        btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
345 257
         lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
346 258
         lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
347 259
       }
348 260
       else if (upload_result == 3) {
349
-        btnOk = lv_btn_create(scr, NULL);
350
-        lv_obj_set_pos(btnOk, BTN_OK_X+90, BTN_OK_Y);
351
-        lv_obj_set_size(btnOk, 100, 50);
352
-        lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
353
-        lv_btn_use_button_style(btnOk);
261
+        btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
354 262
         lv_obj_t *labelOk = lv_label_create_empty(btnOk);
355 263
         lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
356 264
       }
357 265
     }
358
-  #endif //USE_WIFI_FUNCTION
359
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT
360
-        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT
361
-  ) {
362
-    btnCancel = lv_btn_create(scr, NULL);
363
-    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
364
-    lv_obj_set_size(btnCancel, 100, 50);
365
-    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
366
-    lv_btn_use_button_style(btnCancel);
266
+  #endif
267
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT)) {
268
+    btnCancel = lv_button_btn_create(scr, BTN_OK_X+90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
367 269
     lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
368 270
     lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
369 271
 
370 272
     tempText1 = lv_label_create_empty(scr);
371 273
     filament_sprayer_temp();
372 274
   }
373
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED
374
-        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED
375
-  ) {
376
-    btnOk = lv_btn_create(scr, NULL);
377
-    lv_obj_set_pos(btnOk, BTN_OK_X + 90, BTN_OK_Y);
378
-    lv_obj_set_size(btnOk, 100, 50);
379
-    lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
380
-    lv_btn_use_button_style(btnOk);
275
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED, TYPE_FILAMENT_UNLOAD_COMPLETED)) {
276
+    btnOk = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_ok_event_cb);
381 277
     lv_obj_t *labelOk = lv_label_create_empty(btnOk);
382 278
     lv_label_set_text(labelOk, print_file_dialog_menu.confirm);
383 279
   }
384
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
385
-        || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
386
-  ) {
387
-    btnCancel = lv_btn_create(scr, NULL);
388
-    lv_obj_set_pos(btnCancel, BTN_OK_X+90, BTN_OK_Y);
389
-    lv_obj_set_size(btnCancel, 100, 50);
390
-    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
391
-    lv_btn_use_button_style(btnCancel);
280
+  else if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING)) {
281
+    btnCancel = lv_button_btn_create(scr, BTN_OK_X + 90, BTN_OK_Y, 100, 50, btn_cancel_event_cb);
392 282
     lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);
393 283
     lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
394 284
 
395
-    filament_bar = lv_bar_create(scr, NULL);
285
+    filament_bar = lv_bar_create(scr, nullptr);
396 286
     lv_obj_set_pos(filament_bar, (TFT_WIDTH-400)/2, ((TFT_HEIGHT - titleHeight)-40)/2);
397 287
     lv_obj_set_size(filament_bar, 400, 25);
398 288
     lv_bar_set_style(filament_bar, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
@@ -400,21 +290,13 @@ void lv_draw_dialog(uint8_t type) {
400 290
     lv_bar_set_value(filament_bar, 0, LV_ANIM_ON);
401 291
   }
402 292
   else {
403
-    btnOk = lv_btn_create(scr, NULL);                   // Add a button the current screen
404
-    lv_obj_set_pos(btnOk, BTN_OK_X, BTN_OK_Y);                     // Set its position
405
-    lv_obj_set_size(btnOk, 100, 50);                               // Set its size
406
-    lv_obj_set_event_cb(btnOk, btn_ok_event_cb);
407
-    lv_btn_use_button_style(btnOk);
293
+    btnOk = lv_button_btn_create(scr, BTN_OK_X, BTN_OK_Y, 100, 50, btn_ok_event_cb);
408 294
     lv_obj_t *labelOk = lv_label_create_empty(btnOk);             // Add a label to the button
409 295
 
410
-    btnCancel = lv_btn_create(scr, NULL);               // Add a button the current screen
411
-    lv_obj_set_pos(btnCancel, BTN_CANCEL_X, BTN_CANCEL_Y);         // Set its position
412
-    lv_obj_set_size(btnCancel, 100, 50);                           // Set its size
413
-    lv_obj_set_event_cb(btnCancel, btn_cancel_event_cb);
414
-    lv_btn_use_button_style(btnCancel);
296
+    btnCancel = lv_button_btn_create(scr, BTN_CANCEL_X, BTN_CANCEL_Y, 100, 50, btn_cancel_event_cb);
415 297
     lv_obj_t *labelCancel = lv_label_create_empty(btnCancel);     // Add a label to the button
416 298
 
417
-    if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
299
+    if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
418 300
       lv_label_set_text(labelOk, pause_msg_menu.purgeMore);        // Set the labels text
419 301
       lv_label_set_text(labelCancel, pause_msg_menu.continuePrint);
420 302
     }
@@ -423,105 +305,103 @@ void lv_draw_dialog(uint8_t type) {
423 305
       lv_label_set_text(labelCancel, print_file_dialog_menu.cancle);
424 306
     }
425 307
   }
426
-  if (uiCfg.dialogType == DIALOG_TYPE_PRINT_FILE) {
308
+  if (DIALOG_IS(TYPE_PRINT_FILE)) {
427 309
     lv_label_set_text(labelDialog, print_file_dialog_menu.print_file);
428
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
310
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
429 311
 
430 312
     lv_obj_t *labelFile = lv_label_create(scr, list_file.long_name[sel_id]);
431
-    lv_obj_align(labelFile, NULL, LV_ALIGN_CENTER, 0, -60);
313
+    lv_obj_align(labelFile, nullptr, LV_ALIGN_CENTER, 0, -60);
432 314
   }
433
-  else if (uiCfg.dialogType == DIALOG_TYPE_STOP) {
315
+  else if (DIALOG_IS(TYPE_STOP)) {
434 316
     lv_label_set_text(labelDialog, print_file_dialog_menu.cancle_print);
435
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
317
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
436 318
   }
437
-  else if (uiCfg.dialogType == DIALOG_TYPE_FINISH_PRINT) {
319
+  else if (DIALOG_IS(TYPE_FINISH_PRINT)) {
438 320
     lv_label_set_text(labelDialog, print_file_dialog_menu.print_finish);
439
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
321
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
440 322
   }
441
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PAUSING) {
323
+  else if (DIALOG_IS(PAUSE_MESSAGE_PAUSING)) {
442 324
     lv_label_set_text(labelDialog, pause_msg_menu.pausing);
443
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
325
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
444 326
   }
445
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_CHANGING) {
327
+  else if (DIALOG_IS(PAUSE_MESSAGE_CHANGING)) {
446 328
     lv_label_set_text(labelDialog, pause_msg_menu.changing);
447
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
329
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
448 330
   }
449
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_UNLOAD) {
331
+  else if (DIALOG_IS(PAUSE_MESSAGE_UNLOAD)) {
450 332
     lv_label_set_text(labelDialog, pause_msg_menu.unload);
451
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
333
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
452 334
   }
453
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_WAITING) {
335
+  else if (DIALOG_IS(PAUSE_MESSAGE_WAITING)) {
454 336
     lv_label_set_text(labelDialog, pause_msg_menu.waiting);
455
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
337
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
456 338
   }
457
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_INSERT) {
339
+  else if (DIALOG_IS(PAUSE_MESSAGE_INSERT)) {
458 340
     lv_label_set_text(labelDialog, pause_msg_menu.insert);
459
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
341
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
460 342
   }
461
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_LOAD) {
343
+  else if (DIALOG_IS(PAUSE_MESSAGE_LOAD)) {
462 344
     lv_label_set_text(labelDialog, pause_msg_menu.load);
463
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
345
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
464 346
   }
465
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_PURGE) {
347
+  else if (DIALOG_IS(PAUSE_MESSAGE_PURGE)) {
466 348
     lv_label_set_text(labelDialog, pause_msg_menu.purge);
467
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
349
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
468 350
   }
469
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_RESUME) {
351
+  else if (DIALOG_IS(PAUSE_MESSAGE_RESUME)) {
470 352
     lv_label_set_text(labelDialog, pause_msg_menu.resume);
471
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
353
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
472 354
   }
473
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEAT) {
355
+  else if (DIALOG_IS(PAUSE_MESSAGE_HEAT)) {
474 356
     lv_label_set_text(labelDialog, pause_msg_menu.heat);
475
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
357
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
476 358
   }
477
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_HEATING) {
359
+  else if (DIALOG_IS(PAUSE_MESSAGE_HEATING)) {
478 360
     lv_label_set_text(labelDialog, pause_msg_menu.heating);
479
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
361
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
480 362
   }
481
-  else if (uiCfg.dialogType == DIALOG_PAUSE_MESSAGE_OPTION) {
363
+  else if (DIALOG_IS(PAUSE_MESSAGE_OPTION)) {
482 364
     lv_label_set_text(labelDialog, pause_msg_menu.option);
483
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
365
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
484 366
   }
485
-  else if (uiCfg.dialogType == DIALOG_STORE_EEPROM_TIPS) {
367
+  else if (DIALOG_IS(STORE_EEPROM_TIPS)) {
486 368
     lv_label_set_text(labelDialog, eeprom_menu.storeTips);
487
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
369
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
488 370
   }
489
-  else if (uiCfg.dialogType == DIALOG_READ_EEPROM_TIPS) {
371
+  else if (DIALOG_IS(READ_EEPROM_TIPS)) {
490 372
     lv_label_set_text(labelDialog, eeprom_menu.readTips);
491
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
373
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
492 374
   }
493
-  else if (uiCfg.dialogType == DIALOG_REVERT_EEPROM_TIPS) {
375
+  else if (DIALOG_IS(REVERT_EEPROM_TIPS)) {
494 376
     lv_label_set_text(labelDialog, eeprom_menu.revertTips);
495
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
377
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
496 378
   }
497
-  else if (uiCfg.dialogType == DIALOG_WIFI_CONFIG_TIPS) {
379
+  else if (DIALOG_IS(WIFI_CONFIG_TIPS)) {
498 380
     lv_label_set_text(labelDialog, machine_menu.wifiConfigTips);
499
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
381
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
500 382
   }
501
-  else if (uiCfg.dialogType == WIFI_ENABLE_TIPS) {
383
+  else if (DIALOG_IS(WIFI_ENABLE_TIPS)) {
502 384
     lv_label_set_text(labelDialog, print_file_dialog_menu.wifi_enable_tips);
503
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
385
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
504 386
   }
505
-  else if (uiCfg.dialogType == DIALOG_TRANSFER_NO_DEVICE) {
387
+  else if (DIALOG_IS(TRANSFER_NO_DEVICE)) {
506 388
     lv_label_set_text(labelDialog, DIALOG_UPDATE_NO_DEVICE_EN);
507
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
389
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
508 390
   }
509 391
   #if ENABLED(USE_WIFI_FUNCTION)
510
-    else if (uiCfg.dialogType == DIALOG_TYPE_UPLOAD_FILE) {
392
+    else if (DIALOG_IS(TYPE_UPLOAD_FILE)) {
511 393
       if (upload_result == 1) {
512 394
         lv_label_set_text(labelDialog, DIALOG_UPLOAD_ING_EN);
513
-        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
395
+        lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
514 396
       }
515 397
       else if (upload_result == 2) {
516 398
         lv_label_set_text(labelDialog, DIALOG_UPLOAD_ERROR_EN);
517
-        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
399
+        lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
518 400
       }
519 401
       else if (upload_result == 3) {
520 402
         char buf[200];
521 403
         int _index = 0;
522 404
 
523
-        ZERO(buf);
524
-
525 405
         strcpy(buf, DIALOG_UPLOAD_FINISH_EN);
526 406
         _index = strlen(buf);
527 407
         buf[_index] = '\n';
@@ -546,41 +426,41 @@ void lv_draw_dialog(uint8_t type) {
546 426
         sprintf(&buf[_index], " %d KBytes/s\n", (int)(upload_size / upload_time / 1024));
547 427
 
548 428
         lv_label_set_text(labelDialog, buf);
549
-        lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
429
+        lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
550 430
       }
551 431
     }
552
-  #endif //USE_WIFI_FUNCTION
553
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT) {
432
+  #endif // USE_WIFI_FUNCTION
433
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT)) {
554 434
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat);
555
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
435
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
556 436
   }
557
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED) {
437
+  else if (DIALOG_IS(TYPE_FILAMENT_HEAT_LOAD_COMPLETED)) {
558 438
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_heat_confirm);
559
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
439
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
560 440
   }
561
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT) {
441
+  else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_HEAT)) {
562 442
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat);
563
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
443
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
564 444
   }
565
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED) {
445
+  else if (DIALOG_IS(TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED)) {
566 446
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_heat_confirm);
567
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
447
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
568 448
   }
569
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_COMPLETED) {
449
+  else if (DIALOG_IS(TYPE_FILAMENT_LOAD_COMPLETED)) {
570 450
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_load_completed);
571
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
451
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
572 452
   }
573
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED) {
453
+  else if (DIALOG_IS(TYPE_FILAMENT_UNLOAD_COMPLETED)) {
574 454
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_unload_completed);
575
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -20);
455
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -20);
576 456
   }
577
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING) {
457
+  else if (DIALOG_IS(TYPE_FILAMENT_LOADING)) {
578 458
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_loading);
579
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
459
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
580 460
   }
581
-  else if (uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING) {
461
+  else if (DIALOG_IS(TYPE_FILAMENT_UNLOADING)) {
582 462
     lv_label_set_text(labelDialog, filament_menu.filament_dialog_unloading);
583
-    lv_obj_align(labelDialog, NULL, LV_ALIGN_CENTER, 0, -70);
463
+    lv_obj_align(labelDialog, nullptr, LV_ALIGN_CENTER, 0, -70);
584 464
   }
585 465
   #if HAS_ROTARY_ENCODER
586 466
     if (gCfgItems.encoder_enable) {
@@ -592,28 +472,19 @@ void lv_draw_dialog(uint8_t type) {
592 472
 
593 473
 void filament_sprayer_temp() {
594 474
   char buf[20] = {0};
475
+  sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
595 476
 
596
-  public_buf_l[0] = '\0';
597
-
598
-  if (uiCfg.curSprayerChoose < 1)
599
-    strcat(public_buf_l, preheat_menu.ext1);
600
-  else
601
-    strcat(public_buf_l, preheat_menu.ext2);
602
-  sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius,  (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
603
-
477
+  strcpy(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
604 478
   strcat_P(public_buf_l, PSTR(": "));
605 479
   strcat(public_buf_l, buf);
606 480
   lv_label_set_text(tempText1, public_buf_l);
607
-  lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
481
+  lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
608 482
 }
609 483
 
610 484
 void filament_dialog_handle() {
611
-  if ((temperature_change_frequency == 1)
612
-      && ((uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOAD_HEAT)
613
-      || (uiCfg.dialogType  == DIALOG_TYPE_FILAMENT_UNLOAD_HEAT))
614
-  ) {
485
+  if (temps_update_flag && (DIALOG_IS(TYPE_FILAMENT_LOAD_HEAT, TYPE_FILAMENT_UNLOAD_HEAT))) {
615 486
     filament_sprayer_temp();
616
-    temperature_change_frequency = 0;
487
+    temps_update_flag = false;
617 488
   }
618 489
   if (uiCfg.filament_heat_completed_load == 1) {
619 490
     uiCfg.filament_heat_completed_load = 0;
@@ -667,9 +538,8 @@ void filament_dialog_handle() {
667 538
     lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED);
668 539
   }
669 540
 
670
-  if ( uiCfg.dialogType == DIALOG_TYPE_FILAMENT_LOADING
671
-    || uiCfg.dialogType == DIALOG_TYPE_FILAMENT_UNLOADING
672
-  ) lv_filament_setbar();
541
+  if (DIALOG_IS(TYPE_FILAMENT_LOADING, TYPE_FILAMENT_UNLOADING))
542
+    lv_filament_setbar();
673 543
 }
674 544
 
675 545
 void lv_filament_setbar() {

+ 40
- 37
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.h View File

@@ -25,52 +25,55 @@
25 25
   extern "C" { /* C-declarations for C++ */
26 26
 #endif
27 27
 
28
-#define DIALOG_TYPE_STOP                             0
29
-#define DIALOG_TYPE_PRINT_FILE                       1
30
-#define DIALOG_TYPE_REPRINT_NO_FILE                  2
28
+enum {
29
+  DIALOG_TYPE_STOP = 0,
30
+  DIALOG_TYPE_PRINT_FILE,
31
+  DIALOG_TYPE_REPRINT_NO_FILE,
31 32
 
32
-#define DIALOG_TYPE_M80_FAIL                         3  //**
33
-#define DIALOG_TYPE_MESSAGE_ERR1                     4  //**
33
+  DIALOG_TYPE_M80_FAIL,
34
+  DIALOG_TYPE_MESSAGE_ERR1,
34 35
 
35
-#define DIALOG_TYPE_UPDATE_ESP_FIRMARE               5
36
-#define DIALOG_TYPE_UPDATE_ESP_DATA                  6
37
-#define DIALOG_TYPE_UPLOAD_FILE                      7
38
-#define DIALOG_TYPE_UNBIND                           8
36
+  DIALOG_TYPE_UPDATE_ESP_FIRMARE,
37
+  DIALOG_TYPE_UPDATE_ESP_DATA,
38
+  DIALOG_TYPE_UPLOAD_FILE,
39
+  DIALOG_TYPE_UNBIND,
39 40
 
40
-#define DIALOG_TYPE_FILAMENT_LOAD_HEAT               9
41
-#define DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED    10
42
-#define DIALOG_TYPE_FILAMENT_LOADING                11
43
-#define DIALOG_TYPE_FILAMENT_LOAD_COMPLETED         12
44
-#define DIALOG_TYPE_FILAMENT_UNLOAD_HEAT            13
45
-#define DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED  14
46
-#define DIALOG_TYPE_FILAMENT_UNLOADING              15
47
-#define DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED       16
41
+  DIALOG_TYPE_FILAMENT_LOAD_HEAT,
42
+  DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED,
43
+  DIALOG_TYPE_FILAMENT_LOADING,
44
+  DIALOG_TYPE_FILAMENT_LOAD_COMPLETED,
45
+  DIALOG_TYPE_FILAMENT_UNLOAD_HEAT,
46
+  DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED,
47
+  DIALOG_TYPE_FILAMENT_UNLOADING,
48
+  DIALOG_TYPE_FILAMENT_UNLOAD_COMPLETED,
48 49
 
49
-#define DIALOG_TYPE_FILE_LOADING                    17  //**
50
+  DIALOG_TYPE_FILE_LOADING,
50 51
 
51
-#define DIALOG_TYPE_FILAMENT_NO_PRESS               18
52
-#define DIALOG_TYPE_FINISH_PRINT                    19
52
+  DIALOG_TYPE_FILAMENT_NO_PRESS,
53
+  DIALOG_TYPE_FINISH_PRINT,
53 54
 
54
-#define WIFI_ENABLE_TIPS                            20
55
+  DIALOG_WIFI_ENABLE_TIPS,
55 56
 
56
-#define DIALOG_PAUSE_MESSAGE_PAUSING                21
57
-#define DIALOG_PAUSE_MESSAGE_CHANGING               22
58
-#define DIALOG_PAUSE_MESSAGE_UNLOAD                 23
59
-#define DIALOG_PAUSE_MESSAGE_WAITING                24
60
-#define DIALOG_PAUSE_MESSAGE_INSERT                 25
61
-#define DIALOG_PAUSE_MESSAGE_LOAD                   26
62
-#define DIALOG_PAUSE_MESSAGE_PURGE                  27
63
-#define DIALOG_PAUSE_MESSAGE_RESUME                 28
64
-#define DIALOG_PAUSE_MESSAGE_HEAT                   29
65
-#define DIALOG_PAUSE_MESSAGE_HEATING                30
66
-#define DIALOG_PAUSE_MESSAGE_OPTION                 31
57
+  DIALOG_PAUSE_MESSAGE_PAUSING,
58
+  DIALOG_PAUSE_MESSAGE_CHANGING,
59
+  DIALOG_PAUSE_MESSAGE_UNLOAD,
60
+  DIALOG_PAUSE_MESSAGE_WAITING,
61
+  DIALOG_PAUSE_MESSAGE_INSERT,
62
+  DIALOG_PAUSE_MESSAGE_LOAD,
63
+  DIALOG_PAUSE_MESSAGE_PURGE,
64
+  DIALOG_PAUSE_MESSAGE_RESUME,
65
+  DIALOG_PAUSE_MESSAGE_HEAT,
66
+  DIALOG_PAUSE_MESSAGE_HEATING,
67
+  DIALOG_PAUSE_MESSAGE_OPTION,
67 68
 
68
-#define DIALOG_STORE_EEPROM_TIPS                    32
69
-#define DIALOG_READ_EEPROM_TIPS                     33
70
-#define DIALOG_REVERT_EEPROM_TIPS                   34
69
+  DIALOG_STORE_EEPROM_TIPS,
70
+  DIALOG_READ_EEPROM_TIPS,
71
+  DIALOG_REVERT_EEPROM_TIPS,
72
+
73
+  DIALOG_WIFI_CONFIG_TIPS,
74
+  DIALOG_TRANSFER_NO_DEVICE
75
+};
71 76
 
72
-#define DIALOG_WIFI_CONFIG_TIPS                     35
73
-#define DIALOG_TRANSFER_NO_DEVICE                   36
74 77
 #define BTN_OK_X      100
75 78
 #define BTN_OK_Y      180
76 79
 #define BTN_CANCEL_X  280

+ 27
- 132
Marlin/src/lcd/extui/lib/mks_ui/draw_eeprom_settings.cpp View File

@@ -28,163 +28,58 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
34
-#define ID_EEPROM_RETURN        1
35
-#define ID_EEPROM_STORE         2
36
-#define ID_EEPROM_STORE_ARROW   3
37
-#define ID_EEPROM_READ          4
38
-#define ID_EEPROM_READ_ARROW    5
39
-#define ID_EEPROM_REVERT        6
40
-#define ID_EEPROM_REVERT_ARROW  7
41
-
42
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_EEPROM_RETURN = 1,
36
+  ID_EEPROM_STORE,
37
+  ID_EEPROM_STORE_ARROW,
38
+  ID_EEPROM_READ,
39
+  ID_EEPROM_READ_ARROW,
40
+  ID_EEPROM_REVERT,
41
+  ID_EEPROM_REVERT_ARROW
42
+};
43
+
44
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
45
+  if (event != LV_EVENT_RELEASED) return;
43 46
   switch (obj->mks_obj_id) {
44 47
     case ID_EEPROM_RETURN:
45
-      if (event == LV_EVENT_CLICKED) {
46
-      }
47
-      else if (event == LV_EVENT_RELEASED) {
48
-        lv_clear_eeprom_settings();
49
-        draw_return_ui();
50
-      }
48
+      lv_clear_eeprom_settings();
49
+      draw_return_ui();
51 50
       break;
52 51
     case ID_EEPROM_STORE:
53
-      if (event == LV_EVENT_CLICKED) {
54
-
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) {
63
-
64
-      }
65
-      else if (event == LV_EVENT_RELEASED) {
66
-        lv_clear_eeprom_settings();
67
-        lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
68
-      }
52
+      lv_clear_eeprom_settings();
53
+      lv_draw_dialog(DIALOG_STORE_EEPROM_TIPS);
69 54
       break;
70 55
     #if 0
71 56
       case ID_EEPROM_READ:
72
-        if (event == LV_EVENT_CLICKED) {
73
-
74
-        }
75
-        else if (event == LV_EVENT_RELEASED) {
76
-          lv_clear_eeprom_settings();
77
-          lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
78
-        }
79
-        break;
80
-      case ID_EEPROM_READ_ARROW:
81
-        if (event == LV_EVENT_CLICKED) {
82
-
83
-        }
84
-        else if (event == LV_EVENT_RELEASED) {
85
-          lv_clear_eeprom_settings();
86
-          lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
87
-        }
57
+        lv_clear_eeprom_settings();
58
+        lv_draw_dialog(DIALOG_READ_EEPROM_TIPS);
88 59
         break;
89 60
     #endif
90
-
91 61
     case ID_EEPROM_REVERT:
92
-      if (event == LV_EVENT_CLICKED) {
93
-
94
-      }
95
-      else if (event == LV_EVENT_RELEASED) {
96
-        lv_clear_eeprom_settings();
97
-        lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
98
-      }
99
-      break;
100
-    case ID_EEPROM_REVERT_ARROW:
101
-      if (event == LV_EVENT_CLICKED) {
102
-
103
-      }
104
-      else if (event == LV_EVENT_RELEASED) {
105
-        lv_clear_eeprom_settings();
106
-        lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
107
-      }
62
+      lv_clear_eeprom_settings();
63
+      lv_draw_dialog(DIALOG_REVERT_EEPROM_TIPS);
108 64
       break;
109 65
   }
110 66
 }
111 67
 
112 68
 void lv_draw_eeprom_settings(void) {
113
-  lv_obj_t *buttonBack, *label_Back;
114
-  lv_obj_t *buttonStore, *labelStore;
115
-  //lv_obj_t *buttonRead,*labelRead,*buttonReadNarrow;
116
-  lv_obj_t *buttonRevert, *labelRevert;
117
-  lv_obj_t * line1, * line2; //* line3;
118 69
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EEPROM_SETTINGS_UI) {
119 70
     disp_state_stack._disp_index++;
120 71
     disp_state_stack._disp_state[disp_state_stack._disp_index] = EEPROM_SETTINGS_UI;
121 72
   }
122 73
   disp_state = EEPROM_SETTINGS_UI;
123 74
 
124
-  scr = lv_obj_create(NULL, NULL);
125
-
126
-  lv_obj_set_style(scr, &tft_style_scr);
127
-  lv_scr_load(scr);
128
-  lv_obj_clean(scr);
75
+  scr = lv_screen_create();
129 76
 
130 77
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
131
-
132 78
   lv_refr_now(lv_refr_get_disp_refreshing());
133 79
 
134
-  buttonRevert = lv_btn_create(scr, NULL);   /*Add a button the current screen*/
135
-  lv_obj_set_pos(buttonRevert, PARA_UI_POS_X, PARA_UI_POS_Y);                         /*Set its position*/
136
-  lv_obj_set_size(buttonRevert, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
137
-  //lv_obj_set_event_cb(buttonMotor, event_handler);
138
-  lv_obj_set_event_cb_mks(buttonRevert, event_handler, ID_EEPROM_REVERT, NULL, 0);
139
-  lv_btn_use_label_style(buttonRevert);
140
-  lv_btn_set_layout(buttonRevert, LV_LAYOUT_OFF);
141
-  labelRevert = lv_label_create_empty(buttonRevert);        /*Add a label to the button*/
142
-
143
-  (void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_EEPROM_REVERT_ARROW);
144
-
145
-  //line3 = lv_line_create(scr, NULL);
146
-  //lv_ex_line(line3,line_points[2]);
147
-  line1 = lv_line_create(scr, NULL);
148
-  lv_ex_line(line1, line_points[0]);
149
-
150
-  buttonStore = lv_btn_create(scr, NULL);   /*Add a button the current screen*/
151
-  lv_obj_set_pos(buttonStore, PARA_UI_POS_X, PARA_UI_POS_Y * 2);                      /*Set its position*/
152
-  lv_obj_set_size(buttonStore, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
153
-  //lv_obj_set_event_cb(buttonMotor, event_handler);
154
-  lv_obj_set_event_cb_mks(buttonStore, event_handler, ID_EEPROM_STORE, NULL, 0);
155
-  lv_btn_use_label_style(buttonStore);
156
-  lv_btn_set_layout(buttonStore, LV_LAYOUT_OFF);
157
-  labelStore = lv_label_create_empty(buttonStore);        /*Add a label to the button*/
158
-
159
-  (void)lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_EEPROM_STORE_ARROW);
160
-
161
-  line2 = lv_line_create(scr, NULL);
162
-  lv_ex_line(line2, line_points[1]);
163
-
164
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN);
165
-  label_Back = lv_label_create_empty(buttonBack);
166
-
167
-  if (gCfgItems.multiple_language) {
168
-    lv_label_set_text(label_Back, common_menu.text_back);
169
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
170
-
171
-    lv_label_set_text(labelStore, eeprom_menu.store);
172
-    lv_obj_align(labelStore, buttonStore, LV_ALIGN_IN_LEFT_MID,0, 0);
173
-
174
-    //lv_label_set_text(labelRead, eeprom_menu.read);
175
-    //lv_obj_align(labelRead, buttonRead, LV_ALIGN_IN_LEFT_MID,0, 0);
176
-
177
-    lv_label_set_text(labelRevert, eeprom_menu.revert);
178
-    lv_obj_align(labelRevert, buttonRevert, LV_ALIGN_IN_LEFT_MID, 0, 0);
179
-  }
180
-  #if HAS_ROTARY_ENCODER
181
-    if (gCfgItems.encoder_enable) {
182
-      lv_group_add_obj(g, buttonRevert);
183
-      lv_group_add_obj(g, buttonStore);
184
-      lv_group_add_obj(g, buttonBack);
185
-    }
186
-  #endif
187
-
80
+  lv_screen_menu_item(scr, eeprom_menu.revert, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_EEPROM_REVERT, 0);
81
+  lv_screen_menu_item(scr, eeprom_menu.store, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_EEPROM_STORE, 1);
82
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_EEPROM_RETURN, true);
188 83
 }
189 84
 
190 85
 void lv_clear_eeprom_settings() {

+ 17
- 57
Marlin/src/lcd/extui/lib/mks_ui/draw_encoder_settings.cpp View File

@@ -30,84 +30,44 @@
30 30
 
31 31
 #if BUTTONS_EXIST(EN1, EN2)
32 32
 
33
-extern lv_group_t * g;
34
-static lv_obj_t * scr;
35
-static lv_obj_t * buttonEncoderState = NULL;
36
-static lv_obj_t *labelEncoderState = NULL;
33
+extern lv_group_t *g;
34
+static lv_obj_t *scr;
35
+static lv_obj_t *buttonEncoderState = nullptr;
37 36
 
38
-#define ID_ENCODER_RETURN 1
39
-#define ID_ENCODER_STATE 2
37
+enum {
38
+  ID_ENCODER_RETURN = 1,
39
+  ID_ENCODER_STATE
40
+};
40 41
 
41
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
42 44
   switch (obj->mks_obj_id) {
43 45
     case ID_ENCODER_RETURN:
44
-      if (event == LV_EVENT_CLICKED) {
45
-
46
-      }
47
-      else if (event == LV_EVENT_RELEASED) {
48
-        lv_clear_encoder_settings();
49
-        draw_return_ui();
50
-      }
46
+      lv_clear_encoder_settings();
47
+      draw_return_ui();
51 48
       break;
52 49
     case ID_ENCODER_STATE:
53
-      if (event == LV_EVENT_CLICKED) {
54
-
55
-      }
56
-      else if (event == LV_EVENT_RELEASED) {
57
-        gCfgItems.encoder_enable ^= true;
58
-        lv_imgbtn_set_src_both(buttonEncoderState, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin");
59
-        lv_label_set_text(labelEncoderState, machine_menu.enable);
60
-        update_spi_flash();
61
-      }
50
+      gCfgItems.encoder_enable ^= true;
51
+      lv_screen_menu_item_onoff_update(buttonEncoderState, gCfgItems.encoder_enable);
52
+      update_spi_flash();
62 53
       break;
63 54
   }
64 55
 }
65 56
 
66 57
 void lv_draw_encoder_settings(void) {
67
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
68
-  lv_obj_t *labelEncoderTips = NULL;
69
-
70
-  lv_obj_t * line1 = NULL;
71
-
72 58
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ENCODER_SETTINGS_UI) {
73 59
     disp_state_stack._disp_index++;
74 60
     disp_state_stack._disp_state[disp_state_stack._disp_index] = ENCODER_SETTINGS_UI;
75 61
   }
76 62
   disp_state = ENCODER_SETTINGS_UI;
77 63
 
78
-  scr = lv_obj_create(NULL, NULL);
79
-
80
-  lv_obj_set_style(scr, &tft_style_scr);
81
-  lv_scr_load(scr);
82
-  lv_obj_clean(scr);
83
-
64
+  scr = lv_screen_create();
84 65
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.EncoderConfTitle);
85
-
86 66
   lv_refr_now(lv_refr_get_disp_refreshing());
87 67
 
88
-  labelEncoderTips = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.EncoderConfText);
68
+  buttonEncoderState = lv_screen_menu_item_onoff(scr, machine_menu.EncoderConfText, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_ENCODER_STATE, 0, gCfgItems.encoder_enable);
89 69
 
90
-  buttonEncoderState = lv_imgbtn_create(scr, gCfgItems.encoder_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_ENCODER_STATE);
91
-  labelEncoderState = lv_label_create_empty(buttonEncoderState);
92
-
93
-  line1 = lv_line_create(scr, NULL);
94
-  lv_ex_line(line1, line_points[0]);
95
-
96
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN);
97
-  label_Back = lv_label_create_empty(buttonBack);
98
-
99
-  lv_label_set_text(labelEncoderState, gCfgItems.encoder_enable ? machine_menu.enable : machine_menu.disable);
100
-  lv_obj_align(labelEncoderState, buttonEncoderState, LV_ALIGN_CENTER, 0, 0);
101
-
102
-  lv_label_set_text(label_Back, common_menu.text_back);
103
-  lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
104
-
105
-  #if HAS_ROTARY_ENCODER
106
-    if (gCfgItems.encoder_enable) {
107
-      lv_group_add_obj(g, buttonEncoderState);
108
-      lv_group_add_obj(g, buttonBack);
109
-    }
110
-  #endif
70
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_ENCODER_RETURN, true);
111 71
 }
112 72
 
113 73
 void lv_clear_encoder_settings() {

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

@@ -36,35 +36,31 @@
36 36
 #include "mks_hardware_test.h"
37 37
 #include "../../../../inc/MarlinConfig.h"
38 38
 
39
-static lv_obj_t * scr;
39
+static lv_obj_t *scr;
40 40
 
41 41
 void lv_draw_error_message(PGM_P const msg) {
42 42
   #if 0
43
-    static lv_obj_t * message = NULL, *kill_message = NULL, *reset_tips = NULL;
43
+    static lv_obj_t *message = nullptr, *kill_message = nullptr, *reset_tips = nullptr;
44 44
     if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ERROR_MESSAGE_UI) {
45 45
       disp_state_stack._disp_index++;
46 46
       disp_state_stack._disp_state[disp_state_stack._disp_index] = ERROR_MESSAGE_UI;
47 47
     }
48 48
     disp_state = ERROR_MESSAGE_UI;
49 49
 
50
-    scr = lv_obj_create(NULL, NULL);
51
-
52
-    lv_obj_set_style(scr, &tft_style_scr);
53
-    lv_scr_load(scr);
54
-    lv_obj_clean(scr);
50
+    scr = lv_screen_create();
55 51
 
56 52
     lv_refr_now(lv_refr_get_disp_refreshing());
57 53
 
58 54
     if (msg) {
59 55
       message = lv_label_create(scr, msg);
60
-      lv_obj_align(message, NULL, LV_ALIGN_CENTER, 0, -50);
56
+      lv_obj_align(message, nullptr, LV_ALIGN_CENTER, 0, -50);
61 57
     }
62 58
 
63 59
     kill_message = lv_label_create(scr, "PRINTER HALTED");
64
-    lv_obj_align(kill_message, NULL, LV_ALIGN_CENTER, 0, -10);
60
+    lv_obj_align(kill_message, nullptr, LV_ALIGN_CENTER, 0, -10);
65 61
 
66 62
     reset_tips = lv_label_create(scr, "Please Reset");
67
-    lv_obj_align(reset_tips, NULL, LV_ALIGN_CENTER, 0, 30);
63
+    lv_obj_align(reset_tips, nullptr, LV_ALIGN_CENTER, 0, 30);
68 64
 
69 65
     lv_task_handler();
70 66
   #endif

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

@@ -43,172 +43,121 @@ static lv_obj_t *labelSpeed;
43 43
 static lv_obj_t *tempText;
44 44
 static lv_obj_t *ExtruText;
45 45
 
46
-#define ID_E_ADD    1
47
-#define ID_E_DEC    2
48
-#define ID_E_TYPE   3
49
-#define ID_E_STEP   4
50
-#define ID_E_SPEED  5
51
-#define ID_E_RETURN 6
52
-
53
-static int32_t extructAmount;
54
-
55
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
46
+enum {
47
+  ID_E_ADD = 1,
48
+  ID_E_DEC,
49
+  ID_E_TYPE,
50
+  ID_E_STEP,
51
+  ID_E_SPEED,
52
+  ID_E_RETURN
53
+};
54
+
55
+static int32_t extrudeAmount;
56
+
57
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
58
+  if (event != LV_EVENT_RELEASED) return;
56 59
   switch (obj->mks_obj_id) {
57 60
     case ID_E_ADD:
58
-      if (event == LV_EVENT_CLICKED) {
59
-        // nothing to do
60
-      }
61
-      else if (event == LV_EVENT_RELEASED) {
62
-        if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
63
-          queue.enqueue_now_P(PSTR("G91"));
64
-          ZERO(public_buf_l);
65
-          sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
66
-          queue.enqueue_one_now(public_buf_l);
67
-          queue.enqueue_now_P(PSTR("G90"));
68
-          extructAmount += uiCfg.extruStep;
69
-          disp_extru_amount();
70
-        }
61
+      if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
62
+        queue.enqueue_now_P(PSTR("G91"));
63
+        sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), uiCfg.extruStep, 60 * uiCfg.extruSpeed);
64
+        queue.enqueue_one_now(public_buf_l);
65
+        queue.enqueue_now_P(PSTR("G90"));
66
+        extrudeAmount += uiCfg.extruStep;
67
+        disp_extru_amount();
71 68
       }
72 69
       break;
73 70
     case ID_E_DEC:
74
-      if (event == LV_EVENT_CLICKED) {
75
-        // nothing to do
76
-      }
77
-      else if (event == LV_EVENT_RELEASED) {
78
-        if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
79
-          queue.enqueue_now_P(PSTR("G91"));
80
-          ZERO(public_buf_l);
81
-          sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
82
-          queue.enqueue_one_now(public_buf_l);
83
-          queue.enqueue_now_P(PSTR("G90"));
84
-          extructAmount -= uiCfg.extruStep;
85
-          disp_extru_amount();
86
-        }
71
+      if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= EXTRUDE_MINTEMP) {
72
+        queue.enqueue_now_P(PSTR("G91"));
73
+        sprintf_P((char *)public_buf_l, PSTR("G1 E%d F%d"), 0 - uiCfg.extruStep, 60 * uiCfg.extruSpeed);
74
+        queue.enqueue_one_now(public_buf_l);
75
+        queue.enqueue_now_P(PSTR("G90"));
76
+        extrudeAmount -= uiCfg.extruStep;
77
+        disp_extru_amount();
87 78
       }
88 79
       break;
89 80
     case ID_E_TYPE:
90
-      if (event == LV_EVENT_CLICKED) {
91
-        // nothing to do
92
-      }
93
-      else if (event == LV_EVENT_RELEASED) {
94
-        if (ENABLED(HAS_MULTI_EXTRUDER)) {
95
-          if (uiCfg.curSprayerChoose == 0) {
96
-            uiCfg.curSprayerChoose = 1;
97
-            queue.inject_P(PSTR("T1"));
98
-          }
99
-          else {
100
-            uiCfg.curSprayerChoose = 0;
101
-            queue.inject_P(PSTR("T0"));
102
-          }
81
+      if (ENABLED(HAS_MULTI_EXTRUDER)) {
82
+        if (uiCfg.curSprayerChoose == 0) {
83
+          uiCfg.curSprayerChoose = 1;
84
+          queue.inject_P(PSTR("T1"));
103 85
         }
104
-        else
86
+        else {
105 87
           uiCfg.curSprayerChoose = 0;
106
-
107
-        extructAmount = 0;
108
-        disp_hotend_temp();
109
-        disp_ext_type();
110
-        disp_extru_amount();
88
+          queue.inject_P(PSTR("T0"));
89
+        }
111 90
       }
91
+      else
92
+        uiCfg.curSprayerChoose = 0;
93
+
94
+      extrudeAmount = 0;
95
+      disp_hotend_temp();
96
+      disp_ext_type();
97
+      disp_extru_amount();
112 98
       break;
113 99
     case ID_E_STEP:
114
-      if (event == LV_EVENT_CLICKED) {
115
-        // nothing to do
116
-      }
117
-      else if (event == LV_EVENT_RELEASED) {
118
-        switch (abs(uiCfg.extruStep)) {
119
-          case  1: uiCfg.extruStep = 5; break;
120
-          case  5: uiCfg.extruStep = 10; break;
121
-          case 10: uiCfg.extruStep = 1; break;
122
-          default: break;
123
-        }
124
-        disp_ext_step();
100
+      switch (abs(uiCfg.extruStep)) {
101
+        case  1: uiCfg.extruStep = 5; break;
102
+        case  5: uiCfg.extruStep = 10; break;
103
+        case 10: uiCfg.extruStep = 1; break;
104
+        default: break;
125 105
       }
106
+      disp_ext_step();
126 107
       break;
127 108
     case ID_E_SPEED:
128
-      if (event == LV_EVENT_CLICKED) {
129
-        // nothing to do
130
-      }
131
-      else if (event == LV_EVENT_RELEASED) {
132
-        switch (uiCfg.extruSpeed) {
133
-          case  1: uiCfg.extruSpeed = 10; break;
134
-          case 10: uiCfg.extruSpeed = 20; break;
135
-          case 20: uiCfg.extruSpeed = 1; break;
136
-          default: break;
137
-        }
138
-        disp_ext_speed();
109
+      switch (uiCfg.extruSpeed) {
110
+        case  1: uiCfg.extruSpeed = 10; break;
111
+        case 10: uiCfg.extruSpeed = 20; break;
112
+        case 20: uiCfg.extruSpeed = 1; break;
113
+        default: break;
139 114
       }
115
+      disp_ext_speed();
140 116
       break;
141 117
     case ID_E_RETURN:
142
-      if (event == LV_EVENT_CLICKED) {
143
-        // nothing to do
144
-      }
145
-      else if (event == LV_EVENT_RELEASED) {
146
-        clear_cur_ui();
147
-        draw_return_ui();
148
-      }
118
+      clear_cur_ui();
119
+      draw_return_ui();
149 120
       break;
150 121
   }
151 122
 }
152 123
 
153 124
 void lv_draw_extrusion(void) {
154
-  lv_obj_t *buttonAdd, *buttonDec, *buttonBack;
155
-
156 125
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != EXTRUSION_UI) {
157 126
     disp_state_stack._disp_index++;
158 127
     disp_state_stack._disp_state[disp_state_stack._disp_index] = EXTRUSION_UI;
159 128
   }
160 129
   disp_state = EXTRUSION_UI;
161 130
 
162
-  scr = lv_obj_create(NULL, NULL);
163
-
164
-  lv_obj_set_style(scr, &tft_style_scr);
165
-  lv_scr_load(scr);
166
-  lv_obj_clean(scr);
131
+  scr = lv_screen_create();
167 132
 
168 133
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
169 134
 
170 135
   lv_refr_now(lv_refr_get_disp_refreshing());
171 136
 
172 137
   // Create image buttons
173
-  buttonAdd = lv_imgbtn_create(scr, "F:/bmp_in.bin", INTERVAL_V, titleHeight, event_handler, ID_E_ADD);
138
+  lv_obj_t *buttonAdd = lv_big_button_create(scr, "F:/bmp_in.bin", extrude_menu.in, INTERVAL_V, titleHeight, event_handler, ID_E_ADD);
174 139
   lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
140
+  lv_big_button_create(scr, "F:/bmp_out.bin", extrude_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_E_DEC);
175 141
 
176
-  buttonDec = lv_imgbtn_create(scr, "F:/bmp_out.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_E_DEC);
177
-  buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_TYPE);
178
-  buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_STEP);
179
-  buttonSpeed = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_SPEED);
180
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_RETURN);
181
-
182
-  // Create labels on the image buttons
183
-  lv_obj_t *labelAdd   = lv_label_create_empty(buttonAdd);
184
-  lv_obj_t *labelDec   = lv_label_create_empty(buttonDec);
185
-  labelType             = lv_label_create_empty(buttonType);
186
-  labelStep             = lv_label_create_empty(buttonStep);
187
-  labelSpeed            = lv_label_create_empty(buttonSpeed);
188
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
189
-
190
-  if (gCfgItems.multiple_language) {
191
-    lv_label_set_text(labelAdd, extrude_menu.in);
192
-    lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
193
-
194
-    lv_label_set_text(labelDec, extrude_menu.out);
195
-    lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
196
-
197
-    lv_label_set_text(label_Back, common_menu.text_back);
198
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
199
-  }
142
+  buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_TYPE);
143
+  buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_STEP);
144
+  buttonSpeed = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_SPEED);
200 145
 
201 146
   #if HAS_ROTARY_ENCODER
202 147
     if (gCfgItems.encoder_enable) {
203
-      lv_group_add_obj(g, buttonAdd);
204
-      lv_group_add_obj(g, buttonDec);
205 148
       lv_group_add_obj(g, buttonType);
206 149
       lv_group_add_obj(g, buttonStep);
207 150
       lv_group_add_obj(g, buttonSpeed);
208
-      lv_group_add_obj(g, buttonBack);
209 151
     }
210 152
   #endif
211 153
 
154
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_E_RETURN);
155
+
156
+  // Create labels on the image buttons
157
+  labelType = lv_label_create_empty(buttonType);
158
+  labelStep = lv_label_create_empty(buttonStep);
159
+  labelSpeed = lv_label_create_empty(buttonSpeed);
160
+
212 161
   disp_ext_type();
213 162
   disp_ext_step();
214 163
   disp_ext_speed();
@@ -265,12 +214,11 @@ void disp_ext_speed() {
265 214
 
266 215
 void disp_hotend_temp() {
267 216
   char buf[20] = {0};
268
-  public_buf_l[0] = '\0';
269
-  strcat(public_buf_l, extrude_menu.temper_text);
270 217
   sprintf(buf, extrude_menu.temp_value, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
218
+  strcpy(public_buf_l, extrude_menu.temper_text);
271 219
   strcat(public_buf_l, buf);
272 220
   lv_label_set_text(tempText, public_buf_l);
273
-  lv_obj_align(tempText, NULL, LV_ALIGN_CENTER, 0, -50);
221
+  lv_obj_align(tempText, nullptr, LV_ALIGN_CENTER, 0, -50);
274 222
 }
275 223
 
276 224
 void disp_extru_amount() {
@@ -278,33 +226,17 @@ void disp_extru_amount() {
278 226
 
279 227
   public_buf_l[0] = '\0';
280 228
 
281
-  if (extructAmount < 999 && extructAmount > -99) {
282
-    sprintf(buf1, extrude_menu.count_value_mm, extructAmount);
283
-    if (uiCfg.curSprayerChoose < 1)
284
-      strcat(public_buf_l, extrude_menu.ext1);
285
-    else
286
-      strcat(public_buf_l, extrude_menu.ext2);
287
-    strcat(public_buf_l, buf1);
288
-  }
289
-  else if (extructAmount < 9999 && extructAmount > -999) {
290
-    sprintf(buf1, extrude_menu.count_value_cm, extructAmount / 10);
291
-    if (uiCfg.curSprayerChoose < 1)
292
-      strcat(public_buf_l, extrude_menu.ext1);
293
-    else
294
-      strcat(public_buf_l, extrude_menu.ext2);
295
-    strcat(public_buf_l, buf1);
296
-  }
297
-  else {
298
-    sprintf(buf1, extrude_menu.count_value_m, extructAmount / 1000);
299
-    if (uiCfg.curSprayerChoose < 1)
300
-      strcat(public_buf_l, extrude_menu.ext1);
301
-    else
302
-      strcat(public_buf_l, extrude_menu.ext2);
303
-    strcat(public_buf_l, buf1);
304
-  }
229
+  if (extrudeAmount < 999 && extrudeAmount > -99)
230
+    sprintf(buf1, extrude_menu.count_value_mm, extrudeAmount);
231
+  else if (extrudeAmount < 9999 && extrudeAmount > -999)
232
+    sprintf(buf1, extrude_menu.count_value_cm, extrudeAmount / 10);
233
+  else
234
+    sprintf(buf1, extrude_menu.count_value_m, extrudeAmount / 1000);
235
+  strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? extrude_menu.ext1 : extrude_menu.ext2);
236
+  strcat(public_buf_l, buf1);
305 237
 
306 238
   lv_label_set_text(ExtruText, public_buf_l);
307
-  lv_obj_align(ExtruText, NULL, LV_ALIGN_CENTER, 0, -75);
239
+  lv_obj_align(ExtruText, nullptr, LV_ALIGN_CENTER, 0, -75);
308 240
 }
309 241
 
310 242
 void disp_ext_step() {

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

@@ -35,87 +35,56 @@
35 35
 #include "../../../../gcode/gcode.h"
36 36
 #include "../../../../inc/MarlinConfig.h"
37 37
 
38
-extern lv_group_t * g;
39
-static lv_obj_t * scr;
40
-static lv_obj_t * fanText;
41
-
42
-#define ID_F_ADD     1
43
-#define ID_F_DEC     2
44
-#define ID_F_HIGH    3
45
-#define ID_F_MID     4
46
-#define ID_F_OFF     5
47
-#define ID_F_RETURN  6
38
+extern lv_group_t *g;
39
+static lv_obj_t *scr;
40
+static lv_obj_t *fanText;
41
+
42
+enum {
43
+  ID_F_ADD = 1,
44
+  ID_F_DEC,
45
+  ID_F_HIGH,
46
+  ID_F_MID,
47
+  ID_F_OFF,
48
+  ID_F_RETURN
49
+};
48 50
 
49 51
 static uint8_t fanSpeed;
50 52
 
51
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
53
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
54
+  if (event != LV_EVENT_RELEASED) return;
52 55
   switch (obj->mks_obj_id) {
53 56
     case ID_F_ADD:
54
-      if (event == LV_EVENT_CLICKED) {
55
-        // nothing to do
56
-      }
57
-      else if (event == LV_EVENT_RELEASED) {
58
-        if (fanSpeed + 1 <= 255) {
59
-          fanSpeed++;
60
-          ZERO(public_buf_l);
61
-          sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
62
-          gcode.process_subcommands_now(public_buf_l);
63
-        }
57
+      if (fanSpeed + 1 <= 255) {
58
+        fanSpeed++;
59
+        sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
60
+        gcode.process_subcommands_now(public_buf_l);
64 61
       }
65 62
       break;
66 63
     case ID_F_DEC:
67
-      if (event == LV_EVENT_CLICKED) {
68
-        // nothing to do
69
-      }
70
-      else if (event == LV_EVENT_RELEASED) {
71
-        if (fanSpeed > 0) {
72
-          fanSpeed--;
73
-          ZERO(public_buf_l);
74
-          sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
75
-          gcode.process_subcommands_now(public_buf_l);
76
-        }
64
+      if (fanSpeed > 0) {
65
+        fanSpeed--;
66
+        sprintf_P(public_buf_l, PSTR("M106 S%d"), fanSpeed);
67
+        gcode.process_subcommands_now(public_buf_l);
77 68
       }
78
-
79 69
       break;
80 70
     case ID_F_HIGH:
81
-      if (event == LV_EVENT_CLICKED) {
82
-        // nothing to do
83
-      }
84
-      else if (event == LV_EVENT_RELEASED) {
85
-        gcode.process_subcommands_now_P(PSTR("M106 S255"));
86
-      }
71
+      gcode.process_subcommands_now_P(PSTR("M106 S255"));
87 72
       break;
88 73
     case ID_F_MID:
89
-      if (event == LV_EVENT_CLICKED) {
90
-        // nothing to do
91
-      }
92
-      else if (event == LV_EVENT_RELEASED) {
93
-        gcode.process_subcommands_now_P(PSTR("M106 S127"));
94
-      }
74
+      gcode.process_subcommands_now_P(PSTR("M106 S127"));
95 75
       break;
96 76
     case ID_F_OFF:
97
-      if (event == LV_EVENT_CLICKED) {
98
-        // nothing to do
99
-      }
100
-      else if (event == LV_EVENT_RELEASED) {
101
-        gcode.process_subcommands_now_P(PSTR("M107"));
102
-      }
77
+      gcode.process_subcommands_now_P(PSTR("M107"));
103 78
       break;
104 79
     case ID_F_RETURN:
105
-      if (event == LV_EVENT_CLICKED) {
106
-        // nothing to do
107
-      }
108
-      else if (event == LV_EVENT_RELEASED) {
109
-        clear_cur_ui();
110
-        draw_return_ui();
111
-      }
80
+      clear_cur_ui();
81
+      draw_return_ui();
112 82
       break;
113 83
   }
114 84
 }
115 85
 
116 86
 void lv_draw_fan(void) {
117
-  lv_obj_t *buttonAdd, *buttonDec, *buttonHigh, *buttonMid;
118
-  lv_obj_t *buttonOff, *buttonBack;
87
+  lv_obj_t *buttonAdd;
119 88
 
120 89
   #if HAS_FAN
121 90
     fanSpeed = thermalManager.fan_speed[0];
@@ -126,63 +95,20 @@ void lv_draw_fan(void) {
126 95
   }
127 96
   disp_state = FAN_UI;
128 97
 
129
-  scr = lv_obj_create(NULL, NULL);
130
-
131
-  lv_obj_set_style(scr, &tft_style_scr);
132
-  lv_scr_load(scr);
133
-  lv_obj_clean(scr);
98
+  scr = lv_screen_create();
134 99
 
135 100
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
136 101
 
137 102
   lv_refr_now(lv_refr_get_disp_refreshing());
138 103
 
139 104
   // Create an Image button
140
-  buttonAdd  = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
105
+  buttonAdd  = lv_big_button_create(scr, "F:/bmp_Add.bin", fan_menu.add, INTERVAL_V, titleHeight, event_handler, ID_F_ADD);
141 106
   lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
142
-
143
-  buttonDec  = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_F_DEC);
144
-  buttonHigh = lv_imgbtn_create(scr, "F:/bmp_speed255.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_HIGH);
145
-  buttonMid  = lv_imgbtn_create(scr, "F:/bmp_speed127.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_MID);
146
-  buttonOff  = lv_imgbtn_create(scr, "F:/bmp_speed0.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_OFF);
147
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_RETURN);
148
-
149
-  // Create labels on the image buttons
150
-  lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd);
151
-  lv_obj_t *labelDec = lv_label_create_empty(buttonDec);
152
-  lv_obj_t *labelHigh = lv_label_create_empty(buttonHigh);
153
-  lv_obj_t *labelMid = lv_label_create_empty(buttonMid);
154
-  lv_obj_t *labelOff = lv_label_create_empty(buttonOff);
155
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
156
-
157
-  if (gCfgItems.multiple_language) {
158
-    lv_label_set_text(labelAdd, fan_menu.add);
159
-    lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
160
-
161
-    lv_label_set_text(labelDec, fan_menu.dec);
162
-    lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
163
-
164
-    lv_label_set_text(labelHigh, fan_menu.full);
165
-    lv_obj_align(labelHigh, buttonHigh, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
166
-
167
-    lv_label_set_text(labelMid, fan_menu.half);
168
-    lv_obj_align(labelMid, buttonMid, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
169
-
170
-    lv_label_set_text(labelOff, fan_menu.off);
171
-    lv_obj_align(labelOff, buttonOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
172
-
173
-    lv_label_set_text(label_Back, common_menu.text_back);
174
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
175
-  }
176
-  #if HAS_ROTARY_ENCODER
177
-    if (gCfgItems.encoder_enable) {
178
-      lv_group_add_obj(g, buttonAdd);
179
-      lv_group_add_obj(g, buttonDec);
180
-      lv_group_add_obj(g, buttonHigh);
181
-      lv_group_add_obj(g, buttonMid);
182
-      lv_group_add_obj(g, buttonOff);
183
-      lv_group_add_obj(g, buttonBack);
184
-    }
185
-  #endif
107
+  lv_big_button_create(scr, "F:/bmp_Dec.bin", fan_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_F_DEC);
108
+  lv_big_button_create(scr, "F:/bmp_speed255.bin", fan_menu.full, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_HIGH);
109
+  lv_big_button_create(scr, "F:/bmp_speed127.bin", fan_menu.half, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_MID);
110
+  lv_big_button_create(scr, "F:/bmp_speed0.bin", fan_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_OFF);
111
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_F_RETURN);
186 112
 
187 113
   fanText = lv_label_create_empty(scr);
188 114
   lv_obj_set_style(fanText, &tft_style_label_rel);
@@ -197,7 +123,7 @@ void disp_fan_value() {
197 123
   sprintf_P(buf1, PSTR("%3d"), thermalManager.fan_speed[0]);
198 124
   strcat(public_buf_l, buf1);
199 125
   lv_label_set_text(fanText, public_buf_l);
200
-  lv_obj_align(fanText, NULL, LV_ALIGN_CENTER, 0, -65);
126
+  lv_obj_align(fanText, nullptr, LV_ALIGN_CENTER, 0, -65);
201 127
 }
202 128
 
203 129
 void lv_clear_fan() {

+ 63
- 107
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp View File

@@ -38,150 +38,109 @@ static lv_obj_t *buttonType;
38 38
 static lv_obj_t *labelType;
39 39
 static lv_obj_t *tempText1;
40 40
 
41
-#define ID_FILAMNT_IN     1
42
-#define ID_FILAMNT_OUT    2
43
-#define ID_FILAMNT_TYPE   3
44
-#define ID_FILAMNT_RETURN 4
41
+enum {
42
+  ID_FILAMNT_IN = 1,
43
+  ID_FILAMNT_OUT,
44
+  ID_FILAMNT_TYPE,
45
+  ID_FILAMNT_RETURN
46
+};
45 47
 
46 48
 extern feedRate_t feedrate_mm_s;
47 49
 
48
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
50
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
51
+  if (event != LV_EVENT_RELEASED) return;
49 52
   switch (obj->mks_obj_id) {
50 53
     case ID_FILAMNT_IN:
51
-      if (event == LV_EVENT_CLICKED) {
52
-        // nothing to do
54
+      uiCfg.filament_load_heat_flg = 1;
55
+      if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1)
56
+          || (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) {
57
+        lv_clear_filament_change();
58
+        lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
53 59
       }
54
-      else if (event == LV_EVENT_RELEASED) {
55
-        uiCfg.filament_load_heat_flg = 1;
56
-        if ((abs(thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius) <= 1)
57
-            || (gCfgItems.filament_limit_temper <= thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) {
58
-          lv_clear_filament_change();
59
-          lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
60
-        }
61
-        else {
62
-          lv_clear_filament_change();
63
-          lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
64
-          if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
65
-            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
66
-            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
67
-          }
60
+      else {
61
+        lv_clear_filament_change();
62
+        lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
63
+        if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
64
+          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
65
+          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
68 66
         }
69 67
       }
70 68
       break;
71 69
     case ID_FILAMNT_OUT:
72
-      if (event == LV_EVENT_CLICKED) {
73
-        // nothing to do
70
+      uiCfg.filament_unload_heat_flg=1;
71
+      if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0)
72
+        && ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1)
73
+        || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper))
74
+      ) {
75
+        lv_clear_filament_change();
76
+        lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
74 77
       }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        uiCfg.filament_unload_heat_flg=1;
77
-        if ((thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > 0)
78
-          && ((abs((int)((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target - thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius)) <= 1)
79
-          || ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius >= gCfgItems.filament_limit_temper))
80
-        ) {
81
-          lv_clear_filament_change();
82
-          lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
83
-        }
84
-        else {
85
-          lv_clear_filament_change();
86
-          lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
87
-          if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
88
-            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
89
-            thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
90
-          }
91
-          filament_sprayer_temp();
78
+      else {
79
+        lv_clear_filament_change();
80
+        lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
81
+        if (thermalManager.temp_hotend[uiCfg.curSprayerChoose].target < gCfgItems.filament_limit_temper) {
82
+          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = gCfgItems.filament_limit_temper;
83
+          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
92 84
         }
85
+        filament_sprayer_temp();
93 86
       }
94 87
       break;
95 88
     case ID_FILAMNT_TYPE:
96
-      if (event == LV_EVENT_CLICKED) {
97
-        // nothing to do
98
-      }
99
-      else if (event == LV_EVENT_RELEASED) {
100
-        #if HAS_MULTI_EXTRUDER
101
-          if (uiCfg.curSprayerChoose == 0)
102
-            uiCfg.curSprayerChoose = 1;
103
-          else if (uiCfg.curSprayerChoose == 1)
104
-            uiCfg.curSprayerChoose = 0;
105
-        #endif
106
-        disp_filament_type();
107
-      }
89
+      #if HAS_MULTI_EXTRUDER
90
+        if (uiCfg.curSprayerChoose == 0)
91
+          uiCfg.curSprayerChoose = 1;
92
+        else if (uiCfg.curSprayerChoose == 1)
93
+          uiCfg.curSprayerChoose = 0;
94
+      #endif
95
+      disp_filament_type();
108 96
       break;
109 97
     case ID_FILAMNT_RETURN:
110
-      if (event == LV_EVENT_CLICKED) {
111
-        // nothing to do
112
-      }
113
-      else if (event == LV_EVENT_RELEASED) {
114
-        #if HAS_MULTI_EXTRUDER
115
-          if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
116
-            gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
117
-        #endif
118
-        feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
119
-        if (uiCfg.print_state == PAUSED)
120
-          planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
121
-          //current_position.e = destination.e = uiCfg.current_e_position_bak;
122
-        thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
123
-
124
-        clear_cur_ui();
125
-        draw_return_ui();
126
-      }
98
+      #if HAS_MULTI_EXTRUDER
99
+        if (uiCfg.print_state != IDLE && uiCfg.print_state != REPRINTED)
100
+          gcode.process_subcommands_now_P(uiCfg.curSprayerChoose_bak == 1 ? PSTR("T1") : PSTR("T0"));
101
+      #endif
102
+      feedrate_mm_s = (float)uiCfg.moveSpeed_bak;
103
+      if (uiCfg.print_state == PAUSED)
104
+        planner.set_e_position_mm((destination.e = current_position.e = uiCfg.current_e_position_bak));
105
+        //current_position.e = destination.e = uiCfg.current_e_position_bak;
106
+      thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = uiCfg.desireSprayerTempBak;
107
+
108
+      clear_cur_ui();
109
+      draw_return_ui();
127 110
       break;
128 111
   }
129 112
 }
130 113
 
131 114
 void lv_draw_filament_change(void) {
132
-  lv_obj_t *buttonIn, *buttonOut;
133
-  lv_obj_t *buttonBack;
134
-
135 115
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENTCHANGE_UI) {
136 116
     disp_state_stack._disp_index++;
137 117
     disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENTCHANGE_UI;
138 118
   }
139 119
   disp_state = FILAMENTCHANGE_UI;
140 120
 
141
-  scr = lv_obj_create(NULL, NULL);
142
-
143
-  lv_obj_set_style(scr, &tft_style_scr);
144
-  lv_scr_load(scr);
145
-  lv_obj_clean(scr);
121
+  scr = lv_screen_create();
146 122
 
147 123
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
148 124
 
149 125
   lv_refr_now(lv_refr_get_disp_refreshing());
150 126
 
151 127
   // Create an Image button
152
-  buttonIn = lv_imgbtn_create(scr, "F:/bmp_in.bin", INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN);
128
+  lv_obj_t *buttonIn = lv_big_button_create(scr, "F:/bmp_in.bin", filament_menu.in, INTERVAL_V, titleHeight, event_handler, ID_FILAMNT_IN);
153 129
   lv_obj_clear_protect(buttonIn, LV_PROTECT_FOLLOW);
130
+  lv_big_button_create(scr, "F:/bmp_out.bin", filament_menu.out, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT);
154 131
 
155
-  buttonOut = lv_imgbtn_create(scr, "F:/bmp_out.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_FILAMNT_OUT);
156
-  buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
157
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
158
-
159
-  // Create labels on the image buttons
160
-  lv_obj_t *labelIn  = lv_label_create_empty(buttonIn);
161
-  lv_obj_t *labelOut = lv_label_create_empty(buttonOut);
162
-  labelType = lv_label_create_empty(buttonType);
163
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
164
-
165
-  if (gCfgItems.multiple_language) {
166
-    lv_label_set_text(labelIn, filament_menu.in);
167
-    lv_obj_align(labelIn, buttonIn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
168
-
169
-    lv_label_set_text(labelOut, filament_menu.out);
170
-    lv_obj_align(labelOut, buttonOut, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
171
-
172
-    lv_label_set_text(label_Back, common_menu.text_back);
173
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
174
-  }
175
-
132
+  buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_TYPE);
176 133
   #if HAS_ROTARY_ENCODER
177 134
     if (gCfgItems.encoder_enable) {
178
-      lv_group_add_obj(g, buttonIn);
179
-      lv_group_add_obj(g, buttonOut);
180 135
       lv_group_add_obj(g, buttonType);
181
-      lv_group_add_obj(g, buttonBack);
182 136
     }
183 137
   #endif
184 138
 
139
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FILAMNT_RETURN);
140
+
141
+  // Create labels on the image buttons
142
+  labelType = lv_label_create_empty(buttonType);
143
+
185 144
   disp_filament_type();
186 145
 
187 146
   tempText1 = lv_label_create_empty(scr);
@@ -211,16 +170,13 @@ void disp_filament_temp() {
211 170
 
212 171
   public_buf_l[0] = '\0';
213 172
 
214
-  if (uiCfg.curSprayerChoose < 1)
215
-    strcat(public_buf_l, preheat_menu.ext1);
216
-  else
217
-    strcat(public_buf_l, preheat_menu.ext2);
173
+  strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
218 174
   sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius,  (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
219 175
 
220 176
   strcat_P(public_buf_l, PSTR(": "));
221 177
   strcat(public_buf_l, buf);
222 178
   lv_label_set_text(tempText1, public_buf_l);
223
-  lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
179
+  lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
224 180
 }
225 181
 
226 182
 void lv_clear_filament_change() {

+ 54
- 185
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp View File

@@ -28,233 +28,102 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
34
-#define ID_FILAMENT_SET_RETURN      1
35
-#define ID_FILAMENT_SET_IN_LENGTH   2
36
-#define ID_FILAMENT_SET_IN_SPEED    3
37
-#define ID_FILAMENT_SET_OUT_LENGTH  4
38
-#define ID_FILAMENT_SET_OUT_SPEED   5
39
-#define ID_FILAMENT_SET_TEMP        6
40
-#define ID_FILAMENT_SET_DOWN        12
41
-#define ID_FILAMENT_SET_UP          13
42
-
43
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_FILAMENT_SET_RETURN = 1,
36
+  ID_FILAMENT_SET_IN_LENGTH,
37
+  ID_FILAMENT_SET_IN_SPEED,
38
+  ID_FILAMENT_SET_OUT_LENGTH,
39
+  ID_FILAMENT_SET_OUT_SPEED,
40
+  ID_FILAMENT_SET_TEMP,
41
+  ID_FILAMENT_SET_DOWN,
42
+  ID_FILAMENT_SET_UP
43
+};
44
+
45
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
46
+  if (event != LV_EVENT_RELEASED) return;
44 47
   switch (obj->mks_obj_id) {
45 48
     case ID_FILAMENT_SET_RETURN:
46
-      if (event == LV_EVENT_CLICKED) {
47
-
48
-      }
49
-      else if (event == LV_EVENT_RELEASED) {
50
-        uiCfg.para_ui_page = 0;
51
-        lv_clear_filament_settings();
52
-        draw_return_ui();
53
-      }
49
+      uiCfg.para_ui_page = 0;
50
+      lv_clear_filament_settings();
51
+      draw_return_ui();
54 52
       break;
55 53
     case ID_FILAMENT_SET_IN_LENGTH:
56
-      if (event == LV_EVENT_CLICKED) {
57
-
58
-      }
59
-      else if (event == LV_EVENT_RELEASED) {
60
-        value = load_length;
61
-        lv_clear_filament_settings();
62
-        lv_draw_number_key();
63
-      }
54
+      value = load_length;
55
+      lv_clear_filament_settings();
56
+      lv_draw_number_key();
64 57
       break;
65 58
     case ID_FILAMENT_SET_IN_SPEED:
66
-      if (event == LV_EVENT_CLICKED) {
67
-
68
-      }
69
-      else if (event == LV_EVENT_RELEASED) {
70
-        value = load_speed;
71
-        lv_clear_filament_settings();
72
-        lv_draw_number_key();
73
-      }
59
+      value = load_speed;
60
+      lv_clear_filament_settings();
61
+      lv_draw_number_key();
74 62
       break;
75 63
     case ID_FILAMENT_SET_OUT_LENGTH:
76
-      if (event == LV_EVENT_CLICKED) {
77
-
78
-      }
79
-      else if (event == LV_EVENT_RELEASED) {
80
-        value = unload_length;
81
-        lv_clear_filament_settings();
82
-        lv_draw_number_key();
83
-      }
64
+      value = unload_length;
65
+      lv_clear_filament_settings();
66
+      lv_draw_number_key();
84 67
       break;
85 68
     case ID_FILAMENT_SET_OUT_SPEED:
86
-      if (event == LV_EVENT_CLICKED) {
87
-
88
-      }
89
-      else if (event == LV_EVENT_RELEASED) {
90
-        value = unload_speed;
91
-        lv_clear_filament_settings();
92
-        lv_draw_number_key();
93
-      }
69
+      value = unload_speed;
70
+      lv_clear_filament_settings();
71
+      lv_draw_number_key();
94 72
       break;
95 73
     case ID_FILAMENT_SET_TEMP:
96
-      if (event == LV_EVENT_CLICKED) {
97
-
98
-      }
99
-      else if (event == LV_EVENT_RELEASED) {
100
-        value = filament_temp;
101
-        lv_clear_filament_settings();
102
-        lv_draw_number_key();
103
-      }
74
+      value = filament_temp;
75
+      lv_clear_filament_settings();
76
+      lv_draw_number_key();
104 77
       break;
105 78
     case ID_FILAMENT_SET_UP:
106
-      if (event == LV_EVENT_CLICKED) {
107
-
108
-      }
109
-      else if (event == LV_EVENT_RELEASED) {
110
-        uiCfg.para_ui_page = 0;
111
-        lv_clear_filament_settings();
112
-        lv_draw_filament_settings();
113
-      }
79
+      uiCfg.para_ui_page = 0;
80
+      lv_clear_filament_settings();
81
+      lv_draw_filament_settings();
114 82
       break;
115 83
     case ID_FILAMENT_SET_DOWN:
116
-      if (event == LV_EVENT_CLICKED) {
117
-
118
-      }
119
-      else if (event == LV_EVENT_RELEASED) {
120
-        uiCfg.para_ui_page = 1;
121
-        lv_clear_filament_settings();
122
-        lv_draw_filament_settings();
123
-      }
84
+      uiCfg.para_ui_page = 1;
85
+      lv_clear_filament_settings();
86
+      lv_draw_filament_settings();
124 87
       break;
125 88
   }
126 89
 }
127 90
 
128 91
 void lv_draw_filament_settings(void) {
129
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
130
-  lv_obj_t *buttonInLengthValue = NULL, *labelInLengthValue = NULL;
131
-  lv_obj_t *buttonInSpeedValue = NULL, *labelInSpeedValue = NULL;
132
-  lv_obj_t *buttonOutLengthValue = NULL, *labelOutLengthValue = NULL;
133
-  lv_obj_t *buttonOutSpeedValue = NULL, *labelOutSpeedValue = NULL;
134
-  lv_obj_t *buttonTemperValue = NULL, *labelTemperValue = NULL;
135
-  lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
136 92
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != FILAMENT_SETTINGS_UI) {
137 93
     disp_state_stack._disp_index++;
138 94
     disp_state_stack._disp_state[disp_state_stack._disp_index] = FILAMENT_SETTINGS_UI;
139 95
   }
140 96
   disp_state = FILAMENT_SETTINGS_UI;
141 97
 
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);
98
+  scr = lv_screen_create();
147 99
 
148 100
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.FilamentConfTitle);
149 101
 
150 102
   lv_refr_now(lv_refr_get_disp_refreshing());
151 103
 
152 104
   if (uiCfg.para_ui_page != 1) {
153
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.InLength);
154
-
155
-    buttonInLengthValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_IN_LENGTH);
156
-    labelInLengthValue = lv_label_create_empty(buttonInLengthValue);
157
-
158
-    line1 = lv_line_create(scr, NULL);
159
-    lv_ex_line(line1, line_points[0]);
160
-
161
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.InSpeed);
162
-
163
-    buttonInSpeedValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_IN_SPEED);
164
-    labelInSpeedValue = lv_label_create_empty(buttonInSpeedValue);
165
-
166
-    line2 = lv_line_create(scr, NULL);
167
-    lv_ex_line(line2, line_points[1]);
168
-
169
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 6, machine_menu.OutLength);
170
-
171
-    buttonOutLengthValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_OUT_LENGTH);
172
-    labelOutLengthValue = lv_label_create_empty(buttonOutLengthValue);
105
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length);
106
+    lv_screen_menu_item_1_edit(scr, machine_menu.InLength, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_IN_LENGTH, 0, public_buf_l);
173 107
 
174
-    line3 = lv_line_create(scr, NULL);
175
-    lv_ex_line(line3, line_points[2]);
108
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed);
109
+    lv_screen_menu_item_1_edit(scr, machine_menu.InSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FILAMENT_SET_IN_SPEED, 1, public_buf_l);
176 110
 
177
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.OutSpeed);
111
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length);
112
+    lv_screen_menu_item_1_edit(scr, machine_menu.OutLength, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FILAMENT_SET_OUT_LENGTH, 2, public_buf_l);
178 113
 
179
-    buttonOutSpeedValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_OUT_SPEED);
180
-    labelOutSpeedValue = lv_label_create_empty(buttonOutSpeedValue);
114
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
115
+    lv_screen_menu_item_1_edit(scr, machine_menu.OutSpeed, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FILAMENT_SET_OUT_SPEED, 3, public_buf_l);
181 116
 
182
-    line4 = lv_line_create(scr, NULL);
183
-    lv_ex_line(line4, line_points[3]);
184
-
185
-    buttonTurnPage = lv_btn_create_back(scr, event_handler, ID_FILAMENT_SET_DOWN);
186
-
187
-    #if HAS_ROTARY_ENCODER
188
-      if (gCfgItems.encoder_enable) {
189
-        lv_group_add_obj(g, buttonInLengthValue);
190
-        lv_group_add_obj(g, buttonInSpeedValue);
191
-        lv_group_add_obj(g, buttonOutLengthValue);
192
-        lv_group_add_obj(g, buttonOutSpeedValue);
193
-        lv_group_add_obj(g, buttonTurnPage);
194
-      }
195
-    #endif
117
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_DOWN, true);
196 118
   }
197 119
   else {
198
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.FilamentTemperature);
199
-
200
-    buttonTemperValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_TEMP);
201
-    labelTemperValue = lv_label_create_empty(buttonTemperValue);
202
-
203
-    line1 = lv_line_create(scr, NULL);
204
-    lv_ex_line(line1, line_points[0]);
205
-
206
-    buttonTurnPage = lv_btn_create_back(scr, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_UP);
120
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
121
+    lv_screen_menu_item_1_edit(scr, machine_menu.FilamentTemperature, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FILAMENT_SET_TEMP, 0, public_buf_l);
207 122
 
208
-    #if HAS_ROTARY_ENCODER
209
-      if (gCfgItems.encoder_enable) {
210
-        lv_group_add_obj(g, buttonTemperValue);
211
-        lv_group_add_obj(g, buttonTurnPage);
212
-      }
213
-    #endif
123
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FILAMENT_SET_UP, true);
214 124
   }
215 125
 
216
-  labelTurnPage = lv_label_create_empty(buttonTurnPage);
217
-
218
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_FILAMENT_SET_RETURN);
219
-  label_Back = lv_label_create_empty(buttonBack);
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) {
226
-    if (uiCfg.para_ui_page != 1) {
227
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_length);
228
-      lv_label_set_text(labelInLengthValue, public_buf_l);
229
-      lv_obj_align(labelInLengthValue, buttonInLengthValue, LV_ALIGN_CENTER, 0, 0);
230
-
231
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_load_speed);
232
-      lv_label_set_text(labelInSpeedValue, public_buf_l);
233
-      lv_obj_align(labelInSpeedValue, buttonInSpeedValue, LV_ALIGN_CENTER, 0, 0);
234
-
235
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_length);
236
-      lv_label_set_text(labelOutLengthValue, public_buf_l);
237
-      lv_obj_align(labelOutLengthValue, buttonOutLengthValue, LV_ALIGN_CENTER, 0, 0);
238
-
239
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
240
-      lv_label_set_text(labelOutSpeedValue, public_buf_l);
241
-      lv_obj_align(labelOutSpeedValue, buttonOutSpeedValue, LV_ALIGN_CENTER, 0, 0);
242
-
243
-      lv_label_set_text(labelTurnPage, machine_menu.next);
244
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
245
-    }
246
-    else {
247
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
248
-      lv_label_set_text(labelTemperValue, public_buf_l);
249
-      lv_obj_align(labelTemperValue, buttonTemperValue, LV_ALIGN_CENTER, 0, 0);
250
-
251
-      lv_label_set_text(labelTurnPage, machine_menu.previous);
252
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
253
-    }
254
-
255
-    lv_label_set_text(label_Back, common_menu.text_back);
256
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
257
-  }
126
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FILAMENT_SET_RETURN, true);
258 127
 }
259 128
 
260 129
 void lv_clear_filament_settings() {

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

@@ -35,149 +35,67 @@
35 35
 #include "../../../../gcode/queue.h"
36 36
 #include "../../../../inc/MarlinConfig.h"
37 37
 
38
-extern lv_group_t * g;
39
-static lv_obj_t * scr;
40
-
41
-#define ID_H_ALL      1
42
-#define ID_H_X        2
43
-#define ID_H_Y        3
44
-#define ID_H_Z        4
45
-#define ID_H_RETURN   5
46
-#define ID_H_OFF_ALL  6
47
-#define ID_H_OFF_XY   7
48
-
49
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
38
+extern lv_group_t *g;
39
+static lv_obj_t *scr;
40
+
41
+enum {
42
+  ID_H_ALL = 1,
43
+  ID_H_X,
44
+  ID_H_Y,
45
+  ID_H_Z,
46
+  ID_H_RETURN,
47
+  ID_H_OFF_ALL,
48
+  ID_H_OFF_XY
49
+};
50
+
51
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
52
+  if (event != LV_EVENT_RELEASED) return;
50 53
   switch (obj->mks_obj_id) {
51 54
     case ID_H_ALL:
52
-      if (event == LV_EVENT_CLICKED) {
53
-      }
54
-      else if (event == LV_EVENT_RELEASED) {
55
-        queue.inject_P(PSTR("G28"));
56
-      }
55
+      queue.inject_P(PSTR("G28"));
57 56
       break;
58 57
     case ID_H_X:
59
-      if (event == LV_EVENT_CLICKED) {
60
-      }
61
-      else if (event == LV_EVENT_RELEASED) {
62
-        queue.inject_P(PSTR("G28 X0"));
63
-      }
58
+      queue.inject_P(PSTR("G28 X0"));
64 59
       break;
65 60
     case ID_H_Y:
66
-      if (event == LV_EVENT_CLICKED) {
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        queue.inject_P(PSTR("G28 Y0"));
70
-      }
61
+      queue.inject_P(PSTR("G28 Y0"));
71 62
       break;
72 63
     case ID_H_Z:
73
-      if (event == LV_EVENT_CLICKED) {
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        queue.inject_P(PSTR("G28 Z0"));
77
-      }
64
+      queue.inject_P(PSTR("G28 Z0"));
78 65
       break;
79 66
     case ID_H_OFF_ALL:
80
-      if (event == LV_EVENT_CLICKED) {
81
-      }
82
-      else if (event == LV_EVENT_RELEASED) {
83
-        queue.inject_P(PSTR("M84"));
84
-      }
67
+      queue.inject_P(PSTR("M84"));
85 68
       break;
86 69
     case ID_H_OFF_XY:
87
-      if (event == LV_EVENT_CLICKED) {
88
-      }
89
-      else if (event == LV_EVENT_RELEASED) {
90
-        queue.inject_P(PSTR("M84 X Y"));
91
-      }
70
+      queue.inject_P(PSTR("M84 X Y"));
92 71
       break;
93 72
     case ID_H_RETURN:
94
-      if (event == LV_EVENT_CLICKED) {
95
-      }
96
-      else if (event == LV_EVENT_RELEASED) {
97
-        lv_clear_home();
98
-        lv_draw_tool();
99
-      }
73
+      lv_clear_home();
74
+      lv_draw_tool();
100 75
       break;
101 76
   }
102 77
 }
103 78
 
104 79
 void lv_draw_home(void) {
105
-  lv_obj_t *buttonHomeAll, *buttonHomeX, *buttonHomeY, *buttonHomeZ;
106
-  lv_obj_t *buttonBack;
107
-  lv_obj_t *buttonOffAll, *buttonOffXY;
108
-
109 80
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != ZERO_UI) {
110 81
     disp_state_stack._disp_index++;
111 82
     disp_state_stack._disp_state[disp_state_stack._disp_index] = ZERO_UI;
112 83
   }
113 84
   disp_state = ZERO_UI;
114 85
 
115
-  scr = lv_obj_create(NULL, NULL);
116
-
117
-  //static lv_style_t tool_style;
118
-
119
-  lv_obj_set_style(scr, &tft_style_scr);
120
-  lv_scr_load(scr);
121
-  lv_obj_clean(scr);
86
+  scr = lv_screen_create();
122 87
 
123 88
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
124 89
 
125 90
   lv_refr_now(lv_refr_get_disp_refreshing());
126 91
 
127
-  // Create image buttons
128
-  //buttonWifi     = lv_imgbtn_create(scr, NULL);
129
-  //buttonContinue = lv_imgbtn_create(scr, NULL);
130
-  buttonHomeAll = lv_imgbtn_create(scr, "F:/bmp_zeroAll.bin", INTERVAL_V, titleHeight, event_handler, ID_H_ALL);
131
-  buttonHomeX   = lv_imgbtn_create(scr, "F:/bmp_zeroX.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X);
132
-  buttonHomeY   = lv_imgbtn_create(scr, "F:/bmp_zeroY.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y);
133
-  buttonHomeZ   = lv_imgbtn_create(scr, "F:/bmp_zeroZ.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_H_Z);
134
-  buttonOffAll  = lv_imgbtn_create(scr, "F:/bmp_function1.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_ALL);
135
-  buttonOffXY   = lv_imgbtn_create(scr, "F:/bmp_function1.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_XY);
136
-  buttonBack    = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_RETURN);
137
-
138
-  // Create labels on the image buttons
139
-  lv_obj_t *labelHomeAll = lv_label_create_empty(buttonHomeAll);
140
-  lv_obj_t *labelHomeX = lv_label_create_empty(buttonHomeX);
141
-  lv_obj_t *labelHomeY = lv_label_create_empty(buttonHomeY);
142
-  lv_obj_t *labelHomeZ = lv_label_create_empty(buttonHomeZ);
143
-  lv_obj_t *labelOffAll = lv_label_create_empty(buttonOffAll);
144
-  lv_obj_t *labelOffXY = lv_label_create_empty(buttonOffXY);
145
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
146
-
147
-  if (gCfgItems.multiple_language) {
148
-    lv_label_set_text(labelHomeAll, home_menu.home_all);
149
-    lv_obj_align(labelHomeAll, buttonHomeAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
150
-
151
-    lv_label_set_text(labelHomeX, home_menu.home_x);
152
-    lv_obj_align(labelHomeX, buttonHomeX, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
153
-
154
-    lv_label_set_text(labelHomeY, home_menu.home_y);
155
-    lv_obj_align(labelHomeY, buttonHomeY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
156
-
157
-    lv_label_set_text(labelHomeZ, home_menu.home_z);
158
-    lv_obj_align(labelHomeZ, buttonHomeZ, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
159
-
160
-    lv_label_set_text(labelOffAll, set_menu.motoroff);
161
-    lv_obj_align(labelOffAll, buttonOffAll, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
162
-
163
-    lv_label_set_text(labelOffXY, set_menu.motoroffXY);
164
-    lv_obj_align(labelOffXY, buttonOffXY, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
165
-
166
-    lv_label_set_text(label_Back, common_menu.text_back);
167
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
168
-  }
169
-
170
-  #if HAS_ROTARY_ENCODER
171
-    if (gCfgItems.encoder_enable) {
172
-      lv_group_add_obj(g, buttonHomeAll);
173
-      lv_group_add_obj(g, buttonHomeX);
174
-      lv_group_add_obj(g, buttonHomeY);
175
-      lv_group_add_obj(g, buttonHomeZ);
176
-      lv_group_add_obj(g, buttonOffAll);
177
-      lv_group_add_obj(g, buttonOffXY);
178
-      lv_group_add_obj(g, buttonBack);
179
-    }
180
-  #endif
92
+  lv_big_button_create(scr, "F:/bmp_zeroAll.bin", home_menu.home_all, INTERVAL_V, titleHeight, event_handler, ID_H_ALL);
93
+  lv_big_button_create(scr, "F:/bmp_zeroX.bin", home_menu.home_x, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_H_X);
94
+  lv_big_button_create(scr, "F:/bmp_zeroY.bin", home_menu.home_y, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_H_Y);
95
+  lv_big_button_create(scr, "F:/bmp_zeroZ.bin", home_menu.home_z, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_H_Z);
96
+  lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroff, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_ALL);
97
+  lv_big_button_create(scr, "F:/bmp_function1.bin", set_menu.motoroffXY, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_OFF_XY);
98
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_H_RETURN);
181 99
 }
182 100
 
183 101
 void lv_clear_home() {

+ 37
- 142
Marlin/src/lcd/extui/lib/mks_ui/draw_homing_sensitivity_settings.cpp View File

@@ -31,180 +31,75 @@
31 31
 #include "../../../../module/stepper/indirection.h"
32 32
 #include "../../../../feature/tmc_util.h"
33 33
 
34
-extern lv_group_t * g;
35
-static lv_obj_t * scr;
36
-
37
-#define ID_SENSITIVITY_RETURN   1
38
-#define ID_SENSITIVITY_X        2
39
-#define ID_SENSITIVITY_Y        3
40
-#define ID_SENSITIVITY_Z        4
41
-#define ID_SENSITIVITY_Z2       5
42
-
43
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
34
+extern lv_group_t *g;
35
+static lv_obj_t *scr;
36
+
37
+enum {
38
+  ID_SENSITIVITY_RETURN = 1,
39
+  ID_SENSITIVITY_X,
40
+  ID_SENSITIVITY_Y,
41
+  ID_SENSITIVITY_Z,
42
+  ID_SENSITIVITY_Z2
43
+};
44
+
45
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
46
+  if (event != LV_EVENT_RELEASED) return;
44 47
   switch (obj->mks_obj_id) {
45 48
     case ID_SENSITIVITY_RETURN:
46
-      if (event == LV_EVENT_CLICKED) {
47
-
48
-      }
49
-      else if (event == LV_EVENT_RELEASED) {
50
-        lv_clear_homing_sensitivity_settings();
51
-        draw_return_ui();
52
-      }
49
+      lv_clear_homing_sensitivity_settings();
50
+      draw_return_ui();
53 51
       break;
54 52
     case ID_SENSITIVITY_X:
55
-      if (event == LV_EVENT_CLICKED) {
56
-
57
-      }
58
-      else if (event == LV_EVENT_RELEASED) {
59
-        value = x_sensitivity;
60
-        lv_clear_homing_sensitivity_settings();
61
-        lv_draw_number_key();
62
-      }
53
+      value = x_sensitivity;
54
+      lv_clear_homing_sensitivity_settings();
55
+      lv_draw_number_key();
63 56
       break;
64 57
     case ID_SENSITIVITY_Y:
65
-      if (event == LV_EVENT_CLICKED) {
66
-
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        value = y_sensitivity;
70
-        lv_clear_homing_sensitivity_settings();
71
-        lv_draw_number_key();
72
-      }
58
+      value = y_sensitivity;
59
+      lv_clear_homing_sensitivity_settings();
60
+      lv_draw_number_key();
73 61
       break;
74 62
     case ID_SENSITIVITY_Z:
75
-      if (event == LV_EVENT_CLICKED) {
76
-
77
-      }
78
-      else if (event == LV_EVENT_RELEASED) {
79
-        value = z_sensitivity;
80
-        lv_clear_homing_sensitivity_settings();
81
-        lv_draw_number_key();
82
-      }
63
+      value = z_sensitivity;
64
+      lv_clear_homing_sensitivity_settings();
65
+      lv_draw_number_key();
83 66
       break;
84 67
     #if Z2_SENSORLESS
85 68
       case ID_SENSITIVITY_Z2:
86
-      if (event == LV_EVENT_CLICKED) {
87
-
88
-      }
89
-      else if (event == LV_EVENT_RELEASED) {
90
-        value = z2_sensitivity;
91
-        lv_clear_homing_sensitivity_settings();
92
-        lv_draw_number_key();
93
-      }
69
+      value = z2_sensitivity;
70
+      lv_clear_homing_sensitivity_settings();
71
+      lv_draw_number_key();
94 72
       break;
95 73
     #endif
96 74
   }
97 75
 }
98 76
 
99 77
 void lv_draw_homing_sensitivity_settings(void) {
100
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
101
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
102
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
103
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
104
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
105
-  #if Z2_SENSORLESS
106
-    lv_obj_t *buttonZ2Value = NULL, *labelZ2Value = NULL;
107
-    lv_obj_t *line4 = NULL;
108
-  #endif
109 78
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != HOMING_SENSITIVITY_UI) {
110 79
     disp_state_stack._disp_index++;
111 80
     disp_state_stack._disp_state[disp_state_stack._disp_index] = HOMING_SENSITIVITY_UI;
112 81
   }
113 82
   disp_state = HOMING_SENSITIVITY_UI;
114 83
 
115
-  scr = lv_obj_create(NULL, NULL);
116
-
117
-  lv_obj_set_style(scr, &tft_style_scr);
118
-  lv_scr_load(scr);
119
-  lv_obj_clean(scr);
120
-
84
+  scr = lv_screen_create();
121 85
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.HomingSensitivityConfTitle);
122
-
123 86
   lv_refr_now(lv_refr_get_disp_refreshing());
124 87
 
125
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Sensitivity);
126
-
127
-  buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_X);
128
-  labelXValue = lv_label_create_empty(buttonXValue);
129
-
130
-  #if HAS_ROTARY_ENCODER
131
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXValue);
132
-  #endif
133
-
134
-  line1 = lv_line_create(scr, NULL);
135
-  lv_ex_line(line1, line_points[0]);
136
-
137
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Sensitivity);
138
-
139
-  buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Y);
140
-  labelYValue = lv_label_create_empty(buttonYValue);
141
-
142
-  #if HAS_ROTARY_ENCODER
143
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYValue);
144
-  #endif
145
-
146
-  line2 = lv_line_create(scr, NULL);
147
-  lv_ex_line(line2, line_points[1]);
148
-
149
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Sensitivity);
88
+  sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
89
+  lv_screen_menu_item_1_edit(scr, machine_menu.X_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_SENSITIVITY_X, 0, public_buf_l);
150 90
 
151
-  buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Z);
152
-  labelZValue = lv_label_create_empty(buttonZValue);
153
-
154
-  #if HAS_ROTARY_ENCODER
155
-    if (gCfgItems.encoder_enable == true) lv_group_add_obj(g, buttonZValue);
156
-  #endif
91
+  sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
92
+  lv_screen_menu_item_1_edit(scr, machine_menu.Y_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_SENSITIVITY_Y, 1, public_buf_l);
157 93
 
158
-  line3 = lv_line_create(scr, NULL);
159
-  lv_ex_line(line3, line_points[2]);
94
+  sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
95
+  lv_screen_menu_item_1_edit(scr, machine_menu.Z_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_SENSITIVITY_Z, 2, public_buf_l);
160 96
 
161 97
   #if Z2_SENSORLESS
162
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.Z2_Sensitivity);
163
-
164
-    buttonZ2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_Z2);
165
-    labelZ2Value = lv_label_create_empty(buttonZ2Value);
166
-
167
-    #if HAS_ROTARY_ENCODER
168
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZ2Value);
169
-    #endif
170
-
171
-    line4 = lv_line_create(scr, NULL);
172
-    lv_ex_line(line4, line_points[3]);
98
+    sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
99
+    lv_screen_menu_item_1_edit(scr, machine_menu.Z2_Sensitivity, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_SENSITIVITY_Z2, 3, public_buf_l);
173 100
   #endif
174 101
 
175
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_SENSITIVITY_RETURN);
176
-  label_Back = lv_label_create_empty(buttonBack);
177
-
178
-  #if HAS_ROTARY_ENCODER
179
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
180
-  #endif
181
-
182
-  if (gCfgItems.multiple_language) {
183
-    ZERO(public_buf_l);
184
-    sprintf_P(public_buf_l, PSTR("%d"), TERN(X_SENSORLESS, stepperX.homing_threshold(), 0));
185
-    lv_label_set_text(labelXValue, public_buf_l);
186
-    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
187
-
188
-    ZERO(public_buf_l);
189
-    sprintf_P(public_buf_l, PSTR("%d"), TERN(Y_SENSORLESS, stepperY.homing_threshold(), 0));
190
-    lv_label_set_text(labelYValue, public_buf_l);
191
-    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
192
-
193
-    ZERO(public_buf_l);
194
-    sprintf_P(public_buf_l, PSTR("%d"), TERN(Z_SENSORLESS, stepperZ.homing_threshold(), 0));
195
-    lv_label_set_text(labelZValue, public_buf_l);
196
-    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
197
-
198
-    #if Z2_SENSORLESS
199
-      ZERO(public_buf_l);
200
-      sprintf_P(public_buf_l, PSTR("%d"), TERN(Z2_SENSORLESS, stepperZ2.homing_threshold(), 0));
201
-      lv_label_set_text(labelZ2Value, public_buf_l);
202
-      lv_obj_align(labelZ2Value, buttonZ2Value, LV_ALIGN_CENTER, 0, 0);
203
-    #endif
204
-
205
-    lv_label_set_text(label_Back, common_menu.text_back);
206
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
207
-  }
102
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_SENSITIVITY_RETURN, true);
208 103
 }
209 104
 
210 105
 void lv_clear_homing_sensitivity_settings() {

+ 37
- 127
Marlin/src/lcd/extui/lib/mks_ui/draw_jerk_settings.cpp View File

@@ -29,161 +29,71 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_JERK_RETURN  1
36
-#define ID_JERK_X       2
37
-#define ID_JERK_Y       3
38
-#define ID_JERK_Z       4
39
-#define ID_JERK_E       5
40
-
41
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_JERK_RETURN = 1,
37
+  ID_JERK_X,
38
+  ID_JERK_Y,
39
+  ID_JERK_Z,
40
+  ID_JERK_E
41
+};
42
+
43
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
44
+  if (event != LV_EVENT_RELEASED) return;
42 45
   switch (obj->mks_obj_id) {
43 46
     case ID_JERK_RETURN:
44
-      if (event == LV_EVENT_CLICKED) {
45
-
46
-      }
47
-      else if (event == LV_EVENT_RELEASED) {
48
-        lv_clear_jerk_settings();
49
-        draw_return_ui();
50
-      }
47
+      lv_clear_jerk_settings();
48
+      draw_return_ui();
51 49
       break;
52 50
     case ID_JERK_X:
53
-      if (event == LV_EVENT_CLICKED) {
54
-
55
-      }
56
-      else if (event == LV_EVENT_RELEASED) {
57
-        value = XJerk;
58
-        lv_clear_jerk_settings();
59
-        lv_draw_number_key();
60
-      }
51
+      value = XJerk;
52
+      lv_clear_jerk_settings();
53
+      lv_draw_number_key();
61 54
       break;
62 55
     case ID_JERK_Y:
63
-      if (event == LV_EVENT_CLICKED) {
64
-
65
-      }
66
-      else if (event == LV_EVENT_RELEASED) {
67
-        value = YJerk;
68
-        lv_clear_jerk_settings();
69
-        lv_draw_number_key();
70
-      }
56
+      value = YJerk;
57
+      lv_clear_jerk_settings();
58
+      lv_draw_number_key();
71 59
       break;
72 60
     case ID_JERK_Z:
73
-      if (event == LV_EVENT_CLICKED) {
74
-
75
-      }
76
-      else if (event == LV_EVENT_RELEASED) {
77
-        value = ZJerk;
78
-        lv_clear_jerk_settings();
79
-        lv_draw_number_key();
80
-      }
61
+      value = ZJerk;
62
+      lv_clear_jerk_settings();
63
+      lv_draw_number_key();
81 64
       break;
82 65
     case ID_JERK_E:
83
-      if (event == LV_EVENT_CLICKED) {
84
-
85
-      }
86
-      else if (event == LV_EVENT_RELEASED) {
87
-        value = EJerk;
88
-        lv_clear_jerk_settings();
89
-        lv_draw_number_key();
90
-      }
66
+      value = EJerk;
67
+      lv_clear_jerk_settings();
68
+      lv_draw_number_key();
91 69
       break;
92 70
   }
93 71
 }
94 72
 
95 73
 void lv_draw_jerk_settings(void) {
96
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
97
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
98
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
99
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
100
-  lv_obj_t *buttonEValue = NULL, *labelEValue = NULL;
101
-  lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
102 74
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != JERK_UI) {
103 75
     disp_state_stack._disp_index++;
104 76
     disp_state_stack._disp_state[disp_state_stack._disp_index] = JERK_UI;
105 77
   }
106 78
   disp_state = JERK_UI;
107 79
 
108
-  scr = lv_obj_create(NULL, NULL);
109
-
110
-  lv_obj_set_style(scr, &tft_style_scr);
111
-  lv_scr_load(scr);
112
-  lv_obj_clean(scr);
113
-
80
+  scr = lv_screen_create();
114 81
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.JerkConfTitle);
115
-
116 82
   lv_refr_now(lv_refr_get_disp_refreshing());
117 83
 
118
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Jerk);
119
-
120
-  buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_X);
121
-  labelXValue = lv_label_create_empty(buttonXValue);
122
-
123
-  line1 = lv_line_create(scr, NULL);
124
-  lv_ex_line(line1, line_points[0]);
125
-
126
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Jerk);
127
-
128
-  buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_Y);
129
-  labelYValue = lv_label_create_empty(buttonYValue);
84
+  sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
85
+  lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l);
130 86
 
131
-  line2 = lv_line_create(scr, NULL);
132
-  lv_ex_line(line2, line_points[1]);
87
+  sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
88
+  lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l);
133 89
 
134
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Jerk);
90
+  sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
91
+  lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l);
135 92
 
136
-  buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_Z);
137
-  labelZValue = lv_label_create_empty(buttonZValue);
93
+  sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
94
+  lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l);
138 95
 
139
-  line3 = lv_line_create(scr, NULL);
140
-  lv_ex_line(line3, line_points[2]);
141
-
142
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E_Jerk);
143
-
144
-  buttonEValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_JERK_E);
145
-  labelEValue = lv_label_create_empty(buttonEValue);
146
-
147
-  line4 = lv_line_create(scr, NULL);
148
-  lv_ex_line(line4, line_points[3]);
149
-
150
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_JERK_RETURN);
151
-  label_Back = lv_label_create_empty(buttonBack);
152
-
153
-  #if HAS_ROTARY_ENCODER
154
-    if (gCfgItems.encoder_enable == true) {
155
-      lv_group_add_obj(g, buttonXValue);
156
-      lv_group_add_obj(g, buttonYValue);
157
-      lv_group_add_obj(g, buttonZValue);
158
-      lv_group_add_obj(g, buttonEValue);
159
-      lv_group_add_obj(g, buttonBack);
160
-    }
161
-  #endif
162
-
163
-  if (gCfgItems.multiple_language) {
164
-    ZERO(public_buf_l);
165
-    sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[X_AXIS]);
166
-    lv_label_set_text(labelXValue, public_buf_l);
167
-    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
168
-
169
-    ZERO(public_buf_l);
170
-    sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Y_AXIS]);
171
-    lv_label_set_text(labelYValue, public_buf_l);
172
-    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
173
-
174
-    ZERO(public_buf_l);
175
-    sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[Z_AXIS]);
176
-    lv_label_set_text(labelZValue, public_buf_l);
177
-    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
178
-
179
-    ZERO(public_buf_l);
180
-    sprintf_P(public_buf_l, PSTR("%.1f"), planner.max_jerk[E_AXIS]);
181
-    lv_label_set_text(labelEValue, public_buf_l);
182
-    lv_obj_align(labelEValue, buttonEValue, LV_ALIGN_CENTER, 0, 0);
183
-
184
-    lv_label_set_text(label_Back, common_menu.text_back);
185
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
186
-  }
96
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_JERK_RETURN, true);
187 97
 }
188 98
 
189 99
 void lv_clear_jerk_settings() {

+ 15
- 21
Marlin/src/lcd/extui/lib/mks_ui/draw_keyboard.cpp View File

@@ -28,8 +28,8 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33 33
 
34 34
 #define LV_KB_CTRL_BTN_FLAGS (LV_BTNM_CTRL_NO_REPEAT | LV_BTNM_CTRL_CLICK_TRIG)
35 35
 
@@ -72,7 +72,7 @@ static const lv_btnm_ctrl_t kb_ctrl_num_map[] = {
72 72
         1, 1, 1, 2,
73 73
         1, 1, 1, 1, 1};
74 74
 
75
-static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
75
+static void lv_kb_event_cb(lv_obj_t *kb, lv_event_t event) {
76 76
   //LV_ASSERT_OBJ(kb, LV_OBJX_NAME);
77 77
 
78 78
   if (event != LV_EVENT_VALUE_CHANGED) return;
@@ -84,7 +84,7 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
84 84
   if (lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return;
85 85
 
86 86
   const char * txt = lv_btnm_get_active_btn_text(kb);
87
-  if (txt == NULL) return;
87
+  if (txt == nullptr) return;
88 88
 
89 89
   // Do the corresponding action according to the text of the button
90 90
   if (strcmp(txt, "abc") == 0) {
@@ -104,13 +104,13 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
104 104
   }
105 105
   else if (strcmp(txt, LV_SYMBOL_CLOSE) == 0) {
106 106
     if (kb->event_cb != lv_kb_def_event_cb) {
107
-      //lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, NULL);
107
+      //lv_res_t res = lv_event_send(kb, LV_EVENT_CANCEL, nullptr);
108 108
       //if (res != LV_RES_OK) return;
109 109
       lv_clear_keyboard();
110 110
       draw_return_ui();
111 111
     }
112 112
     else {
113
-      lv_kb_set_ta(kb, NULL); /*De-assign the text area  to hide it cursor if needed*/
113
+      lv_kb_set_ta(kb, nullptr); /*De-assign the text area  to hide it cursor if needed*/
114 114
       lv_obj_del(kb);
115 115
       return;
116 116
     }
@@ -118,7 +118,7 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
118 118
   }
119 119
   else if (strcmp(txt, LV_SYMBOL_OK) == 0) {
120 120
     if (kb->event_cb != lv_kb_def_event_cb) {
121
-      //lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL);
121
+      //lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, nullptr);
122 122
       //if (res != LV_RES_OK) return;
123 123
       const char * ret_ta_txt = lv_ta_get_text(ext->ta);
124 124
       switch (keyboard_value) {
@@ -134,18 +134,16 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
134 134
             draw_return_ui();
135 135
             break;
136 136
           case wifiConfig:
137
-            memset((void *)uiCfg.wifi_name, 0, sizeof(uiCfg.wifi_name));
137
+            ZERO(uiCfg.wifi_name);
138 138
             memcpy((void *)uiCfg.wifi_name, wifi_list.wifiName[wifi_list.nameIndex], 32);
139 139
 
140
-            memset((void *)uiCfg.wifi_key, 0, sizeof(uiCfg.wifi_key));
140
+            ZERO(uiCfg.wifi_key);
141 141
             memcpy((void *)uiCfg.wifi_key, ret_ta_txt, sizeof(uiCfg.wifi_key));
142 142
 
143 143
             gCfgItems.wifi_mode_sel = STA_MODEL;
144 144
 
145 145
             package_to_wifi(WIFI_PARA_SET, (char *)0, 0);
146 146
 
147
-            memset(public_buf_l,0,sizeof(public_buf_l));
148
-
149 147
             public_buf_l[0] = 0xA5;
150 148
             public_buf_l[1] = 0x09;
151 149
             public_buf_l[2] = 0x01;
@@ -172,13 +170,13 @@ static void lv_kb_event_cb(lv_obj_t * kb, lv_event_t event) {
172 170
       }
173 171
     }
174 172
     else {
175
-      lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/
173
+      lv_kb_set_ta(kb, nullptr); /*De-assign the text area to hide it cursor if needed*/
176 174
     }
177 175
   return;
178 176
   }
179 177
 
180 178
   /*Add the characters to the text area if set*/
181
-  if (ext->ta == NULL) return;
179
+  if (ext->ta == nullptr) return;
182 180
 
183 181
   if (strcmp(txt, "Enter") == 0 || strcmp(txt, LV_SYMBOL_NEW_LINE) == 0)
184 182
     lv_ta_add_char(ext->ta, '\n');
@@ -221,11 +219,7 @@ void lv_draw_keyboard() {
221 219
   }
222 220
   disp_state = KEY_BOARD_UI;
223 221
 
224
-  scr = lv_obj_create(NULL, NULL);
225
-
226
-  lv_obj_set_style(scr, &tft_style_scr);
227
-  lv_scr_load(scr);
228
-  lv_obj_clean(scr);
222
+  scr = lv_screen_create();
229 223
 
230 224
   lv_refr_now(lv_refr_get_disp_refreshing());
231 225
 
@@ -245,7 +239,7 @@ void lv_draw_keyboard() {
245 239
   pr_style.body.grad_color = lv_color_make(0x6A, 0x3A, 0x0C);
246 240
 
247 241
   /*Create a keyboard and apply the styles*/
248
-  lv_obj_t *kb = lv_kb_create(scr, NULL);
242
+  lv_obj_t *kb = lv_kb_create(scr, nullptr);
249 243
   lv_obj_set_event_cb(kb, lv_kb_event_cb);
250 244
   lv_kb_set_cursor_manage(kb, true);
251 245
   lv_kb_set_style(kb, LV_KB_STYLE_BG, &lv_style_transp_tight);
@@ -259,8 +253,8 @@ void lv_draw_keyboard() {
259 253
   #endif
260 254
 
261 255
   /*Create a text area. The keyboard will write here*/
262
-  lv_obj_t *ta = lv_ta_create(scr, NULL);
263
-  lv_obj_align(ta, NULL, LV_ALIGN_IN_TOP_MID, 0, 10);
256
+  lv_obj_t *ta = lv_ta_create(scr, nullptr);
257
+  lv_obj_align(ta, nullptr, LV_ALIGN_IN_TOP_MID, 0, 10);
264 258
   if (keyboard_value == gcodeCommand) {
265 259
     get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
266 260
     public_buf_m[sizeof(public_buf_m)-1] = 0;

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

@@ -33,139 +33,98 @@
33 33
 #include "../../../../inc/MarlinConfig.h"
34 34
 #include <string.h>
35 35
 
36
-//static lv_obj_t *buttonMoveZ,*buttonTest,*buttonZ0,*buttonStop,*buttonReturn;
37
-
38
-#define ID_CN       1
39
-#define ID_T_CN     2
40
-#define ID_EN       3
41
-#define ID_RU       4
42
-#define ID_ES       5
43
-#define ID_FR       6
44
-#define ID_IT       7
45
-#define ID_L_RETURN 8
36
+enum {
37
+  ID_CN = 1,
38
+  ID_T_CN,
39
+  ID_EN,
40
+  ID_RU,
41
+  ID_ES,
42
+  ID_FR,
43
+  ID_IT,
44
+  ID_L_RETURN
45
+};
46 46
 
47 47
 #define SELECTED    1
48 48
 #define UNSELECTED  0
49 49
 
50 50
 static void disp_language(uint8_t language, uint8_t state);
51 51
 
52
-extern lv_group_t * g;
53
-static lv_obj_t * scr;
52
+extern lv_group_t *g;
53
+static lv_obj_t *scr;
54 54
 static lv_obj_t *buttonCN, *buttonT_CN, *buttonEN, *buttonRU;
55
-static lv_obj_t *buttonES, *buttonFR, *buttonIT, *buttonBack;
55
+static lv_obj_t *buttonES, *buttonFR, *buttonIT;
56 56
 
57
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
57
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
58
+  if (event != LV_EVENT_RELEASED) return;
58 59
   switch (obj->mks_obj_id) {
59 60
     case ID_CN:
60
-      if (event == LV_EVENT_CLICKED) {
61
-        // nothing to do
62
-      }
63
-      else if (event == LV_EVENT_RELEASED) {
64
-        disp_language(gCfgItems.language, UNSELECTED);
65
-        lv_imgbtn_set_src_both(buttonCN, "F:/bmp_simplified_cn_sel.bin");
66
-        lv_obj_refresh_ext_draw_pad(buttonCN);
67
-        gCfgItems.language = LANG_SIMPLE_CHINESE;
68
-        update_spi_flash();
69
-        disp_language_init();
70
-      }
61
+      disp_language(gCfgItems.language, UNSELECTED);
62
+      lv_imgbtn_set_src_both(buttonCN, "F:/bmp_simplified_cn_sel.bin");
63
+      lv_obj_refresh_ext_draw_pad(buttonCN);
64
+      gCfgItems.language = LANG_SIMPLE_CHINESE;
65
+      update_spi_flash();
66
+      disp_language_init();
71 67
       break;
72 68
     case ID_T_CN:
73
-      if (event == LV_EVENT_CLICKED) {
74
-        // nothing to do
75
-      }
76
-      else if (event == LV_EVENT_RELEASED) {
77
-        disp_language(gCfgItems.language, UNSELECTED);
78
-        lv_imgbtn_set_src_both(buttonT_CN, "F:/bmp_traditional_cn_sel.bin");
79
-        lv_obj_refresh_ext_draw_pad(buttonT_CN);
80
-        gCfgItems.language = LANG_COMPLEX_CHINESE;
81
-        update_spi_flash();
82
-        disp_language_init();
83
-      }
69
+      disp_language(gCfgItems.language, UNSELECTED);
70
+      lv_imgbtn_set_src_both(buttonT_CN, "F:/bmp_traditional_cn_sel.bin");
71
+      lv_obj_refresh_ext_draw_pad(buttonT_CN);
72
+      gCfgItems.language = LANG_COMPLEX_CHINESE;
73
+      update_spi_flash();
74
+      disp_language_init();
84 75
       break;
85 76
     case ID_EN:
86
-      if (event == LV_EVENT_CLICKED) {
87
-        // nothing to do
88
-      }
89
-      else if (event == LV_EVENT_RELEASED) {
90
-        disp_language(gCfgItems.language, UNSELECTED);
91
-        lv_imgbtn_set_src_both(buttonEN, "F:/bmp_english_sel.bin");
92
-        lv_obj_refresh_ext_draw_pad(buttonEN);
93
-        gCfgItems.language = LANG_ENGLISH;
94
-        update_spi_flash();
95
-        disp_language_init();
96
-      }
77
+      disp_language(gCfgItems.language, UNSELECTED);
78
+      lv_imgbtn_set_src_both(buttonEN, "F:/bmp_english_sel.bin");
79
+      lv_obj_refresh_ext_draw_pad(buttonEN);
80
+      gCfgItems.language = LANG_ENGLISH;
81
+      update_spi_flash();
82
+      disp_language_init();
97 83
       break;
98 84
     case ID_RU:
99
-      if (event == LV_EVENT_CLICKED) {
100
-        // nothing to do
101
-      }
102
-      else if (event == LV_EVENT_RELEASED) {
103
-        disp_language(gCfgItems.language, UNSELECTED);
104
-        lv_imgbtn_set_src_both(buttonRU, "F:/bmp_russian_sel.bin");
105
-        lv_obj_refresh_ext_draw_pad(buttonRU);
106
-        gCfgItems.language = LANG_RUSSIAN;
107
-        update_spi_flash();
108
-        disp_language_init();
109
-      }
85
+      disp_language(gCfgItems.language, UNSELECTED);
86
+      lv_imgbtn_set_src_both(buttonRU, "F:/bmp_russian_sel.bin");
87
+      lv_obj_refresh_ext_draw_pad(buttonRU);
88
+      gCfgItems.language = LANG_RUSSIAN;
89
+      update_spi_flash();
90
+      disp_language_init();
110 91
       break;
111 92
     case ID_ES:
112
-      if (event == LV_EVENT_CLICKED) {
113
-        // nothing to do
114
-      }
115
-      else if (event == LV_EVENT_RELEASED) {
116
-        disp_language(gCfgItems.language, UNSELECTED);
117
-        lv_imgbtn_set_src_both(buttonES, "F:/bmp_spanish_sel.bin");
118
-        lv_obj_refresh_ext_draw_pad(buttonES);
119
-        gCfgItems.language = LANG_SPANISH;
120
-        update_spi_flash();
121
-        disp_language_init();
122
-      }
93
+      disp_language(gCfgItems.language, UNSELECTED);
94
+      lv_imgbtn_set_src_both(buttonES, "F:/bmp_spanish_sel.bin");
95
+      lv_obj_refresh_ext_draw_pad(buttonES);
96
+      gCfgItems.language = LANG_SPANISH;
97
+      update_spi_flash();
98
+      disp_language_init();
123 99
       break;
124 100
     case ID_FR:
125
-      if (event == LV_EVENT_CLICKED) {
126
-        // nothing to do
127
-      }
128
-      else if (event == LV_EVENT_RELEASED) {
129
-        disp_language(gCfgItems.language, UNSELECTED);
130
-        lv_imgbtn_set_src_both(buttonFR, "F:/bmp_french_sel.bin");
131
-        lv_obj_refresh_ext_draw_pad(buttonFR);
132
-        gCfgItems.language = LANG_FRENCH;
133
-        update_spi_flash();
134
-        disp_language_init();
135
-      }
101
+      disp_language(gCfgItems.language, UNSELECTED);
102
+      lv_imgbtn_set_src_both(buttonFR, "F:/bmp_french_sel.bin");
103
+      lv_obj_refresh_ext_draw_pad(buttonFR);
104
+      gCfgItems.language = LANG_FRENCH;
105
+      update_spi_flash();
106
+      disp_language_init();
136 107
       break;
137 108
     case ID_IT:
138
-      if (event == LV_EVENT_CLICKED) {
139
-        // nothing to do
140
-      }
141
-      else if (event == LV_EVENT_RELEASED) {
142
-        disp_language(gCfgItems.language, UNSELECTED);
143
-        lv_imgbtn_set_src_both(buttonIT, "F:/bmp_italy_sel.bin");
144
-        lv_obj_refresh_ext_draw_pad(buttonIT);
145
-        gCfgItems.language = LANG_ITALY;
146
-        update_spi_flash();
147
-        disp_language_init();
148
-      }
109
+      disp_language(gCfgItems.language, UNSELECTED);
110
+      lv_imgbtn_set_src_both(buttonIT, "F:/bmp_italy_sel.bin");
111
+      lv_obj_refresh_ext_draw_pad(buttonIT);
112
+      gCfgItems.language = LANG_ITALY;
113
+      update_spi_flash();
114
+      disp_language_init();
149 115
       break;
150 116
     case ID_L_RETURN:
151
-      if (event == LV_EVENT_CLICKED) {
152
-
153
-      }
154
-      else if (event == LV_EVENT_RELEASED) {
155
-        buttonCN   = NULL;
156
-        buttonT_CN = NULL;
157
-        buttonEN   = NULL;
158
-        buttonRU   = NULL;
159
-        buttonES   = NULL;
160
-        buttonFR   = NULL;
161
-        buttonFR   = NULL;
162
-        buttonIT   = NULL;
163
-        buttonBack = NULL;
164
-        lv_clear_language();
165
-        lv_draw_set();
166
-      }
117
+      buttonCN   = nullptr;
118
+      buttonT_CN = nullptr;
119
+      buttonEN   = nullptr;
120
+      buttonRU   = nullptr;
121
+      buttonES   = nullptr;
122
+      buttonFR   = nullptr;
123
+      buttonFR   = nullptr;
124
+      buttonIT   = nullptr;
125
+      lv_clear_language();
126
+      lv_draw_set();
167 127
       break;
168
-
169 128
   }
170 129
 }
171 130
 
@@ -222,7 +181,7 @@ static void disp_language(uint8_t language, uint8_t state) {
222 181
 
223 182
   strcat_P(public_buf_l, PSTR(".bin"));
224 183
 
225
-  lv_obj_set_event_cb_mks(obj, event_handler, id, NULL, 0);
184
+  lv_obj_set_event_cb_mks(obj, event_handler, id, nullptr, 0);
226 185
   lv_imgbtn_set_src_both(obj, public_buf_l);
227 186
 
228 187
   if (state == UNSELECTED) lv_obj_refresh_ext_draw_pad(obj);
@@ -236,78 +195,24 @@ void lv_draw_language(void) {
236 195
   }
237 196
   disp_state = LANGUAGE_UI;
238 197
 
239
-  scr = lv_obj_create(NULL, NULL);
240
-
241
-  // static lv_style_t tool_style;
242
-
243
-  lv_obj_set_style(scr, &tft_style_scr);
244
-  lv_scr_load(scr);
245
-  lv_obj_clean(scr);
198
+  scr = lv_screen_create();
246 199
 
247 200
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
248 201
 
249 202
   lv_refr_now(lv_refr_get_disp_refreshing());
250 203
 
251 204
   // Create image buttons
252
-  buttonCN = lv_imgbtn_create(scr, "F:/bmp_simplified_cn.bin", INTERVAL_V, titleHeight, event_handler, ID_CN);
205
+  buttonCN = lv_big_button_create(scr, "F:/bmp_simplified_cn.bin", language_menu.chinese_s, INTERVAL_V, titleHeight, event_handler, ID_CN);
253 206
   lv_obj_clear_protect(buttonCN, LV_PROTECT_FOLLOW);
254
-  buttonT_CN = lv_imgbtn_create(scr, "F:/bmp_traditional_cn.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_CN);
255
-  buttonEN = lv_imgbtn_create(scr, "F:/bmp_english.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_EN);
256
-  buttonRU = lv_imgbtn_create(scr, "F:/bmp_russian.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_RU);
257
-  buttonES = lv_imgbtn_create(scr, "F:/bmp_spanish.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_ES);
258
-  buttonFR = lv_imgbtn_create(scr, "F:/bmp_french.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR);
259
-  buttonIT = lv_imgbtn_create(scr, "F:/bmp_italy.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT);
260
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_L_RETURN);
261
-
262
-  // Create labels on the image buttons
263
-  lv_obj_t *label_CN   = lv_label_create_empty(buttonCN);
264
-  lv_obj_t *label_T_CN = lv_label_create_empty(buttonT_CN);
265
-  lv_obj_t *label_EN   = lv_label_create_empty(buttonEN);
266
-  lv_obj_t *label_RU   = lv_label_create_empty(buttonRU);
267
-  lv_obj_t *label_ES   = lv_label_create_empty(buttonES);
268
-  lv_obj_t *label_FR   = lv_label_create_empty(buttonFR);
269
-  lv_obj_t *label_IT   = lv_label_create_empty(buttonIT);
270
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
207
+  buttonT_CN = lv_big_button_create(scr, "F:/bmp_traditional_cn.bin", language_menu.chinese_t, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_CN);
208
+  buttonEN = lv_big_button_create(scr, "F:/bmp_english.bin", language_menu.english, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_EN);
209
+  buttonRU = lv_big_button_create(scr, "F:/bmp_russian.bin", language_menu.russian, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_RU);
210
+  buttonES = lv_big_button_create(scr, "F:/bmp_spanish.bin", language_menu.spanish, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_ES);
211
+  buttonFR = lv_big_button_create(scr, "F:/bmp_french.bin", language_menu.french, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_FR);
212
+  buttonIT = lv_big_button_create(scr, "F:/bmp_italy.bin", language_menu.italy, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_IT);
213
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_L_RETURN);
271 214
 
272 215
   disp_language(gCfgItems.language, SELECTED);
273
-
274
-  if (gCfgItems.multiple_language) {
275
-    lv_label_set_text(label_CN, language_menu.chinese_s);
276
-    lv_obj_align(label_CN, buttonCN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
277
-
278
-    lv_label_set_text(label_T_CN, language_menu.chinese_t);
279
-    lv_obj_align(label_T_CN, buttonT_CN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
280
-
281
-    lv_label_set_text(label_EN, language_menu.english);
282
-    lv_obj_align(label_EN, buttonEN, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
283
-
284
-    lv_label_set_text(label_RU, language_menu.russian);
285
-    lv_obj_align(label_RU, buttonRU, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
286
-
287
-    lv_label_set_text(label_ES, language_menu.spanish);
288
-    lv_obj_align(label_ES, buttonES, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
289
-
290
-    lv_label_set_text(label_FR, language_menu.french);
291
-    lv_obj_align(label_FR, buttonFR, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
292
-
293
-    lv_label_set_text(label_IT, language_menu.italy);
294
-    lv_obj_align(label_IT, buttonIT, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
295
-
296
-    lv_label_set_text(label_Back, common_menu.text_back);
297
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
298
-  }
299
-  #if HAS_ROTARY_ENCODER
300
-    if (gCfgItems.encoder_enable) {
301
-      lv_group_add_obj(g, buttonCN);
302
-      lv_group_add_obj(g, buttonT_CN);
303
-      lv_group_add_obj(g, buttonEN);
304
-      lv_group_add_obj(g, buttonRU);
305
-      lv_group_add_obj(g, buttonES);
306
-      lv_group_add_obj(g, buttonFR);
307
-      lv_group_add_obj(g, buttonIT);
308
-      lv_group_add_obj(g, buttonBack);
309
-    }
310
-  #endif
311 216
 }
312 217
 
313 218
 void lv_clear_language() {

+ 23
- 160
Marlin/src/lcd/extui/lib/mks_ui/draw_level_settings.cpp View File

@@ -28,194 +28,57 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33 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
34
+enum {
35
+  ID_LEVEL_RETURN = 1,
36
+  ID_LEVEL_POSITION,
37
+  ID_LEVEL_COMMAND,
38
+  ID_LEVEL_ZOFFSET
39
+};
41 40
 
42
-
43
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
41
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
44 42
   switch (obj->mks_obj_id) {
45 43
     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
-      }
44
+      lv_clear_level_settings();
45
+      draw_return_ui();
53 46
       break;
54 47
     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
-      }
48
+      lv_clear_level_settings();
49
+      lv_draw_manual_level_pos_settings();
71 50
       break;
72 51
     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
-      }
52
+      keyboard_value = gcodeCommand;
53
+      lv_clear_level_settings();
54
+      lv_draw_keyboard();
91 55
       break;
92 56
     #if HAS_BED_PROBE
93 57
       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
-        }
58
+        lv_clear_level_settings();
59
+        lv_draw_auto_level_offset_settings();
110 60
         break;
111 61
     #endif
112 62
   }
113 63
 }
114 64
 
115 65
 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 66
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_PARA_UI) {
125 67
     disp_state_stack._disp_index++;
126 68
     disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_PARA_UI;
127 69
   }
128 70
   disp_state = LEVELING_PARA_UI;
129 71
 
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
-
72
+  scr = lv_screen_create();
136 73
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle);
137
-
138 74
   lv_refr_now(lv_refr_get_disp_refreshing());
139 75
 
140
-
141
-  buttonPosition = lv_btn_create(scr, NULL);                                   /*Add a button the current screen*/
142
-  lv_obj_set_pos(buttonPosition, PARA_UI_POS_X, PARA_UI_POS_Y);                /*Set its position*/
143
-  lv_obj_set_size(buttonPosition, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);             /*Set its size*/
144
-  lv_obj_set_event_cb_mks(buttonPosition, event_handler, ID_LEVEL_POSITION, NULL, 0);
145
-  lv_btn_use_label_style(buttonPosition);
146
-  lv_btn_set_layout(buttonPosition, LV_LAYOUT_OFF);
147
-  labelPosition = lv_label_create_empty(buttonPosition);                       /*Add a label to the button*/
148
-
149
-  #if HAS_ROTARY_ENCODER
150
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonPosition);
151
-  #endif
152
-
153
-  buttonPositionNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_LEVEL_POSITION_ARROW);
154
-  lv_btn_set_layout(buttonPositionNarrow, LV_LAYOUT_OFF);
155
-
156
-  line1 = lv_line_create(scr, NULL);
157
-  lv_ex_line(line1, line_points[0]);
158
-
159
-  buttonCommand = lv_btn_create(scr, NULL);
160
-  lv_obj_set_pos(buttonCommand, PARA_UI_POS_X, PARA_UI_POS_Y * 2);
161
-  lv_obj_set_size(buttonCommand, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);
162
-  lv_obj_set_event_cb_mks(buttonCommand, event_handler, ID_LEVEL_COMMAND, NULL, 0);
163
-  lv_btn_use_label_style(buttonCommand);
164
-  lv_btn_set_layout(buttonCommand, LV_LAYOUT_OFF);
165
-  labelCommand = lv_label_create_empty(buttonCommand);
166
-
167
-  #if HAS_ROTARY_ENCODER
168
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonCommand);
169
-  #endif
170
-
171
-  buttonCommandNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_LEVEL_COMMAND_ARROW);
172
-  lv_btn_set_layout(buttonCommandNarrow, LV_LAYOUT_OFF);
173
-
174
-  line2 = lv_line_create(scr, NULL);
175
-  lv_ex_line(line2, line_points[1]);
176
-
76
+  lv_screen_menu_item(scr, machine_menu.LevelingManuPosConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_LEVEL_POSITION, 0);
77
+  lv_screen_menu_item(scr, machine_menu.LevelingAutoCommandConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_LEVEL_COMMAND, 1);
177 78
   #if HAS_BED_PROBE
178
-
179
-    buttonZoffset = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_LEVEL_ZOFFSET);
180
-    lv_btn_set_layout(buttonZoffset, LV_LAYOUT_OFF);
181
-    labelZoffset = lv_label_create_empty(buttonZoffset);                      /*Add a label to the button*/
182
-
183
-    #if HAS_ROTARY_ENCODER
184
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZoffset);
185
-    #endif
186
-
187
-    buttonZoffsetNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_LEVEL_ZOFFSET_ARROW);
188
-    lv_btn_set_layout(buttonZoffsetNarrow, LV_LAYOUT_OFF);
189
-
190
-    line3 = lv_line_create(scr, NULL);
191
-    lv_ex_line(line3, line_points[2]);
192
-
193
-  #endif // HAS_BED_PROBE
194
-
195
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_LEVEL_RETURN);
196
-  #if HAS_ROTARY_ENCODER
197
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
79
+    lv_screen_menu_item(scr, machine_menu.LevelingAutoZoffsetConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_LEVEL_ZOFFSET, 2);
198 80
   #endif
199
-
200
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
201
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
202
-  label_Back = lv_label_create_empty(buttonBack);
203
-
204
-  if (gCfgItems.multiple_language) {
205
-    lv_label_set_text(label_Back, common_menu.text_back);
206
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
207
-
208
-    lv_label_set_text(labelPosition, machine_menu.LevelingManuPosConf);
209
-    lv_obj_align(labelPosition, buttonPosition, LV_ALIGN_IN_LEFT_MID, 0, 0);
210
-
211
-    lv_label_set_text(labelCommand, machine_menu.LevelingAutoCommandConf);
212
-    lv_obj_align(labelCommand, buttonCommand, LV_ALIGN_IN_LEFT_MID, 0, 0);
213
-    #if HAS_BED_PROBE
214
-      lv_label_set_text(labelZoffset, machine_menu.LevelingAutoZoffsetConf);
215
-      lv_obj_align(labelZoffset, buttonZoffset, LV_ALIGN_IN_LEFT_MID, 0, 0);
216
-    #endif
217
-  }
218
-
81
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_LEVEL_RETURN, true);
219 82
 }
220 83
 
221 84
 void lv_clear_level_settings() {

+ 29
- 178
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_para.cpp View File

@@ -28,209 +28,60 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
34
-#define ID_PARA_RETURN        1
35
-#define ID_PARA_MACHINE       2
36
-#define ID_PARA_MACHINE_ARROW 3
37
-#define ID_PARA_MOTOR         4
38
-#define ID_PARA_MOTOR_ARROW   5
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
43
-
44
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_PARA_RETURN = 1,
36
+  ID_PARA_MACHINE,
37
+  ID_PARA_MOTOR,
38
+  ID_PARA_LEVEL,
39
+  ID_PARA_ADVANCE
40
+};
41
+
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
45 44
   switch (obj->mks_obj_id) {
46 45
     case ID_PARA_RETURN:
47
-      if (event == LV_EVENT_CLICKED) {
48
-
49
-      }
50
-      else if (event == LV_EVENT_RELEASED) {
51
-        lv_clear_machine_para();
52
-        draw_return_ui();
53
-      }
46
+      lv_clear_machine_para();
47
+      draw_return_ui();
54 48
       break;
55 49
     case ID_PARA_MACHINE:
56
-      if (event == LV_EVENT_CLICKED) {
57
-
58
-      }
59
-      else if (event == LV_EVENT_RELEASED) {
60
-        lv_clear_machine_para();
61
-        lv_draw_machine_settings();
62
-      }
63
-      break;
64
-    case ID_PARA_MACHINE_ARROW:
65
-      if (event == LV_EVENT_CLICKED) {
66
-
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        lv_clear_machine_para();
70
-        lv_draw_machine_settings();
71
-      }
50
+      lv_clear_machine_para();
51
+      lv_draw_machine_settings();
72 52
       break;
73 53
     case ID_PARA_MOTOR:
74
-      if (event == LV_EVENT_CLICKED) {
75
-
76
-      }
77
-      else if (event == LV_EVENT_RELEASED) {
78
-        lv_clear_machine_para();
79
-        lv_draw_motor_settings();
80
-      }
81
-      break;
82
-    case ID_PARA_MOTOR_ARROW:
83
-      if (event == LV_EVENT_CLICKED) {
84
-
85
-      }
86
-      else if (event == LV_EVENT_RELEASED) {
87
-        lv_clear_machine_para();
88
-        lv_draw_motor_settings();
89
-      }
54
+      lv_clear_machine_para();
55
+      lv_draw_motor_settings();
90 56
       break;
91 57
     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
-      }
58
+      lv_clear_machine_para();
59
+      lv_draw_level_settings();
108 60
       break;
109 61
     case ID_PARA_ADVANCE:
110
-      if (event == LV_EVENT_CLICKED) {
111
-
112
-      }
113
-      else if (event == LV_EVENT_RELEASED) {
114
-        lv_clear_machine_para();
115
-        lv_draw_advance_settings();
116
-      }
117
-      break;
118
-    case ID_PARA_ADVANCE_ARROW:
119
-      if (event == LV_EVENT_CLICKED) {
120
-
121
-      }
122
-      else if (event == LV_EVENT_RELEASED) {
123
-        lv_clear_machine_para();
124
-        lv_draw_advance_settings();
125
-      }
62
+      lv_clear_machine_para();
63
+      lv_draw_advance_settings();
126 64
       break;
127 65
   }
128 66
 }
129 67
 
130 68
 void lv_draw_machine_para(void) {
131
-  lv_obj_t *buttonBack, *label_Back;
132
-  lv_obj_t *buttonMachine, *labelMachine, *buttonMachineNarrow;
133
-  lv_obj_t *buttonMotor, *labelMotor, *buttonMotorNarrow;
134
-  lv_obj_t *buttonLevel, *labelLevel, *buttonLevelNarrow;
135
-  lv_obj_t *buttonAdvance, *labelAdvance, *buttonAdvanceNarrow;
136
-  lv_obj_t * line1, * line2, * line3, * line4;
137 69
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_PARA_UI) {
138 70
     disp_state_stack._disp_index++;
139 71
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_PARA_UI;
140 72
   }
141 73
   disp_state = MACHINE_PARA_UI;
142 74
 
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);
75
+  scr = lv_screen_create();
148 76
 
149 77
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
150
-
151 78
   lv_refr_now(lv_refr_get_disp_refreshing());
152 79
 
153
-  buttonMachine = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
154
-  lv_obj_set_pos(buttonMachine, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
155
-  lv_obj_set_size(buttonMachine, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
156
-  //lv_obj_set_event_cb(buttonMachine, event_handler);
157
-  lv_obj_set_event_cb_mks(buttonMachine, event_handler, ID_PARA_MACHINE, NULL, 0);
158
-  lv_btn_use_label_style(buttonMachine);
159
-  lv_btn_set_layout(buttonMachine, LV_LAYOUT_OFF);
160
-  labelMachine = lv_label_create_empty(buttonMachine);                      /*Add a label to the button*/
161
-
162
-  buttonMachineNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_PARA_MACHINE_ARROW);
163
-
164
-  line1 = lv_line_create(scr, NULL);
165
-  lv_ex_line(line1, line_points[0]);
166
-
167
-  buttonMotor = lv_btn_create(scr, NULL);                                   /*Add a button the current screen*/
168
-  lv_obj_set_pos(buttonMotor, PARA_UI_POS_X, PARA_UI_POS_Y * 2);            /*Set its position*/
169
-  lv_obj_set_size(buttonMotor, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);             /*Set its size*/
170
-  //lv_obj_set_event_cb(buttonMotor, event_handler);
171
-  lv_obj_set_event_cb_mks(buttonMotor, event_handler, ID_PARA_MOTOR, NULL, 0);
172
-  lv_btn_use_label_style(buttonMotor);
173
-  lv_btn_set_layout(buttonMotor, LV_LAYOUT_OFF);
174
-  labelMotor = lv_label_create_empty(buttonMotor);                          /*Add a label to the button*/
175
-
176
-  buttonMotorNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_PARA_MOTOR_ARROW);
177
-
178
-  line2 = lv_line_create(scr, NULL);
179
-  lv_ex_line(line2, line_points[1]);
180
-
181
-  buttonLevel = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_PARA_LEVEL);
182
-  //lv_obj_set_event_cb(buttonMotor, event_handler);
183
-  lv_btn_set_layout(buttonLevel, LV_LAYOUT_OFF);
184
-  labelLevel = lv_label_create_empty(buttonLevel);                      /*Add a label to the button*/
185
-
186
-  buttonLevelNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_PARA_LEVEL_ARROW);
187
-
188
-  line3 = lv_line_create(scr, NULL);
189
-  lv_ex_line(line3, line_points[2]);
190
-
191
-  buttonAdvance = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
192
-  lv_obj_set_pos(buttonAdvance, PARA_UI_POS_X, PARA_UI_POS_Y * 4);          /*Set its position*/
193
-  lv_obj_set_size(buttonAdvance, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
194
-  //lv_obj_set_event_cb(buttonMotor, event_handler);
195
-  lv_obj_set_event_cb_mks(buttonAdvance, event_handler, ID_PARA_ADVANCE, NULL, 0);
196
-  lv_btn_use_label_style(buttonAdvance);
197
-  lv_btn_set_layout(buttonAdvance, LV_LAYOUT_OFF);
198
-  labelAdvance = lv_label_create_empty(buttonAdvance);                      /*Add a label to the button*/
199
-
200
-  buttonAdvanceNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 4 + PARA_UI_ARROW_V, event_handler, ID_PARA_ADVANCE_ARROW);
201
-  lv_btn_set_layout(buttonAdvanceNarrow, LV_LAYOUT_OFF);
202
-
203
-  line4 = lv_line_create(scr, NULL);
204
-  lv_ex_line(line4, line_points[3]);
205
-
206
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_PARA_RETURN);
207
-  label_Back = lv_label_create_empty(buttonBack);
208
-
209
-  if (gCfgItems.multiple_language) {
210
-    lv_label_set_text(label_Back, common_menu.text_back);
211
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, -2);
212
-
213
-    lv_label_set_text(labelMachine, MachinePara_menu.MachineSetting);
214
-    lv_obj_align(labelMachine, buttonMachine, LV_ALIGN_IN_LEFT_MID, 0, -3);
215
-
216
-    lv_label_set_text(labelMotor, MachinePara_menu.MotorSetting);
217
-    lv_obj_align(labelMotor, buttonMotor, LV_ALIGN_IN_LEFT_MID, 0, -3);
218
-
219
-    lv_label_set_text(labelLevel, MachinePara_menu.leveling);
220
-    lv_obj_align(labelLevel, buttonLevel, LV_ALIGN_IN_LEFT_MID, 0, -3);
221
-
222
-    lv_label_set_text(labelAdvance, MachinePara_menu.AdvanceSetting);
223
-    lv_obj_align(labelAdvance, buttonAdvance, LV_ALIGN_IN_LEFT_MID, 0, -3);
224
-  }
225
-  #if HAS_ROTARY_ENCODER
226
-    if (gCfgItems.encoder_enable) {
227
-      lv_group_add_obj(g, buttonMachine);
228
-      lv_group_add_obj(g, buttonMotor);
229
-      lv_group_add_obj(g, buttonLevel);
230
-      lv_group_add_obj(g, buttonAdvance);
231
-      lv_group_add_obj(g, buttonBack);
232
-    }
233
-  #endif
80
+  lv_screen_menu_item(scr, MachinePara_menu.MachineSetting, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PARA_MACHINE, 0);
81
+  lv_screen_menu_item(scr, MachinePara_menu.MotorSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PARA_MOTOR, 1);
82
+  lv_screen_menu_item(scr, MachinePara_menu.leveling, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PARA_LEVEL, 2);
83
+  lv_screen_menu_item(scr, MachinePara_menu.AdvanceSetting, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_PARA_ADVANCE, 3);
84
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_PARA_RETURN, true);
234 85
 }
235 86
 
236 87
 void lv_clear_machine_para() {

+ 28
- 157
Marlin/src/lcd/extui/lib/mks_ui/draw_machine_settings.cpp View File

@@ -28,188 +28,59 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
34
-#define ID_MACHINE_RETURN             1
35
-#define ID_MACHINE_ACCELERATION       2
36
-#define ID_MACHINE_ACCELERATION_ARROW 3
37
-#define ID_MACHINE_FEEDRATE           4
38
-#define ID_MACHINE_FEEDRATE_ARROW     5
39
-#define ID_MACHINE_JERK               6
40
-#define ID_MACHINE_JERK_ARROW         7
41
-
42
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_MACHINE_RETURN = 1,
36
+  ID_MACHINE_ACCELERATION,
37
+  ID_MACHINE_FEEDRATE,
38
+  ID_MACHINE_JERK
39
+};
40
+
41
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
42
+  if (event != LV_EVENT_RELEASED) return;
43 43
   switch (obj->mks_obj_id) {
44 44
     case ID_MACHINE_RETURN:
45
-      if (event == LV_EVENT_CLICKED) {
46
-
47
-      }
48
-      else if (event == LV_EVENT_RELEASED) {
49
-        lv_clear_machine_settings();
50
-        draw_return_ui();
51
-      }
45
+      lv_clear_machine_settings();
46
+      draw_return_ui();
52 47
       break;
53 48
     case ID_MACHINE_ACCELERATION:
54
-      if (event == LV_EVENT_CLICKED) {
55
-
56
-      }
57
-      else if (event == LV_EVENT_RELEASED) {
58
-        lv_clear_machine_settings();
59
-        lv_draw_acceleration_settings();
60
-      }
61
-      break;
62
-    case ID_MACHINE_ACCELERATION_ARROW:
63
-      if (event == LV_EVENT_CLICKED) {
64
-
65
-      }
66
-      else if (event == LV_EVENT_RELEASED) {
67
-        lv_clear_machine_settings();
68
-        lv_draw_acceleration_settings();
69
-      }
49
+      lv_clear_machine_settings();
50
+      lv_draw_acceleration_settings();
70 51
       break;
71 52
     case ID_MACHINE_FEEDRATE:
72
-      if (event == LV_EVENT_CLICKED) {
73
-
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        lv_clear_machine_settings();
77
-        lv_draw_max_feedrate_settings();
78
-      }
53
+      lv_clear_machine_settings();
54
+      lv_draw_max_feedrate_settings();
79 55
       break;
80
-    case ID_MACHINE_FEEDRATE_ARROW:
81
-      if (event == LV_EVENT_CLICKED) {
82
-
83
-      }
84
-      else if (event == LV_EVENT_RELEASED) {
56
+    #if HAS_CLASSIC_JERK
57
+      case ID_MACHINE_JERK:
85 58
         lv_clear_machine_settings();
86
-        lv_draw_max_feedrate_settings();
87
-      }
88
-      break;
89
-      #if HAS_CLASSIC_JERK
90
-        case ID_MACHINE_JERK:
91
-          if (event == LV_EVENT_CLICKED) {
92
-
93
-          }
94
-          else if (event == LV_EVENT_RELEASED) {
95
-            lv_clear_machine_settings();
96
-            lv_draw_jerk_settings();
97
-          }
98
-          break;
99
-        case ID_MACHINE_JERK_ARROW:
100
-          if (event == LV_EVENT_CLICKED) {
101
-
102
-          }
103
-          else if (event == LV_EVENT_RELEASED) {
104
-            lv_clear_machine_settings();
105
-            lv_draw_jerk_settings();
106
-          }
107
-          break;
108
-      #endif
59
+        lv_draw_jerk_settings();
60
+        break;
61
+    #endif
109 62
   }
110 63
 }
111 64
 
112 65
 void lv_draw_machine_settings(void) {
113
-  lv_obj_t *buttonBack, *label_Back;
114
-  lv_obj_t *buttonAcceleration, *labelAcceleration, *buttonAccelerationNarrow;
115
-  lv_obj_t *buttonMaxFeedrate, *labelMaxFeedrate, *buttonMaxFeedrateNarrow;
116
-  #if HAS_CLASSIC_JERK
117
-    lv_obj_t *buttonJerk, *labelJerk, *buttonJerkNarrow;
118
-  #endif
119
-  lv_obj_t * line1, * line2;
120
-  #if HAS_CLASSIC_JERK
121
-    lv_obj_t * line3;
122
-  #endif
123 66
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MACHINE_SETTINGS_UI) {
124 67
     disp_state_stack._disp_index++;
125 68
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MACHINE_SETTINGS_UI;
126 69
   }
127 70
   disp_state = MACHINE_SETTINGS_UI;
128 71
 
129
-  scr = lv_obj_create(NULL, NULL);
130
-
131
-  lv_obj_set_style(scr, &tft_style_scr);
132
-  lv_scr_load(scr);
133
-  lv_obj_clean(scr);
72
+  scr = lv_screen_create();
134 73
 
135 74
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MachineConfigTitle);
136 75
 
137 76
   lv_refr_now(lv_refr_get_disp_refreshing());
138 77
 
139
-  buttonAcceleration = lv_btn_create(scr, NULL);                                // Add a button the current screen
140
-  lv_obj_set_pos(buttonAcceleration, PARA_UI_POS_X, PARA_UI_POS_Y);             // Set its position
141
-  lv_obj_set_size(buttonAcceleration, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          // Set its size
142
-  //lv_obj_set_event_cb(buttonMachine, event_handler);
143
-  lv_obj_set_event_cb_mks(buttonAcceleration, event_handler, ID_MACHINE_ACCELERATION, NULL, 0);
144
-  lv_btn_use_label_style(buttonAcceleration);
145
-  lv_btn_set_layout(buttonAcceleration, LV_LAYOUT_OFF);
146
-  labelAcceleration = lv_label_create_empty(buttonAcceleration);                // Add a label to the button
147
-
148
-  buttonAccelerationNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_MACHINE_ACCELERATION_ARROW);
149
-
150
-  line1 = lv_line_create(lv_scr_act(), NULL);
151
-  lv_ex_line(line1, line_points[0]);
152
-
153
-  buttonMaxFeedrate = lv_btn_create(scr, NULL);                                 // Add a button the current screen
154
-  lv_obj_set_pos(buttonMaxFeedrate, PARA_UI_POS_X, PARA_UI_POS_Y * 2);          // Set its position
155
-  lv_obj_set_size(buttonMaxFeedrate, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           // Set its size
156
-  //lv_obj_set_event_cb(buttonMachine, event_handler);
157
-  lv_obj_set_event_cb_mks(buttonMaxFeedrate, event_handler, ID_MACHINE_FEEDRATE, NULL, 0);
158
-  lv_btn_use_label_style(buttonMaxFeedrate);
159
-  lv_btn_set_layout(buttonMaxFeedrate, LV_LAYOUT_OFF);
160
-  labelMaxFeedrate = lv_label_create_empty(buttonMaxFeedrate);                  // Add a label to the button
161
-
162
-  buttonMaxFeedrateNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_MACHINE_FEEDRATE_ARROW);
163
-
164
-  line2 = lv_line_create(lv_scr_act(), NULL);
165
-  lv_ex_line(line2, line_points[1]);
166
-
78
+  lv_screen_menu_item(scr, machine_menu.AccelerationConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MACHINE_ACCELERATION, 0);
79
+  lv_screen_menu_item(scr, machine_menu.MaxFeedRateConf, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MACHINE_FEEDRATE, 1);
167 80
   #if HAS_CLASSIC_JERK
168
-    buttonJerk = lv_btn_create(scr, NULL);                                      // Add a button the current screen
169
-    lv_obj_set_pos(buttonJerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3);               // Set its position
170
-    lv_obj_set_size(buttonJerk, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                // Set its size
171
-    //lv_obj_set_event_cb(buttonMotor, event_handler);
172
-    lv_obj_set_event_cb_mks(buttonJerk, event_handler, ID_MACHINE_JERK, NULL, 0);
173
-    lv_btn_use_label_style(buttonJerk);
174
-    lv_btn_set_layout(buttonJerk, LV_LAYOUT_OFF);
175
-    labelJerk = lv_label_create_empty(buttonJerk);                              // Add a label to the button
176
-
177
-    buttonJerkNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 3 + PARA_UI_ARROW_V, event_handler, ID_MACHINE_JERK_ARROW);
178
-
179
-    line3 = lv_line_create(lv_scr_act(), NULL);
180
-    lv_ex_line(line3, line_points[2]);
181
-  #endif
182
-
183
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_MACHINE_RETURN);
184
-
185
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
186
-  lv_btn_set_layout(buttonBack, LV_LAYOUT_OFF);
187
-  label_Back = lv_label_create_empty(buttonBack);
188
-
189
-  if (gCfgItems.multiple_language) {
190
-    lv_label_set_text(label_Back, common_menu.text_back);
191
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
192
-
193
-    lv_label_set_text(labelAcceleration, machine_menu.AccelerationConf);
194
-    lv_obj_align(labelAcceleration, buttonAcceleration, LV_ALIGN_IN_LEFT_MID, 0, 0);
195
-
196
-    lv_label_set_text(labelMaxFeedrate, machine_menu.MaxFeedRateConf);
197
-    lv_obj_align(labelMaxFeedrate, buttonMaxFeedrate, LV_ALIGN_IN_LEFT_MID, 0, 0);
198
-    #if HAS_CLASSIC_JERK
199
-      lv_label_set_text(labelJerk, machine_menu.JerkConf);
200
-      lv_obj_align(labelJerk, buttonJerk, LV_ALIGN_IN_LEFT_MID, 0, 0);
201
-    #endif
202
-  }
203
-  #if HAS_ROTARY_ENCODER
204
-    if (gCfgItems.encoder_enable) {
205
-      lv_group_add_obj(g, buttonAcceleration);
206
-      lv_group_add_obj(g, buttonMaxFeedrate);
207
-      #if HAS_CLASSIC_JERK
208
-        lv_group_add_obj(g, buttonJerk);
209
-      #endif
210
-      lv_group_add_obj(g, buttonBack);
211
-    }
81
+    lv_screen_menu_item(scr, machine_menu.JerkConf, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MACHINE_JERK, 2);
212 82
   #endif
83
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MACHINE_RETURN, true);
213 84
 }
214 85
 
215 86
 void lv_clear_machine_settings() {

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

@@ -33,201 +33,109 @@
33 33
 #include "../../../../gcode/queue.h"
34 34
 #include "../../../../inc/MarlinConfig.h"
35 35
 
36
-extern lv_group_t * g;
37
-static lv_obj_t * scr;
36
+extern lv_group_t *g;
37
+static lv_obj_t *scr;
38 38
 
39
-#define ID_M_POINT1      1
40
-#define ID_M_POINT2      2
41
-#define ID_M_POINT3      3
42
-#define ID_M_POINT4      4
43
-#define ID_M_POINT5      5
44
-#define ID_MANUAL_RETURN 6
39
+enum {
40
+  ID_M_POINT1 = 1,
41
+  ID_M_POINT2,
42
+  ID_M_POINT3,
43
+  ID_M_POINT4,
44
+  ID_M_POINT5,
45
+  ID_MANUAL_RETURN
46
+};
47
+
48
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
49
+  if (event != LV_EVENT_RELEASED) return;
45 50
 
46
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
47 51
   switch (obj->mks_obj_id) {
48 52
     case ID_M_POINT1:
49
-      if (event == LV_EVENT_CLICKED) {
50
-        // nothing to do
51
-      }
52
-      else if (event == LV_EVENT_RELEASED) {
53
-
54
-        if (queue.length == 0) {
55
-          if (uiCfg.leveling_first_time) {
56
-            queue.enqueue_now_P(PSTR("G28"));
57
-            uiCfg.leveling_first_time = 0;
58
-          }
59
-
60
-          queue.enqueue_now_P(PSTR("G1 Z10"));
61
-
62
-          ZERO(public_buf_l);
63
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
64
-          queue.enqueue_one_now(public_buf_l);
65
-          queue.enqueue_now_P(PSTR("G1 Z0"));
53
+      if (queue.length == 0) {
54
+        if (uiCfg.leveling_first_time) {
55
+          queue.enqueue_now_P(PSTR("G28"));
56
+          uiCfg.leveling_first_time = 0;
66 57
         }
58
+        queue.enqueue_now_P(PSTR("G1 Z10"));
59
+        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[0][0], (int)gCfgItems.levelingPos[0][1]);
60
+        queue.enqueue_one_now(public_buf_l);
61
+        queue.enqueue_now_P(PSTR("G1 Z0"));
67 62
       }
68 63
       break;
69 64
     case ID_M_POINT2:
70
-      if (event == LV_EVENT_CLICKED) {
71
-        // nothing to do
72
-      }
73
-      else if (event == LV_EVENT_RELEASED) {
74
-        if (queue.length == 0) {
75
-          if (uiCfg.leveling_first_time) {
76
-            queue.enqueue_now_P(PSTR("G28"));
77
-            uiCfg.leveling_first_time = 0;
78
-          }
79
-
80
-          queue.enqueue_now_P(PSTR("G1 Z10"));
81
-
82
-          ZERO(public_buf_l);
83
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
84
-          queue.enqueue_one_now(public_buf_l);
85
-          queue.enqueue_now_P(PSTR("G1 Z0"));
65
+      if (queue.length == 0) {
66
+        if (uiCfg.leveling_first_time) {
67
+          queue.enqueue_now_P(PSTR("G28"));
68
+          uiCfg.leveling_first_time = 0;
86 69
         }
70
+        queue.enqueue_now_P(PSTR("G1 Z10"));
71
+        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[1][0], (int)gCfgItems.levelingPos[1][1]);
72
+        queue.enqueue_one_now(public_buf_l);
73
+        queue.enqueue_now_P(PSTR("G1 Z0"));
87 74
       }
88 75
       break;
89 76
     case ID_M_POINT3:
90
-      if (event == LV_EVENT_CLICKED) {
91
-        // nothing to do
92
-      }
93
-      else if (event == LV_EVENT_RELEASED) {
94
-        if (queue.length == 0) {
95
-          if (uiCfg.leveling_first_time) {
96
-            queue.enqueue_now_P(PSTR("G28"));
97
-            uiCfg.leveling_first_time = 0;
98
-          }
99
-
100
-          queue.enqueue_now_P(PSTR("G1 Z10"));
101
-
102
-          ZERO(public_buf_l);
103
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
104
-          queue.enqueue_one_now(public_buf_l);
105
-          queue.enqueue_now_P(PSTR("G1 Z0"));
77
+      if (queue.length == 0) {
78
+        if (uiCfg.leveling_first_time) {
79
+          queue.enqueue_now_P(PSTR("G28"));
80
+          uiCfg.leveling_first_time = 0;
106 81
         }
82
+        queue.enqueue_now_P(PSTR("G1 Z10"));
83
+        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[2][0], (int)gCfgItems.levelingPos[2][1]);
84
+        queue.enqueue_one_now(public_buf_l);
85
+        queue.enqueue_now_P(PSTR("G1 Z0"));
107 86
       }
108 87
 
109 88
       break;
110 89
     case ID_M_POINT4:
111
-      if (event == LV_EVENT_CLICKED) {
112
-        // nothing to do
113
-      }
114
-      else if (event == LV_EVENT_RELEASED) {
115
-        if (queue.length == 0) {
116
-          if (uiCfg.leveling_first_time) {
117
-            queue.enqueue_now_P(PSTR("G28"));
118
-            uiCfg.leveling_first_time = 0;
119
-          }
120
-
121
-          queue.enqueue_now_P(PSTR("G1 Z10"));
122
-
123
-          ZERO(public_buf_l);
124
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
125
-          queue.enqueue_one_now(public_buf_l);
126
-          queue.enqueue_now_P(PSTR("G1 Z0"));
90
+      if (queue.length == 0) {
91
+        if (uiCfg.leveling_first_time) {
92
+          queue.enqueue_now_P(PSTR("G28"));
93
+          uiCfg.leveling_first_time = 0;
127 94
         }
95
+        queue.enqueue_now_P(PSTR("G1 Z10"));
96
+        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[3][0], (int)gCfgItems.levelingPos[3][1]);
97
+        queue.enqueue_one_now(public_buf_l);
98
+        queue.enqueue_now_P(PSTR("G1 Z0"));
128 99
       }
129 100
       break;
130 101
     case ID_M_POINT5:
131
-      if (event == LV_EVENT_CLICKED) {
132
-        // nothing to do
133
-      }
134
-      else if (event == LV_EVENT_RELEASED) {
135
-        if (queue.length == 0) {
136
-          if (uiCfg.leveling_first_time) {
137
-            queue.enqueue_now_P(PSTR("G28"));
138
-            uiCfg.leveling_first_time = 0;
139
-          }
140
-
141
-          queue.enqueue_now_P(PSTR("G1 Z10"));
142
-
143
-          ZERO(public_buf_l);
144
-          sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
145
-          queue.enqueue_one_now(public_buf_l);
146
-          queue.enqueue_now_P(PSTR("G1 Z0"));
102
+      if (queue.length == 0) {
103
+        if (uiCfg.leveling_first_time) {
104
+          queue.enqueue_now_P(PSTR("G28"));
105
+          uiCfg.leveling_first_time = 0;
147 106
         }
107
+        queue.enqueue_now_P(PSTR("G1 Z10"));
108
+        sprintf_P(public_buf_l, PSTR("G1 X%d Y%d"), (int)gCfgItems.levelingPos[4][0], (int)gCfgItems.levelingPos[4][1]);
109
+        queue.enqueue_one_now(public_buf_l);
110
+        queue.enqueue_now_P(PSTR("G1 Z0"));
148 111
       }
149
-
150 112
       break;
151 113
     case ID_MANUAL_RETURN:
152
-      if (event == LV_EVENT_CLICKED) {
153
-        // nothing to do
154
-      }
155
-      else if (event == LV_EVENT_RELEASED) {
156
-        lv_clear_manualLevel();
157
-        lv_draw_tool();
158
-      }
114
+      lv_clear_manualLevel();
115
+      lv_draw_tool();
159 116
       break;
160 117
   }
161 118
 }
162 119
 
163 120
 void lv_draw_manualLevel(void) {
164
-  lv_obj_t *buttonPoint1, *buttonPoint2, *buttonPoint3, *buttonPoint4, *buttonPoint5;
165
-  lv_obj_t *buttonBack;
166
-
167 121
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != LEVELING_UI) {
168 122
     disp_state_stack._disp_index++;
169 123
     disp_state_stack._disp_state[disp_state_stack._disp_index] = LEVELING_UI;
170 124
   }
171 125
   disp_state = LEVELING_UI;
172 126
 
173
-  scr = lv_obj_create(NULL, NULL);
174
-
175
-  // static lv_style_t tool_style;
176
-
177
-  lv_obj_set_style(scr, &tft_style_scr);
178
-  lv_scr_load(scr);
179
-  lv_obj_clean(scr);
180
-
127
+  scr = lv_screen_create();
181 128
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
182
-
183 129
   lv_refr_now(lv_refr_get_disp_refreshing());
184 130
 
185 131
   // Create an Image button
186
-  buttonPoint1 = lv_imgbtn_create(scr, "F:/bmp_leveling1.bin", INTERVAL_V, titleHeight, event_handler, ID_M_POINT1);
132
+  lv_obj_t *buttonPoint1 = lv_big_button_create(scr, "F:/bmp_leveling1.bin", leveling_menu.position1, INTERVAL_V, titleHeight, event_handler, ID_M_POINT1);
187 133
   lv_obj_clear_protect(buttonPoint1, LV_PROTECT_FOLLOW);
188
-  buttonPoint2 = lv_imgbtn_create(scr, "F:/bmp_leveling2.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2);
189
-  buttonPoint3 = lv_imgbtn_create(scr, "F:/bmp_leveling3.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3);
190
-  buttonPoint4 = lv_imgbtn_create(scr, "F:/bmp_leveling4.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4);
191
-  buttonPoint5 = lv_imgbtn_create(scr, "F:/bmp_leveling5.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5);
192
-  buttonBack   = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN);
193
-
194
-  // Create labels on the image buttons
195
-  lv_obj_t *label_Point1 = lv_label_create_empty(buttonPoint1);
196
-  lv_obj_t *label_Point2 = lv_label_create_empty(buttonPoint2);
197
-  lv_obj_t *label_Point3 = lv_label_create_empty(buttonPoint3);
198
-  lv_obj_t *label_Point4 = lv_label_create_empty(buttonPoint4);
199
-  lv_obj_t *label_Point5 = lv_label_create_empty(buttonPoint5);
200
-  lv_obj_t *label_Back   = lv_label_create_empty(buttonBack);
201
-
202
-  if (gCfgItems.multiple_language) {
203
-    lv_label_set_text(label_Point1, leveling_menu.position1);
204
-    lv_obj_align(label_Point1, buttonPoint1, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
205
-
206
-    lv_label_set_text(label_Point2, leveling_menu.position2);
207
-    lv_obj_align(label_Point2, buttonPoint2, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
208
-
209
-    lv_label_set_text(label_Point3, leveling_menu.position3);
210
-    lv_obj_align(label_Point3, buttonPoint3, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
211
-
212
-    lv_label_set_text(label_Point4, leveling_menu.position4);
213
-    lv_obj_align(label_Point4, buttonPoint4, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
214
-
215
-    lv_label_set_text(label_Point5, leveling_menu.position5);
216
-    lv_obj_align(label_Point5, buttonPoint5, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
217
-
218
-    lv_label_set_text(label_Back, common_menu.text_back);
219
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
220
-  }
221
-  #if HAS_ROTARY_ENCODER
222
-    if (gCfgItems.encoder_enable) {
223
-      lv_group_add_obj(g, buttonPoint1);
224
-      lv_group_add_obj(g, buttonPoint2);
225
-      lv_group_add_obj(g, buttonPoint3);
226
-      lv_group_add_obj(g, buttonPoint4);
227
-      lv_group_add_obj(g, buttonPoint5);
228
-      lv_group_add_obj(g, buttonBack);
229
-    }
230
-  #endif
134
+  lv_big_button_create(scr, "F:/bmp_leveling2.bin", leveling_menu.position2, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_POINT2);
135
+  lv_big_button_create(scr, "F:/bmp_leveling3.bin", leveling_menu.position3, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_POINT3);
136
+  lv_big_button_create(scr, "F:/bmp_leveling4.bin", leveling_menu.position4, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_POINT4);
137
+  lv_big_button_create(scr, "F:/bmp_leveling5.bin", leveling_menu.position5, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_POINT5);
138
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_MANUAL_RETURN);
231 139
 }
232 140
 
233 141
 void lv_clear_manualLevel() {

+ 80
- 297
Marlin/src/lcd/extui/lib/mks_ui/draw_manual_level_pos_settings.cpp View File

@@ -29,353 +29,136 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 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) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_MANUAL_POS_RETURN = 1,
37
+  ID_MANUAL_POS_X1,
38
+  ID_MANUAL_POS_Y1,
39
+  ID_MANUAL_POS_X2,
40
+  ID_MANUAL_POS_Y2,
41
+  ID_MANUAL_POS_X3,
42
+  ID_MANUAL_POS_Y3,
43
+  ID_MANUAL_POS_X4,
44
+  ID_MANUAL_POS_Y4,
45
+  ID_MANUAL_POS_X5,
46
+  ID_MANUAL_POS_Y5,
47
+  ID_MANUAL_POS_DOWN,
48
+  ID_MANUAL_POS_UP
49
+};
50
+
51
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
52
+  if (event != LV_EVENT_RELEASED) return;
50 53
   switch (obj->mks_obj_id) {
51 54
     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
-      }
55
+      uiCfg.para_ui_page = 0;
56
+      lv_clear_manual_level_pos_settings();
57
+      draw_return_ui();
60 58
       break;
61 59
     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
-      }
60
+      value = level_pos_x1;
61
+      lv_clear_manual_level_pos_settings();
62
+      lv_draw_number_key();
70 63
       break;
71 64
     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
-      }
65
+      value = level_pos_y1;
66
+      lv_clear_manual_level_pos_settings();
67
+      lv_draw_number_key();
80 68
       break;
81 69
     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
-      }
70
+      value = level_pos_x2;
71
+      lv_clear_manual_level_pos_settings();
72
+      lv_draw_number_key();
90 73
       break;
91 74
     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
-      }
75
+      value = level_pos_y2;
76
+      lv_clear_manual_level_pos_settings();
77
+      lv_draw_number_key();
100 78
       break;
101 79
     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
-      }
80
+      value = level_pos_x3;
81
+      lv_clear_manual_level_pos_settings();
82
+      lv_draw_number_key();
110 83
       break;
111 84
     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
-      }
85
+      value = level_pos_y3;
86
+      lv_clear_manual_level_pos_settings();
87
+      lv_draw_number_key();
120 88
       break;
121 89
     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
-      }
90
+      value = level_pos_x4;
91
+      lv_clear_manual_level_pos_settings();
92
+      lv_draw_number_key();
130 93
       break;
131 94
     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
-      }
95
+      value = level_pos_y4;
96
+      lv_clear_manual_level_pos_settings();
97
+      lv_draw_number_key();
140 98
       break;
141 99
     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
-      }
100
+      value = level_pos_y5;
101
+      lv_clear_manual_level_pos_settings();
102
+      lv_draw_number_key();
150 103
       break;
151 104
     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
-      }
105
+      value = level_pos_y5;
106
+      lv_clear_manual_level_pos_settings();
107
+      lv_draw_number_key();
160 108
       break;
161 109
     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
-      }
110
+      uiCfg.para_ui_page = 0;
111
+      lv_clear_manual_level_pos_settings();
112
+      lv_draw_manual_level_pos_settings();
170 113
       break;
171 114
     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
-      }
115
+      uiCfg.para_ui_page = 1;
116
+      lv_clear_manual_level_pos_settings();
117
+      lv_draw_manual_level_pos_settings();
180 118
       break;
181 119
   }
182 120
 }
183 121
 
184 122
 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 *buttonX1Value = NULL, *labelX1Value = NULL;
187
-  lv_obj_t *buttonY1Value = NULL, *labelY1Value = NULL;
188
-  lv_obj_t *buttonX2Value = NULL, *labelX2Value = NULL;
189
-  lv_obj_t *buttonY2Value = NULL, *labelY2Value = NULL;
190
-  lv_obj_t *buttonX3Value = NULL, *labelX3Value = NULL;
191
-  lv_obj_t *buttonY3Value = NULL, *labelY3Value = NULL;
192
-  lv_obj_t *buttonX4Value = NULL, *labelX4Value = NULL;
193
-  lv_obj_t *buttonY4Value = NULL, *labelY4Value = NULL;
194
-  lv_obj_t *buttonX5Value = NULL, *labelX5Value = NULL;
195
-  lv_obj_t *buttonY5Value = NULL, *labelY5Value = NULL;
196
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
123
+  char buf2[50];
197 124
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MANUAL_LEVELING_POSIGION_UI) {
198 125
     disp_state_stack._disp_index++;
199 126
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MANUAL_LEVELING_POSIGION_UI;
200 127
   }
201 128
   disp_state = MANUAL_LEVELING_POSIGION_UI;
202 129
 
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
-
130
+  scr = lv_screen_create();
209 131
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.LevelingParaConfTitle);
210
-
211 132
   lv_refr_now(lv_refr_get_disp_refreshing());
212 133
 
213 134
   if (uiCfg.para_ui_page != 1) {
214
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, leveling_menu.position1);
215
-
216
-    buttonX1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X1);
217
-    labelX1Value = lv_label_create_empty(buttonX1Value);
218
-
219
-    buttonY1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y1);
220
-    labelY1Value = lv_label_create_empty(buttonY1Value);
221
-
222
-    line1 = lv_line_create(scr, NULL);
223
-    lv_ex_line(line1, line_points[0]);
224
-
225
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, leveling_menu.position2);
226
-
227
-    buttonX2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X2);
228
-    labelX2Value = lv_label_create_empty(buttonX2Value);
229
-
230
-    buttonY2Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y2);
231
-    labelY2Value = lv_label_create_empty(buttonY2Value);
232
-
233
-    line2 = lv_line_create(scr, NULL);
234
-    lv_ex_line(line2, line_points[1]);
235
-
236
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, leveling_menu.position3);
135
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]);
136
+    sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[0][1]);
137
+    lv_screen_menu_item_2_edit(scr, leveling_menu.position1, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y1, 0, buf2, ID_MANUAL_POS_X1, public_buf_l);
237 138
 
238
-    buttonX3Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X3);
239
-    labelX3Value = lv_label_create_empty(buttonX3Value);
139
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]);
140
+    sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[1][1]);
141
+    lv_screen_menu_item_2_edit(scr, leveling_menu.position2, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_MANUAL_POS_Y2, 1, buf2, ID_MANUAL_POS_X2, public_buf_l);
240 142
 
241
-    buttonY3Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y3);
242
-    labelY3Value = lv_label_create_empty(buttonY3Value);
143
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]);
144
+    sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[2][1]);
145
+    lv_screen_menu_item_2_edit(scr, leveling_menu.position3, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_MANUAL_POS_Y3, 2, buf2, ID_MANUAL_POS_X3, public_buf_l);
243 146
 
244
-    line3 = lv_line_create(scr, NULL);
245
-    lv_ex_line(line3, line_points[2]);
147
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]);
148
+    sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[3][1]);
149
+    lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_MANUAL_POS_Y4, 3, buf2, ID_MANUAL_POS_X4, public_buf_l);
246 150
 
247
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, leveling_menu.position4);
248
-
249
-    buttonX4Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X4);
250
-    labelX4Value = lv_label_create_empty(buttonX4Value);
251
-
252
-    buttonY4Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y4);
253
-    labelY4Value = lv_label_create_empty(buttonY4Value);
254
-
255
-    line4 = lv_line_create(scr, NULL);
256
-    lv_ex_line(line4, line_points[3]);
257
-
258
-    buttonTurnPage = lv_btn_create(scr, NULL);
259
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_DOWN, NULL, 0);
260
-    lv_btn_set_style_both(buttonTurnPage, &style_para_back);
261
-
262
-    #if HAS_ROTARY_ENCODER
263
-      if (gCfgItems.encoder_enable) {
264
-        lv_group_add_obj(g, buttonX1Value);
265
-        lv_group_add_obj(g, buttonY1Value);
266
-        lv_group_add_obj(g, buttonX2Value);
267
-        lv_group_add_obj(g, buttonY2Value);
268
-        lv_group_add_obj(g, buttonX3Value);
269
-        lv_group_add_obj(g, buttonY3Value);
270
-        lv_group_add_obj(g, buttonX4Value);
271
-        lv_group_add_obj(g, buttonY4Value);
272
-        lv_group_add_obj(g, buttonTurnPage);
273
-      }
274
-    #endif
151
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_DOWN, true);
275 152
   }
276 153
   else {
277
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, leveling_menu.position5);
278
-
279
-    buttonX5Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X_2, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_X5);
280
-    labelX5Value = lv_label_create_empty(buttonX5Value);
281
-
282
-    buttonY5Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_MANUAL_POS_Y5);
283
-    labelY5Value = lv_label_create_empty(buttonY5Value);
154
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]);
155
+    sprintf_P(buf2, PSTR("%d"), gCfgItems.levelingPos[4][1]);
156
+    lv_screen_menu_item_2_edit(scr, leveling_menu.position4, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MANUAL_POS_Y5, 0, buf2, ID_MANUAL_POS_X5, public_buf_l);
284 157
 
285
-    line1 = lv_line_create(scr, NULL);
286
-    lv_ex_line(line1, line_points[0]);
287
-
288
-    buttonTurnPage = lv_btn_create(scr, NULL);
289
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_MANUAL_POS_UP, NULL, 0);
290
-    lv_btn_set_style_both(buttonTurnPage, &style_para_back);
291
-
292
-    #if HAS_ROTARY_ENCODER
293
-      if (gCfgItems.encoder_enable) {
294
-        lv_group_add_obj(g, buttonX5Value);
295
-        lv_group_add_obj(g, buttonY5Value);
296
-        lv_group_add_obj(g, buttonTurnPage);
297
-      }
298
-    #endif
158
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_MANUAL_POS_UP, true);
299 159
   }
300 160
 
301
-  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
302
-  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
303
-  labelTurnPage = lv_label_create_empty(buttonTurnPage);
304
-
305
-  buttonBack = lv_btn_create(scr, NULL);
306
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_MANUAL_POS_RETURN, NULL, 0);
307
-  lv_btn_set_style_both(buttonBack, &style_para_back);
308
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
309
-  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
310
-  label_Back = lv_label_create_empty(buttonBack);
311
-
312
-  #if HAS_ROTARY_ENCODER
313
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
314
-  #endif
315
-
316
-  if (gCfgItems.multiple_language) {
317
-    if (uiCfg.para_ui_page != 1) {
318
-      ZERO(public_buf_l);
319
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][0]);
320
-      lv_label_set_text(labelX1Value, public_buf_l);
321
-      lv_obj_align(labelX1Value, buttonX1Value, LV_ALIGN_CENTER, 0, 0);
322
-
323
-      ZERO(public_buf_l);
324
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[0][1]);
325
-      lv_label_set_text(labelY1Value, public_buf_l);
326
-      lv_obj_align(labelY1Value, buttonY1Value, LV_ALIGN_CENTER, 0, 0);
327
-
328
-      ZERO(public_buf_l);
329
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][0]);
330
-      lv_label_set_text(labelX2Value, public_buf_l);
331
-      lv_obj_align(labelX2Value, buttonX2Value, LV_ALIGN_CENTER, 0, 0);
332
-
333
-      ZERO(public_buf_l);
334
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[1][1]);
335
-      lv_label_set_text(labelY2Value, public_buf_l);
336
-      lv_obj_align(labelY2Value, buttonY2Value, LV_ALIGN_CENTER, 0, 0);
337
-
338
-      ZERO(public_buf_l);
339
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][0]);
340
-      lv_label_set_text(labelX3Value, public_buf_l);
341
-      lv_obj_align(labelX3Value, buttonX3Value, LV_ALIGN_CENTER, 0, 0);
342
-
343
-      ZERO(public_buf_l);
344
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[2][1]);
345
-      lv_label_set_text(labelY3Value, public_buf_l);
346
-      lv_obj_align(labelY3Value, buttonY3Value, LV_ALIGN_CENTER, 0, 0);
347
-
348
-      ZERO(public_buf_l);
349
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][0]);
350
-      lv_label_set_text(labelX4Value, public_buf_l);
351
-      lv_obj_align(labelX4Value, buttonX4Value, LV_ALIGN_CENTER, 0, 0);
352
-
353
-      ZERO(public_buf_l);
354
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[3][1]);
355
-      lv_label_set_text(labelY4Value, public_buf_l);
356
-      lv_obj_align(labelY4Value, buttonY4Value, LV_ALIGN_CENTER, 0, 0);
357
-
358
-      lv_label_set_text(labelTurnPage, machine_menu.next);
359
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
360
-    }
361
-    else {
362
-      ZERO(public_buf_l);
363
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][0]);
364
-      lv_label_set_text(labelX5Value, public_buf_l);
365
-      lv_obj_align(labelX5Value, buttonX5Value, LV_ALIGN_CENTER, 0, 0);
366
-
367
-      ZERO(public_buf_l);
368
-      sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.levelingPos[4][1]);
369
-      lv_label_set_text(labelY5Value, public_buf_l);
370
-      lv_obj_align(labelY5Value, buttonY5Value, LV_ALIGN_CENTER, 0, 0);
371
-
372
-      lv_label_set_text(labelTurnPage, machine_menu.previous);
373
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
374
-    }
375
-
376
-    lv_label_set_text(label_Back, common_menu.text_back);
377
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
378
-  }
161
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MANUAL_POS_RETURN, true);
379 162
 }
380 163
 
381 164
 void lv_clear_manual_level_pos_settings() {

+ 54
- 208
Marlin/src/lcd/extui/lib/mks_ui/draw_max_feedrate_settings.cpp View File

@@ -29,254 +29,100 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_FEED_RETURN  1
36
-#define ID_FEED_X       2
37
-#define ID_FEED_Y       3
38
-#define ID_FEED_Z       4
39
-#define ID_FEED_E0      5
40
-#define ID_FEED_E1      6
41
-#define ID_FEED_DOWN    7
42
-#define ID_FEED_UP      8
43
-
44
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_FEED_RETURN = 1,
37
+  ID_FEED_X,
38
+  ID_FEED_Y,
39
+  ID_FEED_Z,
40
+  ID_FEED_E0,
41
+  ID_FEED_E1,
42
+  ID_FEED_DOWN,
43
+  ID_FEED_UP
44
+};
45
+
46
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
47
+  if (event != LV_EVENT_RELEASED) return;
45 48
   switch (obj->mks_obj_id) {
46 49
     case ID_FEED_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_max_feedrate_settings();
53
-        draw_return_ui();
54
-      }
50
+      uiCfg.para_ui_page = 0;
51
+      lv_clear_max_feedrate_settings();
52
+      draw_return_ui();
55 53
       break;
56 54
     case ID_FEED_X:
57
-      if (event == LV_EVENT_CLICKED) {
58
-
59
-      }
60
-      else if (event == LV_EVENT_RELEASED) {
61
-        value = XMaxFeedRate;
62
-        lv_clear_max_feedrate_settings();
63
-        lv_draw_number_key();
64
-      }
55
+      value = XMaxFeedRate;
56
+      lv_clear_max_feedrate_settings();
57
+      lv_draw_number_key();
65 58
       break;
66 59
     case ID_FEED_Y:
67
-      if (event == LV_EVENT_CLICKED) {
68
-
69
-      }
70
-      else if (event == LV_EVENT_RELEASED) {
71
-        value = YMaxFeedRate;
72
-        lv_clear_max_feedrate_settings();
73
-        lv_draw_number_key();
74
-      }
60
+      value = YMaxFeedRate;
61
+      lv_clear_max_feedrate_settings();
62
+      lv_draw_number_key();
75 63
       break;
76 64
     case ID_FEED_Z:
77
-      if (event == LV_EVENT_CLICKED) {
78
-
79
-      }
80
-      else if (event == LV_EVENT_RELEASED) {
81
-        value = ZMaxFeedRate;
82
-        lv_clear_max_feedrate_settings();
83
-        lv_draw_number_key();
84
-      }
65
+      value = ZMaxFeedRate;
66
+      lv_clear_max_feedrate_settings();
67
+      lv_draw_number_key();
85 68
       break;
86 69
     case ID_FEED_E0:
87
-      if (event == LV_EVENT_CLICKED) {
88
-
89
-      }
90
-      else if (event == LV_EVENT_RELEASED) {
91
-        value = E0MaxFeedRate;
92
-        lv_clear_max_feedrate_settings();
93
-        lv_draw_number_key();
94
-      }
70
+      value = E0MaxFeedRate;
71
+      lv_clear_max_feedrate_settings();
72
+      lv_draw_number_key();
95 73
       break;
96 74
     case ID_FEED_E1:
97
-      if (event == LV_EVENT_CLICKED) {
98
-
99
-      }
100
-      else if (event == LV_EVENT_RELEASED) {
101
-        value = E1MaxFeedRate;
102
-        lv_clear_max_feedrate_settings();
103
-        lv_draw_number_key();
104
-      }
75
+      value = E1MaxFeedRate;
76
+      lv_clear_max_feedrate_settings();
77
+      lv_draw_number_key();
105 78
       break;
106 79
     case ID_FEED_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_max_feedrate_settings();
113
-        lv_draw_max_feedrate_settings();
114
-      }
80
+      uiCfg.para_ui_page = 0;
81
+      lv_clear_max_feedrate_settings();
82
+      lv_draw_max_feedrate_settings();
115 83
       break;
116 84
     case ID_FEED_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_max_feedrate_settings();
123
-        lv_draw_max_feedrate_settings();
124
-      }
85
+      uiCfg.para_ui_page = 1;
86
+      lv_clear_max_feedrate_settings();
87
+      lv_draw_max_feedrate_settings();
125 88
       break;
126 89
   }
127 90
 }
128 91
 
129 92
 void lv_draw_max_feedrate_settings(void) {
130
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
131
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
132
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
133
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
134
-  lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
135
-  lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
136
-  lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
137 93
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MAXFEEDRATE_UI) {
138 94
     disp_state_stack._disp_index++;
139 95
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MAXFEEDRATE_UI;
140 96
   }
141 97
   disp_state = MAXFEEDRATE_UI;
142 98
 
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
-
99
+  scr = lv_screen_create();
149 100
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MaxFeedRateConfTitle);
150
-
151 101
   lv_refr_now(lv_refr_get_disp_refreshing());
152 102
 
153 103
   if (uiCfg.para_ui_page != 1) {
154
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.XMaxFeedRate);
155
-
156
-    buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_X);
157
-    lv_btn_set_layout(buttonXValue, LV_LAYOUT_OFF);
158
-    labelXValue = lv_label_create_empty(buttonXValue);
159
-
160
-    line1 = lv_line_create(scr, NULL);
161
-    lv_ex_line(line1, line_points[0]);
162
-
163
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.YMaxFeedRate);
164
-
165
-    buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_Y);
166
-    lv_btn_set_layout(buttonYValue, LV_LAYOUT_OFF);
167
-    labelYValue = lv_label_create_empty(buttonYValue);
168
-
169
-    line2 = lv_line_create(scr, NULL);
170
-    lv_ex_line(line2, line_points[1]);
171
-
172
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.ZMaxFeedRate);
104
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
105
+    lv_screen_menu_item_1_edit(scr, machine_menu.XMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_X, 0, public_buf_l);
173 106
 
174
-    buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_Z);
175
-    lv_btn_set_layout(buttonZValue, LV_LAYOUT_OFF);
176
-    labelZValue = lv_label_create_empty(buttonZValue);
107
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
108
+    lv_screen_menu_item_1_edit(scr, machine_menu.YMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_FEED_Y, 1, public_buf_l);
177 109
 
178
-    line3 = lv_line_create(scr, NULL);
179
-    lv_ex_line(line3, line_points[2]);
110
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
111
+    lv_screen_menu_item_1_edit(scr, machine_menu.ZMaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_FEED_Z, 2, public_buf_l);
180 112
 
181
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0MaxFeedRate);
113
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
114
+    lv_screen_menu_item_1_edit(scr, machine_menu.E0MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_FEED_E0, 3, public_buf_l);
182 115
 
183
-    buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_E0);
184
-    lv_btn_set_layout(buttonE0Value, LV_LAYOUT_OFF);
185
-    labelE0Value = lv_label_create_empty(buttonE0Value);
186
-
187
-    line4 = lv_line_create(scr, NULL);
188
-    lv_ex_line(line4, line_points[3]);
189
-
190
-    buttonTurnPage = lv_btn_create(scr, NULL);
191
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_DOWN, NULL, 0);
192
-    lv_btn_set_style_both(buttonTurnPage, &style_para_back);
193
-
194
-    #if HAS_ROTARY_ENCODER
195
-      if (gCfgItems.encoder_enable) {
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, buttonE0Value);
200
-        lv_group_add_obj(g, buttonTurnPage);
201
-      }
202
-    #endif
116
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_DOWN, true);
203 117
   }
204 118
   else {
205
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1MaxFeedRate);
206
-
207
-    buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_FEED_E1);
208
-    lv_btn_set_layout(buttonE1Value, LV_LAYOUT_OFF);
209
-    labelE1Value = lv_label_create_empty(buttonE1Value);
210
-
119
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
120
+    lv_screen_menu_item_1_edit(scr, machine_menu.E1MaxFeedRate, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_FEED_E1, 0, public_buf_l);
211 121
 
212
-    line1 = lv_line_create(scr, NULL);
213
-    lv_ex_line(line1, line_points[0]);
214
-
215
-    buttonTurnPage = lv_btn_create(scr, NULL);
216
-    lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_FEED_UP, NULL, 0);
217
-    lv_btn_set_style_both(buttonTurnPage, &style_para_back);
218
-
219
-    #if HAS_ROTARY_ENCODER
220
-      if (gCfgItems.encoder_enable) {
221
-        lv_group_add_obj(g, buttonE1Value);
222
-        lv_group_add_obj(g, buttonTurnPage);
223
-      }
224
-    #endif
122
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_FEED_UP, true);
225 123
   }
226 124
 
227
-  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
228
-  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
229
-  labelTurnPage = lv_label_create_empty(buttonTurnPage);
230
-
231
-  buttonBack = lv_btn_create(scr, NULL);
232
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_FEED_RETURN, NULL, 0);
233
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
234
-  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
235
-  lv_btn_set_style_both(buttonBack, &style_para_back);
236
-  label_Back = lv_label_create_empty(buttonBack);
237
-  #if HAS_ROTARY_ENCODER
238
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
239
-  #endif
240
-
241
-  if (gCfgItems.multiple_language) {
242
-    if (uiCfg.para_ui_page != 1) {
243
-
244
-      lv_label_set_text(labelTurnPage, machine_menu.next);
245
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
246
-
247
-      ZERO(public_buf_l);
248
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[X_AXIS]);
249
-      lv_label_set_text(labelXValue, public_buf_l);
250
-      lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
251
-
252
-      ZERO(public_buf_l);
253
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Y_AXIS]);
254
-      lv_label_set_text(labelYValue, public_buf_l);
255
-      lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
256
-
257
-      ZERO(public_buf_l);
258
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[Z_AXIS]);
259
-      lv_label_set_text(labelZValue, public_buf_l);
260
-      lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
261
-
262
-      ZERO(public_buf_l);
263
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS]);
264
-      lv_label_set_text(labelE0Value, public_buf_l);
265
-      lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
266
-    }
267
-    else {
268
-      lv_label_set_text(labelTurnPage, machine_menu.previous);
269
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
270
-
271
-      ZERO(public_buf_l);
272
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.max_feedrate_mm_s[E_AXIS_N(1)]);
273
-      lv_label_set_text(labelE1Value, public_buf_l);
274
-      lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
275
-    }
276
-
277
-    lv_label_set_text(label_Back, common_menu.text_back);
278
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
279
-  }
125
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_FEED_RETURN, true);
280 126
 }
281 127
 
282 128
 void lv_clear_max_feedrate_settings() {

+ 40
- 220
Marlin/src/lcd/extui/lib/mks_ui/draw_motor_settings.cpp View File

@@ -28,258 +28,78 @@
28 28
 
29 29
 #include "../../../../inc/MarlinConfig.h"
30 30
 
31
-extern lv_group_t * g;
32
-static lv_obj_t * scr;
33
-
34
-#define ID_MOTOR_RETURN            1
35
-#define ID_MOTOR_STEPS             2
36
-#define ID_MOTOR_STEPS_ARROW       3
37
-#define ID_MOTOR_TMC_CURRENT       4
38
-#define ID_MOTOR_TMC_CURRENT_ARROW 5
39
-#define ID_MOTOR_STEP_MODE         6
40
-#define ID_MOTOR_STEP_MODE_ARROW   7
41
-#define ID_HOME_SENSE              8
42
-#define ID_HOME_SENSE_ARROW        9
43
-
44
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
31
+extern lv_group_t *g;
32
+static lv_obj_t *scr;
33
+
34
+enum {
35
+  ID_MOTOR_RETURN = 1,
36
+  ID_MOTOR_STEPS,
37
+  ID_MOTOR_TMC_CURRENT,
38
+  ID_MOTOR_STEP_MODE,
39
+  ID_HOME_SENSE
40
+};
41
+
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
45 44
   switch (obj->mks_obj_id) {
46 45
     case ID_MOTOR_RETURN:
47
-      if (event == LV_EVENT_CLICKED) {
48
-
49
-      }
50
-      else if (event == LV_EVENT_RELEASED) {
51
-        lv_clear_motor_settings();
52
-        draw_return_ui();
53
-      }
46
+      lv_clear_motor_settings();
47
+      draw_return_ui();
54 48
       break;
55 49
     case ID_MOTOR_STEPS:
56
-      if (event == LV_EVENT_CLICKED) {
57
-
58
-      }
59
-      else if (event == LV_EVENT_RELEASED) {
60
-        lv_clear_motor_settings();
61
-        lv_draw_step_settings();
62
-      }
63
-      break;
64
-    case ID_MOTOR_STEPS_ARROW:
65
-      if (event == LV_EVENT_CLICKED) {
66
-
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        lv_clear_motor_settings();
70
-        lv_draw_step_settings();
71
-      }
50
+      lv_clear_motor_settings();
51
+      lv_draw_step_settings();
72 52
       break;
73 53
     #if USE_SENSORLESS
74
-    case ID_HOME_SENSE:
75
-      if (event == LV_EVENT_CLICKED) {
76
-
77
-      }
78
-      else if (event == LV_EVENT_RELEASED) {
54
+      case ID_HOME_SENSE:
79 55
         lv_clear_motor_settings();
80 56
         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;
57
+        break;
92 58
     #endif
93
-      #if HAS_TRINAMIC_CONFIG
94
-        case ID_MOTOR_TMC_CURRENT:
95
-          if (event == LV_EVENT_CLICKED) {
96 59
 
97
-          }
98
-          else if (event == LV_EVENT_RELEASED) {
99
-            lv_clear_motor_settings();
100
-            lv_draw_tmc_current_settings();
101
-          }
102
-          break;
103
-        case ID_MOTOR_TMC_CURRENT_ARROW:
104
-          if (event == LV_EVENT_CLICKED) {
105
-
106
-          }
107
-          else if (event == LV_EVENT_RELEASED) {
108
-            lv_clear_motor_settings();
109
-            lv_draw_tmc_current_settings();
110
-          }
60
+    #if HAS_TRINAMIC_CONFIG
61
+      case ID_MOTOR_TMC_CURRENT:
62
+        lv_clear_motor_settings();
63
+        lv_draw_tmc_current_settings();
64
+        break;
65
+      #if HAS_STEALTHCHOP
66
+        case ID_MOTOR_STEP_MODE:
67
+          lv_clear_motor_settings();
68
+          lv_draw_tmc_step_mode_settings();
111 69
           break;
112
-          #if HAS_STEALTHCHOP
113
-            case ID_MOTOR_STEP_MODE:
114
-              if (event == LV_EVENT_CLICKED) {
115
-
116
-              }
117
-              else if (event == LV_EVENT_RELEASED) {
118
-                lv_clear_motor_settings();
119
-                lv_draw_tmc_step_mode_settings();
120
-              }
121
-              break;
122
-            case ID_MOTOR_STEP_MODE_ARROW:
123
-              if (event == LV_EVENT_CLICKED) {
124
-
125
-              }
126
-              else if (event == LV_EVENT_RELEASED) {
127
-                lv_clear_motor_settings();
128
-                lv_draw_tmc_step_mode_settings();
129
-              }
130
-              break;
131
-          #endif
132 70
       #endif
71
+    #endif
133 72
   }
134 73
 }
135 74
 
136 75
 void lv_draw_motor_settings(void) {
137
-  lv_obj_t *buttonBack, *label_Back;
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
144
-  #if HAS_TRINAMIC_CONFIG
145
-    #if USE_SENSORLESS
146
-      lv_obj_t * line3;
147
-    #else
148
-      lv_obj_t * line2;
149
-    #endif
150
-    lv_obj_t *buttonTMCcurrent, *labelTMCcurrent, *buttonTMCcurrentNarrow;
151
-    #if HAS_STEALTHCHOP
152
-      #if USE_SENSORLESS
153
-        lv_obj_t * line4;
154
-      #else
155
-        lv_obj_t * line3;
156
-      #endif
157
-      lv_obj_t *buttonStepMode, *labelStepMode, *buttonStepModeNarrow;
158
-    #endif
159
-  #endif
160 76
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOTOR_SETTINGS_UI) {
161 77
     disp_state_stack._disp_index++;
162 78
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MOTOR_SETTINGS_UI;
163 79
   }
164 80
   disp_state = MOTOR_SETTINGS_UI;
165 81
 
166
-  scr = lv_obj_create(NULL, NULL);
167
-
168
-  lv_obj_set_style(scr, &tft_style_scr);
169
-  lv_scr_load(scr);
170
-  lv_obj_clean(scr);
82
+  scr = lv_screen_create();
171 83
 
172 84
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.MotorConfTitle);
173 85
 
174 86
   lv_refr_now(lv_refr_get_disp_refreshing());
175 87
 
176
-  buttonSteps = lv_btn_create(scr, NULL);                                 /*Add a button the current screen*/
177
-  lv_obj_set_pos(buttonSteps, PARA_UI_POS_X, PARA_UI_POS_Y);              /*Set its position*/
178
-  lv_obj_set_size(buttonSteps, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);           /*Set its size*/
179
-  //lv_obj_set_event_cb(buttonMachine, event_handler);
180
-  lv_obj_set_event_cb_mks(buttonSteps, event_handler, ID_MOTOR_STEPS, NULL, 0);
181
-  lv_btn_use_label_style(buttonSteps);
182
-  lv_btn_set_layout(buttonSteps, LV_LAYOUT_OFF);
183
-  labelSteps = lv_label_create_empty(buttonSteps);                        /*Add a label to the button*/
184
-
185
-  #if HAS_ROTARY_ENCODER
186
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSteps);
187
-  #endif
188
-
189
-  buttonStepsNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y + PARA_UI_ARROW_V, event_handler, ID_MOTOR_STEPS_ARROW);
190
-
191
-  line1 = lv_line_create(scr, NULL);
192
-  lv_ex_line(line1, line_points[0]);
193
-
88
+  int index = 0;
89
+  lv_screen_menu_item(scr, machine_menu.StepsConf, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_MOTOR_STEPS, index++);
194 90
   #if USE_SENSORLESS
195
-    buttonSensitivity = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2, PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_HOME_SENSE);
196
-    //lv_obj_set_event_cb(buttonMachine, event_handler);
197
-    labelSensitivity = lv_label_create_empty(buttonSensitivity);                  /*Add a label to the button*/
198
-
199
-    #if HAS_ROTARY_ENCODER
200
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonSensitivity);
201
-    #endif
202
-
203
-    buttonSensitivityNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", PARA_UI_POS_X + PARA_UI_SIZE_X, PARA_UI_POS_Y * 2 + PARA_UI_ARROW_V, event_handler, ID_HOME_SENSE_ARROW);
204
-
205
-    line2 = lv_line_create(scr, NULL);
206
-    lv_ex_line(line2, line_points[1]);
91
+    lv_screen_menu_item(scr, machine_menu.HomingSensitivityConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_HOME_SENSE, index);
92
+    index++;
207 93
   #endif
208
-
209
-
210 94
   #if HAS_TRINAMIC_CONFIG
211
-    buttonTMCcurrent = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
212
-    lv_obj_set_pos(buttonTMCcurrent, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 3, PARA_UI_POS_Y * 2));
213
-    lv_obj_set_size(buttonTMCcurrent, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);          /*Set its size*/
214
-    //lv_obj_set_event_cb(buttonMachine, event_handler);
215
-    lv_obj_set_event_cb_mks(buttonTMCcurrent, event_handler, ID_MOTOR_TMC_CURRENT, NULL, 0);
216
-    lv_btn_use_label_style(buttonTMCcurrent);
217
-    lv_btn_set_layout(buttonTMCcurrent, LV_LAYOUT_OFF);
218
-    labelTMCcurrent = lv_label_create_empty(buttonTMCcurrent);                  /*Add a label to the button*/
219
-    #if HAS_ROTARY_ENCODER
220
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTMCcurrent);
221
-    #endif
222
-
223
-    buttonTMCcurrentNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", 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, event_handler, ID_MOTOR_TMC_CURRENT_ARROW);
224
-
225
-    #if USE_SENSORLESS
226
-      line3 = lv_line_create(scr, NULL);
227
-      lv_ex_line(line3, line_points[2]);
228
-    #else
229
-      line2 = lv_line_create(scr, NULL);
230
-      lv_ex_line(line2, line_points[1]);
231
-    #endif
232
-
95
+    lv_screen_menu_item(scr, machine_menu.TMCcurrentConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_TMC_CURRENT, index);
96
+    index++;
233 97
     #if HAS_STEALTHCHOP
234
-      buttonStepMode = lv_btn_create(scr, NULL, PARA_UI_POS_X, TERN(USE_SENSORLESS, PARA_UI_POS_Y * 4, PARA_UI_POS_Y * 3), PARA_UI_SIZE_X, PARA_UI_SIZE_Y, event_handler, ID_MOTOR_STEP_MODE);
235
-      labelStepMode = lv_label_create_empty(buttonStepMode);                    /*Add a label to the button*/
236
-
237
-      #if HAS_ROTARY_ENCODER
238
-        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonStepMode);
239
-      #endif
240
-
241
-      buttonStepModeNarrow = lv_imgbtn_create(scr, "F:/bmp_arrow.bin", 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, event_handler, ID_MOTOR_STEP_MODE_ARROW);
242
-
243
-      #if USE_SENSORLESS
244
-        line4 = lv_line_create(scr, NULL);
245
-        lv_ex_line(line4, line_points[3]);
246
-      #else
247
-        line3 = lv_line_create(scr, NULL);
248
-        lv_ex_line(line3, line_points[2]);
249
-      #endif
250
-
251
-    #endif // HAS_STEALTHCHOP
252
-
253
-  #endif // HAS_TRINAMIC_CONFIG
254
-
255
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_MOTOR_RETURN);
256
-  label_Back = lv_label_create_empty(buttonBack);
257
-
258
-  #if HAS_ROTARY_ENCODER
259
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
260
-  #endif
261
-
262
-  if (gCfgItems.multiple_language) {
263
-    lv_label_set_text(label_Back, common_menu.text_back);
264
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
265
-
266
-    lv_label_set_text(labelSteps, machine_menu.StepsConf);
267
-    lv_obj_align(labelSteps, buttonSteps, LV_ALIGN_IN_LEFT_MID, 0, 0);
268
-
269
-    #if USE_SENSORLESS
270
-      lv_label_set_text(labelSensitivity, machine_menu.HomingSensitivityConf);
271
-      lv_obj_align(labelSensitivity, buttonSensitivity, LV_ALIGN_IN_LEFT_MID, 0, 0);
98
+      lv_screen_menu_item(scr, machine_menu.TMCStepModeConf, PARA_UI_POS_X, PARA_UI_POS_Y * (index + 1), event_handler, ID_MOTOR_STEP_MODE, index);
99
+      index++;
272 100
     #endif
273
-    #if HAS_TRINAMIC_CONFIG
274
-      lv_label_set_text(labelTMCcurrent, machine_menu.TMCcurrentConf);
275
-      lv_obj_align(labelTMCcurrent, buttonTMCcurrent, LV_ALIGN_IN_LEFT_MID, 0, 0);
276
-      #if HAS_STEALTHCHOP
277
-        lv_label_set_text(labelStepMode, machine_menu.TMCStepModeConf);
278
-        lv_obj_align(labelStepMode, buttonStepMode, LV_ALIGN_IN_LEFT_MID, 0, 0);
279
-      #endif
280
-    #endif
281
-  }
282
-
101
+  #endif
102
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X + 10, PARA_UI_BACL_POS_Y, event_handler, ID_MOTOR_RETURN, true);
283 103
 }
284 104
 
285 105
 void lv_clear_motor_settings() {

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

@@ -33,210 +33,119 @@
33 33
 #include "../../../../gcode/queue.h"
34 34
 #include "../../../../inc/MarlinConfig.h"
35 35
 
36
-extern lv_group_t * g;
37
-static lv_obj_t * scr;
36
+extern lv_group_t *g;
37
+static lv_obj_t *scr;
38 38
 
39 39
 static lv_obj_t *labelV, *buttonV;
40 40
 
41
-#define ID_M_X_P    1
42
-#define ID_M_X_N    2
43
-#define ID_M_Y_P    3
44
-#define ID_M_Y_N    4
45
-#define ID_M_Z_P    5
46
-#define ID_M_Z_N    6
47
-#define ID_M_STEP   7
48
-#define ID_M_RETURN 8
49
-
50
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
41
+enum {
42
+  ID_M_X_P = 1,
43
+  ID_M_X_N,
44
+  ID_M_Y_P,
45
+  ID_M_Y_N,
46
+  ID_M_Z_P,
47
+  ID_M_Z_N,
48
+  ID_M_STEP,
49
+  ID_M_RETURN
50
+};
51
+
52
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
53
+  if (event != LV_EVENT_RELEASED) return;
51 54
   switch (obj->mks_obj_id) {
52 55
     case ID_M_X_P:
53
-      if (event == LV_EVENT_CLICKED) {
54
-        // nothing to do
55
-      }
56
-      else if (event == LV_EVENT_RELEASED) {
57
-        if (queue.length <= (BUFSIZE - 3)) {
58
-          ZERO(public_buf_l);
59
-          queue.enqueue_one_P(PSTR("G91"));
60
-          sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
61
-          queue.enqueue_one_now(public_buf_l);
62
-          queue.enqueue_one_P(PSTR("G90"));
63
-        }
56
+      if (queue.length <= (BUFSIZE - 3)) {
57
+        queue.enqueue_one_P(PSTR("G91"));
58
+        sprintf_P(public_buf_l, PSTR("G1 X%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
59
+        queue.enqueue_one_now(public_buf_l);
60
+        queue.enqueue_one_P(PSTR("G90"));
64 61
       }
65 62
       break;
66 63
     case ID_M_X_N:
67
-      if (event == LV_EVENT_CLICKED) {
68
-        // nothing to do
69
-      }
70
-      else if (event == LV_EVENT_RELEASED) {
71
-        if (queue.length <= (BUFSIZE - 3)) {
72
-          ZERO(public_buf_l);
73
-          queue.enqueue_now_P(PSTR("G91"));
74
-          sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
75
-          queue.enqueue_one_now(public_buf_l);
76
-          queue.enqueue_now_P(PSTR("G90"));
77
-        }
64
+      if (queue.length <= (BUFSIZE - 3)) {
65
+        queue.enqueue_now_P(PSTR("G91"));
66
+        sprintf_P(public_buf_l, PSTR("G1 X-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
67
+        queue.enqueue_one_now(public_buf_l);
68
+        queue.enqueue_now_P(PSTR("G90"));
78 69
       }
79 70
       break;
80 71
     case ID_M_Y_P:
81
-      if (event == LV_EVENT_CLICKED) {
82
-        // nothing to do
83
-      }
84
-      else if (event == LV_EVENT_RELEASED) {
85
-        if (queue.length <= (BUFSIZE - 3)) {
86
-          ZERO(public_buf_l);
87
-          queue.enqueue_now_P(PSTR("G91"));
88
-          sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
89
-          queue.enqueue_one_now(public_buf_l);
90
-          queue.enqueue_now_P(PSTR("G90"));
91
-        }
72
+      if (queue.length <= (BUFSIZE - 3)) {
73
+        queue.enqueue_now_P(PSTR("G91"));
74
+        sprintf_P(public_buf_l, PSTR("G1 Y%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
75
+        queue.enqueue_one_now(public_buf_l);
76
+        queue.enqueue_now_P(PSTR("G90"));
92 77
       }
93 78
       break;
94 79
     case ID_M_Y_N:
95
-      if (event == LV_EVENT_CLICKED) {
96
-        // nothing to do
97
-      }
98
-      else if (event == LV_EVENT_RELEASED) {
99
-        if (queue.length <= (BUFSIZE - 3)) {
100
-          ZERO(public_buf_l);
101
-          queue.enqueue_now_P(PSTR("G91"));
102
-          sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
103
-          queue.enqueue_one_now(public_buf_l);
104
-          queue.enqueue_now_P(PSTR("G90"));
105
-        }
80
+      if (queue.length <= (BUFSIZE - 3)) {
81
+        queue.enqueue_now_P(PSTR("G91"));
82
+        sprintf_P(public_buf_l, PSTR("G1 Y-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
83
+        queue.enqueue_one_now(public_buf_l);
84
+        queue.enqueue_now_P(PSTR("G90"));
106 85
       }
107 86
       break;
108 87
     case ID_M_Z_P:
109
-      if (event == LV_EVENT_CLICKED) {
110
-        // nothing to do
111
-      }
112
-      else if (event == LV_EVENT_RELEASED) {
113
-        if (queue.length <= (BUFSIZE - 3)) {
114
-          ZERO(public_buf_l);
115
-          queue.enqueue_now_P(PSTR("G91"));
116
-          sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
117
-          queue.enqueue_one_now(public_buf_l);
118
-          queue.enqueue_now_P(PSTR("G90"));
119
-        }
88
+      if (queue.length <= (BUFSIZE - 3)) {
89
+        queue.enqueue_now_P(PSTR("G91"));
90
+        sprintf_P(public_buf_l, PSTR("G1 Z%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
91
+        queue.enqueue_one_now(public_buf_l);
92
+        queue.enqueue_now_P(PSTR("G90"));
120 93
       }
121 94
       break;
122 95
     case ID_M_Z_N:
123
-      if (event == LV_EVENT_CLICKED) {
124
-        // nothing to do
125
-      }
126
-      else if (event == LV_EVENT_RELEASED) {
127
-        if (queue.length <= (BUFSIZE - 3)) {
128
-          ZERO(public_buf_l);
129
-          queue.enqueue_now_P(PSTR("G91"));
130
-          sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
131
-          queue.enqueue_one_now(public_buf_l);
132
-          queue.enqueue_now_P(PSTR("G90"));
133
-        }
96
+      if (queue.length <= (BUFSIZE - 3)) {
97
+        queue.enqueue_now_P(PSTR("G91"));
98
+        sprintf_P(public_buf_l, PSTR("G1 Z-%3.1f F%d"), uiCfg.move_dist, uiCfg.moveSpeed);
99
+        queue.enqueue_one_now(public_buf_l);
100
+        queue.enqueue_now_P(PSTR("G90"));
134 101
       }
135 102
       break;
136 103
     case ID_M_STEP:
137
-      if (event == LV_EVENT_CLICKED) {
138
-        // nothing to do
139
-      }
140
-      else if (event == LV_EVENT_RELEASED) {
141
-        if (abs(10 * (int)uiCfg.move_dist) == 100)
142
-          uiCfg.move_dist = 0.1;
143
-        else
144
-          uiCfg.move_dist *= (float)10;
145
-
146
-        disp_move_dist();
147
-      }
148
-
104
+      if (abs(10 * (int)uiCfg.move_dist) == 100)
105
+        uiCfg.move_dist = 0.1;
106
+      else
107
+        uiCfg.move_dist *= (float)10;
108
+      disp_move_dist();
149 109
       break;
150 110
     case ID_M_RETURN:
151
-      if (event == LV_EVENT_CLICKED) {
152
-        // nothing to do
153
-      }
154
-      else if (event == LV_EVENT_RELEASED) {
155
-        clear_cur_ui();
156
-        draw_return_ui();
157
-      }
111
+      clear_cur_ui();
112
+      draw_return_ui();
158 113
       break;
159 114
   }
160 115
 }
161 116
 
162 117
 void lv_draw_move_motor(void) {
163
-  lv_obj_t *buttonXI, *buttonXD, *buttonYI, *buttonYD, *buttonZI, *buttonZD, *buttonBack;
164
-
165 118
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != MOVE_MOTOR_UI) {
166 119
     disp_state_stack._disp_index++;
167 120
     disp_state_stack._disp_state[disp_state_stack._disp_index] = MOVE_MOTOR_UI;
168 121
   }
169 122
   disp_state = MOVE_MOTOR_UI;
170 123
 
171
-  scr = lv_obj_create(NULL, NULL);
172
-
173
-  lv_obj_set_style(scr, &tft_style_scr);
174
-  lv_scr_load(scr);
175
-  lv_obj_clean(scr);
124
+  scr = lv_screen_create();
176 125
 
177 126
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
178 127
 
179 128
   lv_refr_now(lv_refr_get_disp_refreshing());
180 129
 
181
-  // Create an Image button
182
-  buttonXI = lv_imgbtn_create(scr, "F:/bmp_xAdd.bin", INTERVAL_V, titleHeight, event_handler, ID_M_X_P);
130
+  lv_obj_t *buttonXI = lv_big_button_create(scr, "F:/bmp_xAdd.bin", move_menu.x_add, INTERVAL_V, titleHeight, event_handler, ID_M_X_P);
183 131
   lv_obj_clear_protect(buttonXI, LV_PROTECT_FOLLOW);
184
-  buttonXD = lv_imgbtn_create(scr, "F:/bmp_xDec.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N);
185
-  buttonYI = lv_imgbtn_create(scr, "F:/bmp_yAdd.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_Y_P);
186
-  buttonYD = lv_imgbtn_create(scr, "F:/bmp_yDec.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Y_N);
187
-  buttonZI = lv_imgbtn_create(scr, "F:/bmp_zAdd.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_Z_P);
188
-  buttonZD = lv_imgbtn_create(scr, "F:/bmp_zDec.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N);
189
-
190
-  buttonV = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
191
-  //lv_obj_set_event_cb_mks(buttonV, event_handler,ID_T_MORE,"bmp_More.bin",0);
192
-
193
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
194
-
195
-  // Create labels on the image buttons
196
-  lv_obj_t *labelXI = lv_label_create_empty(buttonXI);
197
-  lv_obj_t *labelXD = lv_label_create_empty(buttonXD);
198
-  lv_obj_t *labelYI = lv_label_create_empty(buttonYI);
199
-  lv_obj_t *labelYD = lv_label_create_empty(buttonYD);
200
-  lv_obj_t *labelZI = lv_label_create_empty(buttonZI);
201
-  lv_obj_t *labelZD = lv_label_create_empty(buttonZD);
132
+  lv_big_button_create(scr, "F:/bmp_xDec.bin", move_menu.x_dec, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_X_N);
133
+  lv_big_button_create(scr, "F:/bmp_yAdd.bin", move_menu.y_add, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_M_Y_P);
134
+  lv_big_button_create(scr, "F:/bmp_yDec.bin", move_menu.y_dec, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Y_N);
135
+  lv_big_button_create(scr, "F:/bmp_zAdd.bin", move_menu.z_add, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_M_Z_P);
136
+  lv_big_button_create(scr, "F:/bmp_zDec.bin", move_menu.z_dec, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_Z_N);
137
+
138
+  // button with image and label changed dinamycally by disp_move_dist
139
+  buttonV = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_M_STEP);
202 140
   labelV = lv_label_create_empty(buttonV);
203
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
204
-
205
-  if (gCfgItems.multiple_language) {
206
-    lv_label_set_text(labelXI, move_menu.x_add);
207
-    lv_obj_align(labelXI, buttonXI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
208
-
209
-    lv_label_set_text(labelXD, move_menu.x_dec);
210
-    lv_obj_align(labelXD, buttonXD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
211
-
212
-    lv_label_set_text(labelYI, move_menu.y_add);
213
-    lv_obj_align(labelYI, buttonYI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
214
-
215
-    lv_label_set_text(labelYD, move_menu.y_dec);
216
-    lv_obj_align(labelYD, buttonYD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
217
-
218
-    lv_label_set_text(labelZI, move_menu.z_add);
219
-    lv_obj_align(labelZI, buttonZI, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
220
-
221
-    lv_label_set_text(labelZD, move_menu.z_dec);
222
-    lv_obj_align(labelZD, buttonZD, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
223
-
224
-    lv_label_set_text(label_Back, common_menu.text_back);
225
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
226
-  }
227 141
   #if HAS_ROTARY_ENCODER
228 142
     if (gCfgItems.encoder_enable) {
229
-      lv_group_add_obj(g, buttonXI);
230
-      lv_group_add_obj(g, buttonXD);
231
-      lv_group_add_obj(g, buttonYI);
232
-      lv_group_add_obj(g, buttonYD);
233
-      lv_group_add_obj(g, buttonZI);
234
-      lv_group_add_obj(g, buttonZD);
235 143
       lv_group_add_obj(g, buttonV);
236
-      lv_group_add_obj(g, buttonBack);
237 144
     }
238 145
   #endif
239 146
 
147
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_M_RETURN);
148
+
240 149
   disp_move_dist();
241 150
 }
242 151
 

+ 141
- 332
Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp View File

@@ -49,30 +49,32 @@
49 49
   #include "../../../../module/probe.h"
50 50
 #endif
51 51
 
52
-extern lv_group_t * g;
53
-static lv_obj_t * scr;
54
-static lv_obj_t *buttonValue = NULL;
55
-static lv_obj_t *labelValue  = NULL;
56
-
57
-static char key_value[11] = {0};
58
-static uint8_t cnt        = 0;
59
-static char point_flg     = 1;
60
-
61
-#define ID_NUM_KEY1      1
62
-#define ID_NUM_KEY2      2
63
-#define ID_NUM_KEY3      3
64
-#define ID_NUM_KEY4      4
65
-#define ID_NUM_KEY5      5
66
-#define ID_NUM_KEY6      6
67
-#define ID_NUM_KEY7      7
68
-#define ID_NUM_KEY8      8
69
-#define ID_NUM_KEY9      9
70
-#define ID_NUM_KEY0     10
71
-#define ID_NUM_BACK     11
72
-#define ID_NUM_RESET    12
73
-#define ID_NUM_CONFIRM  13
74
-#define ID_NUM_POINT    14
75
-#define ID_NUM_NAGETIVE 15
52
+extern lv_group_t *g;
53
+static lv_obj_t *scr;
54
+static lv_obj_t *buttonValue = nullptr;
55
+static lv_obj_t *labelValue  = nullptr;
56
+
57
+static char key_value[11] = { 0 };
58
+static uint8_t cnt = 0;
59
+static bool point_flag = true;
60
+
61
+enum {
62
+  ID_NUM_KEY1 = 1,
63
+  ID_NUM_KEY2,
64
+  ID_NUM_KEY3,
65
+  ID_NUM_KEY4,
66
+  ID_NUM_KEY5,
67
+  ID_NUM_KEY6,
68
+  ID_NUM_KEY7,
69
+  ID_NUM_KEY8,
70
+  ID_NUM_KEY9,
71
+  ID_NUM_KEY0,
72
+  ID_NUM_BACK,
73
+  ID_NUM_RESET,
74
+  ID_NUM_CONFIRM,
75
+  ID_NUM_POINT,
76
+  ID_NUM_NEGATIVE
77
+};
76 78
 
77 79
 static void disp_key_value() {
78 80
   char *temp;
@@ -80,8 +82,6 @@ static void disp_key_value() {
80 82
     float milliamps;
81 83
   #endif
82 84
 
83
-  ZERO(public_buf_m);
84
-
85 85
   switch (value) {
86 86
     case PrintAcceleration:
87 87
       sprintf_P(public_buf_m, PSTR("%.1f"), planner.settings.acceleration);
@@ -289,14 +289,11 @@ static void disp_key_value() {
289 289
       #endif
290 290
       break;
291 291
   }
292
-  ZERO(key_value);
292
+
293 293
   strcpy(key_value, public_buf_m);
294 294
   cnt  = strlen(key_value);
295 295
   temp = strchr(key_value, '.');
296
-  if (temp)
297
-    point_flg = 0;
298
-  else
299
-    point_flg = 1;
296
+  point_flag = !temp;
300 297
   lv_label_set_text(labelValue, key_value);
301 298
   lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
302 299
 
@@ -540,406 +537,218 @@ static void set_value_confirm() {
540 537
   gcode.process_subcommands_now_P(PSTR("M500"));
541 538
 }
542 539
 
543
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
540
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
541
+  if (event != LV_EVENT_RELEASED) return;
544 542
   switch (obj->mks_obj_id) {
545 543
     case ID_NUM_KEY1:
546
-      if (event == LV_EVENT_CLICKED) {
547
-
548
-      }
549
-      else if (event == LV_EVENT_RELEASED) {
550
-        if (cnt <= 10) {
551
-          key_value[cnt] = (char)'1';
552
-          lv_label_set_text(labelValue, key_value);
553
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
554
-          cnt++;
555
-        }
544
+      if (cnt <= 10) {
545
+        key_value[cnt] = (char)'1';
546
+        lv_label_set_text(labelValue, key_value);
547
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
548
+        cnt++;
556 549
       }
557 550
       break;
558 551
     case ID_NUM_KEY2:
559
-      if (event == LV_EVENT_CLICKED) {
560
-
561
-      }
562
-      else if (event == LV_EVENT_RELEASED) {
563
-        if (cnt <= 10) {
564
-          key_value[cnt] = (char)'2';
565
-          lv_label_set_text(labelValue, key_value);
566
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
567
-          cnt++;
568
-        }
552
+      if (cnt <= 10) {
553
+        key_value[cnt] = (char)'2';
554
+        lv_label_set_text(labelValue, key_value);
555
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
556
+        cnt++;
569 557
       }
570 558
       break;
571 559
     case ID_NUM_KEY3:
572
-      if (event == LV_EVENT_CLICKED) {
573
-
574
-      }
575
-      else if (event == LV_EVENT_RELEASED) {
576
-        if (cnt <= 10) {
577
-          key_value[cnt] = (char)'3';
578
-          lv_label_set_text(labelValue, key_value);
579
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
580
-          cnt++;
581
-        }
560
+      if (cnt <= 10) {
561
+        key_value[cnt] = (char)'3';
562
+        lv_label_set_text(labelValue, key_value);
563
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
564
+        cnt++;
582 565
       }
583 566
       break;
584 567
     case ID_NUM_KEY4:
585
-      if (event == LV_EVENT_CLICKED) {
586
-
587
-      }
588
-      else if (event == LV_EVENT_RELEASED) {
589
-        if (cnt <= 10) {
590
-          key_value[cnt] = (char)'4';
591
-          lv_label_set_text(labelValue, key_value);
592
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
593
-          cnt++;
594
-        }
568
+      if (cnt <= 10) {
569
+        key_value[cnt] = (char)'4';
570
+        lv_label_set_text(labelValue, key_value);
571
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
572
+        cnt++;
595 573
       }
596 574
       break;
597 575
     case ID_NUM_KEY5:
598
-      if (event == LV_EVENT_CLICKED) {
599
-
600
-      }
601
-      else if (event == LV_EVENT_RELEASED) {
602
-        if (cnt <= 10) {
603
-          key_value[cnt] = (char)'5';
604
-          lv_label_set_text(labelValue, key_value);
605
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
606
-          cnt++;
607
-        }
576
+      if (cnt <= 10) {
577
+        key_value[cnt] = (char)'5';
578
+        lv_label_set_text(labelValue, key_value);
579
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
580
+        cnt++;
608 581
       }
609 582
       break;
610 583
     case ID_NUM_KEY6:
611
-      if (event == LV_EVENT_CLICKED) {
612
-
613
-      }
614
-      else if (event == LV_EVENT_RELEASED) {
615
-        if (cnt <= 10) {
616
-          key_value[cnt] = (char)'6';
617
-          lv_label_set_text(labelValue, key_value);
618
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
619
-          cnt++;
620
-        }
584
+      if (cnt <= 10) {
585
+        key_value[cnt] = (char)'6';
586
+        lv_label_set_text(labelValue, key_value);
587
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
588
+        cnt++;
621 589
       }
622 590
       break;
623 591
     case ID_NUM_KEY7:
624
-      if (event == LV_EVENT_CLICKED) {
625
-
626
-      }
627
-      else if (event == LV_EVENT_RELEASED) {
628
-        if (cnt <= 10) {
629
-          key_value[cnt] = (char)'7';
630
-          lv_label_set_text(labelValue, key_value);
631
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
632
-          cnt++;
633
-        }
592
+      if (cnt <= 10) {
593
+        key_value[cnt] = (char)'7';
594
+        lv_label_set_text(labelValue, key_value);
595
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
596
+        cnt++;
634 597
       }
635 598
       break;
636 599
     case ID_NUM_KEY8:
637
-      if (event == LV_EVENT_CLICKED) {
638
-
639
-      }
640
-      else if (event == LV_EVENT_RELEASED) {
641
-        if (cnt <= 10) {
642
-          key_value[cnt] = (char)'8';
643
-          lv_label_set_text(labelValue, key_value);
644
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
645
-          cnt++;
646
-        }
600
+      if (cnt <= 10) {
601
+        key_value[cnt] = (char)'8';
602
+        lv_label_set_text(labelValue, key_value);
603
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
604
+        cnt++;
647 605
       }
648 606
       break;
649 607
     case ID_NUM_KEY9:
650
-      if (event == LV_EVENT_CLICKED) {
651
-
652
-      }
653
-      else if (event == LV_EVENT_RELEASED) {
654
-        if (cnt <= 10) {
655
-          key_value[cnt] = (char)'9';
656
-          lv_label_set_text(labelValue, key_value);
657
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
658
-          cnt++;
659
-        }
660
-      }
661
-      break;
662
-    case ID_NUM_KEY0:
663
-      if (event == LV_EVENT_CLICKED) {
664
-
665
-      }
666
-      else if (event == LV_EVENT_RELEASED) {
667
-        if (cnt <= 10) {
668
-          key_value[cnt] = (char)'0';
669
-          lv_label_set_text(labelValue, key_value);
670
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
671
-          cnt++;
672
-        }
673
-      }
674
-      break;
675
-    case ID_NUM_BACK:
676
-      if (event == LV_EVENT_CLICKED) {
677
-
678
-      }
679
-      else if (event == LV_EVENT_RELEASED) {
680
-        if (cnt > 0)
681
-          cnt--;
682
-        if (key_value[cnt] == (char)'.') point_flg = 1;
683
-        key_value[cnt] = (char)'\0';
608
+      if (cnt <= 10) {
609
+        key_value[cnt] = (char)'9';
684 610
         lv_label_set_text(labelValue, key_value);
685 611
         lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
612
+        cnt++;
686 613
       }
687 614
       break;
688
-    case ID_NUM_RESET:
689
-      if (event == LV_EVENT_CLICKED) {
690
-
691
-      }
692
-      else if (event == LV_EVENT_RELEASED) {
693
-        ZERO(key_value);
694
-        cnt            = 0;
615
+    case ID_NUM_KEY0:
616
+      if (cnt <= 10) {
695 617
         key_value[cnt] = (char)'0';
696
-        point_flg      = 1;
697 618
         lv_label_set_text(labelValue, key_value);
698 619
         lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
620
+        cnt++;
699 621
       }
700 622
       break;
623
+    case ID_NUM_BACK:
624
+      if (cnt > 0) cnt--;
625
+      if (key_value[cnt] == (char)'.') point_flag = true;
626
+      key_value[cnt] = (char)'\0';
627
+      lv_label_set_text(labelValue, key_value);
628
+      lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
629
+      break;
630
+    case ID_NUM_RESET:
631
+      ZERO(key_value);
632
+      cnt = 0;
633
+      key_value[cnt] = (char)'0';
634
+      point_flag = true;
635
+      lv_label_set_text(labelValue, key_value);
636
+      lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
637
+      break;
701 638
     case ID_NUM_POINT:
702
-      if (event == LV_EVENT_CLICKED) {
703
-
704
-      }
705
-      else if (event == LV_EVENT_RELEASED) {
706
-        if ((cnt != 0) && (point_flg == 1)) {
707
-          point_flg      = 0;
708
-          key_value[cnt] = (char)'.';
709
-          lv_label_set_text(labelValue, key_value);
710
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
711
-          cnt++;
712
-        }
639
+      if (cnt != 0 && point_flag) {
640
+        point_flag = false;
641
+        key_value[cnt] = (char)'.';
642
+        lv_label_set_text(labelValue, key_value);
643
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
644
+        cnt++;
713 645
       }
714 646
       break;
715
-    case ID_NUM_NAGETIVE:
716
-      if (event == LV_EVENT_CLICKED) {
717
-
718
-      }
719
-      else if (event == LV_EVENT_RELEASED) {
720
-        if (cnt == 0) {
721
-          key_value[cnt] = (char)'-';
722
-          lv_label_set_text(labelValue, key_value);
723
-          lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
724
-          cnt++;
725
-        }
647
+    case ID_NUM_NEGATIVE:
648
+      if (cnt == 0) {
649
+        key_value[cnt] = (char)'-';
650
+        lv_label_set_text(labelValue, key_value);
651
+        lv_obj_align(labelValue, buttonValue, LV_ALIGN_CENTER, 0, 0);
652
+        cnt++;
726 653
       }
727 654
       break;
728 655
     case ID_NUM_CONFIRM:
729
-      if (event == LV_EVENT_CLICKED) {
730
-
731
-      }
732
-      else if (event == LV_EVENT_RELEASED) {
733
-        last_disp_state = NUMBER_KEY_UI;
734
-        if (strlen(key_value) != 0)
735
-          set_value_confirm();
736
-        lv_clear_number_key();
737
-        draw_return_ui();
738
-      }
656
+      last_disp_state = NUMBER_KEY_UI;
657
+      if (strlen(key_value) != 0) set_value_confirm();
658
+      lv_clear_number_key();
659
+      draw_return_ui();
739 660
       break;
740 661
   }
741 662
 }
742 663
 
743 664
 void lv_draw_number_key(void) {
744
-  lv_obj_t *NumberKey_1 = NULL, *NumberKey_2 = NULL, *NumberKey_3 = NULL, *NumberKey_4 = NULL, *NumberKey_5 = NULL;
745
-  lv_obj_t *NumberKey_6 = NULL, *NumberKey_7 = NULL, *NumberKey_8 = NULL, *NumberKey_9 = NULL, *NumberKey_0 = NULL;
746
-  lv_obj_t *KeyPoint = NULL, *KeyConfirm = NULL, *KeyReset = NULL, *KeyBack = NULL;
747
-  lv_obj_t *Minus = NULL;
748
-  lv_obj_t *labelKey_1 = NULL, *labelKey_2 = NULL, *labelKey_3 = NULL, *labelKey_4 = NULL, *labelKey_5 = NULL;
749
-  lv_obj_t *labelKey_6 = NULL, *labelKey_7 = NULL, *labelKey_8 = NULL, *labelKey_9 = NULL, *labelKey_0 = NULL;
750
-  lv_obj_t *labelKeyPoint = NULL, *labelKeyConfirm = NULL, *labelKeyReset = NULL, *labelKeyBack = NULL;
751
-  lv_obj_t *labelMinus = NULL;
752
-
753
-  buttonValue = NULL;
754
-  labelValue  = NULL;
755
-
756 665
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != NUMBER_KEY_UI) {
757 666
     disp_state_stack._disp_index++;
758 667
     disp_state_stack._disp_state[disp_state_stack._disp_index] = NUMBER_KEY_UI;
759 668
   }
760 669
   disp_state = NUMBER_KEY_UI;
761 670
 
762
-  scr = lv_obj_create(NULL, NULL);
763
-
764
-  lv_obj_set_style(scr, &tft_style_scr);
765
-  lv_scr_load(scr);
766
-  lv_obj_clean(scr);
671
+  scr = lv_screen_create();
767 672
 
768 673
   //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
769 674
 
770 675
   lv_refr_now(lv_refr_get_disp_refreshing());
771 676
 
772
-  buttonValue = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
773
-  lv_obj_set_pos(buttonValue, 92, 40);                                  /*Set its position*/
774
-  lv_obj_set_size(buttonValue, 296, 40);
775
-  lv_obj_set_event_cb_mks(buttonValue, event_handler, ID_NUM_KEY1, NULL, 0);
776
-  lv_btn_set_style(buttonValue, LV_BTN_STYLE_REL, &style_num_text);     /*Set the button's released style*/
777
-  lv_btn_set_style(buttonValue, LV_BTN_STYLE_PR, &style_num_text);      /*Set the button's pressed style*/
778
-  //lv_btn_set_layout(buttonValue, LV_LAYOUT_OFF);
779
-  labelValue = lv_label_create_empty(buttonValue);                      /*Add a label to the button*/
780
-
781
-  NumberKey_1 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
782
-  lv_obj_set_pos(NumberKey_1, 92, 90);                                  /*Set its position*/
783
-  lv_obj_set_size(NumberKey_1, 68, 40);
784
-  lv_obj_set_event_cb_mks(NumberKey_1, event_handler, ID_NUM_KEY1, NULL, 0);
785
-  lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
786
-  lv_btn_set_style(NumberKey_1, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
787
-  //lv_btn_set_layout(NumberKey_1, LV_LAYOUT_OFF);
788
-  labelKey_1 = lv_label_create_empty(NumberKey_1);                      /*Add a label to the button*/
677
+  buttonValue = lv_btn_create(scr, 92, 40, 296, 40, event_handler, ID_NUM_KEY1, &style_num_text);
678
+  labelValue = lv_label_create_empty(buttonValue);
679
+
680
+  lv_obj_t *NumberKey_1 = lv_btn_create(scr, 92, 90, 68, 40, event_handler, ID_NUM_KEY1, &style_num_key_pre);
681
+  lv_obj_t *labelKey_1 = lv_label_create_empty(NumberKey_1);
789 682
   lv_label_set_text(labelKey_1, machine_menu.key_1);
790 683
   lv_obj_align(labelKey_1, NumberKey_1, LV_ALIGN_CENTER, 0, 0);
791 684
 
792
-  NumberKey_2 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
793
-  lv_obj_set_pos(NumberKey_2, 168, 90);                                 /*Set its position*/
794
-  lv_obj_set_size(NumberKey_2, 68, 40);
795
-  lv_obj_set_event_cb_mks(NumberKey_2, event_handler, ID_NUM_KEY2, NULL, 0);
796
-  lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
797
-  lv_btn_set_style(NumberKey_2, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
798
-  //lv_btn_set_layout(NumberKey_2, LV_LAYOUT_OFF);
799
-  labelKey_2 = lv_label_create_empty(NumberKey_2);                      /*Add a label to the button*/
685
+  lv_obj_t *NumberKey_2 = lv_btn_create(scr, 168, 90, 68, 40, event_handler, ID_NUM_KEY2, &style_num_key_pre);
686
+  lv_obj_t *labelKey_2 = lv_label_create_empty(NumberKey_2);
800 687
   lv_label_set_text(labelKey_2, machine_menu.key_2);
801 688
   lv_obj_align(labelKey_2, NumberKey_2, LV_ALIGN_CENTER, 0, 0);
802 689
 
803
-  NumberKey_3 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
804
-  lv_obj_set_pos(NumberKey_3, 244, 90);                                 /*Set its position*/
805
-  lv_obj_set_size(NumberKey_3, 68, 40);
806
-  lv_obj_set_event_cb_mks(NumberKey_3, event_handler, ID_NUM_KEY3, NULL, 0);
807
-  lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
808
-  lv_btn_set_style(NumberKey_3, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
809
-  //lv_btn_set_layout(NumberKey_3, LV_LAYOUT_OFF);
810
-  labelKey_3 = lv_label_create_empty(NumberKey_3);                      /*Add a label to the button*/
690
+  lv_obj_t *NumberKey_3 = lv_btn_create(scr, 244, 90, 68, 40, event_handler, ID_NUM_KEY3, &style_num_key_pre);
691
+  lv_obj_t *labelKey_3 = lv_label_create_empty(NumberKey_3);
811 692
   lv_label_set_text(labelKey_3, machine_menu.key_3);
812 693
   lv_obj_align(labelKey_3, NumberKey_3, LV_ALIGN_CENTER, 0, 0);
813 694
 
814
-  NumberKey_4 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
815
-  lv_obj_set_pos(NumberKey_4, 92, 140);                                 /*Set its position*/
816
-  lv_obj_set_size(NumberKey_4, 68, 40);
817
-  lv_obj_set_event_cb_mks(NumberKey_4, event_handler, ID_NUM_KEY4, NULL, 0);
818
-  lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
819
-  lv_btn_set_style(NumberKey_4, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
820
-  //lv_btn_set_layout(NumberKey_4, LV_LAYOUT_OFF);
821
-  labelKey_4 = lv_label_create_empty(NumberKey_4);                      /*Add a label to the button*/
695
+  lv_obj_t *NumberKey_4 = lv_btn_create(scr, 92, 140, 68, 40, event_handler, ID_NUM_KEY4, &style_num_key_pre);
696
+  lv_obj_t *labelKey_4 = lv_label_create_empty(NumberKey_4);
822 697
   lv_label_set_text(labelKey_4, machine_menu.key_4);
823 698
   lv_obj_align(labelKey_4, NumberKey_4, LV_ALIGN_CENTER, 0, 0);
824 699
 
825
-  NumberKey_5 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
826
-  lv_obj_set_pos(NumberKey_5, 168, 140);                                /*Set its position*/
827
-  lv_obj_set_size(NumberKey_5, 68, 40);
828
-  lv_obj_set_event_cb_mks(NumberKey_5, event_handler, ID_NUM_KEY5, NULL, 0);
829
-  lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
830
-  lv_btn_set_style(NumberKey_5, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
831
-  //lv_btn_set_layout(NumberKey_5, LV_LAYOUT_OFF);
832
-  labelKey_5 = lv_label_create_empty(NumberKey_5);                      /*Add a label to the button*/
700
+  lv_obj_t *NumberKey_5 = lv_btn_create(scr, 168, 140, 68, 40, event_handler, ID_NUM_KEY5, &style_num_key_pre);
701
+  lv_obj_t *labelKey_5 = lv_label_create_empty(NumberKey_5);
833 702
   lv_label_set_text(labelKey_5, machine_menu.key_5);
834 703
   lv_obj_align(labelKey_5, NumberKey_5, LV_ALIGN_CENTER, 0, 0);
835 704
 
836
-  NumberKey_6 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
837
-  lv_obj_set_pos(NumberKey_6, 244, 140);                                /*Set its position*/
838
-  lv_obj_set_size(NumberKey_6, 68, 40);
839
-  lv_obj_set_event_cb_mks(NumberKey_6, event_handler, ID_NUM_KEY6, NULL, 0);
840
-  lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
841
-  lv_btn_set_style(NumberKey_6, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
842
-  //lv_btn_set_layout(NumberKey_6, LV_LAYOUT_OFF);
843
-  labelKey_6 = lv_label_create_empty(NumberKey_6);                      /*Add a label to the button*/
705
+  lv_obj_t *NumberKey_6 = lv_btn_create(scr, 244, 140, 68, 40, event_handler, ID_NUM_KEY6, &style_num_key_pre);
706
+  lv_obj_t *labelKey_6 = lv_label_create_empty(NumberKey_6);
844 707
   lv_label_set_text(labelKey_6, machine_menu.key_6);
845 708
   lv_obj_align(labelKey_6, NumberKey_6, LV_ALIGN_CENTER, 0, 0);
846 709
 
847
-  NumberKey_7 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
848
-  lv_obj_set_pos(NumberKey_7, 92, 190);                                 /*Set its position*/
849
-  lv_obj_set_size(NumberKey_7, 68, 40);
850
-  lv_obj_set_event_cb_mks(NumberKey_7, event_handler, ID_NUM_KEY7, NULL, 0);
851
-  lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
852
-  lv_btn_set_style(NumberKey_7, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
853
-  //lv_btn_set_layout(NumberKey_7, LV_LAYOUT_OFF);
854
-  labelKey_7 = lv_label_create_empty(NumberKey_7);                      /*Add a label to the button*/
710
+  lv_obj_t *NumberKey_7 = lv_btn_create(scr, 92, 190, 68, 40, event_handler, ID_NUM_KEY7, &style_num_key_pre);
711
+  lv_obj_t *labelKey_7 = lv_label_create_empty(NumberKey_7);
855 712
   lv_label_set_text(labelKey_7, machine_menu.key_7);
856 713
   lv_obj_align(labelKey_7, NumberKey_7, LV_ALIGN_CENTER, 0, 0);
857 714
 
858
-  NumberKey_8 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
859
-  lv_obj_set_pos(NumberKey_8, 168, 190);                                /*Set its position*/
860
-  lv_obj_set_size(NumberKey_8, 68, 40);
861
-  lv_obj_set_event_cb_mks(NumberKey_8, event_handler, ID_NUM_KEY8, NULL, 0);
862
-  lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
863
-  lv_btn_set_style(NumberKey_8, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
864
-  //lv_btn_set_layout(NumberKey_8, LV_LAYOUT_OFF);
865
-  labelKey_8 = lv_label_create_empty(NumberKey_8);                      /*Add a label to the button*/
715
+  lv_obj_t *NumberKey_8 = lv_btn_create(scr, 168, 190, 68, 40, event_handler, ID_NUM_KEY8, &style_num_key_pre);
716
+  lv_obj_t *labelKey_8 = lv_label_create_empty(NumberKey_8);
866 717
   lv_label_set_text(labelKey_8, machine_menu.key_8);
867 718
   lv_obj_align(labelKey_8, NumberKey_8, LV_ALIGN_CENTER, 0, 0);
868 719
 
869
-  NumberKey_9 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
870
-  lv_obj_set_pos(NumberKey_9, 244, 190);                                /*Set its position*/
871
-  lv_obj_set_size(NumberKey_9, 68, 40);
872
-  lv_obj_set_event_cb_mks(NumberKey_9, event_handler, ID_NUM_KEY9, NULL, 0);
873
-  lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
874
-  lv_btn_set_style(NumberKey_9, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
875
-  //lv_btn_set_layout(NumberKey_9, LV_LAYOUT_OFF);
876
-  labelKey_9 = lv_label_create_empty(NumberKey_9);                      /*Add a label to the button*/
720
+  lv_obj_t *NumberKey_9 = lv_btn_create(scr, 244, 190, 68, 40, event_handler, ID_NUM_KEY9, &style_num_key_pre);
721
+  lv_obj_t *labelKey_9 = lv_label_create_empty(NumberKey_9);
877 722
   lv_label_set_text(labelKey_9, machine_menu.key_9);
878 723
   lv_obj_align(labelKey_9, NumberKey_9, LV_ALIGN_CENTER, 0, 0);
879 724
 
880
-  NumberKey_0 = lv_btn_create(scr, NULL);                               /*Add a button the current screen*/
881
-  lv_obj_set_pos(NumberKey_0, 92, 240);                                 /*Set its position*/
882
-  lv_obj_set_size(NumberKey_0, 68, 40);
883
-  lv_obj_set_event_cb_mks(NumberKey_0, event_handler, ID_NUM_KEY0, NULL, 0);
884
-  lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_REL, &style_num_key_pre);  /*Set the button's released style*/
885
-  lv_btn_set_style(NumberKey_0, LV_BTN_STYLE_PR, &style_num_key_rel);   /*Set the button's pressed style*/
886
-  //lv_btn_set_layout(NumberKey_0, LV_LAYOUT_OFF);
887
-  labelKey_0 = lv_label_create_empty(NumberKey_0);                      /*Add a label to the button*/
725
+  lv_obj_t *NumberKey_0 = lv_btn_create(scr, 92, 240, 68, 40, event_handler, ID_NUM_KEY0, &style_num_key_pre);
726
+  lv_obj_t *labelKey_0 = lv_label_create_empty(NumberKey_0);
888 727
   lv_label_set_text(labelKey_0, machine_menu.key_0);
889 728
   lv_obj_align(labelKey_0, NumberKey_0, LV_ALIGN_CENTER, 0, 0);
890 729
 
891
-  KeyBack = lv_btn_create(scr, NULL);                                   /*Add a button the current screen*/
892
-  lv_obj_set_pos(KeyBack, 320, 90);                                     /*Set its position*/
893
-  lv_obj_set_size(KeyBack, 68, 40);
894
-  lv_obj_set_event_cb_mks(KeyBack, event_handler, ID_NUM_BACK, NULL, 0);
895
-  lv_btn_set_style(KeyBack, LV_BTN_STYLE_REL, &style_num_key_pre);      /*Set the button's released style*/
896
-  lv_btn_set_style(KeyBack, LV_BTN_STYLE_PR, &style_num_key_rel);       /*Set the button's pressed style*/
897
-  //lv_btn_set_layout(KeyBack, LV_LAYOUT_OFF);
898
-  labelKeyBack = lv_label_create_empty(KeyBack);                        /*Add a label to the button*/
730
+  lv_obj_t *KeyBack = lv_btn_create(scr, 320, 90, 68, 40, event_handler, ID_NUM_BACK, &style_num_key_pre);
731
+  lv_obj_t *labelKeyBack = lv_label_create_empty(KeyBack);
899 732
   lv_label_set_text(labelKeyBack, machine_menu.key_back);
900 733
   lv_obj_align(labelKeyBack, KeyBack, LV_ALIGN_CENTER, 0, 0);
901 734
 
902
-  KeyReset = lv_btn_create(scr, NULL);                                  /*Add a button the current screen*/
903
-  lv_obj_set_pos(KeyReset, 320, 140);                                   /*Set its position*/
904
-  lv_obj_set_size(KeyReset, 68, 40);
905
-  lv_obj_set_event_cb_mks(KeyReset, event_handler, ID_NUM_RESET, NULL, 0);
906
-  lv_btn_set_style(KeyReset, LV_BTN_STYLE_REL, &style_num_key_pre);     /*Set the button's released style*/
907
-  lv_btn_set_style(KeyReset, LV_BTN_STYLE_PR, &style_num_key_rel);      /*Set the button's pressed style*/
908
-  //lv_btn_set_layout(KeyReset, LV_LAYOUT_OFF);
909
-  labelKeyReset = lv_label_create_empty(KeyReset);                      /*Add a label to the button*/
735
+  lv_obj_t *KeyReset = lv_btn_create(scr, 320, 140, 68, 40, event_handler, ID_NUM_RESET, &style_num_key_pre);
736
+  lv_obj_t *labelKeyReset = lv_label_create_empty(KeyReset);
910 737
   lv_label_set_text(labelKeyReset, machine_menu.key_reset);
911 738
   lv_obj_align(labelKeyReset, KeyReset, LV_ALIGN_CENTER, 0, 0);
912 739
 
913
-  KeyConfirm = lv_btn_create(scr, NULL);                                /*Add a button the current screen*/
914
-  lv_obj_set_pos(KeyConfirm, 320, 190);                                 /*Set its position*/
915
-  lv_obj_set_size(KeyConfirm, 68, 90);
916
-  lv_obj_set_event_cb_mks(KeyConfirm, event_handler, ID_NUM_CONFIRM, NULL, 0);
917
-  lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_REL, &style_num_key_pre);   /*Set the button's released style*/
918
-  lv_btn_set_style(KeyConfirm, LV_BTN_STYLE_PR, &style_num_key_rel);    /*Set the button's pressed style*/
919
-  //lv_btn_set_layout(KeyConfirm, LV_LAYOUT_OFF);
920
-  labelKeyConfirm = lv_label_create_empty(KeyConfirm);                  /*Add a label to the button*/
740
+  lv_obj_t *KeyConfirm = lv_btn_create(scr, 320, 190, 68, 90, event_handler, ID_NUM_CONFIRM, &style_num_key_pre);
741
+  lv_obj_t *labelKeyConfirm = lv_label_create_empty(KeyConfirm);
921 742
   lv_label_set_text(labelKeyConfirm, machine_menu.key_confirm);
922 743
   lv_obj_align(labelKeyConfirm, KeyConfirm, LV_ALIGN_CENTER, 0, 0);
923 744
 
924
-  KeyPoint = lv_btn_create(scr, NULL);                                  /*Add a button the current screen*/
925
-  lv_obj_set_pos(KeyPoint, 244, 240);                                   /*Set its position*/
926
-  lv_obj_set_size(KeyPoint, 68, 40);
927
-  lv_obj_set_event_cb_mks(KeyPoint, event_handler, ID_NUM_POINT, NULL, 0);
928
-  lv_btn_set_style(KeyPoint, LV_BTN_STYLE_REL, &style_num_key_pre);     /*Set the button's released style*/
929
-  lv_btn_set_style(KeyPoint, LV_BTN_STYLE_PR, &style_num_key_rel);      /*Set the button's pressed style*/
930
-  //lv_btn_set_layout(KeyPoint, LV_LAYOUT_OFF);
931
-  labelKeyPoint = lv_label_create_empty(KeyPoint);                      /*Add a label to the button*/
745
+  lv_obj_t *KeyPoint = lv_btn_create(scr, 244, 240, 68, 40, event_handler, ID_NUM_POINT, &style_num_key_pre);
746
+  lv_obj_t *labelKeyPoint = lv_label_create_empty(KeyPoint);
932 747
   lv_label_set_text(labelKeyPoint, machine_menu.key_point);
933 748
   lv_obj_align(labelKeyPoint, KeyPoint, LV_ALIGN_CENTER, 0, 0);
934 749
 
935
-  Minus = lv_btn_create(scr, NULL);                                     /*Add a button the current screen*/
936
-  lv_obj_set_pos(Minus, 168, 240);                                      /*Set its position*/
937
-  lv_obj_set_size(Minus, 68, 40);
938
-  lv_obj_set_event_cb_mks(Minus, event_handler, ID_NUM_NAGETIVE, NULL, 0);
939
-  lv_btn_set_style(Minus, LV_BTN_STYLE_REL, &style_num_key_pre);        /*Set the button's released style*/
940
-  lv_btn_set_style(Minus, LV_BTN_STYLE_PR, &style_num_key_rel);         /*Set the button's pressed style*/
941
-  //lv_btn_set_layout(Minus, LV_LAYOUT_OFF);
942
-  labelMinus = lv_label_create_empty(Minus);                            /*Add a label to the button*/
750
+  lv_obj_t *Minus = lv_btn_create(scr, 168, 240, 68, 40, event_handler, ID_NUM_NEGATIVE, &style_num_key_pre);
751
+  lv_obj_t *labelMinus = lv_label_create_empty(Minus);
943 752
   lv_label_set_text(labelMinus, machine_menu.negative);
944 753
   lv_obj_align(labelMinus, Minus, LV_ALIGN_CENTER, 0, 0);
945 754
 

+ 66
- 112
Marlin/src/lcd/extui/lib/mks_ui/draw_operation.cpp View File

@@ -35,141 +35,99 @@
35 35
 #include "../../../../sd/cardreader.h"
36 36
 #include "../../../../inc/MarlinConfig.h"
37 37
 
38
-extern lv_group_t * g;
39
-static lv_obj_t * scr;
40
-
41
-#define ID_O_PRE_HEAT   1
42
-#define ID_O_EXTRUCT    2
43
-#define ID_O_MOV        3
44
-#define ID_O_FILAMENT   4
45
-#define ID_O_SPEED      5
46
-#define ID_O_RETURN     6
47
-#define ID_O_FAN        7
48
-#define ID_O_POWER_OFF  8
49
-#define ID_O_BABY_STEP  9
38
+extern lv_group_t *g;
39
+static lv_obj_t *scr;
40
+
41
+enum {
42
+  ID_O_PRE_HEAT = 1,
43
+  ID_O_EXTRUCT,
44
+  ID_O_MOV,
45
+  ID_O_FILAMENT,
46
+  ID_O_SPEED,
47
+  ID_O_RETURN,
48
+  ID_O_FAN,
49
+  ID_O_POWER_OFF,
50
+  ID_O_BABY_STEP
51
+};
50 52
 
51 53
 static lv_obj_t *label_PowerOff;
52 54
 static lv_obj_t *buttonPowerOff;
53 55
 
54 56
 extern feedRate_t feedrate_mm_s;
55 57
 
56
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
58
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
59
+  if (event != LV_EVENT_RELEASED) return;
57 60
   switch (obj->mks_obj_id) {
58 61
     case ID_O_PRE_HEAT:
59
-      if (event == LV_EVENT_CLICKED) {
60
-        // nothing to do
61
-      }
62
-      else if (event == LV_EVENT_RELEASED) {
63
-        lv_clear_operation();
64
-        lv_draw_preHeat();
65
-      }
62
+      lv_clear_operation();
63
+      lv_draw_preHeat();
66 64
       break;
67 65
     case ID_O_EXTRUCT:
68
-      if (event == LV_EVENT_CLICKED) {
69
-        // nothing to do
70
-      }
71
-      else if (event == LV_EVENT_RELEASED) {
72
-        lv_clear_operation();
73
-        lv_draw_extrusion();
74
-      }
66
+      lv_clear_operation();
67
+      lv_draw_extrusion();
75 68
       break;
76 69
     case ID_O_MOV:
77
-      if (event == LV_EVENT_CLICKED) {
78
-        // nothing to do
79
-      }
80
-      else if (event == LV_EVENT_RELEASED) {
81
-        lv_clear_operation();
82
-        lv_draw_move_motor();
83
-      }
70
+      lv_clear_operation();
71
+      lv_draw_move_motor();
84 72
       break;
85 73
     case ID_O_FILAMENT:
86
-      if (event == LV_EVENT_CLICKED) {
87
-        // nothing to do
88
-      }
89
-      else if (event == LV_EVENT_RELEASED) {
90
-        #if HAS_MULTI_EXTRUDER
91
-          uiCfg.curSprayerChoose_bak = active_extruder;
74
+      #if HAS_MULTI_EXTRUDER
75
+        uiCfg.curSprayerChoose_bak = active_extruder;
76
+      #endif
77
+      if (uiCfg.print_state == WORKING) {
78
+        #if ENABLED(SDSUPPORT)
79
+          card.pauseSDPrint();
80
+          stop_print_time();
81
+          uiCfg.print_state = PAUSING;
92 82
         #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();
104 83
       }
84
+      uiCfg.moveSpeed_bak = (uint16_t)feedrate_mm_s;
85
+      uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[active_extruder].target;
86
+      lv_clear_operation();
87
+      lv_draw_filament_change();
105 88
       break;
106 89
     case ID_O_FAN:
107
-      if (event == LV_EVENT_CLICKED) {
108
-        // nothing to do
109
-      }
110
-      else if (event == LV_EVENT_RELEASED) {
111
-        lv_clear_operation();
112
-        lv_draw_fan();
113
-      }
90
+      lv_clear_operation();
91
+      lv_draw_fan();
114 92
       break;
115 93
     case ID_O_SPEED:
116
-      if (event == LV_EVENT_CLICKED) {
117
-        // nothing to do
118
-      }
119
-      else if (event == LV_EVENT_RELEASED) {
120
-        lv_clear_operation();
121
-        lv_draw_change_speed();
122
-      }
94
+      lv_clear_operation();
95
+      lv_draw_change_speed();
123 96
       break;
124 97
     case ID_O_RETURN:
125
-      if (event == LV_EVENT_CLICKED) {
126
-        // nothing to do
127
-      }
128
-      else if (event == LV_EVENT_RELEASED) {
129
-        clear_cur_ui();
130
-        draw_return_ui();
131
-      }
98
+      clear_cur_ui();
99
+      draw_return_ui();
132 100
       break;
133 101
     case ID_O_POWER_OFF:
134
-      if (event == LV_EVENT_CLICKED) {
135
-        // nothing to do
136
-      }
137
-      else if (event == LV_EVENT_RELEASED) {
138
-        if (gCfgItems.finish_power_off) {
139
-          gCfgItems.finish_power_off = false;
140
-          lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin");
141
-          lv_label_set_text(label_PowerOff, printing_more_menu.manual);
142
-        }
143
-        else {
144
-          gCfgItems.finish_power_off = true;
145
-          lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
146
-          lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
147
-        }
148
-        lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
149
-        lv_obj_refresh_ext_draw_pad(label_PowerOff);
150
-        update_spi_flash();
151
-      }
102
+      if (gCfgItems.finish_power_off) {
103
+        gCfgItems.finish_power_off = false;
104
+        lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_manual_off.bin");
105
+        lv_label_set_text(label_PowerOff, printing_more_menu.manual);
106
+      }
107
+      else {
108
+        gCfgItems.finish_power_off = true;
109
+        lv_imgbtn_set_src_both(buttonPowerOff, "F:/bmp_auto_off.bin");
110
+        lv_label_set_text(label_PowerOff, printing_more_menu.auto_close);
111
+      }
112
+      lv_obj_align(label_PowerOff, buttonPowerOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
113
+      lv_obj_refresh_ext_draw_pad(label_PowerOff);
114
+      update_spi_flash();
152 115
       break;
153 116
     case ID_O_BABY_STEP:
154
-      if (event == LV_EVENT_CLICKED) {
155
-        // nothing to do
156
-      }
157
-      else if (event == LV_EVENT_RELEASED) {
158
-        lv_clear_operation();
159
-        lv_draw_baby_stepping();
160
-      }
117
+      lv_clear_operation();
118
+      lv_draw_baby_stepping();
161 119
       break;
162 120
   }
163 121
 }
164 122
 
165 123
 void lv_draw_operation(void) {
166
-  lv_obj_t *buttonPreHeat = NULL, *buttonExtrusion = NULL, *buttonSpeed = NULL;
167
-  lv_obj_t *buttonBack = NULL, *buttonFan = NULL;
168
-  lv_obj_t *labelPreHeat = NULL, *labelExtrusion = NULL;
169
-  lv_obj_t *label_Back = NULL, *label_Speed = NULL, *label_Fan = NULL;
170
-  lv_obj_t *buttonMove = NULL, *label_Move = NULL;
171
-  lv_obj_t *buttonBabyStep = NULL, *label_BabyStep = NULL;
172
-  lv_obj_t *buttonFilament = NULL, *label_Filament = NULL;
124
+  lv_obj_t *buttonExtrusion = nullptr, *buttonSpeed = nullptr,
125
+           *buttonBack = nullptr,
126
+           *labelPreHeat = nullptr, *labelExtrusion = nullptr,
127
+           *label_Back = nullptr, *label_Speed = nullptr, *label_Fan = nullptr,
128
+           *buttonMove = nullptr, *label_Move = nullptr,
129
+           *buttonBabyStep = nullptr, *label_BabyStep = nullptr,
130
+           *label_Filament = nullptr;
173 131
 
174 132
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != OPERATE_UI) {
175 133
     disp_state_stack._disp_index++;
@@ -177,20 +135,16 @@ void lv_draw_operation(void) {
177 135
   }
178 136
   disp_state = OPERATE_UI;
179 137
 
180
-  scr = lv_obj_create(NULL, NULL);
181
-
182
-  lv_obj_set_style(scr, &tft_style_scr);
183
-  lv_scr_load(scr);
184
-  lv_obj_clean(scr);
138
+  scr = lv_screen_create();
185 139
 
186 140
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
187 141
 
188 142
   lv_refr_now(lv_refr_get_disp_refreshing());
189 143
 
190 144
   // Create image buttons
191
-  buttonPreHeat  = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT);
192
-  buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT);
193
-  buttonFan      = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN);
145
+  lv_obj_t *buttonPreHeat  = lv_imgbtn_create(scr, "F:/bmp_temp.bin", INTERVAL_V, titleHeight, event_handler, ID_O_PRE_HEAT);
146
+  lv_obj_t *buttonFilament = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_O_FILAMENT);
147
+  lv_obj_t *buttonFan      = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_O_FAN);
194 148
   buttonPowerOff = lv_imgbtn_create(scr, gCfgItems.finish_power_off ? "F:/bmp_auto_off.bin" : "F:/bmp_manual_off.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_O_POWER_OFF);
195 149
 
196 150
   #if HAS_ROTARY_ENCODER

+ 31
- 101
Marlin/src/lcd/extui/lib/mks_ui/draw_pause_position.cpp View File

@@ -29,132 +29,62 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_PAUSE_RETURN 1
36
-#define ID_PAUSE_X      2
37
-#define ID_PAUSE_Y      3
38
-#define ID_PAUSE_Z      4
39
-
40
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_PAUSE_RETURN = 1,
37
+  ID_PAUSE_X,
38
+  ID_PAUSE_Y,
39
+  ID_PAUSE_Z
40
+};
41
+
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
41 44
   switch (obj->mks_obj_id) {
42 45
     case ID_PAUSE_RETURN:
43
-      if (event == LV_EVENT_CLICKED) {
44
-
45
-      }
46
-      else if (event == LV_EVENT_RELEASED) {
47
-        lv_clear_pause_position();
48
-        draw_return_ui();
49
-      }
46
+      lv_clear_pause_position();
47
+      draw_return_ui();
50 48
       break;
51 49
     case ID_PAUSE_X:
52
-      if (event == LV_EVENT_CLICKED) {
53
-
54
-      }
55
-      else if (event == LV_EVENT_RELEASED) {
56
-        value = pause_pos_x;
57
-        lv_clear_pause_position();
58
-        lv_draw_number_key();
59
-      }
50
+      value = pause_pos_x;
51
+      lv_clear_pause_position();
52
+      lv_draw_number_key();
60 53
       break;
61 54
     case ID_PAUSE_Y:
62
-      if (event == LV_EVENT_CLICKED) {
63
-
64
-      }
65
-      else if (event == LV_EVENT_RELEASED) {
66
-        value = pause_pos_y;
67
-        lv_clear_pause_position();
68
-        lv_draw_number_key();
69
-      }
55
+      value = pause_pos_y;
56
+      lv_clear_pause_position();
57
+      lv_draw_number_key();
70 58
       break;
71 59
     case ID_PAUSE_Z:
72
-      if (event == LV_EVENT_CLICKED) {
73
-
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
76
-        value = pause_pos_z;
77
-        lv_clear_pause_position();
78
-        lv_draw_number_key();
79
-      }
60
+      value = pause_pos_z;
61
+      lv_clear_pause_position();
62
+      lv_draw_number_key();
80 63
       break;
81 64
   }
82 65
 }
83 66
 
84 67
 void lv_draw_pause_position(void) {
85
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
86
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
87
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
88
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
89
-
90
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL;
91 68
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PAUSE_POS_UI) {
92 69
     disp_state_stack._disp_index++;
93 70
     disp_state_stack._disp_state[disp_state_stack._disp_index] = PAUSE_POS_UI;
94 71
   }
95 72
   disp_state = PAUSE_POS_UI;
96 73
 
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
-
74
+  scr = lv_screen_create();
103 75
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.PausePosText);
104
-
105 76
   lv_refr_now(lv_refr_get_disp_refreshing());
106 77
 
107
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.xPos);
108
-
109
-  buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_X);
110
-  labelXValue = lv_label_create_empty(buttonXValue);
111
-
112
-  line1 = lv_line_create(scr, NULL);
113
-  lv_ex_line(line1, line_points[0]);
78
+  sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX);
79
+  lv_screen_menu_item_1_edit(scr, machine_menu.xPos, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_PAUSE_X, 0, public_buf_l);
114 80
 
115
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.yPos);
81
+  sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosY);
82
+  lv_screen_menu_item_1_edit(scr, machine_menu.yPos, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_PAUSE_Y, 1, public_buf_l);
116 83
 
117
-  buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_Y);
118
-  labelYValue = lv_label_create_empty(buttonYValue);
84
+  sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosZ);
85
+  lv_screen_menu_item_1_edit(scr, machine_menu.zPos, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_PAUSE_Z, 2, public_buf_l);
119 86
 
120
-  line2 = lv_line_create(scr, NULL);
121
-  lv_ex_line(line2, line_points[1]);
122
-
123
-  (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.zPos);
124
-
125
-  buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_PAUSE_Z);
126
-  labelZValue = lv_label_create_empty(buttonZValue);
127
-
128
-  line3 = lv_line_create(scr, NULL);
129
-  lv_ex_line(line3, line_points[2]);
130
-
131
-  buttonBack = lv_btn_create_back(scr, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE, event_handler, ID_PAUSE_RETURN);
132
-  label_Back = lv_label_create_empty(buttonBack);
133
-
134
-  if (gCfgItems.multiple_language) {
135
-    sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosX);
136
-    lv_label_set_text(labelXValue, public_buf_l);
137
-    lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
138
-
139
-    sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosY);
140
-    lv_label_set_text(labelYValue, public_buf_l);
141
-    lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
142
-
143
-    sprintf_P(public_buf_l, PSTR("%.1f"), gCfgItems.pausePosZ);
144
-    lv_label_set_text(labelZValue, public_buf_l);
145
-    lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
146
-
147
-    lv_label_set_text(label_Back, common_menu.text_back);
148
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
149
-  }
150
-  #if HAS_ROTARY_ENCODER
151
-    if (gCfgItems.encoder_enable) {
152
-      lv_group_add_obj(g, buttonXValue);
153
-      lv_group_add_obj(g, buttonYValue);
154
-      lv_group_add_obj(g, buttonZValue);
155
-      lv_group_add_obj(g, buttonBack);
156
-    }
157
-  #endif
87
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_PAUSE_RETURN, true);
158 88
 }
159 89
 
160 90
 void lv_clear_pause_position() {

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

@@ -33,221 +33,163 @@
33 33
 #include "../../../../module/temperature.h"
34 34
 #include "../../../../inc/MarlinConfig.h"
35 35
 
36
-static lv_obj_t * scr;
36
+static lv_obj_t *scr;
37 37
 extern lv_group_t*  g;
38 38
 static lv_obj_t *buttonType, *buttonStep;
39 39
 static lv_obj_t *labelType;
40 40
 static lv_obj_t *labelStep;
41
-static lv_obj_t * tempText1;
41
+static lv_obj_t *tempText1;
42 42
 
43
-#define ID_P_ADD    1
44
-#define ID_P_DEC    2
45
-#define ID_P_TYPE   3
46
-#define ID_P_STEP   4
47
-#define ID_P_OFF    5
48
-#define ID_P_RETURN 6
43
+enum {
44
+  ID_P_ADD = 1,
45
+  ID_P_DEC,
46
+  ID_P_TYPE,
47
+  ID_P_STEP,
48
+  ID_P_OFF,
49
+  ID_P_RETURN
50
+};
49 51
 
50
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
52
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
53
+  if (event != LV_EVENT_RELEASED) return;
51 54
   switch (obj->mks_obj_id) {
52 55
     case ID_P_ADD:
53
-      if (event == LV_EVENT_CLICKED) {
54
-        // nothing to do
55
-      }
56
-      else if (event == LV_EVENT_RELEASED) {
57
-        if (uiCfg.curTempType == 0) {
58
-          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat;
59
-          if (uiCfg.curSprayerChoose == 0) {
60
-            if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
61
-              thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
62
-            }
56
+      if (uiCfg.curTempType == 0) {
57
+        thermalManager.temp_hotend[uiCfg.curSprayerChoose].target += uiCfg.stepHeat;
58
+        if (uiCfg.curSprayerChoose == 0) {
59
+          if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
60
+            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_0_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
63 61
           }
64
-          #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
65
-            else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
66
-              thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
67
-            }
68
-          #endif
69
-          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
70 62
         }
71
-        #if HAS_HEATED_BED
72
-          else {
73
-            thermalManager.temp_bed.target += uiCfg.stepHeat;
74
-            if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
75
-              thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
76
-            }
77
-            thermalManager.start_watching_bed();
63
+        #if !defined(SINGLENOZZLE) && HAS_MULTI_EXTRUDER
64
+          else if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > (HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1))) {
65
+            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)HEATER_1_MAXTEMP - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1);
78 66
           }
79 67
         #endif
80
-        disp_desire_temp();
68
+        thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
81 69
       }
82
-      break;
83
-    case ID_P_DEC:
84
-      if (event == LV_EVENT_CLICKED) {
85
-        // nothing to do
86
-      }
87
-      else if (event == LV_EVENT_RELEASED) {
88
-        if (uiCfg.curTempType == 0) {
89
-          if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat) {
90
-            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
91
-          }
92
-          else {
93
-            thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0;
70
+      #if HAS_HEATED_BED
71
+        else {
72
+          thermalManager.temp_bed.target += uiCfg.stepHeat;
73
+          if ((int)thermalManager.temp_bed.target > BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1)) {
74
+            thermalManager.temp_bed.target = (float)BED_MAXTEMP - (WATCH_BED_TEMP_INCREASE + TEMP_BED_HYSTERESIS + 1);
94 75
           }
95
-          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
76
+          thermalManager.start_watching_bed();
96 77
         }
97
-        #if HAS_HEATED_BED
98
-          else {
99
-            if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat) {
100
-              thermalManager.temp_bed.target -= uiCfg.stepHeat;
101
-            }
102
-            else {
103
-              thermalManager.temp_bed.target = (float)0;
104
-            }
105
-            thermalManager.start_watching_bed();
106
-          }
107
-        #endif
108
-        disp_desire_temp();
78
+      #endif
79
+      disp_desire_temp();
80
+      break;
81
+    case ID_P_DEC:
82
+      if (uiCfg.curTempType == 0) {
83
+        if ((int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target > uiCfg.stepHeat)
84
+          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target -= uiCfg.stepHeat;
85
+        else
86
+          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
87
+
88
+        thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
109 89
       }
90
+      #if HAS_HEATED_BED
91
+        else {
92
+          if ((int)thermalManager.temp_bed.target > uiCfg.stepHeat)
93
+            thermalManager.temp_bed.target -= uiCfg.stepHeat;
94
+          else
95
+            thermalManager.temp_bed.target = 0;
110 96
 
97
+          thermalManager.start_watching_bed();
98
+        }
99
+      #endif
100
+      disp_desire_temp();
111 101
       break;
112 102
     case ID_P_TYPE:
113
-      if (event == LV_EVENT_CLICKED) {
114
-        // nothing to do
115
-      }
116
-      else if (event == LV_EVENT_RELEASED) {
117
-        if (uiCfg.curTempType == 0) {
118
-          if (ENABLED(HAS_MULTI_EXTRUDER)) {
119
-            if (uiCfg.curSprayerChoose == 0) {
120
-              uiCfg.curSprayerChoose = 1;
121
-            }
122
-            else if (uiCfg.curSprayerChoose == 1) {
123
-              if (TEMP_SENSOR_BED != 0) {
124
-                uiCfg.curTempType = 1;
125
-              }
126
-              else {
127
-                uiCfg.curTempType      = 0;
128
-                uiCfg.curSprayerChoose = 0;
129
-              }
130
-            }
103
+      if (uiCfg.curTempType == 0) {
104
+        if (ENABLED(HAS_MULTI_EXTRUDER)) {
105
+          if (uiCfg.curSprayerChoose == 0) {
106
+            uiCfg.curSprayerChoose = 1;
131 107
           }
132
-          else if (uiCfg.curSprayerChoose == 0) {
133
-            if (TEMP_SENSOR_BED != 0)
108
+          else if (uiCfg.curSprayerChoose == 1) {
109
+            if (TEMP_SENSOR_BED != 0) {
134 110
               uiCfg.curTempType = 1;
135
-            else
136
-              uiCfg.curTempType = 0;
111
+            }
112
+            else {
113
+              uiCfg.curTempType      = 0;
114
+              uiCfg.curSprayerChoose = 0;
115
+            }
137 116
           }
138 117
         }
139
-        else if (uiCfg.curTempType == 1) {
140
-          uiCfg.curSprayerChoose = 0;
141
-          uiCfg.curTempType      = 0;
118
+        else if (uiCfg.curSprayerChoose == 0) {
119
+          if (TEMP_SENSOR_BED != 0)
120
+            uiCfg.curTempType = 1;
121
+          else
122
+            uiCfg.curTempType = 0;
142 123
         }
143
-        disp_temp_type();
144 124
       }
125
+      else if (uiCfg.curTempType == 1) {
126
+        uiCfg.curSprayerChoose = 0;
127
+        uiCfg.curTempType      = 0;
128
+      }
129
+      disp_temp_type();
145 130
       break;
146 131
     case ID_P_STEP:
147
-      if (event == LV_EVENT_CLICKED) {
148
-        // nothing to do
149
-      }
150
-      else if (event == LV_EVENT_RELEASED) {
151
-        switch (uiCfg.stepHeat) {
152
-          case  1: uiCfg.stepHeat =  5; break;
153
-          case  5: uiCfg.stepHeat = 10; break;
154
-          case 10: uiCfg.stepHeat =  1; break;
155
-          default: break;
156
-        }
157
-        disp_step_heat();
132
+      switch (uiCfg.stepHeat) {
133
+        case  1: uiCfg.stepHeat =  5; break;
134
+        case  5: uiCfg.stepHeat = 10; break;
135
+        case 10: uiCfg.stepHeat =  1; break;
136
+        default: break;
158 137
       }
138
+      disp_step_heat();
159 139
       break;
160 140
     case ID_P_OFF:
161
-      if (event == LV_EVENT_CLICKED) {
162
-        // nothing to do
141
+      if (uiCfg.curTempType == 0) {
142
+        thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = 0;
143
+        thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
163 144
       }
164
-      else if (event == LV_EVENT_RELEASED) {
165
-        if (uiCfg.curTempType == 0) {
166
-          thermalManager.temp_hotend[uiCfg.curSprayerChoose].target = (float)0;
167
-          thermalManager.start_watching_hotend(uiCfg.curSprayerChoose);
145
+      #if HAS_HEATED_BED
146
+        else {
147
+          thermalManager.temp_bed.target = 0;
148
+          thermalManager.start_watching_bed();
168 149
         }
169
-        #if HAS_HEATED_BED
170
-          else {
171
-            thermalManager.temp_bed.target = (float)0;
172
-            thermalManager.start_watching_bed();
173
-          }
174
-        #endif
175
-        disp_desire_temp();
176
-      }
150
+      #endif
151
+      disp_desire_temp();
177 152
       break;
178 153
     case ID_P_RETURN:
179
-      if (event == LV_EVENT_CLICKED) {
180
-        // nothing to do
181
-      }
182
-      else if (event == LV_EVENT_RELEASED) {
183
-        clear_cur_ui();
184
-        draw_return_ui();
185
-      }
154
+      clear_cur_ui();
155
+      draw_return_ui();
186 156
       break;
187 157
   }
188 158
 }
189 159
 
190 160
 void lv_draw_preHeat(void) {
191
-  lv_obj_t *buttonAdd, *buttonDec;
192
-  lv_obj_t *buttonOff, *buttonBack;
193
-
194 161
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != PRE_HEAT_UI) {
195 162
     disp_state_stack._disp_index++;
196 163
     disp_state_stack._disp_state[disp_state_stack._disp_index] = PRE_HEAT_UI;
197 164
   }
198 165
   disp_state = PRE_HEAT_UI;
199 166
 
200
-  scr = lv_obj_create(NULL, NULL);
201
-
202
-  lv_obj_set_style(scr, &tft_style_scr);
203
-  lv_scr_load(scr);
204
-  lv_obj_clean(scr);
167
+  scr = lv_screen_create();
205 168
 
206 169
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
207 170
 
208 171
   lv_refr_now(lv_refr_get_disp_refreshing());
209 172
 
210 173
   // Create image buttons
211
-  buttonAdd = lv_imgbtn_create(scr, "F:/bmp_Add.bin", INTERVAL_V, titleHeight, event_handler, ID_P_ADD);
212
-  lv_obj_clear_protect(buttonAdd, LV_PROTECT_FOLLOW);
213
-  buttonDec = lv_imgbtn_create(scr, "F:/bmp_Dec.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_DEC);
214
-  buttonType = lv_imgbtn_create(scr, NULL, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_TYPE);
215
-  buttonStep = lv_imgbtn_create(scr, NULL, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_STEP);
216
-  buttonOff = lv_imgbtn_create(scr, "F:/bmp_speed0.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
217
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);
218
-
219
-  // Create labels on the image buttons
220
-  lv_obj_t *labelAdd = lv_label_create_empty(buttonAdd);
221
-  lv_obj_t *labelDec = lv_label_create_empty(buttonDec);
222
-  labelType = lv_label_create_empty(buttonType);
223
-  labelStep = lv_label_create_empty(buttonStep);
224
-  lv_obj_t *labelOff   = lv_label_create_empty(buttonOff);
225
-  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
226
-
227
-  if (gCfgItems.multiple_language) {
228
-    lv_label_set_text(labelAdd, preheat_menu.add);
229
-    lv_obj_align(labelAdd, buttonAdd, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
230
-
231
-    lv_label_set_text(labelDec, preheat_menu.dec);
232
-    lv_obj_align(labelDec, buttonDec, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
233
-
234
-    lv_label_set_text(labelOff, preheat_menu.off);
235
-    lv_obj_align(labelOff, buttonOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
174
+  lv_big_button_create(scr, "F:/bmp_Add.bin", preheat_menu.add, INTERVAL_V, titleHeight, event_handler, ID_P_ADD);
175
+  lv_big_button_create(scr, "F:/bmp_Dec.bin", preheat_menu.dec, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_P_DEC);
236 176
 
237
-    lv_label_set_text(label_Back, common_menu.text_back);
238
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
239
-  }
177
+  buttonType = lv_imgbtn_create(scr, nullptr, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_TYPE);
178
+  buttonStep = lv_imgbtn_create(scr, nullptr, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_STEP);
240 179
   #if HAS_ROTARY_ENCODER
241 180
     if (gCfgItems.encoder_enable) {
242
-      lv_group_add_obj(g, buttonAdd);
243
-      lv_group_add_obj(g, buttonDec);
244 181
       lv_group_add_obj(g, buttonType);
245 182
       lv_group_add_obj(g, buttonStep);
246
-      lv_group_add_obj(g, buttonOff);
247
-      lv_group_add_obj(g, buttonBack);
248 183
     }
249 184
   #endif
250 185
 
186
+  lv_big_button_create(scr, "F:/bmp_speed0.bin", preheat_menu.off, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_OFF);
187
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_P_RETURN);
188
+
189
+  // Create labels on the image buttons
190
+  labelType = lv_label_create_empty(buttonType);
191
+  labelStep = lv_label_create_empty(buttonStep);
192
+
251 193
   disp_temp_type();
252 194
   disp_step_heat();
253 195
 
@@ -289,10 +231,7 @@ void disp_desire_temp() {
289 231
   public_buf_l[0] = '\0';
290 232
 
291 233
   if (uiCfg.curTempType == 0) {
292
-    if (uiCfg.curSprayerChoose < 1)
293
-      strcat(public_buf_l, preheat_menu.ext1);
294
-    else
295
-      strcat(public_buf_l, preheat_menu.ext2);
234
+    strcat(public_buf_l, uiCfg.curSprayerChoose < 1 ? preheat_menu.ext1 : preheat_menu.ext2);
296 235
     sprintf(buf, preheat_menu.value_state, (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].celsius,  (int)thermalManager.temp_hotend[uiCfg.curSprayerChoose].target);
297 236
   }
298 237
   #if HAS_HEATED_BED
@@ -304,7 +243,7 @@ void disp_desire_temp() {
304 243
   strcat_P(public_buf_l, PSTR(": "));
305 244
   strcat(public_buf_l, buf);
306 245
   lv_label_set_text(tempText1, public_buf_l);
307
-  lv_obj_align(tempText1, NULL, LV_ALIGN_CENTER, 0, -50);
246
+  lv_obj_align(tempText1, nullptr, LV_ALIGN_CENTER, 0, -50);
308 247
 }
309 248
 
310 249
 void disp_step_heat() {

+ 103
- 146
Marlin/src/lcd/extui/lib/mks_ui/draw_print_file.cpp View File

@@ -33,15 +33,17 @@
33 33
 #include "../../../../sd/cardreader.h"
34 34
 #include "../../../../inc/MarlinConfig.h"
35 35
 
36
-static lv_obj_t * scr;
36
+static lv_obj_t *scr;
37 37
 extern lv_group_t*  g;
38 38
 
39 39
 static lv_obj_t *buttonPageUp, *buttonPageDown, *buttonBack,
40 40
                 *buttonGcode[FILE_BTN_CNT], *labelPageUp[FILE_BTN_CNT], *buttonText[FILE_BTN_CNT];
41 41
 
42
-#define ID_P_UP     7
43
-#define ID_P_DOWN   8
44
-#define ID_P_RETURN 9
42
+enum {
43
+  ID_P_UP = 7,
44
+  ID_P_DOWN,
45
+  ID_P_RETURN
46
+};
45 47
 
46 48
 int8_t curDirLever = 0;
47 49
 LIST_FILE list_file;
@@ -74,38 +76,21 @@ uint8_t sel_id = 0;
74 76
         const uint16_t nr = SD_ORDER(i, fileCnt);
75 77
         card.getfilename_sorted(nr);
76 78
 
77
-        if (card.flag.filenameIsDir) {
78
-          //SERIAL_ECHOLN(card.longest_filename);
79
-          list_file.IsFolder[valid_name_cnt] = 1;
80
-        }
81
-        else {
82
-          //SERIAL_ECHOLN(card.longFilename);
83
-          list_file.IsFolder[valid_name_cnt] = 0;
84
-        }
85
-
86
-        #if 1
87
-          //
88
-          memset(list_file.file_name[valid_name_cnt], 0, strlen(list_file.file_name[valid_name_cnt]));
89
-          strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath);
90
-          strcat_P(list_file.file_name[valid_name_cnt], PSTR("/"));
91
-          strcat(list_file.file_name[valid_name_cnt], card.filename);
92
-          //
93
-          memset(list_file.long_name[valid_name_cnt], 0, strlen(list_file.long_name[valid_name_cnt]));
94
-          if (card.longFilename[0] == 0)
95
-            strncpy(list_file.long_name[valid_name_cnt], card.filename, strlen(card.filename));
96
-          else
97
-            strncpy(list_file.long_name[valid_name_cnt], card.longFilename, strlen(card.longFilename));
98
-
99
-          valid_name_cnt++;
100
-          if (valid_name_cnt == 1)
101
-            dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset;
102
-          if (valid_name_cnt >= FILE_NUM) {
103
-            dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset;
104
-            list_file.Sd_file_offset++;
105
-            break;
106
-          }
79
+        list_file.IsFolder[valid_name_cnt] = card.flag.filenameIsDir;
80
+        strcpy(list_file.file_name[valid_name_cnt], list_file.curDirPath);
81
+        strcat_P(list_file.file_name[valid_name_cnt], PSTR("/"));
82
+        strcat(list_file.file_name[valid_name_cnt], card.filename);
83
+        strcpy(list_file.long_name[valid_name_cnt], card.longest_filename());
84
+
85
+        valid_name_cnt++;
86
+        if (valid_name_cnt == 1)
87
+          dir_offset[curDirLever].cur_page_first_offset = list_file.Sd_file_offset;
88
+        if (valid_name_cnt >= FILE_NUM) {
89
+          dir_offset[curDirLever].cur_page_last_offset = list_file.Sd_file_offset;
107 90
           list_file.Sd_file_offset++;
108
-        #endif
91
+          break;
92
+        }
93
+        list_file.Sd_file_offset++;
109 94
       }
110 95
       list_file.Sd_file_cnt++;
111 96
     }
@@ -115,125 +100,105 @@ uint8_t sel_id = 0;
115 100
 
116 101
 #endif // SDSUPPORT
117 102
 
118
-uint8_t have_pre_pic(char *path) {
103
+bool have_pre_pic(char *path) {
119 104
   #if ENABLED(SDSUPPORT)
120 105
     char *ps1, *ps2, *cur_name = strrchr(path, '/');
121
-
122 106
     card.openFileRead(cur_name);
123 107
     card.read(public_buf, 512);
124 108
     ps1 = strstr((char *)public_buf, ";simage:");
125 109
     card.read(public_buf, 512);
126 110
     ps2 = strstr((char *)public_buf, ";simage:");
127
-    if (ps1 || ps2) {
128
-      card.closefile();
129
-      return 1;
130
-    }
131 111
     card.closefile();
112
+    if (ps1 || ps2) return true;
132 113
   #endif
133 114
 
134
-  return 0;
115
+  return false;
135 116
 }
136 117
 
137
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
118
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
119
+  if (event != LV_EVENT_RELEASED) return;
138 120
   uint8_t i, file_count = 0;
139 121
   //switch (obj->mks_obj_id)
140 122
   //{
141 123
   if (obj->mks_obj_id == ID_P_UP) {
142
-    if (event == LV_EVENT_CLICKED) {
143
-    }
144
-    else if (event == LV_EVENT_RELEASED) {
145
-      if (dir_offset[curDirLever].curPage > 0) {
146
-        // 2015.05.19
147
-        list_file.Sd_file_cnt = 0;
124
+    if (dir_offset[curDirLever].curPage > 0) {
125
+      // 2015.05.19
126
+      list_file.Sd_file_cnt = 0;
148 127
 
149
-        if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
150
-          list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;
128
+      if (dir_offset[curDirLever].cur_page_first_offset >= FILE_NUM)
129
+        list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset - FILE_NUM;
151 130
 
152
-        #if ENABLED(SDSUPPORT)
153
-          file_count = search_file();
154
-        #endif
155
-        if (file_count != 0) {
156
-          dir_offset[curDirLever].curPage--;
157
-          lv_clear_print_file();
158
-          disp_gcode_icon(file_count);
159
-        }
131
+      #if ENABLED(SDSUPPORT)
132
+        file_count = search_file();
133
+      #endif
134
+      if (file_count != 0) {
135
+        dir_offset[curDirLever].curPage--;
136
+        lv_clear_print_file();
137
+        disp_gcode_icon(file_count);
160 138
       }
161 139
     }
162 140
   }
163 141
   else if (obj->mks_obj_id == ID_P_DOWN) {
164
-    if (event == LV_EVENT_CLICKED) {
165
-    }
166
-    else if (event == LV_EVENT_RELEASED) {
167
-      if (dir_offset[curDirLever].cur_page_last_offset > 0) {
168
-        list_file.Sd_file_cnt    = 0;
169
-        list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1;
170
-        #if ENABLED(SDSUPPORT)
171
-          file_count = search_file();
172
-        #endif
173
-        if (file_count != 0) {
174
-          dir_offset[curDirLever].curPage++;
175
-          lv_clear_print_file();
176
-          disp_gcode_icon(file_count);
177
-        }
178
-        if (file_count < FILE_NUM)
179
-          dir_offset[curDirLever].cur_page_last_offset = 0;
142
+    if (dir_offset[curDirLever].cur_page_last_offset > 0) {
143
+      list_file.Sd_file_cnt    = 0;
144
+      list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_last_offset + 1;
145
+      #if ENABLED(SDSUPPORT)
146
+        file_count = search_file();
147
+      #endif
148
+      if (file_count != 0) {
149
+        dir_offset[curDirLever].curPage++;
150
+        lv_clear_print_file();
151
+        disp_gcode_icon(file_count);
180 152
       }
153
+      if (file_count < FILE_NUM)
154
+        dir_offset[curDirLever].cur_page_last_offset = 0;
181 155
     }
182 156
   }
183 157
   else if (obj->mks_obj_id == ID_P_RETURN) {
184
-    if (event == LV_EVENT_CLICKED) {
185
-    }
186
-    else if (event == LV_EVENT_RELEASED) {
187
-      if (curDirLever > 0) {
188
-        int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/');
189
-        if (ch) {
190
-          *ch = 0;
191
-          #if ENABLED(SDSUPPORT)
192
-            card.cdup();
193
-          #endif
194
-          dir_offset[curDirLever].curPage               = 0;
195
-          dir_offset[curDirLever].cur_page_first_offset = 0;
196
-          dir_offset[curDirLever].cur_page_last_offset  = 0;
197
-          curDirLever--;
198
-          list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
199
-          #if ENABLED(SDSUPPORT)
200
-            file_count = search_file();
201
-          #endif
202
-          lv_clear_print_file();
203
-          disp_gcode_icon(file_count);
204
-        }
205
-      }
206
-      else {
158
+    if (curDirLever > 0) {
159
+      int8_t *ch = (int8_t *)strrchr(list_file.curDirPath, '/');
160
+      if (ch) {
161
+        *ch = 0;
162
+        #if ENABLED(SDSUPPORT)
163
+          card.cdup();
164
+        #endif
165
+        dir_offset[curDirLever].curPage               = 0;
166
+        dir_offset[curDirLever].cur_page_first_offset = 0;
167
+        dir_offset[curDirLever].cur_page_last_offset  = 0;
168
+        curDirLever--;
169
+        list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
170
+        #if ENABLED(SDSUPPORT)
171
+          file_count = search_file();
172
+        #endif
207 173
         lv_clear_print_file();
208
-        lv_draw_ready_print();
174
+        disp_gcode_icon(file_count);
209 175
       }
210 176
     }
177
+    else {
178
+      lv_clear_print_file();
179
+      lv_draw_ready_print();
180
+    }
211 181
   }
212 182
   else {
213 183
     for (i = 0; i < FILE_BTN_CNT; i++) {
214 184
       if (obj->mks_obj_id == (i + 1)) {
215
-        if (event == LV_EVENT_CLICKED) {
216
-        }
217
-        else if (event == LV_EVENT_RELEASED) {
218
-          if (list_file.file_name[i][0] != 0) {
219
-            if (list_file.IsFolder[i] == 1) {
220
-              ZERO(list_file.curDirPath);
221
-              strcpy(list_file.curDirPath,  list_file.file_name[i]);
222
-              curDirLever++;
223
-              list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
224
-              #if ENABLED(SDSUPPORT)
225
-                file_count = search_file();
226
-              #endif
227
-              lv_clear_print_file();
228
-              disp_gcode_icon(file_count);
229
-            }
230
-            else {
231
-              sel_id = i;
232
-              lv_clear_print_file();
233
-              lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
234
-            }
235
-            break;
185
+        if (list_file.file_name[i][0] != 0) {
186
+          if (list_file.IsFolder[i]) {
187
+            strcpy(list_file.curDirPath, list_file.file_name[i]);
188
+            curDirLever++;
189
+            list_file.Sd_file_offset = dir_offset[curDirLever].cur_page_first_offset;
190
+            #if ENABLED(SDSUPPORT)
191
+              file_count = search_file();
192
+            #endif
193
+            lv_clear_print_file();
194
+            disp_gcode_icon(file_count);
236 195
           }
196
+          else {
197
+            sel_id = i;
198
+            lv_clear_print_file();
199
+            lv_draw_dialog(DIALOG_TYPE_PRINT_FILE);
200
+          }
201
+          break;
237 202
         }
238 203
       }
239 204
     }
@@ -249,11 +214,11 @@ void lv_draw_print_file(void) {
249 214
   }
250 215
   disp_state = PRINT_FILE_UI;
251 216
 
252
-  curDirLever                     = 0;
217
+  curDirLever = 0;
253 218
   dir_offset[curDirLever].curPage = 0;
254 219
 
255 220
   list_file.Sd_file_offset = 0;
256
-  list_file.Sd_file_cnt    = 0;
221
+  list_file.Sd_file_cnt = 0;
257 222
 
258 223
   ZERO(dir_offset);
259 224
   ZERO(list_file.IsFolder);
@@ -287,14 +252,7 @@ static char test_public_buf_l[40];
287 252
 void disp_gcode_icon(uint8_t file_num) {
288 253
   uint8_t i;
289 254
 
290
-  scr = lv_obj_create(NULL, NULL);
291
-
292
-  //static lv_style_t tool_style;
293
-
294
-  lv_obj_set_style(scr, &tft_style_scr);
295
-  lv_scr_load(scr);
296
-  lv_obj_clean(scr);
297
-
255
+  scr = lv_screen_create();
298 256
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
299 257
 
300 258
   lv_refr_now(lv_refr_get_disp_refreshing());
@@ -319,17 +277,17 @@ void disp_gcode_icon(uint8_t file_num) {
319 277
     if (i >= file_num) break;
320 278
 
321 279
     #ifdef TFT35
322
-      buttonGcode[i] = lv_imgbtn_create(scr, NULL);
280
+      buttonGcode[i] = lv_imgbtn_create(scr, nullptr);
323 281
 
324 282
       lv_imgbtn_use_label_style(buttonGcode[i]);
325 283
       lv_obj_clear_protect(buttonGcode[i], LV_PROTECT_FOLLOW);
326 284
       lv_btn_set_layout(buttonGcode[i], LV_LAYOUT_OFF);
327 285
 
328 286
       ZERO(public_buf_m);
329
-      cutFileName((char *)list_file.long_name[i], 16, 8,  (char *)public_buf_m);
287
+      cutFileName((char *)list_file.long_name[i], 16, 8, (char *)public_buf_m);
330 288
 
331
-      if (list_file.IsFolder[i] == 1) {
332
-        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
289
+      if (list_file.IsFolder[i]) {
290
+        lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
333 291
         lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_dir.bin");
334 292
         if (i < 3)
335 293
           lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
@@ -344,34 +302,33 @@ void disp_gcode_icon(uint8_t file_num) {
344 302
 
345 303
           //lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), list_file.file_name[i], 1);
346 304
 
347
-          ZERO(test_public_buf_l);
348
-          strcat(test_public_buf_l,"S:");
349
-          strcat(test_public_buf_l,list_file.file_name[i]);
350
-          char *temp = strstr(test_public_buf_l,".GCO");
351
-          if (temp) { strcpy(temp,".bin"); }
352
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
305
+          strcpy(test_public_buf_l, "S:");
306
+          strcat(test_public_buf_l, list_file.file_name[i]);
307
+          char *temp = strstr(test_public_buf_l, ".GCO");
308
+          if (temp) strcpy(temp, ".bin");
309
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
353 310
           lv_imgbtn_set_src_both(buttonGcode[i], test_public_buf_l);
354 311
           if (i < 3) {
355 312
             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);
356
-            buttonText[i] = lv_btn_create(scr, NULL);
313
+            buttonText[i] = lv_btn_create(scr, nullptr);
357 314
             //lv_obj_set_event_cb(buttonText[i], event_handler);
358 315
 
359 316
             lv_btn_use_label_style(buttonText[i]);
360 317
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
361 318
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
362
-            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL, 0);
319
+            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
363 320
             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);
364 321
             lv_obj_set_size(buttonText[i], 100, 40);
365 322
           }
366 323
           else {
367 324
             lv_obj_set_pos(buttonGcode[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);
368
-            buttonText[i] = lv_btn_create(scr, NULL);
325
+            buttonText[i] = lv_btn_create(scr, nullptr);
369 326
             //lv_obj_set_event_cb(buttonText[i], event_handler);
370 327
 
371 328
             lv_btn_use_label_style(buttonText[i]);
372 329
             lv_obj_clear_protect(buttonText[i], LV_PROTECT_FOLLOW);
373 330
             lv_btn_set_layout(buttonText[i], LV_LAYOUT_OFF);
374
-            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),NULL, 0);
331
+            //lv_obj_set_event_cb_mks(buttonText[i], event_handler,(i+10),nullptr, 0);
375 332
             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);
376 333
             lv_obj_set_size(buttonText[i], 100, 40);
377 334
           }
@@ -379,7 +336,7 @@ void disp_gcode_icon(uint8_t file_num) {
379 336
           lv_obj_align(labelPageUp[i], buttonText[i], LV_ALIGN_IN_BOTTOM_MID, 0, 0);
380 337
         }
381 338
         else {
382
-          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), NULL, 0);
339
+          lv_obj_set_event_cb_mks(buttonGcode[i], event_handler, (i + 1), nullptr, 0);
383 340
           lv_imgbtn_set_src_both(buttonGcode[i], "F:/bmp_file.bin");
384 341
           if (i < 3)
385 342
             lv_obj_set_pos(buttonGcode[i], BTN_X_PIXEL * i + INTERVAL_V * (i + 1), titleHeight);
@@ -502,7 +459,7 @@ void lv_gcode_file_seek(uint32_t pos) {
502 459
   card.setIndex(pos);
503 460
 }
504 461
 
505
-void cutFileName(char *path, int len, int bytePerLine,  char *outStr) {
462
+void cutFileName(char *path, int len, int bytePerLine, char *outStr) {
506 463
   #if _LFN_UNICODE
507 464
     TCHAR *tmpFile;
508 465
     TCHAR *strIndex1 = 0, *strIndex2 = 0, *beginIndex;

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

@@ -43,7 +43,7 @@ typedef struct {
43 43
   char file_name[FILE_NUM][SHORT_NEME_LEN * MAX_DIR_LEVEL + 1];
44 44
   char curDirPath[SHORT_NEME_LEN * MAX_DIR_LEVEL + 1];
45 45
   char long_name[FILE_NUM][SHORT_NEME_LEN * 2 + 1];
46
-  char IsFolder[FILE_NUM];
46
+  bool IsFolder[FILE_NUM];
47 47
   char Sd_file_cnt;
48 48
   char sd_file_index;
49 49
   char Sd_file_offset;
@@ -55,7 +55,7 @@ extern void lv_draw_print_file(void);
55 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
-extern void cutFileName(char *path, int len, int bytePerLine,  char *outStr);
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 61
 extern void lv_gcode_file_seek(uint32_t pos);

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

@@ -59,78 +59,61 @@ TERN_(HAS_MULTI_EXTRUDER, static lv_obj_t *labelExt2);
59 59
   static lv_obj_t* labelBed;
60 60
 #endif
61 61
 
62
-#define ID_PAUSE  1
63
-#define ID_STOP   2
64
-#define ID_OPTION 3
62
+enum {
63
+  ID_PAUSE = 1,
64
+  ID_STOP,
65
+  ID_OPTION
66
+};
65 67
 
66 68
 bool once_flag; // = false
67 69
 extern bool flash_preview_begin, default_preview_flg, gcode_preview_over;
68 70
 extern uint32_t To_pre_view;
69 71
 
70
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
72
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
73
+  if (event != LV_EVENT_RELEASED) return;
74
+  if (gcode_preview_over) return;
71 75
   switch (obj->mks_obj_id) {
72 76
     case ID_PAUSE:
73
-      if (event == LV_EVENT_CLICKED) {
74
-        // nothing to do
77
+      if (uiCfg.print_state == WORKING) {
78
+        // #if ENABLED(PARK_HEAD_ON_PAUSE)
79
+        // queue.inject_P(PSTR("M25 P\nM24"));
80
+        #if ENABLED(SDSUPPORT)
81
+          // queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
82
+          card.pauseSDPrint();
83
+          stop_print_time();
84
+          uiCfg.print_state = PAUSING;
85
+        #endif
86
+        lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin");
87
+        lv_label_set_text(labelPause, printing_menu.resume);
88
+        lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
75 89
       }
76
-      else if (event == LV_EVENT_RELEASED) {
77
-        if (!gcode_preview_over) {
78
-          if (uiCfg.print_state == WORKING) {
79
-            // #if ENABLED(PARK_HEAD_ON_PAUSE)
80
-            // queue.inject_P(PSTR("M25 P\nM24"));
81
-            #if ENABLED(SDSUPPORT)
82
-              // queue.inject_P(PSTR("M25\nG91\nG1 Z10\nG90"));
83
-              card.pauseSDPrint();
84
-              stop_print_time();
85
-              uiCfg.print_state = PAUSING;
86
-            #endif
87
-            lv_imgbtn_set_src_both(buttonPause, "F:/bmp_resume.bin");
88
-            lv_label_set_text(labelPause, printing_menu.resume);
89
-            lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
90
-          }
91
-          else if (uiCfg.print_state == PAUSED) {
92
-            uiCfg.print_state = RESUMING;
93
-            lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
94
-            lv_label_set_text(labelPause, printing_menu.pause);
95
-            lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
96
-          }
97
-          #if ENABLED(POWER_LOSS_RECOVERY)
98
-            else if (uiCfg.print_state == REPRINTING) {
99
-              uiCfg.print_state = REPRINTED;
100
-              lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
101
-              lv_label_set_text(labelPause, printing_menu.pause);
102
-              lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
103
-              // recovery.resume();
104
-              print_time.minutes = recovery.info.print_job_elapsed / 60;
105
-              print_time.seconds = recovery.info.print_job_elapsed % 60;
106
-              print_time.hours   = print_time.minutes / 60;
107
-            }
108
-          #endif
109
-        }
90
+      else if (uiCfg.print_state == PAUSED) {
91
+        uiCfg.print_state = RESUMING;
92
+        lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
93
+        lv_label_set_text(labelPause, printing_menu.pause);
94
+        lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
110 95
       }
96
+      #if ENABLED(POWER_LOSS_RECOVERY)
97
+        else if (uiCfg.print_state == REPRINTING) {
98
+          uiCfg.print_state = REPRINTED;
99
+          lv_imgbtn_set_src_both(obj, "F:/bmp_pause.bin");
100
+          lv_label_set_text(labelPause, printing_menu.pause);
101
+          lv_obj_align(labelPause, buttonPause, LV_ALIGN_CENTER, 30, 0);
102
+          // recovery.resume();
103
+          print_time.minutes = recovery.info.print_job_elapsed / 60;
104
+          print_time.seconds = recovery.info.print_job_elapsed % 60;
105
+          print_time.hours   = print_time.minutes / 60;
106
+        }
107
+      #endif
111 108
       break;
112 109
 
113 110
     case ID_STOP:
114
-      if (event == LV_EVENT_CLICKED) {
115
-        // nothing to do
116
-      }
117
-      else if (event == LV_EVENT_RELEASED) {
118
-        if (!gcode_preview_over) {
119
-          lv_clear_printing();
120
-          lv_draw_dialog(DIALOG_TYPE_STOP);
121
-        }
122
-      }
111
+      lv_clear_printing();
112
+      lv_draw_dialog(DIALOG_TYPE_STOP);
123 113
       break;
124 114
     case ID_OPTION:
125
-      if (event == LV_EVENT_CLICKED) {
126
-        // nothing to do
127
-      }
128
-      else if (event == LV_EVENT_RELEASED) {
129
-        if (!gcode_preview_over) {
130
-          lv_clear_printing();
131
-          lv_draw_operation();
132
-        }
133
-      }
115
+      lv_clear_printing();
116
+      lv_draw_operation();
134 117
       break;
135 118
   }
136 119
 }
@@ -142,44 +125,38 @@ void lv_draw_printing(void) {
142 125
 
143 126
   disp_state = PRINTING_UI;
144 127
 
145
-  scr = lv_obj_create(NULL, NULL);
146
-
147
-  // static lv_style_t tool_style;
148
-
149
-  lv_obj_set_style(scr, &tft_style_scr);
150
-  lv_scr_load(scr);
151
-  lv_obj_clean(scr);
128
+  scr = lv_screen_create();
152 129
 
153 130
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
154 131
 
155 132
   lv_refr_now(lv_refr_get_disp_refreshing());
156 133
 
157 134
   // Create image buttons
158
-  lv_obj_t *buttonExt1 = lv_img_create(scr, NULL);
135
+  lv_obj_t *buttonExt1 = lv_img_create(scr, nullptr);
159 136
   lv_img_set_src(buttonExt1, "F:/bmp_ext1_state.bin");
160 137
   lv_obj_set_pos(buttonExt1, 205, 136);
161 138
 
162 139
   #if HAS_MULTI_EXTRUDER
163
-    lv_obj_t *buttonExt2 = lv_img_create(scr, NULL);
140
+    lv_obj_t *buttonExt2 = lv_img_create(scr, nullptr);
164 141
     lv_img_set_src(buttonExt2, "F:/bmp_ext2_state.bin");
165 142
     lv_obj_set_pos(buttonExt2, 350, 136);
166 143
   #endif
167 144
 
168 145
   #if HAS_HEATED_BED
169
-    lv_obj_t *buttonBedstate = lv_img_create(scr, NULL);
146
+    lv_obj_t *buttonBedstate = lv_img_create(scr, nullptr);
170 147
     lv_img_set_src(buttonBedstate, "F:/bmp_bed_state.bin");
171 148
     lv_obj_set_pos(buttonBedstate, 205, 186);
172 149
   #endif
173 150
 
174
-  lv_obj_t *buttonFanstate = lv_img_create(scr, NULL);
151
+  lv_obj_t *buttonFanstate = lv_img_create(scr, nullptr);
175 152
   lv_img_set_src(buttonFanstate, "F:/bmp_fan_state.bin");
176 153
   lv_obj_set_pos(buttonFanstate, 350, 186);
177 154
 
178
-  lv_obj_t *buttonTime = lv_img_create(scr, NULL);
155
+  lv_obj_t *buttonTime = lv_img_create(scr, nullptr);
179 156
   lv_img_set_src(buttonTime, "F:/bmp_time_state.bin");
180 157
   lv_obj_set_pos(buttonTime, 205, 86);
181 158
 
182
-  lv_obj_t *buttonZpos = lv_img_create(scr, NULL);
159
+  lv_obj_t *buttonZpos = lv_img_create(scr, nullptr);
183 160
   lv_img_set_src(buttonZpos, "F:/bmp_zpos_state.bin");
184 161
   lv_obj_set_pos(buttonZpos, 350, 86);
185 162
 
@@ -209,19 +186,19 @@ void lv_draw_printing(void) {
209 186
   //lv_btn_set_layout(buttonTime, LV_LAYOUT_OFF);
210 187
   //lv_btn_set_layout(buttonZpos, LV_LAYOUT_OFF);
211 188
 
212
-  labelExt1 = lv_label_create(scr, 250, 146, NULL);
189
+  labelExt1 = lv_label_create(scr, 250, 146, nullptr);
213 190
 
214 191
   #if HAS_MULTI_EXTRUDER
215
-    labelExt2 = lv_label_create(scr, 395, 146, NULL);
192
+    labelExt2 = lv_label_create(scr, 395, 146, nullptr);
216 193
   #endif
217 194
 
218 195
   #if HAS_HEATED_BED
219
-    labelBed = lv_label_create(scr, 250, 196, NULL);
196
+    labelBed = lv_label_create(scr, 250, 196, nullptr);
220 197
   #endif
221 198
 
222
-  labelFan = lv_label_create(scr, 395, 196, NULL);
223
-  labelTime = lv_label_create(scr, 250, 96, NULL);
224
-  labelZpos = lv_label_create(scr, 395, 96, NULL);
199
+  labelFan = lv_label_create(scr, 395, 196, nullptr);
200
+  labelTime = lv_label_create(scr, 250, 96, nullptr);
201
+  labelZpos = lv_label_create(scr, 395, 96, nullptr);
225 202
 
226 203
   labelPause  = lv_label_create_empty(buttonPause);
227 204
   labelStop   = lv_label_create_empty(buttonStop);
@@ -238,7 +215,7 @@ void lv_draw_printing(void) {
238 215
     lv_obj_align(labelOperat, buttonOperat, LV_ALIGN_CENTER, 20, 0);
239 216
   }
240 217
 
241
-  bar1 = lv_bar_create(scr, NULL);
218
+  bar1 = lv_bar_create(scr, nullptr);
242 219
   lv_obj_set_pos(bar1, 205, 36);
243 220
   lv_obj_set_size(bar1, 270, 40);
244 221
   lv_bar_set_style(bar1, LV_BAR_STYLE_INDIC, &lv_bar_style_indic);
@@ -256,12 +233,10 @@ void lv_draw_printing(void) {
256 233
 }
257 234
 
258 235
 void disp_ext_temp() {
259
-  ZERO(public_buf_l);
260 236
   sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[0].celsius, (int)thermalManager.temp_hotend[0].target);
261 237
   lv_label_set_text(labelExt1, public_buf_l);
262 238
 
263 239
   #if HAS_MULTI_EXTRUDER
264
-    ZERO(public_buf_l);
265 240
     sprintf(public_buf_l, printing_menu.temp1, (int)thermalManager.temp_hotend[1].celsius, (int)thermalManager.temp_hotend[1].target);
266 241
     lv_label_set_text(labelExt2, public_buf_l);
267 242
   #endif
@@ -269,20 +244,17 @@ void disp_ext_temp() {
269 244
 
270 245
 void disp_bed_temp() {
271 246
   #if HAS_HEATED_BED
272
-    ZERO(public_buf_l);
273 247
     sprintf(public_buf_l, printing_menu.bed_temp, (int)thermalManager.temp_bed.celsius, (int)thermalManager.temp_bed.target);
274 248
     lv_label_set_text(labelBed, public_buf_l);
275 249
   #endif
276 250
 }
277 251
 
278 252
 void disp_fan_speed() {
279
-  ZERO(public_buf_l);
280 253
   sprintf_P(public_buf_l, PSTR("%3d"), thermalManager.fan_speed[0]);
281 254
   lv_label_set_text(labelFan, public_buf_l);
282 255
 }
283 256
 
284 257
 void disp_print_time() {
285
-  ZERO(public_buf_l);
286 258
   #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
287 259
     const uint32_t r = ui.get_remaining_time();
288 260
     sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60);
@@ -293,7 +265,6 @@ void disp_print_time() {
293 265
 }
294 266
 
295 267
 void disp_fan_Zpos() {
296
-  ZERO(public_buf_l);
297 268
   sprintf_P(public_buf_l, PSTR("%.3f"), current_position[Z_AXIS]);
298 269
   lv_label_set_text(labelZpos, public_buf_l);
299 270
 }
@@ -333,7 +304,6 @@ void setProBarRate() {
333 304
 
334 305
   if (disp_state == PRINTING_UI) {
335 306
     lv_bar_set_value(bar1, rate, LV_ANIM_ON);
336
-    ZERO(public_buf_l);
337 307
     sprintf_P(public_buf_l, "%d%%", rate);
338 308
     lv_label_set_text(bar1ValueText,public_buf_l);
339 309
     lv_obj_align(bar1ValueText, bar1, LV_ALIGN_CENTER, 0, 0);

+ 10
- 8
Marlin/src/lcd/extui/lib/mks_ui/draw_printing.h View File

@@ -25,14 +25,16 @@
25 25
   extern "C" { /* C-declarations for C++ */
26 26
 #endif
27 27
 
28
-#define IDLE        0
29
-#define WORKING     1
30
-#define PAUSING     2
31
-#define PAUSED      3
32
-#define REPRINTING  4
33
-#define REPRINTED   5
34
-#define RESUMING    6
35
-#define STOP        7
28
+enum {
29
+  IDLE,
30
+  WORKING,
31
+  PAUSING,
32
+  PAUSED,
33
+  REPRINTING,
34
+  REPRINTED,
35
+  RESUMING,
36
+  STOP
37
+};
36 38
 
37 39
 extern void lv_draw_printing(void);
38 40
 extern void lv_clear_printing();

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

@@ -43,44 +43,31 @@
43 43
 
44 44
 //static lv_obj_t *buttonPrint, *buttonTool, *buttonSet;
45 45
 extern lv_group_t*  g;
46
-static lv_obj_t * scr;
46
+static lv_obj_t *scr;
47 47
 #if ENABLED(MKS_TEST)
48 48
   uint8_t curent_disp_ui = 0;
49 49
 #endif
50 50
 
51
-#define ID_TOOL   1
52
-#define ID_SET    2
53
-#define ID_PRINT  3
51
+enum {
52
+  ID_TOOL = 1,
53
+  ID_SET,
54
+  ID_PRINT
55
+};
54 56
 
55
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
57
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
58
+  if (event != LV_EVENT_RELEASED) return;
56 59
   switch (obj->mks_obj_id) {
57 60
     case ID_TOOL:
58
-      if (event == LV_EVENT_CLICKED) {
59
-        // nothing to do
60
-      }
61
-      else if (event == LV_EVENT_RELEASED) {
62
-
63
-        lv_clear_ready_print();
64
-        lv_draw_tool();
65
-      }
61
+      lv_clear_ready_print();
62
+      lv_draw_tool();
66 63
       break;
67 64
     case ID_SET:
68
-      if (event == LV_EVENT_CLICKED) {
69
-        // nothing to do
70
-      }
71
-      else if (event == LV_EVENT_RELEASED) {
72
-        lv_clear_ready_print();
73
-        lv_draw_set();
74
-      }
65
+      lv_clear_ready_print();
66
+      lv_draw_set();
75 67
       break;
76 68
     case ID_PRINT:
77
-      if (event == LV_EVENT_CLICKED) {
78
-        // nothing to do
79
-      }
80
-      else if (event == LV_EVENT_RELEASED) {
81
-        lv_clear_ready_print();
82
-        lv_draw_print_file();
83
-      }
69
+      lv_clear_ready_print();
70
+      lv_draw_print_file();
84 71
       break;
85 72
   }
86 73
 }
@@ -114,20 +101,16 @@ void mks_disp_test() {
114 101
   char buf[30] = {0};
115 102
   //lv_obj_t *label_tool2 = lv_label_create_empty(scr);
116 103
   //lv_obj_set_pos(label_tool, 20, 50);
117
-  ZERO(buf);
118 104
   sprintf_P(buf, PSTR("e1:%d"), (int)thermalManager.temp_hotend[0].celsius);
119 105
   lv_label_set_text(e1, buf);
120 106
   #if HAS_MULTI_HOTEND
121
-    ZERO(buf);
122 107
     sprintf_P(buf, PSTR("e2:%d"), (int)thermalManager.temp_hotend[1].celsius);
123 108
     lv_label_set_text(e2, buf);
124 109
   #endif
125 110
 
126
-  //ZERO(buf);
127 111
   //sprintf_P(buf, PSTR("e3:%d"), (int)thermalManager.temp_hotend[2].celsius);
128 112
   //lv_label_set_text(e3, buf);
129 113
   #if HAS_HEATED_BED
130
-    ZERO(buf);
131 114
     sprintf_P(buf, PSTR("bed:%d"), (int)thermalManager.temp_bed.celsius);
132 115
     lv_label_set_text(bed, buf);
133 116
   #endif
@@ -135,7 +118,7 @@ void mks_disp_test() {
135 118
 
136 119
 void lv_draw_ready_print(void) {
137 120
   char buf[30] = {0};
138
-  lv_obj_t *buttonPrint, *buttonTool, *buttonSet;
121
+  lv_obj_t *buttonTool;
139 122
 
140 123
   disp_state_stack._disp_index = 0;
141 124
   ZERO(disp_state_stack._disp_state);
@@ -143,11 +126,7 @@ void lv_draw_ready_print(void) {
143 126
 
144 127
   disp_state = PRINT_READY_UI;
145 128
 
146
-  scr = lv_obj_create(NULL, NULL);
147
-
148
-  lv_obj_set_style(scr, &tft_style_scr);
149
-  lv_scr_load(scr);
150
-  lv_obj_clean(scr);
129
+  scr = lv_screen_create();
151 130
   //lv_obj_set_hidden(scr, true);
152 131
   lv_refr_now(lv_refr_get_disp_refreshing());
153 132
 
@@ -155,12 +134,12 @@ void lv_draw_ready_print(void) {
155 134
     //(void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
156 135
 
157 136
     // Create image buttons
158
-    //buttonPrint = lv_imgbtn_create(scr, NULL);
137
+    //buttonPrint = lv_imgbtn_create(scr, nullptr);
159 138
     buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", event_handler, ID_TOOL);
160 139
 
161 140
     lv_obj_set_pos(buttonTool, 360, 180);
162 141
 
163
-    //buttonSet = lv_imgbtn_create(scr, NULL);
142
+    //buttonSet = lv_imgbtn_create(scr, nullptr);
164 143
     //lv_obj_set_pos(buttonSet, 180, 90);
165 144
     //lv_obj_set_pos(buttonPrint, 340, 90);
166 145
 
@@ -237,34 +216,9 @@ void lv_draw_ready_print(void) {
237 216
 
238 217
   }
239 218
   else {
240
-    // Create an Image button
241
-    buttonTool = lv_imgbtn_create(scr, "F:/bmp_tool.bin", 20, 90, event_handler, ID_TOOL);
242
-    lv_obj_t *label_tool = lv_label_create_empty(buttonTool);
243
-
244
-    buttonSet = lv_imgbtn_create(scr, "F:/bmp_set.bin", 180, 90, event_handler, ID_SET);
245
-    lv_obj_t *label_set = lv_label_create_empty(buttonSet);
246
-
247
-    buttonPrint = lv_imgbtn_create(scr, "F:/bmp_printing.bin", 340, 90, event_handler, ID_PRINT);
248
-    lv_obj_t *label_print = lv_label_create_empty(buttonPrint);
249
-
250
-    if (gCfgItems.multiple_language) {
251
-      lv_label_set_text(label_print, main_menu.print);
252
-      lv_obj_align(label_print, buttonPrint, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
253
-
254
-      lv_label_set_text(label_set, main_menu.set);
255
-      lv_obj_align(label_set, buttonSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
256
-
257
-      lv_label_set_text(label_tool, main_menu.tool);
258
-      lv_obj_align(label_tool, buttonTool, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
259
-    }
260
-
261
-    #if HAS_ROTARY_ENCODER
262
-      if (gCfgItems.encoder_enable == true) {
263
-        lv_group_add_obj(g, buttonTool);
264
-        lv_group_add_obj(g, buttonSet);
265
-        lv_group_add_obj(g, buttonPrint);
266
-      }
267
-    #endif
219
+    lv_big_button_create(scr, "F:/bmp_tool.bin", main_menu.tool, 20, 90, event_handler, ID_TOOL);
220
+    lv_big_button_create(scr, "F:/bmp_set.bin", main_menu.set, 180, 90, event_handler, ID_SET);
221
+    lv_big_button_create(scr, "F:/bmp_printing.bin", main_menu.print, 340, 90, event_handler, ID_PRINT);
268 222
   }
269 223
 }
270 224
 

+ 41
- 178
Marlin/src/lcd/extui/lib/mks_ui/draw_set.cpp View File

@@ -37,100 +37,58 @@
37 37
 #include "../../../../gcode/queue.h"
38 38
 #include "../../../../inc/MarlinConfig.h"
39 39
 
40
-static lv_obj_t * scr;
40
+static lv_obj_t *scr;
41 41
 extern lv_group_t*  g;
42 42
 
43
-#define ID_S_WIFI         1
44
-#define ID_S_FAN          2
45
-#define ID_S_ABOUT        3
46
-#define ID_S_CONTINUE     4
47
-#define ID_S_MOTOR_OFF    5
48
-#define ID_S_LANGUAGE     6
49
-#define ID_S_MACHINE_PARA 7
50
-#define ID_S_EEPROM_SET   8
51
-#define ID_S_RETURN       9
52
-
53
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
43
+enum {
44
+  ID_S_WIFI = 1,
45
+  ID_S_FAN,
46
+  ID_S_ABOUT,
47
+  ID_S_CONTINUE,
48
+  ID_S_MOTOR_OFF,
49
+  ID_S_LANGUAGE,
50
+  ID_S_MACHINE_PARA,
51
+  ID_S_EEPROM_SET,
52
+  ID_S_RETURN
53
+};
54
+
55
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
56
+  if (event != LV_EVENT_RELEASED) return;
54 57
   #if ENABLED(USE_WIFI_FUNCTION)
55 58
     char buf[6] = { 0 };
56 59
   #endif
57 60
   switch (obj->mks_obj_id) {
58
-
59 61
     case ID_S_FAN:
60
-      if (event == LV_EVENT_CLICKED) {
61
-        // nothing to do
62
-      }
63
-      else if (event == LV_EVENT_RELEASED) {
64
-        lv_clear_set();
65
-        lv_draw_fan();
66
-      }
62
+      lv_clear_set();
63
+      lv_draw_fan();
67 64
       break;
68 65
     case ID_S_ABOUT:
69
-      if (event == LV_EVENT_CLICKED) {
70
-        // nothing to do
71
-      }
72
-      else if (event == LV_EVENT_RELEASED) {
73
-        lv_clear_set();
74
-        lv_draw_about();
75
-      }
76
-      break;
77
-    case ID_S_CONTINUE:
78
-
66
+      lv_clear_set();
67
+      lv_draw_about();
79 68
       break;
69
+    case ID_S_CONTINUE: break;
80 70
     case ID_S_MOTOR_OFF:
81
-      if (event == LV_EVENT_CLICKED) {
82
-        // nothing to do
83
-      }
84
-      else if (event == LV_EVENT_RELEASED) {
85
-        #if HAS_SUICIDE
86
-          suicide();
87
-        #else
88
-          queue.enqueue_now_P(PSTR("M84"));
89
-        #endif
90
-      }
71
+      TERN(HAS_SUICIDE, suicide(), queue.enqueue_now_P(PSTR("M84")));
91 72
       break;
92 73
     case ID_S_LANGUAGE:
93
-      if (event == LV_EVENT_CLICKED) {
94
-        // nothing to do
95
-      }
96
-      else if (event == LV_EVENT_RELEASED) {
97
-        lv_clear_set();
98
-        lv_draw_language();
99
-      }
74
+      lv_clear_set();
75
+      lv_draw_language();
100 76
       break;
101 77
     case ID_S_MACHINE_PARA:
102
-      if (event == LV_EVENT_CLICKED) {
103
-
104
-      }
105
-      else if (event == LV_EVENT_RELEASED) {
106
-        lv_clear_set();
107
-        lv_draw_machine_para();
108
-      }
78
+      lv_clear_set();
79
+      lv_draw_machine_para();
109 80
       break;
110 81
     case ID_S_EEPROM_SET:
111
-      if (event == LV_EVENT_CLICKED) {
112
-
113
-      }
114
-      else if (event == LV_EVENT_RELEASED) {
115
-        lv_clear_set();
116
-        lv_draw_eeprom_settings();
117
-      }
82
+      lv_clear_set();
83
+      lv_draw_eeprom_settings();
118 84
       break;
119 85
     case ID_S_RETURN:
120
-      if (event == LV_EVENT_CLICKED) {
121
-        // nothing to do
122
-      }
123
-      else if (event == LV_EVENT_RELEASED) {
124
-        lv_clear_set();
125
-        lv_draw_ready_print();
126
-      }
86
+      lv_clear_set();
87
+      lv_draw_ready_print();
127 88
       break;
89
+
128 90
     #if ENABLED(USE_WIFI_FUNCTION)
129 91
       case ID_S_WIFI:
130
-        if (event == LV_EVENT_CLICKED) {
131
-
132
-        }
133
-        else if (event == LV_EVENT_RELEASED) {
134 92
         if (gCfgItems.wifi_mode_sel == STA_MODEL) {
135 93
           if (wifi_link_state == WIFI_CONNECTED) {
136 94
             last_disp_state = SET_UI;
@@ -153,7 +111,7 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
153 111
             else {
154 112
               last_disp_state = SET_UI;
155 113
               lv_clear_set();
156
-              lv_draw_dialog(WIFI_ENABLE_TIPS);
114
+              lv_draw_dialog(DIALOG_WIFI_ENABLE_TIPS);
157 115
             }
158 116
           }
159 117
         }
@@ -162,131 +120,36 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
162 120
           lv_clear_set();
163 121
           lv_draw_wifi();
164 122
         }
165
-      }
166
-      break;
123
+        break;
167 124
     #endif
168 125
   }
169 126
 }
170 127
 
171 128
 void lv_draw_set(void) {
172
-  lv_obj_t *buttonFan, *buttonAbout;
173
-  lv_obj_t *buMotorOff, *buttonBack;
174
-  #if HAS_LANG_SELECT_SCREEN
175
-    lv_obj_t *buttonLanguage;
176
-  #endif
177
-  lv_obj_t *buttonMachinePara;
178
-  lv_obj_t *buttonEepromSet;
179
-  #if ENABLED(USE_WIFI_FUNCTION)
180
-    lv_obj_t *buttonWifi;
181
-  #endif
182
-
183 129
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != SET_UI) {
184 130
     disp_state_stack._disp_index++;
185 131
     disp_state_stack._disp_state[disp_state_stack._disp_index] = SET_UI;
186 132
   }
187 133
   disp_state = SET_UI;
188 134
 
189
-  scr = lv_obj_create(NULL, NULL);
190
-
191
-  //static lv_style_t tool_style;
192
-
193
-  lv_obj_set_style(scr, &tft_style_scr);
194
-  lv_scr_load(scr);
195
-  lv_obj_clean(scr);
135
+  scr = lv_screen_create();
196 136
 
197 137
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
198 138
 
199 139
   lv_refr_now(lv_refr_get_disp_refreshing());
200 140
 
201
-  // Create image buttons
202
-  buttonEepromSet = lv_imgbtn_create(scr, "F:/bmp_eeprom_settings.bin", INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET);
203
-  //buttonWifi = lv_imgbtn_create(scr, NULL);
204
-  buttonFan = lv_imgbtn_create(scr, "F:/bmp_fan.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN);
205
-  buttonAbout = lv_imgbtn_create(scr, "F:/bmp_about.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT);
206
-  //buttonContinue = lv_imgbtn_create(scr, NULL);
207
-  buMotorOff = lv_imgbtn_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
208
-  buttonMachinePara = lv_imgbtn_create(scr, "F:/bmp_machine_para.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
141
+  lv_big_button_create(scr, "F:/bmp_eeprom_settings.bin", set_menu.eepromSet, INTERVAL_V, titleHeight, event_handler, ID_S_EEPROM_SET);
142
+  lv_big_button_create(scr, "F:/bmp_fan.bin", set_menu.fan, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_S_FAN);
143
+  lv_big_button_create(scr, "F:/bmp_about.bin", set_menu.about, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_S_ABOUT);
144
+  lv_big_button_create(scr, ENABLED(HAS_SUICIDE) ? "F:/bmp_manual_off.bin" : "F:/bmp_function1.bin", set_menu.TERN(HAS_SUICIDE, shutdown, motoroff), BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_S_MOTOR_OFF);
145
+  lv_big_button_create(scr, "F:/bmp_machine_para.bin", set_menu.machine_para, INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_MACHINE_PARA);
209 146
   #if HAS_LANG_SELECT_SCREEN
210
-    buttonLanguage = lv_imgbtn_create(scr, "F:/bmp_language.bin", BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE);
147
+    lv_big_button_create(scr, "F:/bmp_language.bin", set_menu.language, BTN_X_PIXEL + INTERVAL_V * 2, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_LANGUAGE);
211 148
   #endif
212 149
   #if ENABLED(USE_WIFI_FUNCTION)
213
-    buttonWifi = lv_imgbtn_create(scr, "F:/bmp_wifi.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI);
214
-  #endif
215
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
216
-
217
-  /*lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
218
-  lv_obj_set_pos(buttonFan,BTN_X_PIXEL+INTERVAL_V*2,titleHeight);
219
-  lv_obj_set_pos(buttonAbout,BTN_X_PIXEL*2+INTERVAL_V*3,titleHeight);
220
-  lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
221
-  lv_obj_set_pos(buMotorOff,INTERVAL_V, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
222
-  lv_obj_set_pos(buttonLanguage,BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight);
223
-  lv_obj_set_pos(buttonBack,BTN_X_PIXEL*3+INTERVAL_V*4, BTN_Y_PIXEL+INTERVAL_H+titleHeight);*/
224
-
225
-  //lv_obj_set_pos(buttonWifi,INTERVAL_V,titleHeight);
226
-  //lv_obj_set_pos(buttonContinue,BTN_X_PIXEL*3+INTERVAL_V*4,titleHeight);
227
-
228
-  /// Create labels on the buttons
229
-  //lv_obj_t *labelWifi= lv_label_create_empty(buttonWifi);
230
-  lv_obj_t *label_EepromSet   = lv_label_create_empty(buttonEepromSet);
231
-  lv_obj_t *labelFan          = lv_label_create_empty(buttonFan);
232
-  lv_obj_t *label_About       = lv_label_create_empty(buttonAbout);
233
-  //lv_obj_t *label_Continue  = lv_label_create_empty(buttonContinue);
234
-  lv_obj_t *label_MotorOff    = lv_label_create_empty(buMotorOff);
235
-  lv_obj_t *label_MachinePara = lv_label_create_empty(buttonMachinePara);
236
-  #if HAS_LANG_SELECT_SCREEN
237
-    lv_obj_t *label_Language  = lv_label_create_empty(buttonLanguage);
238
-  #endif
239
-  #if ENABLED(USE_WIFI_FUNCTION)
240
-    lv_obj_t *label_Wifi      = lv_label_create_empty(buttonWifi);
241
-  #endif
242
-  lv_obj_t *label_Back        = lv_label_create_empty(buttonBack);
243
-
244
-  if (gCfgItems.multiple_language) {
245
-
246
-    lv_label_set_text(label_EepromSet, set_menu.eepromSet);
247
-    lv_obj_align(label_EepromSet, buttonEepromSet, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
248
-
249
-    lv_label_set_text(labelFan, set_menu.fan);
250
-    lv_obj_align(labelFan, buttonFan, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
251
-
252
-    lv_label_set_text(label_About, set_menu.about);
253
-    lv_obj_align(label_About, buttonAbout, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
254
-
255
-    //lv_label_set_text(label_Continue, set_menu.breakpoint);
256
-    //lv_obj_align(label_Continue, buttonContinue, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
257
-    lv_label_set_text(label_MotorOff, set_menu.TERN(HAS_SUICIDE, shutdown, motoroff));
258
-    lv_obj_align(label_MotorOff, buMotorOff, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
259
-
260
-    lv_label_set_text(label_MachinePara, set_menu.machine_para);
261
-    lv_obj_align(label_MachinePara, buttonMachinePara, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
262
-
263
-    #if HAS_LANG_SELECT_SCREEN
264
-      lv_label_set_text(label_Language, set_menu.language);
265
-      lv_obj_align(label_Language, buttonLanguage, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
266
-    #endif
267
-
268
-    #if ENABLED(USE_WIFI_FUNCTION)
269
-      lv_label_set_text(label_Wifi, set_menu.wifi);
270
-      lv_obj_align(label_Wifi, buttonWifi, LV_ALIGN_IN_BOTTOM_MID,0, BUTTON_TEXT_Y_OFFSET);
271
-    #endif
272
-
273
-    lv_label_set_text(label_Back, common_menu.text_back);
274
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
275
-  }
276
-  #if HAS_ROTARY_ENCODER
277
-    if (gCfgItems.encoder_enable) {
278
-      lv_group_add_obj(g, buttonEepromSet);
279
-      lv_group_add_obj(g, buttonFan);
280
-      lv_group_add_obj(g, buttonAbout);
281
-      lv_group_add_obj(g, buMotorOff);
282
-      lv_group_add_obj(g, buttonMachinePara);
283
-      lv_group_add_obj(g, buttonLanguage);
284
-      #if ENABLED(USE_WIFI_FUNCTION)
285
-        lv_group_add_obj(g, buttonWifi);
286
-      #endif
287
-      lv_group_add_obj(g, buttonBack);
288
-    }
150
+    lv_big_button_create(scr, "F:/bmp_wifi.bin", set_menu.wifi, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_WIFI);
289 151
   #endif
152
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_S_RETURN);
290 153
 }
291 154
 
292 155
 void lv_clear_set() {

+ 54
- 197
Marlin/src/lcd/extui/lib/mks_ui/draw_step_settings.cpp View File

@@ -29,243 +29,100 @@
29 29
 #include "../../../../module/planner.h"
30 30
 #include "../../../../inc/MarlinConfig.h"
31 31
 
32
-extern lv_group_t * g;
33
-static lv_obj_t * scr;
34
-
35
-#define ID_STEP_RETURN  1
36
-#define ID_STEP_X       2
37
-#define ID_STEP_Y       3
38
-#define ID_STEP_Z       4
39
-#define ID_STEP_E0      5
40
-#define ID_STEP_E1      6
41
-#define ID_STEP_DOWN    7
42
-#define ID_STEP_UP      8
43
-
44
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
32
+extern lv_group_t *g;
33
+static lv_obj_t *scr;
34
+
35
+enum {
36
+  ID_STEP_RETURN = 1,
37
+  ID_STEP_X,
38
+  ID_STEP_Y,
39
+  ID_STEP_Z,
40
+  ID_STEP_E0,
41
+  ID_STEP_E1,
42
+  ID_STEP_DOWN,
43
+  ID_STEP_UP
44
+};
45
+
46
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
47
+  if (event != LV_EVENT_RELEASED) return;
45 48
   switch (obj->mks_obj_id) {
46 49
     case ID_STEP_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_step_settings();
53
-        draw_return_ui();
54
-      }
50
+      uiCfg.para_ui_page = 0;
51
+      lv_clear_step_settings();
52
+      draw_return_ui();
55 53
       break;
56 54
     case ID_STEP_X:
57
-      if (event == LV_EVENT_CLICKED) {
58
-
59
-      }
60
-      else if (event == LV_EVENT_RELEASED) {
61
-        value = Xstep;
62
-        lv_clear_step_settings();
63
-        lv_draw_number_key();
64
-      }
55
+      value = Xstep;
56
+      lv_clear_step_settings();
57
+      lv_draw_number_key();
65 58
       break;
66 59
     case ID_STEP_Y:
67
-      if (event == LV_EVENT_CLICKED) {
68
-
69
-      }
70
-      else if (event == LV_EVENT_RELEASED) {
71
-        value = Ystep;
72
-        lv_clear_step_settings();
73
-        lv_draw_number_key();
74
-      }
60
+      value = Ystep;
61
+      lv_clear_step_settings();
62
+      lv_draw_number_key();
75 63
       break;
76 64
     case ID_STEP_Z:
77
-      if (event == LV_EVENT_CLICKED) {
78
-
79
-      }
80
-      else if (event == LV_EVENT_RELEASED) {
81
-        value = Zstep;
82
-        lv_clear_step_settings();
83
-        lv_draw_number_key();
84
-      }
65
+      value = Zstep;
66
+      lv_clear_step_settings();
67
+      lv_draw_number_key();
85 68
       break;
86 69
     case ID_STEP_E0:
87
-      if (event == LV_EVENT_CLICKED) {
88
-
89
-      }
90
-      else if (event == LV_EVENT_RELEASED) {
91
-        value = E0step;
92
-        lv_clear_step_settings();
93
-        lv_draw_number_key();
94
-      }
70
+      value = E0step;
71
+      lv_clear_step_settings();
72
+      lv_draw_number_key();
95 73
       break;
96 74
     case ID_STEP_E1:
97
-      if (event == LV_EVENT_CLICKED) {
98
-
99
-      }
100
-      else if (event == LV_EVENT_RELEASED) {
101
-        value = E1step;
102
-        lv_clear_step_settings();
103
-        lv_draw_number_key();
104
-      }
75
+      value = E1step;
76
+      lv_clear_step_settings();
77
+      lv_draw_number_key();
105 78
       break;
106 79
     case ID_STEP_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_step_settings();
113
-        lv_draw_step_settings();
114
-      }
80
+      uiCfg.para_ui_page = 0;
81
+      lv_clear_step_settings();
82
+      lv_draw_step_settings();
115 83
       break;
116 84
     case ID_STEP_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_step_settings();
123
-        lv_draw_step_settings();
124
-      }
85
+      uiCfg.para_ui_page = 1;
86
+      lv_clear_step_settings();
87
+      lv_draw_step_settings();
125 88
       break;
126 89
   }
127 90
 }
128 91
 
129 92
 void lv_draw_step_settings(void) {
130
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonTurnPage = NULL, *labelTurnPage = NULL;
131
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
132
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
133
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
134
-  lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
135
-  lv_obj_t *buttonE1Value = NULL, *labelE1Value = NULL;
136
-  lv_obj_t *line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
137 93
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != STEPS_UI) {
138 94
     disp_state_stack._disp_index++;
139 95
     disp_state_stack._disp_state[disp_state_stack._disp_index] = STEPS_UI;
140 96
   }
141 97
   disp_state = STEPS_UI;
142 98
 
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
-
99
+  scr = lv_screen_create();
149 100
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.StepsConfTitle);
150
-
151 101
   lv_refr_now(lv_refr_get_disp_refreshing());
152 102
 
153 103
   if (uiCfg.para_ui_page != 1) {
154
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Steps);
155
-
156
-    buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_X);
157
-    labelXValue = lv_label_create_empty(buttonXValue);
158
-
159
-    line1 = lv_line_create(scr, NULL);
160
-    lv_ex_line(line1, line_points[0]);
161
-
162
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Steps);
163
-
164
-    buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_Y);
165
-    labelYValue = lv_label_create_empty(buttonYValue);
166
-
167
-    line2 = lv_line_create(scr, NULL);
168
-    lv_ex_line(line2, line_points[1]);
104
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
105
+    lv_screen_menu_item_1_edit(scr, machine_menu.X_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_X, 0, public_buf_l);
169 106
 
170
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Steps);
107
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]);
108
+    lv_screen_menu_item_1_edit(scr, machine_menu.Y_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_STEP_Y, 1, public_buf_l);
171 109
 
172
-    buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_Z);
173
-    labelZValue = lv_label_create_empty(buttonZValue);
110
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]);
111
+    lv_screen_menu_item_1_edit(scr, machine_menu.Z_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_STEP_Z, 2, public_buf_l);
174 112
 
175
-    line3 = lv_line_create(scr, NULL);
176
-    lv_ex_line(line3, line_points[2]);
113
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
114
+    lv_screen_menu_item_1_edit(scr, machine_menu.E0_Steps, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_STEP_E0, 3, public_buf_l);
177 115
 
178
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0_Steps);
179
-
180
-    buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_E0);
181
-    labelE0Value = lv_label_create_empty(buttonE0Value);
182
-
183
-    line4 = lv_line_create(scr, NULL);
184
-    lv_ex_line(line4, line_points[3]);
185
-
186
-    buttonTurnPage = lv_btn_create(scr, event_handler, ID_STEP_DOWN);
187
-
188
-    #if HAS_ROTARY_ENCODER
189
-      if (gCfgItems.encoder_enable) {
190
-        lv_group_add_obj(g, buttonXValue);
191
-        lv_group_add_obj(g, buttonYValue);
192
-        lv_group_add_obj(g, buttonZValue);
193
-        lv_group_add_obj(g, buttonE0Value);
194
-        lv_group_add_obj(g, buttonTurnPage);
195
-      }
196
-    #endif
116
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_DOWN, true);
197 117
   }
198 118
   else {
199
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1_Steps);
200
-
201
-    buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_STEP_E1);
202
-    labelE1Value = lv_label_create_empty(buttonE1Value);
119
+    sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
120
+    lv_screen_menu_item_1_edit(scr, machine_menu.E1_Steps, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_STEP_E1, 0, public_buf_l);
203 121
 
204
-    line1 = lv_line_create(scr, NULL);
205
-    lv_ex_line(line1, line_points[0]);
206
-
207
-    buttonTurnPage = lv_btn_create(scr, event_handler, ID_STEP_UP);
208
-
209
-    #if HAS_ROTARY_ENCODER
210
-      if (gCfgItems.encoder_enable) {
211
-        lv_group_add_obj(g, buttonE1Value);
212
-        lv_group_add_obj(g, buttonTurnPage);
213
-      }
214
-    #endif
122
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_STEP_UP, true);
215 123
   }
216 124
 
217
-  lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
218
-  lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
219
-  labelTurnPage = lv_label_create_empty(buttonTurnPage);
220
-
221
-  buttonBack = lv_btn_create(scr, NULL);
222
-  lv_btn_set_style_both(buttonBack, &style_para_back);
223
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
224
-  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
225
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_STEP_RETURN, NULL, 0);
226
-  label_Back = lv_label_create_empty(buttonBack);
227
-  #if HAS_ROTARY_ENCODER
228
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
229
-  #endif
230
-
231
-  if (gCfgItems.multiple_language) {
232
-    if (uiCfg.para_ui_page != 1) {
233
-      lv_label_set_text(labelTurnPage, machine_menu.next);
234
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
235
-
236
-      ZERO(public_buf_l);
237
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[X_AXIS]);
238
-      lv_label_set_text(labelXValue, public_buf_l);
239
-      lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
240
-
241
-      ZERO(public_buf_l);
242
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Y_AXIS]);
243
-      lv_label_set_text(labelYValue, public_buf_l);
244
-      lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
245
-
246
-      ZERO(public_buf_l);
247
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[Z_AXIS]);
248
-      lv_label_set_text(labelZValue, public_buf_l);
249
-      lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
250
-
251
-      ZERO(public_buf_l);
252
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS]);
253
-      lv_label_set_text(labelE0Value, public_buf_l);
254
-      lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
255
-    }
256
-    else {
257
-      lv_label_set_text(labelTurnPage, machine_menu.previous);
258
-      lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
259
-
260
-      ZERO(public_buf_l);
261
-      sprintf_P(public_buf_l, PSTR("%.1f"), planner.settings.axis_steps_per_mm[E_AXIS_N(1)]);
262
-      lv_label_set_text(labelE1Value, public_buf_l);
263
-      lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
264
-    }
265
-
266
-    lv_label_set_text(label_Back, common_menu.text_back);
267
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
268
-  }
125
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_STEP_RETURN, true);
269 126
 }
270 127
 
271 128
 void lv_clear_step_settings() {

+ 79
- 245
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_current_settings.cpp View File

@@ -30,304 +30,138 @@
30 30
 #include "../../../../feature/tmc_util.h"
31 31
 #include "../../../../inc/MarlinConfig.h"
32 32
 
33
-extern lv_group_t * g;
34
-static lv_obj_t * scr;
35
-
36
-#define ID_TMC_CURRENT_RETURN 1
37
-#define ID_TMC_CURRENT_X      2
38
-#define ID_TMC_CURRENT_Y      3
39
-#define ID_TMC_CURRENT_Z      4
40
-#define ID_TMC_CURRENT_E0     5
41
-#define ID_TMC_CURRENT_E1     6
42
-#define ID_TMC_CURRENT_DOWN   7
43
-#define ID_TMC_CURRENT_UP     8
44
-
45
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
33
+extern lv_group_t *g;
34
+static lv_obj_t *scr;
35
+
36
+enum {
37
+  ID_TMC_CURRENT_RETURN = 1,
38
+  ID_TMC_CURRENT_X,
39
+  ID_TMC_CURRENT_Y,
40
+  ID_TMC_CURRENT_Z,
41
+  ID_TMC_CURRENT_E0,
42
+  ID_TMC_CURRENT_E1,
43
+  ID_TMC_CURRENT_DOWN,
44
+  ID_TMC_CURRENT_UP
45
+};
46
+
47
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
48
+  if (event != LV_EVENT_RELEASED) return;
46 49
   switch (obj->mks_obj_id) {
47 50
     case ID_TMC_CURRENT_RETURN:
48
-      if (event == LV_EVENT_CLICKED) {
49
-
50
-      }
51
-      else if (event == LV_EVENT_RELEASED) {
52
-        uiCfg.para_ui_page = 0;
53
-        lv_clear_tmc_current_settings();
54
-        draw_return_ui();
55
-      }
51
+      uiCfg.para_ui_page = 0;
52
+      lv_clear_tmc_current_settings();
53
+      draw_return_ui();
56 54
       break;
55
+
57 56
     #if AXIS_IS_TMC(X)
58 57
       case ID_TMC_CURRENT_X:
59
-        if (event == LV_EVENT_CLICKED) {
60
-
61
-        }
62
-        else if (event == LV_EVENT_RELEASED) {
63
-          value = Xcurrent;
64
-          lv_clear_tmc_current_settings();
65
-          lv_draw_number_key();
66
-        }
58
+        value = Xcurrent;
59
+        lv_clear_tmc_current_settings();
60
+        lv_draw_number_key();
67 61
         break;
68 62
     #endif
69
-
70 63
     #if AXIS_IS_TMC(Y)
71
-    case ID_TMC_CURRENT_Y:
72
-      if (event == LV_EVENT_CLICKED) {
73
-
74
-      }
75
-      else if (event == LV_EVENT_RELEASED) {
64
+      case ID_TMC_CURRENT_Y:
76 65
         value = Ycurrent;
77 66
         lv_clear_tmc_current_settings();
78 67
         lv_draw_number_key();
79
-      }
80
-      break;
68
+        break;
81 69
     #endif
82
-
83 70
     #if AXIS_IS_TMC(Z)
84
-    case ID_TMC_CURRENT_Z:
85
-      if (event == LV_EVENT_CLICKED) {
86
-
87
-      }
88
-      else if (event == LV_EVENT_RELEASED) {
71
+      case ID_TMC_CURRENT_Z:
89 72
         value = Zcurrent;
90 73
         lv_clear_tmc_current_settings();
91 74
         lv_draw_number_key();
92
-      }
93
-      break;
75
+        break;
94 76
     #endif
95
-
96 77
     #if AXIS_IS_TMC(E0)
97 78
       case ID_TMC_CURRENT_E0:
98
-        if (event == LV_EVENT_CLICKED) {
99
-
100
-        }
101
-        else if (event == LV_EVENT_RELEASED) {
102
-          value = E0current;
103
-          lv_clear_tmc_current_settings();
104
-          lv_draw_number_key();
105
-        }
79
+        value = E0current;
80
+        lv_clear_tmc_current_settings();
81
+        lv_draw_number_key();
106 82
         break;
107 83
     #endif
108
-
109 84
     #if AXIS_IS_TMC(E1)
110 85
       case ID_TMC_CURRENT_E1:
111
-        if (event == LV_EVENT_CLICKED) {
112
-
113
-        }
114
-        else if (event == LV_EVENT_RELEASED) {
115
-          value = E1current;
116
-          lv_clear_tmc_current_settings();
117
-          lv_draw_number_key();
118
-        }
86
+        value = E1current;
87
+        lv_clear_tmc_current_settings();
88
+        lv_draw_number_key();
119 89
         break;
120 90
     #endif
121
-    case ID_TMC_CURRENT_UP:
122
-      if (event == LV_EVENT_CLICKED) {
123 91
 
124
-      }
125
-      else if (event == LV_EVENT_RELEASED) {
126
-        uiCfg.para_ui_page = 0;
127
-        lv_clear_tmc_current_settings();
128
-        lv_draw_tmc_current_settings();
129
-      }
92
+    case ID_TMC_CURRENT_UP:
93
+      uiCfg.para_ui_page = 0;
94
+      lv_clear_tmc_current_settings();
95
+      lv_draw_tmc_current_settings();
130 96
       break;
131 97
     case ID_TMC_CURRENT_DOWN:
132
-      if (event == LV_EVENT_CLICKED) {
133
-
134
-      }
135
-      else if (event == LV_EVENT_RELEASED) {
136
-        uiCfg.para_ui_page = 1;
137
-        lv_clear_tmc_current_settings();
138
-        lv_draw_tmc_current_settings();
139
-      }
98
+      uiCfg.para_ui_page = 1;
99
+      lv_clear_tmc_current_settings();
100
+      lv_draw_tmc_current_settings();
140 101
       break;
141 102
   }
142 103
 }
143 104
 
144 105
 void lv_draw_tmc_current_settings(void) {
145
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
146
-  lv_obj_t *buttonXValue = NULL, *labelXValue = NULL;
147
-  lv_obj_t *buttonYValue = NULL, *labelYValue = NULL;
148
-  lv_obj_t *buttonZValue = NULL, *labelZValue = NULL;
149
-  lv_obj_t *buttonE0Value = NULL, *labelE0Value = NULL;
150
-
151
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
152
-  //#if AXIS_IS_TMC(E1)
153
-    lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
154
-    lv_obj_t *labelE1Text = NULL, *buttonE1Value = NULL, *labelE1Value = NULL;
155
-  //#endif
156
-  float milliamps;
157
-
158 106
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_CURRENT_UI) {
159 107
     disp_state_stack._disp_index++;
160 108
     disp_state_stack._disp_state[disp_state_stack._disp_index] = TMC_CURRENT_UI;
161 109
   }
162 110
   disp_state = TMC_CURRENT_UI;
163 111
 
164
-  scr = lv_obj_create(NULL, NULL);
165
-
166
-  lv_obj_set_style(scr, &tft_style_scr);
167
-  lv_scr_load(scr);
168
-  lv_obj_clean(scr);
169
-
112
+  scr = lv_screen_create();
170 113
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcCurrentConfTitle);
171
-
172 114
   lv_refr_now(lv_refr_get_disp_refreshing());
173 115
 
116
+  float milliamps;
174 117
   if (uiCfg.para_ui_page != 1) {
175
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.X_Current);
176
-
177
-    buttonXValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_X);
178
-    labelXValue = lv_label_create_empty(buttonXValue);
179
-
180
-    line1 = lv_line_create(scr, NULL);
181
-    lv_ex_line(line1, line_points[0]);
182
-
183
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, machine_menu.Y_Current);
184
-
185
-    buttonYValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_Y);
186
-    labelYValue = lv_label_create_empty(buttonYValue);
187
-
188
-    line2 = lv_line_create(scr, NULL);
189
-    lv_ex_line(line2, line_points[1]);
190
-
191
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, machine_menu.Z_Current);
192
-
193
-    buttonZValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_Z);
194
-    labelZValue = lv_label_create_empty(buttonZValue);
195
-
196
-    line3 = lv_line_create(scr, NULL);
197
-    lv_ex_line(line3, line_points[2]);
198
-
199
-    (void)lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.E0_Current);
200
-
201
-    buttonE0Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_E0);
202
-    labelE0Value = lv_label_create_empty(buttonE0Value);
118
+    #if AXIS_IS_TMC(X)
119
+      milliamps = stepperX.getMilliamps();
120
+    #else
121
+      milliamps = -1;
122
+    #endif
123
+    sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
124
+    lv_screen_menu_item_1_edit(scr, machine_menu.X_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_X, 0, public_buf_l);
203 125
 
204
-    #if HAS_ROTARY_ENCODER
205
-      if (gCfgItems.encoder_enable) {
206
-        lv_group_add_obj(g, buttonXValue);
207
-        lv_group_add_obj(g, buttonYValue);
208
-        lv_group_add_obj(g, buttonZValue);
209
-        lv_group_add_obj(g, buttonE0Value);
210
-      }
126
+    #if AXIS_IS_TMC(Y)
127
+      milliamps = stepperY.getMilliamps();
128
+    #else
129
+      milliamps = -1;
211 130
     #endif
131
+    sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
132
+    lv_screen_menu_item_1_edit(scr, machine_menu.Y_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_CURRENT_Y, 1, public_buf_l);
212 133
 
213
-    line4 = lv_line_create(scr, NULL);
214
-    lv_ex_line(line4, line_points[3]);
134
+    #if AXIS_IS_TMC(Z)
135
+      milliamps = stepperZ.getMilliamps();
136
+    #else
137
+      milliamps = -1;
138
+    #endif
139
+    sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
140
+    lv_screen_menu_item_1_edit(scr, machine_menu.Z_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_CURRENT_Z, 2, public_buf_l);
215 141
 
216
-    //#if AXIS_IS_TMC(E1)
217
-      buttonTurnPage = lv_btn_create(scr, NULL);
218
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_DOWN, NULL, 0);
219
-      lv_btn_set_style_both(buttonTurnPage, &style_para_back);
142
+    #if AXIS_IS_TMC(E0)
143
+      milliamps = stepperE0.getMilliamps();
144
+    #else
145
+      milliamps = -1;
146
+    #endif
147
+    sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
148
+    lv_screen_menu_item_1_edit(scr, machine_menu.E0_Current, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_CURRENT_E0, 3, public_buf_l);
220 149
 
221
-      #if HAS_ROTARY_ENCODER
222
-        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
223
-      #endif
224
-    //#endif
150
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_DOWN, true);
225 151
   }
226 152
   else {
227
-    //#if AXIS_IS_TMC(E1)
228
-      labelE1Text = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.E1_Current);
229
-
230
-      buttonE1Value = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_TMC_CURRENT_E1);
231
-      labelE1Value = lv_label_create_empty(buttonE1Value);
232
-
233
-      line1 = lv_line_create(scr, NULL);
234
-      lv_ex_line(line1, line_points[0]);
235
-
236
-      buttonTurnPage = lv_btn_create(scr, NULL);
237
-      lv_obj_set_event_cb_mks(buttonTurnPage, event_handler, ID_TMC_CURRENT_UP, NULL, 0);
238
-      lv_btn_set_style_both(buttonTurnPage, &style_para_back);
153
+    #if AXIS_IS_TMC(E1)
154
+      milliamps = stepperE1.getMilliamps();
155
+    #else
156
+      milliamps = -1;
157
+    #endif
158
+    sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
159
+    lv_screen_menu_item_1_edit(scr, machine_menu.E1_Current, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_CURRENT_E1, 0, public_buf_l);
239 160
 
240
-      #if HAS_ROTARY_ENCODER
241
-        if (gCfgItems.encoder_enable) {
242
-          lv_group_add_obj(g, buttonE1Value);
243
-          lv_group_add_obj(g, buttonTurnPage);
244
-        }
245
-      #endif
246
-    //#endif
161
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_CURRENT_UP, true);
247 162
   }
248
-  //#if AXIS_IS_TMC(E1)
249
-    lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
250
-    lv_obj_set_size(buttonTurnPage, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
251
-    labelTurnPage = lv_label_create_empty(buttonTurnPage);
252
-  //#endif
253 163
 
254
-  buttonBack = lv_btn_create(scr, NULL);
255
-  lv_obj_set_event_cb_mks(buttonBack, event_handler, ID_TMC_CURRENT_RETURN, NULL, 0);
256
-  lv_btn_set_style_both(buttonBack, &style_para_back);
257
-
258
-  #if HAS_ROTARY_ENCODER
259
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
260
-  #endif
261
-
262
-  lv_obj_set_pos(buttonBack, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y);
263
-  lv_obj_set_size(buttonBack, PARA_UI_BACK_BTN_X_SIZE, PARA_UI_BACK_BTN_Y_SIZE);
264
-  label_Back = lv_label_create_empty(buttonBack);
265
-
266
-  if (gCfgItems.multiple_language) {
267
-    if (uiCfg.para_ui_page != 1) {
268
-      //#if AXIS_IS_TMC(E1)
269
-        lv_label_set_text(labelTurnPage, machine_menu.next);
270
-        lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
271
-      //#endif
272
-      #if AXIS_IS_TMC(X)
273
-        milliamps = stepperX.getMilliamps();
274
-      #else
275
-        milliamps = -1;
276
-      #endif
277
-      ZERO(public_buf_l);
278
-      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
279
-      lv_label_set_text(labelXValue, public_buf_l);
280
-      lv_obj_align(labelXValue, buttonXValue, LV_ALIGN_CENTER, 0, 0);
281
-
282
-      #if AXIS_IS_TMC(Y)
283
-        milliamps = stepperY.getMilliamps();
284
-      #else
285
-        milliamps = -1;
286
-      #endif
287
-      ZERO(public_buf_l);
288
-      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
289
-      lv_label_set_text(labelYValue, public_buf_l);
290
-      lv_obj_align(labelYValue, buttonYValue, LV_ALIGN_CENTER, 0, 0);
291
-
292
-      #if AXIS_IS_TMC(Z)
293
-        milliamps = stepperZ.getMilliamps();
294
-      #else
295
-        milliamps = -1;
296
-      #endif
297
-      ZERO(public_buf_l);
298
-      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
299
-      lv_label_set_text(labelZValue, public_buf_l);
300
-      lv_obj_align(labelZValue, buttonZValue, LV_ALIGN_CENTER, 0, 0);
301
-
302
-      #if AXIS_IS_TMC(E0)
303
-        milliamps = stepperE0.getMilliamps();
304
-      #else
305
-        milliamps = -1;
306
-      #endif
307
-      ZERO(public_buf_l);
308
-      sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
309
-      lv_label_set_text(labelE0Value, public_buf_l);
310
-      lv_obj_align(labelE0Value, buttonE0Value, LV_ALIGN_CENTER, 0, 0);
311
-    }
312
-    else {
313
-      //#if AXIS_IS_TMC(E1)
314
-        lv_label_set_text(labelTurnPage, machine_menu.previous);
315
-        lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
316
-        #if AXIS_IS_TMC(E1)
317
-          milliamps = stepperE1.getMilliamps();
318
-        #else
319
-          milliamps = -1;
320
-        #endif
321
-        ZERO(public_buf_l);
322
-        sprintf_P(public_buf_l, PSTR("%.1f"), milliamps);
323
-        lv_label_set_text(labelE1Value, public_buf_l);
324
-        lv_obj_align(labelE1Value, buttonE1Value, LV_ALIGN_CENTER, 0, 0);
325
-      //#endif
326
-    }
327
-
328
-    lv_label_set_text(label_Back, common_menu.text_back);
329
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
330
-  }
164
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_CURRENT_RETURN, true);
331 165
 }
332 166
 
333 167
 void lv_clear_tmc_current_settings() {

+ 55
- 281
Marlin/src/lcd/extui/lib/mks_ui/draw_tmc_step_mode_settings.cpp View File

@@ -34,185 +34,83 @@
34 34
   #include "../../../../module/settings.h"
35 35
 #endif
36 36
 
37
-extern lv_group_t * g;
38
-static lv_obj_t * scr;
39
-
40
-#define ID_TMC_MODE_RETURN 1
41
-#define ID_TMC_MODE_X      2
42
-#define ID_TMC_MODE_Y      3
43
-#define ID_TMC_MODE_Z      4
44
-#define ID_TMC_MODE_E0     5
45
-#define ID_TMC_MODE_E1     6
46
-#define ID_TMC_MODE_DOWN   7
47
-#define ID_TMC_MODE_UP     8
48
-
49
-static lv_obj_t *labelXState = NULL, *labelYState = NULL, *labelZState = NULL, *labelE0State = NULL;
50
-static lv_obj_t *buttonXState = NULL, *buttonYState = NULL, *buttonZState = NULL, *buttonE0State = NULL;
37
+extern lv_group_t *g;
38
+static lv_obj_t *scr;
39
+
40
+enum {
41
+  ID_TMC_MODE_RETURN = 1,
42
+  ID_TMC_MODE_X,
43
+  ID_TMC_MODE_Y,
44
+  ID_TMC_MODE_Z,
45
+  ID_TMC_MODE_E0,
46
+  ID_TMC_MODE_E1,
47
+  ID_TMC_MODE_DOWN,
48
+  ID_TMC_MODE_UP
49
+};
50
+
51
+static lv_obj_t *buttonXState = nullptr, *buttonYState = nullptr, *buttonZState = nullptr, *buttonE0State = nullptr;
51 52
 
52 53
 //#if AXIS_HAS_STEALTHCHOP(E1)
53
-  static lv_obj_t *labelE1State = NULL, *buttonE1State = NULL;
54
+  static lv_obj_t *buttonE1State = nullptr;
54 55
 //#endif
55 56
 
56
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
57
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
58
+  if (event != LV_EVENT_RELEASED) return;
59
+
60
+  auto toggle_chop = [&](auto &stepper, auto &button) {
61
+    const bool isena = stepper.toggle_stepping_mode();
62
+    lv_screen_menu_item_onoff_update(button, isena);
63
+    TERN_(EEPROM_SETTINGS, (void)settings.save());
64
+  };
65
+
57 66
   switch (obj->mks_obj_id) {
58 67
     case ID_TMC_MODE_RETURN:
59
-      if (event == LV_EVENT_CLICKED) {
60
-
61
-      }
62
-      else if (event == LV_EVENT_RELEASED) {
63
-        uiCfg.para_ui_page = 0;
64
-        lv_clear_tmc_step_mode_settings();
65
-        draw_return_ui();
66
-      }
68
+      uiCfg.para_ui_page = 0;
69
+      lv_clear_tmc_step_mode_settings();
70
+      draw_return_ui();
67 71
       break;
68 72
 
69 73
     #if AXIS_HAS_STEALTHCHOP(X)
70 74
       case ID_TMC_MODE_X:
71
-        if (event == LV_EVENT_CLICKED) {
72
-
73
-        }
74
-        else if (event == LV_EVENT_RELEASED) {
75
-          if (stepperX.toggle_stepping_mode()) {
76
-            lv_imgbtn_set_src_both(buttonXState, "F:/bmp_enable.bin");
77
-            lv_label_set_text(labelXState, machine_menu.enable);
78
-          }
79
-          else {
80
-            lv_imgbtn_set_src_both(buttonXState, "F:/bmp_disable.bin");
81
-            lv_label_set_text(labelXState, machine_menu.disable);
82
-            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
83
-          }
84
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
85
-        }
75
+        toggle_chop(stepperX, buttonXState);
86 76
         break;
87
-    #endif // if AXIS_HAS_STEALTHCHOP(X)
88
-
77
+    #endif
89 78
     #if AXIS_HAS_STEALTHCHOP(Y)
90 79
       case ID_TMC_MODE_Y:
91
-        if (event == LV_EVENT_CLICKED) {
92
-
93
-        }
94
-        else if (event == LV_EVENT_RELEASED) {
95
-          if (stepperY.toggle_stepping_mode()) {
96
-            lv_imgbtn_set_src_both(buttonYState, "F:/bmp_enable.bin");
97
-            lv_label_set_text(labelYState, machine_menu.enable);
98
-          }
99
-          else {
100
-            lv_imgbtn_set_src_both(buttonYState, "F:/bmp_disable.bin");
101
-            lv_label_set_text(labelYState, machine_menu.disable);
102
-            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
103
-          }
104
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
105
-        }
80
+        toggle_chop(stepperY, buttonYState);
106 81
         break;
107
-    #endif // if AXIS_HAS_STEALTHCHOP(Y)
108
-
82
+    #endif
109 83
     #if AXIS_HAS_STEALTHCHOP(Z)
110 84
       case ID_TMC_MODE_Z:
111
-        if (event == LV_EVENT_CLICKED) {
112
-
113
-        }
114
-        else if (event == LV_EVENT_RELEASED) {
115
-          if (stepperZ.toggle_stepping_mode()) {
116
-            lv_imgbtn_set_src_both(buttonZState, "F:/bmp_enable.bin");
117
-            lv_label_set_text(labelZState, machine_menu.enable);
118
-          }
119
-          else {
120
-            lv_imgbtn_set_src_both(buttonZState, "F:/bmp_disable.bin");
121
-            lv_label_set_text(labelZState, machine_menu.disable);
122
-            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
123
-          }
124
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
125
-        }
85
+        toggle_chop(stepperZ, buttonZState);
126 86
         break;
127
-    #endif // if AXIS_HAS_STEALTHCHOP(Z)
128
-
87
+    #endif
129 88
     #if AXIS_HAS_STEALTHCHOP(E0)
130 89
       case ID_TMC_MODE_E0:
131
-        if (event == LV_EVENT_CLICKED) {
132
-
133
-        }
134
-        else if (event == LV_EVENT_RELEASED) {
135
-          if (stepperE0.toggle_stepping_mode()) {
136
-            lv_imgbtn_set_src_both(buttonE0State, "F:/bmp_enable.bin");
137
-            lv_label_set_text(labelE0State, machine_menu.enable);
138
-          }
139
-          else {
140
-            lv_imgbtn_set_src_both(buttonE0State, "F:/bmp_disable.bin");
141
-            lv_label_set_text(labelE0State, machine_menu.disable);
142
-            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
143
-          }
144
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
145
-        }
90
+        toggle_chop(stepperE0, buttonE0State);
146 91
         break;
147
-    #endif // if AXIS_HAS_STEALTHCHOP(E0)
148
-
92
+    #endif
149 93
     #if AXIS_HAS_STEALTHCHOP(E1)
150 94
       case ID_TMC_MODE_E1:
151
-        if (event == LV_EVENT_CLICKED) {
152
-
153
-        }
154
-        else if (event == LV_EVENT_RELEASED) {
155
-          if (stepperE1.toggle_stepping_mode()) {
156
-            lv_imgbtn_set_src_both(buttonE1State, "F:/bmp_enable.bin");
157
-            lv_label_set_text(labelE1State, machine_menu.enable);
158
-          }
159
-          else {
160
-            lv_imgbtn_set_src_both(buttonE1State, "F:/bmp_disable.bin");
161
-            lv_label_set_text(labelE1State, machine_menu.disable);
162
-            //lv_obj_align(labelXState, buttonE1State, LV_ALIGN_IN_LEFT_MID,0, 0);
163
-          }
164
-          TERN_(EEPROM_SETTINGS, (void)settings.save());
165
-        }
95
+        toggle_chop(stepperE1, buttonE1State);
166 96
         break;
167
-    #endif // if AXIS_HAS_STEALTHCHOP(E1)
168
-    case ID_TMC_MODE_UP:
169
-      if (event == LV_EVENT_CLICKED) {
97
+    #endif
170 98
 
171
-      }
172
-      else if (event == LV_EVENT_RELEASED) {
173
-        uiCfg.para_ui_page = 0;
174
-        lv_clear_tmc_step_mode_settings();
175
-        lv_draw_tmc_step_mode_settings();
176
-      }
99
+    case ID_TMC_MODE_UP:
100
+      uiCfg.para_ui_page = 0;
101
+      lv_clear_tmc_step_mode_settings();
102
+      lv_draw_tmc_step_mode_settings();
177 103
       break;
178 104
     case ID_TMC_MODE_DOWN:
179
-      if (event == LV_EVENT_CLICKED) {
180
-
181
-      }
182
-      else if (event == LV_EVENT_RELEASED) {
183
-        uiCfg.para_ui_page = 1;
184
-        lv_clear_tmc_step_mode_settings();
185
-        lv_draw_tmc_step_mode_settings();
186
-      }
105
+      uiCfg.para_ui_page = 1;
106
+      lv_clear_tmc_step_mode_settings();
107
+      lv_draw_tmc_step_mode_settings();
187 108
       break;
188 109
   }
189 110
 }
190 111
 
191 112
 void lv_draw_tmc_step_mode_settings(void) {
192
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
193
-  lv_obj_t *buttonXText = NULL, *labelXText = NULL;
194
-  lv_obj_t *buttonYText = NULL, *labelYText = NULL;
195
-  lv_obj_t *buttonZText = NULL, *labelZText = NULL;
196
-  lv_obj_t *buttonE0Text = NULL, *labelE0Text = NULL;
197
-
198
-  lv_obj_t * line1 = NULL, * line2 = NULL, * line3 = NULL, * line4 = NULL;
199
-  //#if AXIS_HAS_STEALTHCHOP(E1)
200
-    lv_obj_t *buttonTurnPage = NULL, *labelTurnPage = NULL;
201
-    lv_obj_t *buttonE1Text = NULL, *labelE1Text = NULL;
202
-  //#endif
203
-
204
-  labelXState   = NULL;
205
-  buttonXState  = NULL;
206
-  labelYState   = NULL;
207
-  buttonYState  = NULL;
208
-  labelZState   = NULL;
209
-  buttonZState  = NULL;
210
-  labelE0State  = NULL;
211
-  buttonE0State = NULL;
212
-  //#if AXIS_HAS_STEALTHCHOP(E1)
213
-    labelE1State  = NULL;
214
-    buttonE1State = NULL;
215
-  //#endif
113
+  buttonXState = buttonYState = buttonZState = buttonE0State = buttonE1State = nullptr;
216 114
 
217 115
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TMC_MODE_UI) {
218 116
     disp_state_stack._disp_index++;
@@ -220,14 +118,8 @@ void lv_draw_tmc_step_mode_settings(void) {
220 118
   }
221 119
   disp_state = TMC_MODE_UI;
222 120
 
223
-  scr = lv_obj_create(NULL, NULL);
224
-
225
-  lv_obj_set_style(scr, &tft_style_scr);
226
-  lv_scr_load(scr);
227
-  lv_obj_clean(scr);
228
-
121
+  scr = lv_screen_create();
229 122
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.TmcStepModeConfTitle);
230
-
231 123
   lv_refr_now(lv_refr_get_disp_refreshing());
232 124
 
233 125
   bool stealth_X = false, stealth_Y = false, stealth_Z = false, stealth_E0 = false, stealth_E1 = false;
@@ -248,136 +140,18 @@ void lv_draw_tmc_step_mode_settings(void) {
248 140
   #endif
249 141
 
250 142
   if (uiCfg.para_ui_page != 1) {
251
-    buttonXText = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
252
-    labelXText = lv_label_create_empty(buttonXText);                        /*Add a label to the button*/
253
-
254
-    buttonXState = lv_imgbtn_create(scr, stealth_X ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_X);
255
-    labelXState = lv_label_create_empty(buttonXState);
256
-    #if HAS_ROTARY_ENCODER
257
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonXState);
258
-    #endif
259
-
260
-    line1 = lv_line_create(scr, NULL);
261
-    lv_ex_line(line1, line_points[0]);
262
-
263
-    buttonYText = lv_btn_create(scr, NULL, PARA_UI_POS_X, PARA_UI_POS_Y * 2, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
264
-    labelYText = lv_label_create_empty(buttonYText);                        /*Add a label to the button*/
265
-
266
-    buttonYState = lv_imgbtn_create(scr, stealth_Y ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_Y);
267
-    labelYState = lv_label_create_empty(buttonYState);
268
-    #if HAS_ROTARY_ENCODER
269
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonYState);
270
-    #endif
271
-
272
-    line2 = lv_line_create(scr, NULL);
273
-    lv_ex_line(line2, line_points[1]);
274
-
275
-    buttonZText = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
276
-    labelZText = lv_label_create_empty(buttonZText);                        /*Add a label to the button*/
277
-
278
-    buttonZState = lv_imgbtn_create(scr, stealth_Z ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_Z);
279
-    labelZState = lv_label_create_empty(buttonZState);
280
-    #if HAS_ROTARY_ENCODER
281
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonZState);
282
-    #endif
283
-
284
-    line3 = lv_line_create(scr, NULL);
285
-    lv_ex_line(line3, line_points[2]);
286
-
287
-    buttonE0Text = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
288
-    labelE0Text = lv_label_create_empty(buttonE0Text);                      /*Add a label to the button*/
289
-
290
-    buttonE0State = lv_imgbtn_create(scr, stealth_E0 ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_E0);
291
-    labelE0State = lv_label_create_empty(buttonE0State);
292
-    #if HAS_ROTARY_ENCODER
293
-      if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE0State);
294
-    #endif
295
-
296
-    line4 = lv_line_create(scr, NULL);
297
-    lv_ex_line(line4, line_points[3]);
298
-
299
-    //#if AXIS_HAS_STEALTHCHOP(E1)
300
-      buttonTurnPage = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_TMC_MODE_DOWN);
301
-      #if HAS_ROTARY_ENCODER
302
-        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonTurnPage);
303
-      #endif
304
-    //#endif
143
+    buttonXState = lv_screen_menu_item_onoff(scr, machine_menu.X_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_X, 0, stealth_X);
144
+    buttonYState = lv_screen_menu_item_onoff(scr, machine_menu.Y_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_TMC_MODE_Y, 1, stealth_Y);
145
+    buttonZState = lv_screen_menu_item_onoff(scr, machine_menu.Z_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_TMC_MODE_Z, 2, stealth_Z);
146
+    buttonE0State = lv_screen_menu_item_onoff(scr, machine_menu.E0_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_TMC_MODE_E0, 2, stealth_E0);
147
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.next, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_DOWN, true);
305 148
   }
306 149
   else {
307
-    //#if AXIS_HAS_STEALTHCHOP(E1)
308
-      buttonE1Text = lv_btn_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y, PARA_UI_VALUE_SIZE_X, PARA_UI_SIZE_Y, event_handler, 0);
309
-      labelE1Text = lv_label_create_empty(buttonE1Text);                      /*Add a label to the button*/
310
-
311
-      buttonE1State = lv_imgbtn_create(scr, stealth_E1 ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y + PARA_UI_STATE_V, event_handler, ID_TMC_MODE_E1);
312
-      labelE1State = lv_label_create_empty(buttonE1State);
313
-      #if HAS_ROTARY_ENCODER
314
-        if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonE1State);
315
-      #endif
316
-
317
-      line1 = lv_line_create(scr, NULL);
318
-      lv_ex_line(line1, line_points[0]);
319
-
320
-      buttonTurnPage = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", event_handler, ID_TMC_MODE_UP);
321
-    //#endif
150
+    buttonE1State = lv_screen_menu_item_onoff(scr, machine_menu.E1_StepMode, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_TMC_MODE_E1, 0, stealth_E1);
151
+    lv_big_button_create(scr, "F:/bmp_back70x40.bin", machine_menu.previous, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_TMC_MODE_UP, true);
322 152
   }
323
-  //#if AXIS_HAS_STEALTHCHOP(E1)
324
-    lv_obj_set_pos(buttonTurnPage, PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y);
325
-    lv_btn_set_layout(buttonTurnPage, LV_LAYOUT_OFF);
326
-    labelTurnPage = lv_label_create_empty(buttonTurnPage);
327
-  //#endif
328
-
329
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_MODE_RETURN);
330
-  #if HAS_ROTARY_ENCODER
331
-    if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
332
-  #endif
333
-  label_Back = lv_label_create_empty(buttonBack);
334
-
335
-  if (gCfgItems.multiple_language) {
336
-    if (uiCfg.para_ui_page != 1) {
337
-      lv_label_set_text(labelXText, machine_menu.X_StepMode);
338
-      lv_obj_align(labelXText, buttonXText, LV_ALIGN_IN_LEFT_MID, 0, 0);
339
-
340
-      lv_label_set_text(labelYText, machine_menu.Y_StepMode);
341
-      lv_obj_align(labelYText, buttonYText, LV_ALIGN_IN_LEFT_MID, 0, 0);
342
-
343
-      lv_label_set_text(labelZText, machine_menu.Z_StepMode);
344
-      lv_obj_align(labelZText, buttonZText, LV_ALIGN_IN_LEFT_MID, 0, 0);
345
-
346
-      lv_label_set_text(labelE0Text, machine_menu.E0_StepMode);
347
-      lv_obj_align(labelE0Text, buttonE0Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
348 153
 
349
-      lv_label_set_text(labelXState, stealth_X ? machine_menu.enable : machine_menu.disable);
350
-      lv_obj_align(labelXState, buttonXState, LV_ALIGN_CENTER, 0, 0);
351
-
352
-      lv_label_set_text(labelYState, stealth_Y ? machine_menu.enable : machine_menu.disable);
353
-      lv_obj_align(labelYState, buttonYState, LV_ALIGN_CENTER, 0, 0);
354
-
355
-      lv_label_set_text(labelZState, stealth_Z ? machine_menu.enable : machine_menu.disable);
356
-      lv_obj_align(labelZState, buttonZState, LV_ALIGN_CENTER, 0, 0);
357
-
358
-      lv_label_set_text(labelE0State, stealth_E0 ? machine_menu.enable : machine_menu.disable);
359
-      lv_obj_align(labelE0State, buttonE0State, LV_ALIGN_CENTER, 0, 0);
360
-
361
-      //#if AXIS_HAS_STEALTHCHOP(E1)
362
-        lv_label_set_text(labelTurnPage, machine_menu.next);
363
-        lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
364
-      //#endif
365
-    }
366
-    else {
367
-      //#if AXIS_HAS_STEALTHCHOP(E1)
368
-        lv_label_set_text(labelE1Text, machine_menu.E1_StepMode);
369
-        lv_obj_align(labelE1Text, buttonE1Text, LV_ALIGN_IN_LEFT_MID, 0, 0);
370
-        lv_label_set_text(labelE1State, stealth_E1 ? machine_menu.enable : machine_menu.disable);
371
-        lv_obj_align(labelE1State, buttonE1State, LV_ALIGN_CENTER, 0, 0);
372
-
373
-        lv_label_set_text(labelTurnPage, machine_menu.previous);
374
-        lv_obj_align(labelTurnPage, buttonTurnPage, LV_ALIGN_CENTER, 0, 0);
375
-      //#endif
376
-    }
377
-
378
-    lv_label_set_text(label_Back, common_menu.text_back);
379
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_CENTER, 0, 0);
380
-  }
154
+  lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_TMC_MODE_RETURN, true);
381 155
 }
382 156
 
383 157
 void lv_clear_tmc_step_mode_settings() {

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

@@ -34,182 +34,92 @@
34 34
 #include "../../../../module/temperature.h"
35 35
 #include "../../../../inc/MarlinConfig.h"
36 36
 
37
-extern lv_group_t * g;
38
-static lv_obj_t * scr;
39
-
40
-#define ID_T_PRE_HEAT   1
41
-#define ID_T_EXTRUCT    2
42
-#define ID_T_MOV        3
43
-#define ID_T_HOME       4
44
-#define ID_T_LEVELING   5
45
-#define ID_T_FILAMENT   6
46
-#define ID_T_MORE       7
47
-#define ID_T_RETURN     8
37
+extern lv_group_t *g;
38
+static lv_obj_t *scr;
39
+
40
+enum {
41
+  ID_T_PRE_HEAT = 1,
42
+  ID_T_EXTRUCT,
43
+  ID_T_MOV,
44
+  ID_T_HOME,
45
+  ID_T_LEVELING,
46
+  ID_T_FILAMENT,
47
+  ID_T_MORE,
48
+  ID_T_RETURN
49
+};
48 50
 
49 51
 #if ENABLED(MKS_TEST)
50 52
   extern uint8_t curent_disp_ui;
51 53
 #endif
52 54
 
53
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
55
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
56
+  if (event != LV_EVENT_RELEASED) return;
54 57
   switch (obj->mks_obj_id) {
55 58
     case ID_T_PRE_HEAT:
56
-      if (event == LV_EVENT_CLICKED) {
57
-        // nothing to do
58
-      }
59
-      else if (event == LV_EVENT_RELEASED) {
60
-        lv_clear_tool();
61
-        lv_draw_preHeat();
62
-      }
59
+      lv_clear_tool();
60
+      lv_draw_preHeat();
63 61
       break;
64 62
     case ID_T_EXTRUCT:
65
-      if (event == LV_EVENT_CLICKED) {
66
-        // nothing to do
67
-      }
68
-      else if (event == LV_EVENT_RELEASED) {
69
-        lv_clear_tool();
70
-        lv_draw_extrusion();
71
-      }
63
+      lv_clear_tool();
64
+      lv_draw_extrusion();
72 65
       break;
73 66
     case ID_T_MOV:
74
-      if (event == LV_EVENT_CLICKED) {
75
-        // nothing to do
76
-      }
77
-      else if (event == LV_EVENT_RELEASED) {
78
-        lv_clear_tool();
79
-        lv_draw_move_motor();
80
-      }
67
+      lv_clear_tool();
68
+      lv_draw_move_motor();
81 69
       break;
82 70
     case ID_T_HOME:
83
-      if (event == LV_EVENT_CLICKED) {
84
-        // nothing to do
85
-      }
86
-      else if (event == LV_EVENT_RELEASED) {
87
-        lv_clear_tool();
88
-        lv_draw_home();
89
-      }
71
+      lv_clear_tool();
72
+      lv_draw_home();
90 73
       break;
91 74
     case ID_T_LEVELING:
92
-      if (event == LV_EVENT_CLICKED) {
93
-        // nothing to do
94
-      }
95
-      else if (event == LV_EVENT_RELEASED) {
96
-        #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
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));
102
-        #else
103
-          uiCfg.leveling_first_time = 1;
104
-          lv_clear_tool();
105
-          lv_draw_manualLevel();
106
-        #endif
107
-      }
75
+      #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
76
+        //queue.enqueue_one_P(PSTR("G28"));
77
+        //queue.enqueue_one_P(PSTR("G29"));
78
+        get_gcode_command(AUTO_LEVELING_COMMAND_ADDR,(uint8_t *)public_buf_m);
79
+        public_buf_m[sizeof(public_buf_m)-1] = 0;
80
+        queue.inject_P(PSTR(public_buf_m));
81
+      #else
82
+        uiCfg.leveling_first_time = 1;
83
+        lv_clear_tool();
84
+        lv_draw_manualLevel();
85
+      #endif
108 86
       break;
109 87
     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
-      }
88
+      uiCfg.desireSprayerTempBak = thermalManager.temp_hotend[uiCfg.curSprayerChoose].target;
89
+      lv_clear_tool();
90
+      lv_draw_filament_change();
118 91
       break;
119 92
     case ID_T_MORE: break;
120 93
     case ID_T_RETURN:
121
-      if (event == LV_EVENT_CLICKED) {
122
-        // nothing to do
123
-      }
124
-      else if (event == LV_EVENT_RELEASED) {
125
-        TERN_(MKS_TEST, curent_disp_ui = 1);
126
-        lv_clear_tool();
127
-        lv_draw_ready_print();
128
-      }
94
+      TERN_(MKS_TEST, curent_disp_ui = 1);
95
+      lv_clear_tool();
96
+      lv_draw_ready_print();
129 97
       break;
130 98
   }
131 99
 }
132 100
 
133 101
 void lv_draw_tool(void) {
134
-  lv_obj_t *buttonPreHeat, *buttonExtrusion, *buttonMove, *buttonHome, *buttonLevel;
135
-  lv_obj_t *buttonFilament;
136
-  lv_obj_t *buttonBack;
137
-
138 102
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != TOOL_UI) {
139 103
     disp_state_stack._disp_index++;
140 104
     disp_state_stack._disp_state[disp_state_stack._disp_index] = TOOL_UI;
141 105
   }
142 106
   disp_state = TOOL_UI;
143 107
 
144
-  scr = lv_obj_create(NULL, NULL);
145
-
146
-  //static lv_style_t tool_style;
147
-
148
-  lv_obj_set_style(scr, &tft_style_scr);
149
-  lv_scr_load(scr);
150
-  lv_obj_clean(scr);
108
+  scr = lv_screen_create();
151 109
 
152 110
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
153 111
 
154 112
   lv_refr_now(lv_refr_get_disp_refreshing());
155 113
 
156
-  // Create image buttons
157
-  buttonPreHeat   = lv_imgbtn_create(scr, "F:/bmp_preHeat.bin", INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT);
158
-  buttonExtrusion = lv_imgbtn_create(scr, "F:/bmp_extruct.bin", BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
159
-  buttonMove      = lv_imgbtn_create(scr, "F:/bmp_mov.bin", BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
160
-  buttonHome      = lv_imgbtn_create(scr, "F:/bmp_zero.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
161
-  buttonLevel     = lv_imgbtn_create(scr, "F:/bmp_leveling.bin", INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
162
-  buttonFilament  = lv_imgbtn_create(scr, "F:/bmp_filamentchange.bin",BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT);
163
-  //buttonMore    = lv_imgbtn_createx(scr, NULL);
164
-  //lv_obj_set_pos(buttonMore,BTN_X_PIXEL*2+INTERVAL_V*3, BTN_Y_PIXEL+INTERVAL_H+titleHeight);
165
-  buttonBack      = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
166
-
167
-  // Create labels on the image buttons
168
-  lv_obj_t *labelPreHeat   = lv_label_create_empty(buttonPreHeat);
169
-  lv_obj_t *labelExtrusion = lv_label_create_empty(buttonExtrusion);
170
-  lv_obj_t *label_Move     = lv_label_create_empty(buttonMove);
171
-  lv_obj_t *label_Home     = lv_label_create_empty(buttonHome);
172
-  lv_obj_t *label_Level    = lv_label_create_empty(buttonLevel);
173
-  lv_obj_t *label_Filament = lv_label_create_empty(buttonFilament);
174
-  //lv_obj_t *label_More   = lv_label_create_empty(buttonMore);
175
-  lv_obj_t *label_Back     = lv_label_create_empty(buttonBack);
176
-
177
-  if (gCfgItems.multiple_language) {
178
-    lv_label_set_text(labelPreHeat, tool_menu.preheat);
179
-    lv_obj_align(labelPreHeat, buttonPreHeat, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
180
-
181
-    lv_label_set_text(labelExtrusion, tool_menu.extrude);
182
-    lv_obj_align(labelExtrusion, buttonExtrusion, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
183
-
184
-    lv_label_set_text(label_Move, tool_menu.move);
185
-    lv_obj_align(label_Move, buttonMove, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
186
-
187
-    lv_label_set_text(label_Home, tool_menu.home);
188
-    lv_obj_align(label_Home, buttonHome, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
189
-
190
-    lv_label_set_text(label_Level, tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling));
191
-    lv_obj_align(label_Level, buttonLevel, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
192
-
193
-    lv_label_set_text(label_Filament, tool_menu.filament);
194
-    lv_obj_align(label_Filament, buttonFilament, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
195
-
196
-    //lv_label_set_text(label_More, tool_menu.more);
197
-    //lv_obj_align(label_More, buttonMore, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
198
-
199
-    lv_label_set_text(label_Back, common_menu.text_back);
200
-    lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
201
-  }
202
-  #if HAS_ROTARY_ENCODER
203
-    if (gCfgItems.encoder_enable) {
204
-      lv_group_add_obj(g, buttonPreHeat);
205
-      lv_group_add_obj(g, buttonExtrusion);
206
-      lv_group_add_obj(g, buttonMove);
207
-      lv_group_add_obj(g, buttonHome);
208
-      lv_group_add_obj(g, buttonLevel);
209
-      lv_group_add_obj(g, buttonFilament);
210
-      lv_group_add_obj(g, buttonBack);
211
-    }
212
-  #endif
114
+  lv_big_button_create(scr, "F:/bmp_preHeat.bin", tool_menu.preheat, INTERVAL_V, titleHeight, event_handler, ID_T_PRE_HEAT);
115
+  lv_big_button_create(scr, "F:/bmp_extruct.bin", tool_menu.extrude, BTN_X_PIXEL + INTERVAL_V * 2, titleHeight, event_handler, ID_T_EXTRUCT);
116
+
117
+  lv_big_button_create(scr, "F:/bmp_mov.bin", tool_menu.move, BTN_X_PIXEL * 2 + INTERVAL_V * 3, titleHeight, event_handler, ID_T_MOV);
118
+  lv_big_button_create(scr, "F:/bmp_zero.bin", tool_menu.home, BTN_X_PIXEL * 3 + INTERVAL_V * 4, titleHeight, event_handler, ID_T_HOME);
119
+
120
+  lv_big_button_create(scr, "F:/bmp_leveling.bin", tool_menu.TERN(AUTO_BED_LEVELING_BILINEAR, autoleveling, leveling), INTERVAL_V, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_LEVELING);
121
+  lv_big_button_create(scr, "F:/bmp_filamentchange.bin", tool_menu.filament, BTN_X_PIXEL+INTERVAL_V*2,BTN_Y_PIXEL+INTERVAL_H+titleHeight, event_handler,ID_T_FILAMENT);
122
+  lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_T_RETURN);
213 123
 }
214 124
 
215 125
 void lv_clear_tool() {

+ 202
- 52
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp View File

@@ -61,13 +61,14 @@ uint32_t To_pre_view;
61 61
 bool gcode_preview_over, flash_preview_begin, default_preview_flg;
62 62
 uint32_t size = 809;
63 63
 uint16_t row;
64
-uint8_t temperature_change_frequency;
64
+bool temps_update_flag;
65 65
 uint8_t printing_rate_update_flag;
66 66
 
67 67
 extern bool once_flag;
68 68
 extern uint8_t sel_id;
69 69
 extern uint8_t public_buf[512];
70 70
 extern uint8_t bmp_public_buf[17 * 1024];
71
+extern lv_group_t *g;
71 72
 
72 73
 extern void LCD_IO_WriteData(uint16_t RegValue);
73 74
 
@@ -282,6 +283,9 @@ lv_style_t style_para_back;
282 283
 
283 284
 lv_style_t lv_bar_style_indic;
284 285
 
286
+lv_style_t style_btn_pr;
287
+lv_style_t style_btn_rel;
288
+
285 289
 void tft_style_init() {
286 290
   lv_style_copy(&tft_style_scr, &lv_style_scr);
287 291
   tft_style_scr.body.main_color   = LV_COLOR_BACKGROUND;
@@ -399,6 +403,25 @@ void tft_style_init() {
399 403
   style_para_back.text.color        = LV_COLOR_WHITE;
400 404
   style_para_back.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
401 405
 
406
+  lv_style_copy(&style_btn_rel, &lv_style_plain);
407
+  style_btn_rel.body.border.color = lv_color_hex3(0x269);
408
+  style_btn_rel.body.border.width = 1;
409
+  style_btn_rel.body.main_color   = lv_color_hex3(0xADF);
410
+  style_btn_rel.body.grad_color   = lv_color_hex3(0x46B);
411
+  style_btn_rel.body.shadow.width = 4;
412
+  style_btn_rel.body.shadow.type  = LV_SHADOW_BOTTOM;
413
+  style_btn_rel.body.radius       = LV_RADIUS_CIRCLE;
414
+  style_btn_rel.text.color        = lv_color_hex3(0xDEF);
415
+  style_btn_rel.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
416
+
417
+  lv_style_copy(&style_btn_pr, &style_btn_rel);
418
+  style_btn_pr.body.border.color = lv_color_hex3(0x46B);
419
+  style_btn_pr.body.main_color   = lv_color_hex3(0x8BD);
420
+  style_btn_pr.body.grad_color   = lv_color_hex3(0x24A);
421
+  style_btn_pr.body.shadow.width = 2;
422
+  style_btn_pr.text.color        = lv_color_hex3(0xBCD);
423
+  style_btn_pr.text.font         = &TERN(HAS_SPI_FLASH_FONT, gb2312_puhui32, lv_font_roboto_22);
424
+
402 425
   lv_style_copy(&lv_bar_style_indic, &lv_style_pretty_color);
403 426
   lv_bar_style_indic.text.color        = lv_color_hex3(0xADF);
404 427
   lv_bar_style_indic.image.color       = lv_color_hex3(0xADF);
@@ -421,7 +444,6 @@ void titleText_cat(char *str, int strSize, char *addPart) {
421 444
 
422 445
 char *getDispText(int index) {
423 446
 
424
-  ZERO(public_buf_l);
425 447
 
426 448
   switch (disp_state_stack._disp_state[index]) {
427 449
     case PRINT_READY_UI:
@@ -926,30 +948,30 @@ void print_time_run() {
926 948
 }
927 949
 
928 950
 void GUI_RefreshPage() {
929
-  if ((systick_uptime_millis % 1000) == 0) temperature_change_frequency = 1;
930
-  if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = 1;
951
+  if ((systick_uptime_millis % 1000) == 0) temps_update_flag = true;
952
+  if ((systick_uptime_millis % 3000) == 0) printing_rate_update_flag = true;
931 953
 
932 954
   switch (disp_state) {
933 955
     case MAIN_UI:
934 956
       //lv_draw_ready_print();
935 957
       break;
936 958
     case EXTRUSION_UI:
937
-      if (temperature_change_frequency == 1) {
938
-        temperature_change_frequency = 0;
959
+      if (temps_update_flag) {
960
+        temps_update_flag = false;
939 961
         disp_hotend_temp();
940 962
       }
941 963
       break;
942 964
     case PRE_HEAT_UI:
943
-      if (temperature_change_frequency == 1) {
944
-        temperature_change_frequency = 0;
965
+      if (temps_update_flag) {
966
+        temps_update_flag = false;
945 967
         disp_desire_temp();
946 968
       }
947 969
       break;
948 970
     case PRINT_READY_UI:
949 971
       /*
950 972
       if (gCfgItems.display_style == 2) {
951
-        if (temperature_change_frequency) {
952
-          temperature_change_frequency = 0;
973
+        if (temps_update_flag) {
974
+          temps_update_flag = false;
953 975
           disp_restro_state();
954 976
         }
955 977
       }
@@ -959,8 +981,8 @@ void GUI_RefreshPage() {
959 981
     case PRINT_FILE_UI: break;
960 982
 
961 983
     case PRINTING_UI:
962
-      if (temperature_change_frequency) {
963
-        temperature_change_frequency = 0;
984
+      if (temps_update_flag) {
985
+        temps_update_flag = false;
964 986
         disp_ext_temp();
965 987
         disp_bed_temp();
966 988
         disp_fan_speed();
@@ -968,15 +990,15 @@ void GUI_RefreshPage() {
968 990
         disp_fan_Zpos();
969 991
       }
970 992
       if (printing_rate_update_flag || marlin_state == MF_SD_COMPLETE) {
971
-        printing_rate_update_flag = 0;
993
+        printing_rate_update_flag = false;
972 994
         if (!gcode_preview_over) setProBarRate();
973 995
       }
974 996
       break;
975 997
 
976 998
     case OPERATE_UI:
977 999
       /*
978
-      if (temperature_change_frequency == 1) {
979
-        temperature_change_frequency = 0;
1000
+      if (temps_update_flag) {
1001
+        temps_update_flag = false;
980 1002
         disp_temp_operate();
981 1003
       }
982 1004
 
@@ -986,16 +1008,16 @@ void GUI_RefreshPage() {
986 1008
 
987 1009
     case PAUSE_UI:
988 1010
       /*
989
-      if (temperature_change_frequency == 1) {
990
-        temperature_change_frequency = 0;
1011
+      if (temps_update_flag) {
1012
+        temps_update_flag = false;
991 1013
         disp_temp_pause();
992 1014
       }
993 1015
       */
994 1016
       break;
995 1017
 
996 1018
     case FAN_UI:
997
-      if (temperature_change_frequency == 1) {
998
-        temperature_change_frequency = 0;
1019
+      if (temps_update_flag) {
1020
+        temps_update_flag = false;
999 1021
         disp_fan_value();
1000 1022
       }
1001 1023
       break;
@@ -1003,14 +1025,12 @@ void GUI_RefreshPage() {
1003 1025
     case MOVE_MOTOR_UI:
1004 1026
       /*
1005 1027
       if (mksReprint.mks_printer_state == MKS_IDLE) {
1006
-        if ((z_high_count==1)&&(temper_error_flg != 1)) {
1028
+        if (z_high_count == 1 && temper_error_flg != 1) {
1007 1029
           z_high_count = 0;
1008
-          {
1009
-            memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate));
1010
-            GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
1011
-            sprintf_P((char *)gCfgItems.move_z_coordinate, PSTR("Z: %.3f"), current_position[Z_AXIS]);
1012
-            GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
1013
-          }
1030
+          memset((char *)gCfgItems.move_z_coordinate, ' ', sizeof(gCfgItems.move_z_coordinate));
1031
+          GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
1032
+          sprintf_P((char *)gCfgItems.move_z_coordinate, PSTR("Z: %.3f"), current_position[Z_AXIS]);
1033
+          GUI_DispStringAt((const char *)gCfgItems.move_z_coordinate, 380, TITLE_YPOS);
1014 1034
         }
1015 1035
       }
1016 1036
       */
@@ -1018,9 +1038,9 @@ void GUI_RefreshPage() {
1018 1038
 
1019 1039
     #if ENABLED(USE_WIFI_FUNCTION)
1020 1040
       case WIFI_UI:
1021
-        if (temperature_change_frequency == 1) {
1041
+        if (temps_update_flag) {
1022 1042
           disp_wifi_state();
1023
-          temperature_change_frequency = 0;
1043
+          temps_update_flag = false;
1024 1044
         }
1025 1045
         break;
1026 1046
     #endif
@@ -1030,8 +1050,8 @@ void GUI_RefreshPage() {
1030 1050
       break;
1031 1051
 
1032 1052
     case FILAMENTCHANGE_UI:
1033
-      if (temperature_change_frequency) {
1034
-        temperature_change_frequency = 0;
1053
+      if (temps_update_flag) {
1054
+        temps_update_flag = false;
1035 1055
         disp_filament_temp();
1036 1056
       }
1037 1057
       break;
@@ -1046,9 +1066,9 @@ void GUI_RefreshPage() {
1046 1066
       break;
1047 1067
     case WIFI_LIST_UI:
1048 1068
       #if ENABLED(USE_WIFI_FUNCTION)
1049
-        if (printing_rate_update_flag == 1) {
1069
+        if (printing_rate_update_flag) {
1050 1070
           disp_wifi_list();
1051
-          printing_rate_update_flag = 0;
1071
+          printing_rate_update_flag = false;
1052 1072
         }
1053 1073
       #endif
1054 1074
       break;
@@ -1103,8 +1123,8 @@ void GUI_RefreshPage() {
1103 1123
     #endif
1104 1124
 
1105 1125
     case BABY_STEP_UI:
1106
-      if (temperature_change_frequency == 1) {
1107
-        temperature_change_frequency = 0;
1126
+      if (temps_update_flag) {
1127
+        temps_update_flag = false;
1108 1128
         disp_z_offset_value();
1109 1129
       }
1110 1130
       break;
@@ -1589,21 +1609,36 @@ void lv_imgbtn_use_label_style(lv_obj_t *imgbtn) {
1589 1609
   lv_imgbtn_set_style(imgbtn, LV_BTN_STATE_PR,  &tft_style_label_pre);
1590 1610
 }
1591 1611
 
1592
-// Use label style for the image button
1612
+// Use label style for the button
1593 1613
 void lv_btn_use_label_style(lv_obj_t *btn) {
1594 1614
   lv_btn_set_style(btn, LV_BTN_STYLE_REL, &tft_style_label_rel);
1595 1615
   lv_btn_set_style(btn, LV_BTN_STYLE_PR,  &tft_style_label_pre);
1596 1616
 }
1597 1617
 
1618
+// Use button style for the button
1619
+void lv_btn_use_button_style(lv_obj_t *btn) {
1620
+  lv_btn_set_style(btn, LV_BTN_STYLE_REL, &style_btn_rel);
1621
+  lv_btn_set_style(btn, LV_BTN_STYLE_PR,  &style_btn_pr);
1622
+}
1623
+
1598 1624
 // Use a single style for both Released and Pressed
1599 1625
 void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style) {
1600 1626
   lv_btn_set_style(btn, LV_BTN_STYLE_REL, style);
1601 1627
   lv_btn_set_style(btn, LV_BTN_STYLE_PR,  style);
1602 1628
 }
1603 1629
 
1630
+// Create a screen
1631
+lv_obj_t* lv_screen_create() {
1632
+  lv_obj_t *scr = lv_obj_create(nullptr, nullptr);
1633
+  lv_obj_set_style(scr, &tft_style_scr);
1634
+  lv_scr_load(scr);
1635
+  lv_obj_clean(scr);
1636
+  return scr;
1637
+}
1638
+
1604 1639
 // Create an empty label
1605 1640
 lv_obj_t* lv_label_create_empty(lv_obj_t *par) {
1606
-  return lv_label_create(par, (lv_obj_t*)NULL);
1641
+  return lv_label_create(par, (lv_obj_t*)nullptr);
1607 1642
 }
1608 1643
 
1609 1644
 // Create a label with style and text
@@ -1621,35 +1656,66 @@ lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char
1621 1656
 }
1622 1657
 
1623 1658
 // Create a button with callback, ID, and Style.
1624
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style) {
1625
-  lv_obj_t *btn = lv_btn_create(par, NULL);
1659
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/, lv_style_t *style/*=&style_para_value*/) {
1660
+  lv_obj_t *btn = lv_btn_create(par, nullptr);
1626 1661
   if (id)
1627
-    lv_obj_set_event_cb_mks(btn, cb, id, NULL, 0);
1662
+    lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1628 1663
   else
1629 1664
     lv_obj_set_event_cb(btn, cb);
1630 1665
   lv_btn_set_style_both(btn, style);
1631 1666
   return btn;
1632 1667
 }
1633 1668
 
1634
-// Create a button with callback and ID. Style set to style_para_value.
1635
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id) {
1636
-  return lv_btn_create(par, cb, id, &style_para_value);
1669
+// Create a button with callback and ID, with label style.
1670
+lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
1671
+  lv_obj_t *btn = lv_btn_create(par, cb, id, nullptr);
1672
+  lv_btn_use_label_style(btn);
1673
+  return btn;
1674
+}
1675
+
1676
+// Create a button with callback and ID, with button style.
1677
+lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
1678
+  lv_obj_t *btn = lv_btn_create(par, cb, id, nullptr);
1679
+  lv_btn_use_button_style(btn);
1680
+  return btn;
1681
+}
1682
+
1683
+// Create a button with position, size, callback, ID, and style.
1684
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id, lv_style_t *style) {
1685
+  lv_obj_t *btn = lv_btn_create(par, cb, id, style);
1686
+  lv_obj_set_pos(btn, x, y);
1687
+  lv_obj_set_size(btn, w, h);
1688
+  return btn;
1637 1689
 }
1638 1690
 
1639 1691
 // Create a button with position, size, callback, and ID. Style set to style_para_value.
1640
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id) {
1641
-  lv_obj_t *btn = lv_btn_create(par, cb, id);
1692
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
1693
+  lv_obj_t *btn = lv_btn_create(par, x, y, w, h, cb, id, &style_para_value);
1694
+  return btn;
1695
+}
1696
+
1697
+// Create a button with position, size, callback, and ID, with label style.
1698
+lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
1699
+  lv_obj_t *btn = lv_label_btn_create(par, cb, id);
1700
+  lv_obj_set_pos(btn, x, y);
1701
+  lv_obj_set_size(btn, w, h);
1702
+  return btn;
1703
+}
1704
+
1705
+// Create a button with position, size, callback, and ID, with label style.
1706
+lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
1707
+  lv_obj_t *btn = lv_button_btn_create(par, cb, id);
1642 1708
   lv_obj_set_pos(btn, x, y);
1643 1709
   lv_obj_set_size(btn, w, h);
1644 1710
   return btn;
1645 1711
 }
1646 1712
 
1647 1713
 // Create a button with callback and ID. Style set to style_para_back.
1648
-lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id) {
1714
+lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id/*=0*/) {
1649 1715
   return lv_btn_create(par, cb, id, &style_para_back);
1650 1716
 }
1651 1717
 // Create a button with position, size, callback, and ID. Style set to style_para_back.
1652
-lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id) {
1718
+lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id/*=0*/) {
1653 1719
   lv_obj_t *btn = lv_btn_create_back(par, cb, id);
1654 1720
   lv_obj_set_pos(btn, x, y);
1655 1721
   lv_obj_set_size(btn, w, h);
@@ -1657,11 +1723,11 @@ lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord
1657 1723
 }
1658 1724
 
1659 1725
 // Create an image button with image, callback, and ID. Use label style.
1660
-lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id) {
1661
-  lv_obj_t *btn = lv_imgbtn_create(par, NULL);
1726
+lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id/*=0*/) {
1727
+  lv_obj_t *btn = lv_imgbtn_create(par, nullptr);
1662 1728
   if (img) lv_imgbtn_set_src_both(btn, img);
1663 1729
   if (id)
1664
-    lv_obj_set_event_cb_mks(btn, cb, id, NULL, 0);
1730
+    lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1665 1731
   else
1666 1732
     lv_obj_set_event_cb(btn, cb);
1667 1733
   lv_imgbtn_use_label_style(btn);
@@ -1670,12 +1736,96 @@ lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, con
1670 1736
 }
1671 1737
 
1672 1738
 // Create an image button with image, position, callback, and ID. Use label style.
1673
-lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id) {
1739
+lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id/*=0*/) {
1740
+  lv_obj_t *btn = lv_imgbtn_create(par, img, cb, id);
1741
+  lv_obj_set_pos(btn, x, y);
1742
+  return btn;
1743
+}
1744
+
1745
+lv_obj_t* lv_big_button_create(lv_obj_t *par, const char *img, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, bool centerLabel) {
1674 1746
   lv_obj_t *btn = lv_imgbtn_create(par, img, cb, id);
1675 1747
   lv_obj_set_pos(btn, x, y);
1748
+  lv_obj_t *label = lv_label_create_empty(btn);
1749
+  if (gCfgItems.multiple_language) {
1750
+    lv_label_set_text(label, text);
1751
+    if (centerLabel)
1752
+      lv_obj_align(label, btn, LV_ALIGN_CENTER, 0, 0);
1753
+    else
1754
+      lv_obj_align(label, btn, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
1755
+  }
1756
+  #if HAS_ROTARY_ENCODER
1757
+    if (gCfgItems.encoder_enable == true)
1758
+      lv_group_add_obj(g, btn);
1759
+  #endif
1760
+  return btn;
1761
+}
1762
+
1763
+lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, bool drawArrow) {
1764
+  lv_obj_t *btn = lv_btn_create(par, nullptr);   /*Add a button the current screen*/
1765
+  lv_obj_set_pos(btn, x, y);                         /*Set its position*/
1766
+  lv_obj_set_size(btn, PARA_UI_SIZE_X, PARA_UI_SIZE_Y);                       /*Set its size*/
1767
+  if (id > -1) lv_obj_set_event_cb_mks(btn, cb, id, nullptr, 0);
1768
+  lv_btn_use_label_style(btn);
1769
+  lv_btn_set_layout(btn, LV_LAYOUT_OFF);
1770
+  lv_obj_t *label = lv_label_create_empty(btn);        /*Add a label to the button*/
1771
+  if (gCfgItems.multiple_language) {
1772
+    lv_label_set_text(label, text);
1773
+    lv_obj_align(label, btn, LV_ALIGN_IN_LEFT_MID, 0, 0);
1774
+  }
1775
+  #if HAS_ROTARY_ENCODER
1776
+    if (gCfgItems.encoder_enable == true) {
1777
+      lv_group_add_obj(g, btn);
1778
+    }
1779
+  #endif
1780
+
1781
+  if (drawArrow) (void)lv_imgbtn_create(par, "F:/bmp_arrow.bin", x + PARA_UI_SIZE_X, y + PARA_UI_ARROW_V, cb, id);
1782
+
1783
+  lv_obj_t *line1 = lv_line_create(par, nullptr);
1784
+  lv_ex_line(line1, line_points[index]);
1785
+
1676 1786
   return btn;
1677 1787
 }
1678 1788
 
1789
+lv_obj_t* lv_screen_menu_item_1_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue) {
1790
+  lv_obj_t* btn = lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
1791
+  lv_obj_t* btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X, y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, id);
1792
+  lv_obj_t* labelValue = lv_label_create_empty(btnValue);
1793
+  lv_label_set_text(labelValue, editValue);
1794
+  lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
1795
+  return btn;
1796
+}
1797
+
1798
+lv_obj_t* lv_screen_menu_item_2_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue, const int idEdit2, const char *editValue2) {
1799
+  lv_obj_t* btn = lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
1800
+
1801
+  lv_obj_t* btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X_2, y + PARA_UI_VALUE_V_2, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, idEdit2);
1802
+  lv_obj_t* labelValue = lv_label_create_empty(btnValue);
1803
+  lv_label_set_text(labelValue, editValue2);
1804
+  lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
1805
+
1806
+  btnValue = lv_btn_create(par, PARA_UI_VALUE_POS_X, y + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, cb, id);
1807
+  labelValue = lv_label_create_empty(btnValue);
1808
+  lv_label_set_text(labelValue, editValue);
1809
+  lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
1810
+
1811
+  return btn;
1812
+}
1813
+
1814
+lv_obj_t* lv_screen_menu_item_onoff(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const bool curValue) {
1815
+  lv_screen_menu_item(par, text, x, y, cb, -1, index, false);
1816
+  lv_obj_t* btnValue = lv_imgbtn_create(par, curValue ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, y + PARA_UI_STATE_V, cb, id);
1817
+  lv_obj_t* labelValue = lv_label_create_empty(btnValue);
1818
+  lv_label_set_text(labelValue, curValue ? machine_menu.enable : machine_menu.disable);
1819
+  lv_obj_align(labelValue, btnValue, LV_ALIGN_CENTER, 0, 0);
1820
+  return btnValue;
1821
+}
1822
+
1823
+void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue) {
1824
+  lv_imgbtn_set_src_both(btn, curValue ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin");
1825
+  lv_label_set_text((lv_obj_t*)btn->child_ll.head, curValue ? machine_menu.enable : machine_menu.disable);
1826
+}
1827
+
1828
+
1679 1829
 #if ENABLED(SDSUPPORT)
1680 1830
 
1681 1831
   void sd_detection() {
@@ -1689,11 +1839,11 @@ lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coor
1689 1839
 
1690 1840
 #endif
1691 1841
 
1692
-void lv_ex_line(lv_obj_t * line, lv_point_t *points) {
1842
+void lv_ex_line(lv_obj_t *line, lv_point_t *points) {
1693 1843
   // Copy the previous line and apply the new style
1694 1844
   lv_line_set_points(line, points, 2);     // Set the points
1695 1845
   lv_line_set_style(line, LV_LINE_STYLE_MAIN, &style_line);
1696
-  lv_obj_align(line, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
1846
+  lv_obj_align(line, nullptr, LV_ALIGN_IN_TOP_MID, 0, 0);
1697 1847
 }
1698 1848
 
1699 1849
 extern volatile uint32_t systick_uptime_millis;

+ 77
- 47
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h View File

@@ -164,48 +164,6 @@
164 164
 
165 165
 #endif // ifdef TFT35
166 166
 
167
-// Set the same image for both Released and Pressed
168
-void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src);
169
-
170
-// Set label styles for Released and Pressed
171
-void lv_imgbtn_use_label_style(lv_obj_t *imgbtn);
172
-
173
-// Set label styles for Released and Pressed
174
-void lv_btn_use_label_style(lv_obj_t *btn);
175
-
176
-// Set the same style for both Released and Pressed
177
-void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style);
178
-
179
-// Create an empty label
180
-lv_obj_t* lv_label_create_empty(lv_obj_t *par);
181
-
182
-// Create a label with style and text
183
-lv_obj_t* lv_label_create(lv_obj_t *par, const char *text);
184
-
185
-// Create a label with style, position, and text
186
-lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char *text);
187
-
188
-// Create a button with callback, ID, and Style.
189
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style);
190
-
191
-// Create a button with callback and ID. Style set to style_para_value.
192
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id);
193
-
194
-// Create a button with position, size, callback, and ID. Style set to style_para_value.
195
-lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id);
196
-
197
-// Create a button with callback and ID. Style set to style_para_back.
198
-lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id);
199
-
200
-// Create a button with position, size, callback, and ID. Style set to style_para_back.
201
-lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id);
202
-
203
-// Create an image button with image, callback, and ID. Use label style.
204
-lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id);
205
-
206
-// Create an image button with image, position, callback, and ID. Use label style.
207
-lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id);
208
-
209 167
 #ifdef __cplusplus
210 168
   extern "C" { /* C-declarations for C++ */
211 169
 #endif
@@ -240,10 +198,10 @@ typedef struct {
240 198
 } CFG_ITMES;
241 199
 
242 200
 typedef struct {
243
-  uint8_t curTempType : 1,
244
-          curSprayerChoose : 3,
245
-          stepHeat : 4;
246
-  uint8_t leveling_first_time : 1,
201
+  uint8_t curTempType:1,
202
+          curSprayerChoose:3,
203
+          stepHeat:4;
204
+  uint8_t leveling_first_time:1,
247 205
           para_ui_page:1,
248 206
           configWifi:1,
249 207
           command_send:1,
@@ -467,6 +425,8 @@ extern lv_style_t style_sel_text;
467 425
 extern lv_style_t style_para_value;
468 426
 extern lv_style_t style_para_back;
469 427
 extern lv_style_t lv_bar_style_indic;
428
+extern lv_style_t style_btn_pr;
429
+extern lv_style_t style_btn_rel;
470 430
 
471 431
 extern lv_point_t line_points[4][2];
472 432
 
@@ -489,8 +449,78 @@ extern void gCfg_to_spiFlah();
489 449
 extern void print_time_count();
490 450
 
491 451
 extern void LV_TASK_HANDLER();
492
-extern void lv_ex_line(lv_obj_t * line, lv_point_t *points);
452
+extern void lv_ex_line(lv_obj_t *line, lv_point_t *points);
493 453
 
494 454
 #ifdef __cplusplus
495 455
   } /* C-declarations for C++ */
496 456
 #endif
457
+
458
+// Set the same image for both Released and Pressed
459
+void lv_imgbtn_set_src_both(lv_obj_t *imgbtn, const void *src);
460
+
461
+// Set label styles for Released and Pressed
462
+void lv_imgbtn_use_label_style(lv_obj_t *imgbtn);
463
+
464
+// Set label styles for Released and Pressed
465
+void lv_btn_use_label_style(lv_obj_t *btn);
466
+
467
+// Set the same style for both Released and Pressed
468
+void lv_btn_set_style_both(lv_obj_t *btn, lv_style_t *style);
469
+
470
+// Create a screen
471
+lv_obj_t* lv_screen_create();
472
+
473
+// Create an empty label
474
+lv_obj_t* lv_label_create_empty(lv_obj_t *par);
475
+
476
+// Create a label with style and text
477
+lv_obj_t* lv_label_create(lv_obj_t *par, const char *text);
478
+
479
+// Create a label with style, position, and text
480
+lv_obj_t* lv_label_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, const char *text);
481
+
482
+// Create a button with callback, ID, and Style.
483
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id, lv_style_t *style=&style_para_value);
484
+
485
+// Create a button with callback and ID, with label style.
486
+lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
487
+
488
+// Create a button with callback and ID, with button style.
489
+lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
490
+
491
+// Create a button with position, size, callback, ID, and style.
492
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id, lv_style_t *style);
493
+
494
+// Create a button with position, size, callback, and ID. Style set to style_para_value.
495
+lv_obj_t* lv_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
496
+
497
+// Create a button with position, size, callback, and ID, with label style.
498
+lv_obj_t* lv_label_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
499
+
500
+// Create a button with position, size, callback, and ID, with button style.
501
+lv_obj_t* lv_button_btn_create(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
502
+
503
+// Create a button with callback and ID. Style set to style_para_back.
504
+lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_event_cb_t cb, const int id=0);
505
+
506
+// Create a button with position, size, callback, and ID. Style set to style_para_back.
507
+lv_obj_t* lv_btn_create_back(lv_obj_t *par, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, lv_event_cb_t cb, const int id=0);
508
+
509
+// Create an image button with image, callback, and ID. Use label style.
510
+lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_event_cb_t cb, const int id=0);
511
+
512
+// Create an image button with image, position, callback, and ID. Use label style.
513
+lv_obj_t* lv_imgbtn_create(lv_obj_t *par, const char *img, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id=0);
514
+
515
+// Create a big image button with a label, follow the LVGL UI standard.
516
+lv_obj_t* lv_big_button_create(lv_obj_t *par, const char *img, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, bool centerLabel = false);
517
+
518
+// Create a menu item, follow the LVGL UI standard.
519
+lv_obj_t* lv_screen_menu_item(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, bool drawArrow = true);
520
+lv_obj_t* lv_screen_menu_item_1_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue);
521
+lv_obj_t* lv_screen_menu_item_2_edit(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const char *editValue, const int idEdit2, const char *editValue2);
522
+lv_obj_t* lv_screen_menu_item_onoff(lv_obj_t *par, const char *text, lv_coord_t x, lv_coord_t y, lv_event_cb_t cb, const int id, const int index, const bool curValue);
523
+void lv_screen_menu_item_onoff_update(lv_obj_t *btn, const bool curValue);
524
+
525
+#define _DIA_1(T)       (uiCfg.dialogType == DIALOG_##T)
526
+#define DIALOG_IS(V...) DO(DIA,||,V)

+ 40
- 73
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi.cpp View File

@@ -30,80 +30,60 @@
30 30
 
31 31
 #include "draw_ui.h"
32 32
 
33
-extern lv_group_t * g;
33
+extern lv_group_t *g;
34 34
 static lv_obj_t *scr, *wifi_name_text, *wifi_key_text, *wifi_state_text, *wifi_ip_text;
35 35
 
36
-#define ID_W_RETURN     1
37
-#define ID_W_CLOUD      2
38
-#define ID_W_RECONNECT  3
36
+enum {
37
+  ID_W_RETURN = 1,
38
+  ID_W_CLOUD,
39
+  ID_W_RECONNECT
40
+};
39 41
 
40
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
42
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
43
+  if (event != LV_EVENT_RELEASED) return;
41 44
   switch (obj->mks_obj_id) {
42 45
     case ID_W_RETURN:
43
-      if (event == LV_EVENT_CLICKED) {
44
-
45
-      }
46
-      else if (event == LV_EVENT_RELEASED) {
47
-        clear_cur_ui();
48
-        lv_draw_set();
49
-      }
50
-    break;
46
+      clear_cur_ui();
47
+      lv_draw_set();
48
+      break;
51 49
     case ID_W_CLOUD:
52
-      if (event == LV_EVENT_CLICKED) {
53
-
54
-      }
55
-      else if (event == LV_EVENT_RELEASED) {
56
-        //clear_cur_ui();
57
-        //draw_return_ui();
58
-      }
59
-    break;
50
+      //clear_cur_ui();
51
+      //draw_return_ui();
52
+      break;
60 53
     case ID_W_RECONNECT:
61
-      if (event == LV_EVENT_CLICKED) {
62
-
63
-      }
64
-      else if (event == LV_EVENT_RELEASED) {
65
-        clear_cur_ui();
66
-        lv_draw_wifi_list();
67
-      }
68
-    break;
54
+      clear_cur_ui();
55
+      lv_draw_wifi_list();
56
+      break;
69 57
   }
70 58
 }
71 59
 
72 60
 void lv_draw_wifi(void) {
73
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL;
74
-  lv_obj_t *buttonCloud = NULL, *label_Cloud = NULL;
75
-  lv_obj_t *buttonReconnect = NULL, *label_Reconnect=NULL;
76 61
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_UI) {
77 62
     disp_state_stack._disp_index++;
78 63
     disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_UI;
79 64
   }
80 65
   disp_state = WIFI_UI;
81 66
 
82
-  scr = lv_obj_create(NULL, NULL);
83
-
84
-  lv_obj_set_style(scr, &tft_style_scr);
85
-  lv_scr_load(scr);
86
-  lv_obj_clean(scr);
67
+  scr = lv_screen_create();
87 68
 
88 69
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
89 70
 
90 71
   lv_refr_now(lv_refr_get_disp_refreshing());
91 72
 
92 73
   // Create an Image button
93
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
94
-
74
+  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_return.bin", BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_W_RETURN);
95 75
   #if HAS_ROTARY_ENCODER
96 76
     if (gCfgItems.encoder_enable) lv_group_add_obj(g, buttonBack);
97 77
   #endif
78
+  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
98 79
 
99
-  if (gCfgItems.wifi_mode_sel == STA_MODEL) {
100
-    //buttonCloud = lv_imgbtn_create(scr, NULL);
101
-    buttonReconnect = lv_imgbtn_create(scr, NULL);
102
-  }
80
+  lv_obj_t *buttonReconnect = nullptr, *label_Reconnect = nullptr;
103 81
 
104 82
   if (gCfgItems.wifi_mode_sel == STA_MODEL) {
105 83
 
106
-    lv_obj_set_event_cb_mks(buttonReconnect, event_handler,ID_W_RECONNECT, NULL, 0);
84
+    buttonReconnect = lv_imgbtn_create(scr, nullptr);
85
+
86
+    lv_obj_set_event_cb_mks(buttonReconnect, event_handler, ID_W_RECONNECT, nullptr, 0);
107 87
     lv_imgbtn_set_src_both(buttonReconnect, "F:/bmp_wifi.bin");
108 88
     lv_imgbtn_use_label_style(buttonReconnect);
109 89
 
@@ -113,12 +93,7 @@ void lv_draw_wifi(void) {
113 93
 
114 94
     lv_obj_set_pos(buttonReconnect, BTN_X_PIXEL * 2 + INTERVAL_V * 3, BTN_Y_PIXEL + INTERVAL_H + titleHeight);
115 95
     lv_btn_set_layout(buttonReconnect, LV_LAYOUT_OFF);
116
-  }
117 96
 
118
-  label_Back = lv_label_create_empty(buttonBack);
119
-
120
-  if (gCfgItems.wifi_mode_sel == STA_MODEL) {
121
-    //label_Cloud = lv_label_create_empty(buttonCloud);
122 97
     label_Reconnect = lv_label_create_empty(buttonReconnect);
123 98
   }
124 99
 
@@ -127,9 +102,6 @@ void lv_draw_wifi(void) {
127 102
     lv_obj_align(label_Back, buttonBack, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
128 103
 
129 104
     if (gCfgItems.wifi_mode_sel == STA_MODEL) {
130
-      //lv_label_set_text(label_Cloud, common_menu.text_back);
131
-      //lv_obj_align(label_Cloud, buttonCloud, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
132
-
133 105
       lv_label_set_text(label_Reconnect, wifi_menu.reconnect);
134 106
       lv_obj_align(label_Reconnect, buttonReconnect, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
135 107
     }
@@ -148,38 +120,33 @@ void lv_draw_wifi(void) {
148 120
 }
149 121
 
150 122
 void disp_wifi_state() {
151
-  memset(public_buf_m, 0, sizeof(public_buf_m));
152
-  strcpy(public_buf_m,wifi_menu.ip);
153
-  strcat(public_buf_m,ipPara.ip_addr);
123
+  strcpy(public_buf_m, wifi_menu.ip);
124
+  strcat(public_buf_m, ipPara.ip_addr);
154 125
   lv_label_set_text(wifi_ip_text, public_buf_m);
155
-  lv_obj_align(wifi_ip_text, NULL, LV_ALIGN_CENTER, 0, -100);
126
+  lv_obj_align(wifi_ip_text, nullptr, LV_ALIGN_CENTER, 0, -100);
156 127
 
157
-  memset(public_buf_m, 0, sizeof(public_buf_m));
158
-  strcpy(public_buf_m,wifi_menu.wifi);
159
-  strcat(public_buf_m,wifiPara.ap_name);
128
+  strcpy(public_buf_m, wifi_menu.wifi);
129
+  strcat(public_buf_m, wifiPara.ap_name);
160 130
   lv_label_set_text(wifi_name_text, public_buf_m);
161
-  lv_obj_align(wifi_name_text, NULL, LV_ALIGN_CENTER, 0, -70);
131
+  lv_obj_align(wifi_name_text, nullptr, LV_ALIGN_CENTER, 0, -70);
162 132
 
163 133
   if (wifiPara.mode == AP_MODEL) {
164
-    memset(public_buf_m, 0, sizeof(public_buf_m));
165
-    strcpy(public_buf_m,wifi_menu.key);
166
-    strcat(public_buf_m,wifiPara.keyCode);
134
+    strcpy(public_buf_m, wifi_menu.key);
135
+    strcat(public_buf_m, wifiPara.keyCode);
167 136
     lv_label_set_text(wifi_key_text, public_buf_m);
168
-    lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER, 0, -40);
137
+    lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -40);
169 138
 
170
-    memset(public_buf_m, 0, sizeof(public_buf_m));
171
-    strcpy(public_buf_m,wifi_menu.state_ap);
139
+    strcpy(public_buf_m, wifi_menu.state_ap);
172 140
     if (wifi_link_state == WIFI_CONNECTED)
173
-      strcat(public_buf_m,wifi_menu.connected);
141
+      strcat(public_buf_m, wifi_menu.connected);
174 142
     else if (wifi_link_state == WIFI_NOT_CONFIG)
175
-      strcat(public_buf_m,wifi_menu.disconnected);
143
+      strcat(public_buf_m, wifi_menu.disconnected);
176 144
     else
177
-      strcat(public_buf_m,wifi_menu.exception);
145
+      strcat(public_buf_m, wifi_menu.exception);
178 146
     lv_label_set_text(wifi_state_text, public_buf_m);
179
-    lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER, 0, -10);
147
+    lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -10);
180 148
   }
181 149
   else {
182
-    ZERO(public_buf_m);
183 150
     strcpy(public_buf_m, wifi_menu.state_sta);
184 151
     if (wifi_link_state == WIFI_CONNECTED)
185 152
       strcat(public_buf_m, wifi_menu.connected);
@@ -188,10 +155,10 @@ void disp_wifi_state() {
188 155
     else
189 156
       strcat(public_buf_m, wifi_menu.exception);
190 157
     lv_label_set_text(wifi_state_text, public_buf_m);
191
-    lv_obj_align(wifi_state_text, NULL, LV_ALIGN_CENTER, 0, -40);
158
+    lv_obj_align(wifi_state_text, nullptr, LV_ALIGN_CENTER, 0, -40);
192 159
 
193 160
     lv_label_set_text(wifi_key_text, "");
194
-    lv_obj_align(wifi_key_text, NULL, LV_ALIGN_CENTER, 0, -10);
161
+    lv_obj_align(wifi_key_text, nullptr, LV_ALIGN_CENTER, 0, -10);
195 162
   }
196 163
 }
197 164
 

+ 37
- 60
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_list.cpp View File

@@ -39,61 +39,48 @@
39 39
 WIFI_LIST wifi_list;
40 40
 list_menu_def list_menu;
41 41
 
42
-extern lv_group_t * g;
43
-static lv_obj_t * scr;
42
+extern lv_group_t *g;
43
+static lv_obj_t *scr;
44 44
 static lv_obj_t *buttonWifiN[NUMBER_OF_PAGE];
45 45
 static lv_obj_t *labelWifiText[NUMBER_OF_PAGE];
46 46
 static lv_obj_t *labelPageText;
47 47
 
48
-#define ID_WL_RETURN      11
49
-#define ID_WL_DOWN        12
48
+#define ID_WL_RETURN 11
49
+#define ID_WL_DOWN   12
50 50
 
51
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
52
-  if (obj->mks_obj_id == ID_WL_RETURN) {
53
-    if (event == LV_EVENT_CLICKED) {
51
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
52
+  if (event != LV_EVENT_RELEASED) return;
54 53
 
55
-    }
56
-    else if (event == LV_EVENT_RELEASED) {
57
-      clear_cur_ui();
58
-      lv_draw_set();
59
-    }
54
+  if (obj->mks_obj_id == ID_WL_RETURN) {
55
+    clear_cur_ui();
56
+    lv_draw_set();
60 57
   }
61 58
   else if (obj->mks_obj_id == ID_WL_DOWN) {
62
-    if (event == LV_EVENT_CLICKED) {
63
-
64
-    }
65
-    else if (event == LV_EVENT_RELEASED) {
66
-      if (wifi_list.getNameNum > 0) {
67
-        if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
68
-          wifi_list.nameIndex = 0;
69
-          wifi_list.currentWifipage = 1;
70
-        }
71
-        else {
72
-          wifi_list.nameIndex += NUMBER_OF_PAGE;
73
-          wifi_list.currentWifipage++;
74
-        }
75
-        disp_wifi_list();
59
+    if (wifi_list.getNameNum > 0) {
60
+      if ((wifi_list.nameIndex + NUMBER_OF_PAGE) >= wifi_list.getNameNum) {
61
+        wifi_list.nameIndex = 0;
62
+        wifi_list.currentWifipage = 1;
63
+      }
64
+      else {
65
+        wifi_list.nameIndex += NUMBER_OF_PAGE;
66
+        wifi_list.currentWifipage++;
76 67
       }
68
+      disp_wifi_list();
77 69
     }
78 70
   }
79 71
   else {
80 72
     for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
81 73
       if (obj->mks_obj_id == i + 1) {
82
-        if (event == LV_EVENT_CLICKED) {
83
-
84
-        }
85
-        else if (event == LV_EVENT_RELEASED) {
86
-          if (wifi_list.getNameNum != 0) {
87
-            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;
88
-            wifi_list.nameIndex += i;
89
-            last_disp_state = WIFI_LIST_UI;
90
-            lv_clear_wifi_list();
91
-            if (do_wifi)
92
-              lv_draw_wifi();
93
-            else {
94
-              keyboard_value = wifiConfig;
95
-              lv_draw_keyboard();
96
-            }
74
+        if (wifi_list.getNameNum != 0) {
75
+          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;
76
+          wifi_list.nameIndex += i;
77
+          last_disp_state = WIFI_LIST_UI;
78
+          lv_clear_wifi_list();
79
+          if (do_wifi)
80
+            lv_draw_wifi();
81
+          else {
82
+            keyboard_value = wifiConfig;
83
+            lv_draw_keyboard();
97 84
           }
98 85
         }
99 86
       }
@@ -102,34 +89,23 @@ static void event_handler(lv_obj_t * obj, lv_event_t event) {
102 89
 }
103 90
 
104 91
 void lv_draw_wifi_list(void) {
105
-  lv_obj_t *buttonBack = NULL, *buttonDown = NULL;
106
-
107 92
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_LIST_UI) {
108 93
     disp_state_stack._disp_index++;
109 94
     disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_LIST_UI;
110 95
   }
111 96
   disp_state = WIFI_LIST_UI;
112 97
 
113
-  scr = lv_obj_create(NULL, NULL);
114
-
115
-  lv_obj_set_style(scr, &tft_style_scr);
116
-  lv_scr_load(scr);
117
-  lv_obj_clean(scr);
98
+  scr = lv_screen_create();
118 99
 
119 100
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, creat_title_text());
120 101
 
121 102
   lv_refr_now(lv_refr_get_disp_refreshing());
122 103
 
123
-  buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN);
124
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN);
104
+  lv_obj_t *buttonDown = lv_imgbtn_create(scr, "F:/bmp_pageDown.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + OTHER_BTN_YPIEL + INTERVAL_H, event_handler, ID_WL_DOWN);
105
+  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back.bin", OTHER_BTN_XPIEL * 3 + INTERVAL_V * 4, titleHeight + (OTHER_BTN_YPIEL + INTERVAL_H) * 2, event_handler, ID_WL_RETURN);
125 106
 
126 107
   for (uint8_t i = 0; i < NUMBER_OF_PAGE; i++) {
127
-    buttonWifiN[i] = lv_btn_create(scr, NULL);     /*Add a button the current screen*/
128
-    lv_obj_set_pos(buttonWifiN[i], 0, NAME_BTN_Y*i+10+titleHeight);                            /*Set its position*/
129
-    lv_obj_set_size(buttonWifiN[i], NAME_BTN_X, NAME_BTN_Y);                          /*Set its size*/
130
-    lv_obj_set_event_cb_mks(buttonWifiN[i], event_handler, (i+1), NULL, 0);
131
-    lv_btn_use_label_style(buttonWifiN[i]);
132
-    lv_btn_set_layout(buttonWifiN[i], LV_LAYOUT_OFF);
108
+    buttonWifiN[i] = lv_label_btn_create(scr, 0, NAME_BTN_Y * i + 10 + titleHeight, NAME_BTN_X, NAME_BTN_Y, event_handler, i + 1);
133 109
     labelWifiText[i] = lv_label_create_empty(buttonWifiN[i]);
134 110
     #if HAS_ROTARY_ENCODER
135 111
       uint8_t j = 0;
@@ -147,9 +123,10 @@ void lv_draw_wifi_list(void) {
147 123
   wifi_list.currentWifipage = 1;
148 124
 
149 125
   if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode == STA_MODEL) {
150
-    memset(wifi_list.wifiConnectedName, 0, sizeof(&wifi_list.wifiConnectedName));
126
+    ZERO(wifi_list.wifiConnectedName);
151 127
     memcpy(wifi_list.wifiConnectedName, wifiPara.ap_name, sizeof(wifi_list.wifiConnectedName));
152 128
   }
129
+
153 130
   #if HAS_ROTARY_ENCODER
154 131
     if (gCfgItems.encoder_enable) {
155 132
       lv_group_add_obj(g, buttonDown);
@@ -166,10 +143,10 @@ void disp_wifi_list(void) {
166 143
 
167 144
   sprintf((char *)tmpStr, list_menu.file_pages, wifi_list.currentWifipage, wifi_list.getPage);
168 145
   lv_label_set_text(labelPageText, (const char *)tmpStr);
169
-  lv_obj_align(labelPageText, NULL, LV_ALIGN_CENTER, 50, -100);
146
+  lv_obj_align(labelPageText, nullptr, LV_ALIGN_CENTER, 50, -100);
170 147
 
171 148
   for (i = 0; i < NUMBER_OF_PAGE; i++) {
172
-    memset(tmpStr, 0, sizeof(tmpStr));
149
+    ZERO(tmpStr);
173 150
 
174 151
     j = wifi_list.nameIndex + i;
175 152
     if (j >= wifi_list.getNameNum) {
@@ -187,7 +164,7 @@ void disp_wifi_list(void) {
187 164
 }
188 165
 
189 166
 void wifi_scan_handle() {
190
-  if (uiCfg.dialogType != WIFI_ENABLE_TIPS || uiCfg.command_send != 1) return;
167
+  if (!DIALOG_IS(WIFI_ENABLE_TIPS) || uiCfg.command_send != 1) return;
191 168
   last_disp_state = DIALOG_UI;
192 169
   lv_clear_dialog();
193 170
   if (wifi_link_state == WIFI_CONNECTED && wifiPara.mode != AP_MODEL)

+ 80
- 126
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_settings.cpp View File

@@ -30,161 +30,117 @@
30 30
 
31 31
 #include "draw_ui.h"
32 32
 
33
-extern lv_group_t * g;
34
-static lv_obj_t *scr, *labelModelValue = NULL, *buttonModelValue = NULL, *labelCloudValue = NULL;
35
-
36
-#define ID_WIFI_RETURN    1
37
-#define ID_WIFI_MODEL     2
38
-#define ID_WIFI_NAME      3
39
-#define ID_WIFI_PASSWORD  4
40
-#define ID_WIFI_CLOUD     5
41
-#define ID_WIFI_CONFIG    6
42
-
43
-static void event_handler(lv_obj_t * obj, lv_event_t event) {
33
+extern lv_group_t *g;
34
+static lv_obj_t *scr, *labelModelValue = nullptr, *buttonModelValue = nullptr, *labelCloudValue = nullptr;
35
+
36
+enum {
37
+  ID_WIFI_RETURN = 1,
38
+  ID_WIFI_MODEL,
39
+  ID_WIFI_NAME,
40
+  ID_WIFI_PASSWORD,
41
+  ID_WIFI_CLOUD,
42
+  ID_WIFI_CONFIG
43
+};
44
+
45
+static void event_handler(lv_obj_t *obj, lv_event_t event) {
46
+  if (event != LV_EVENT_RELEASED) return;
44 47
   switch (obj->mks_obj_id) {
45 48
     case ID_WIFI_RETURN:
46
-      if (event == LV_EVENT_CLICKED) {
47
-
48
-      }
49
-      else if (event == LV_EVENT_RELEASED) {
50
-        lv_clear_wifi_settings();
51
-        draw_return_ui();
52
-      }
53
-    break;
49
+      lv_clear_wifi_settings();
50
+      draw_return_ui();
51
+      break;
54 52
     case ID_WIFI_MODEL:
55
-      if (event == LV_EVENT_CLICKED) {
56
-
53
+      if (gCfgItems.wifi_mode_sel == AP_MODEL) {
54
+        gCfgItems.wifi_mode_sel = STA_MODEL;
55
+        lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
56
+        lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
57
+        update_spi_flash();
57 58
       }
58
-      else if (event == LV_EVENT_RELEASED) {
59
-        if (gCfgItems.wifi_mode_sel == AP_MODEL) {
60
-          gCfgItems.wifi_mode_sel = STA_MODEL;
61
-          lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
62
-          lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
63
-          update_spi_flash();
64
-        }
65
-        else {
66
-          gCfgItems.wifi_mode_sel = AP_MODEL;
67
-          lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
68
-          lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
69
-          update_spi_flash();
70
-        }
59
+      else {
60
+        gCfgItems.wifi_mode_sel = AP_MODEL;
61
+        lv_label_set_text(labelModelValue, WIFI_AP_TEXT);
62
+        lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
63
+        update_spi_flash();
71 64
       }
72
-    break;
65
+      break;
73 66
     case ID_WIFI_NAME:
74
-      if (event == LV_EVENT_CLICKED) {
75
-
76
-      }
77
-      else if (event == LV_EVENT_RELEASED) {
78
-        keyboard_value = wifiName;
79
-        lv_clear_wifi_settings();
80
-        lv_draw_keyboard();
81
-      }
82
-    break;
67
+      keyboard_value = wifiName;
68
+      lv_clear_wifi_settings();
69
+      lv_draw_keyboard();
70
+      break;
83 71
     case ID_WIFI_PASSWORD:
84
-      if (event == LV_EVENT_CLICKED) {
85
-
86
-      }
87
-      else if (event == LV_EVENT_RELEASED) {
88 72
       keyboard_value = wifiPassWord;
89
-        lv_clear_wifi_settings();
90
-        lv_draw_keyboard();
91
-      }
92
-    break;
73
+      lv_clear_wifi_settings();
74
+      lv_draw_keyboard();
75
+      break;
93 76
     case ID_WIFI_CLOUD:
94
-      if (event == LV_EVENT_CLICKED) {
95
-
77
+      if (gCfgItems.cloud_enable) {
78
+        gCfgItems.cloud_enable = false;
79
+        lv_obj_set_event_cb_mks(obj, event_handler, ID_WIFI_CLOUD, "bmp_disable.bin", 0);
80
+        lv_label_set_text(labelCloudValue, machine_menu.disable);
96 81
       }
97
-      else if (event == LV_EVENT_RELEASED) {
98
-        if (gCfgItems.cloud_enable) {
99
-          gCfgItems.cloud_enable = false;
100
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_WIFI_CLOUD, "bmp_disable.bin", 0);
101
-          lv_label_set_text(labelCloudValue, machine_menu.disable);
102
-        }
103
-        else {
104
-          gCfgItems.cloud_enable = true;
105
-          lv_obj_set_event_cb_mks(obj, event_handler, ID_WIFI_CLOUD, "bmp_enable.bin", 0);
106
-          lv_label_set_text(labelCloudValue, machine_menu.enable);
107
-        }
108
-        update_spi_flash();
82
+      else {
83
+        gCfgItems.cloud_enable = true;
84
+        lv_obj_set_event_cb_mks(obj, event_handler, ID_WIFI_CLOUD, "bmp_enable.bin", 0);
85
+        lv_label_set_text(labelCloudValue, machine_menu.enable);
109 86
       }
110
-    break;
87
+      update_spi_flash();
88
+      break;
111 89
     case ID_WIFI_CONFIG:
112
-      if (event == LV_EVENT_CLICKED) {
113
-
114
-      }
115
-      else if (event == LV_EVENT_RELEASED) {
116
-        lv_clear_wifi_settings();
117
-        lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
118
-      }
119
-    break;
90
+      lv_clear_wifi_settings();
91
+      lv_draw_dialog(DIALOG_WIFI_CONFIG_TIPS);
92
+      break;
120 93
   }
121 94
 }
122 95
 
123 96
 void lv_draw_wifi_settings(void) {
124
-  lv_obj_t *buttonBack = NULL, *label_Back = NULL, *buttonConfig = NULL, *labelConfig = NULL;
125
-  lv_obj_t *labelModelText = NULL;
126
-  lv_obj_t *labelNameText = NULL, *buttonNameValue = NULL, *labelNameValue = NULL;
127
-  lv_obj_t *labelPassWordText = NULL, *buttonPassWordValue = NULL, *labelPassWordValue = NULL;
128
-  lv_obj_t *labelCloudText = NULL, *buttonCloudValue = NULL;
129
-  lv_obj_t * line1 = NULL, *line2 = NULL, *line3 = NULL, *line4 = NULL;
130 97
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_SETTINGS_UI) {
131 98
     disp_state_stack._disp_index++;
132 99
     disp_state_stack._disp_state[disp_state_stack._disp_index] = WIFI_SETTINGS_UI;
133 100
   }
134 101
   disp_state = WIFI_SETTINGS_UI;
135 102
 
136
-  scr = lv_obj_create(NULL, NULL);
137
-
138
-  lv_obj_set_style(scr, &tft_style_scr);
139
-  lv_scr_load(scr);
140
-  lv_obj_clean(scr);
103
+  scr = lv_screen_create();
141 104
 
142 105
   (void)lv_label_create(scr, TITLE_XPOS, TITLE_YPOS, machine_menu.WifiConfTitle);
143 106
 
144 107
   lv_refr_now(lv_refr_get_disp_refreshing());
145 108
 
146
-  labelModelText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.wifiMode);
109
+  lv_obj_t *labelModelText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y + 10, machine_menu.wifiMode);
147 110
 
148
-  buttonModelValue = lv_imgbtn_create(scr, NULL);
149
-  lv_imgbtn_set_src_both(buttonModelValue, "F:/bmp_blank_sel.bin");
150
-  lv_obj_set_pos(buttonModelValue, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V);
151
-  lv_obj_set_event_cb_mks(buttonModelValue, event_handler, ID_WIFI_MODEL, NULL, 0);
111
+  lv_obj_t *buttonModelValue = lv_imgbtn_create(scr, "F:/bmp_blank_sel.bin", PARA_UI_VALUE_POS_X, PARA_UI_POS_Y + PARA_UI_VALUE_V, event_handler, ID_WIFI_MODEL);
152 112
   lv_btn_set_style_both(buttonModelValue, &style_para_value_pre);
153
-  lv_btn_set_layout(buttonModelValue, LV_LAYOUT_OFF);
154 113
   labelModelValue = lv_label_create_empty(buttonModelValue);
155 114
 
156
-  line1 = lv_line_create(scr, NULL);
157
-  lv_ex_line(line1,line_points[0]);
158
-
159
-  labelNameText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, NULL);
160
-
161
-  buttonNameValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_NAME);
162
-  labelNameValue = lv_label_create_empty(buttonNameValue);
163
-
164
-  line2 = lv_line_create(scr, NULL);
165
-  lv_ex_line(line2,line_points[1]);
115
+  lv_obj_t *line1 = lv_line_create(scr, nullptr);
116
+  lv_ex_line(line1, line_points[0]);
166 117
 
167
-  labelPassWordText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, NULL);
118
+  lv_obj_t *labelNameText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 2 + 10, nullptr);
119
+  lv_obj_t *buttonNameValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 2 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_NAME);
120
+  lv_obj_t *labelNameValue = lv_label_create_empty(buttonNameValue);
168 121
 
169
-  buttonPassWordValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_PASSWORD);
170
-  labelPassWordValue = lv_label_create_empty(buttonPassWordValue);
122
+  lv_obj_t *line2 = lv_line_create(scr, nullptr);
123
+  lv_ex_line(line2, line_points[1]);
171 124
 
172
-  line3 = lv_line_create(scr, NULL);
173
-  lv_ex_line(line3,line_points[2]);
125
+  lv_obj_t *labelPassWordText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 3 + 10, nullptr);
126
+  lv_obj_t *buttonPassWordValue = lv_btn_create(scr, PARA_UI_VALUE_POS_X, PARA_UI_POS_Y * 3 + PARA_UI_VALUE_V, PARA_UI_VALUE_BTN_X_SIZE, PARA_UI_VALUE_BTN_Y_SIZE, event_handler, ID_WIFI_PASSWORD);
127
+  lv_obj_t *labelPassWordValue = lv_label_create_empty(buttonPassWordValue);
174 128
 
175
-  labelCloudText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.wifiCloud);
129
+  lv_obj_t *line3 = lv_line_create(scr, nullptr);
130
+  lv_ex_line(line3, line_points[2]);
176 131
 
177
-  buttonCloudValue = lv_imgbtn_create(scr, gCfgItems.cloud_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_WIFI_CLOUD);
132
+  lv_obj_t *labelCloudText = lv_label_create(scr, PARA_UI_POS_X, PARA_UI_POS_Y * 4 + 10, machine_menu.wifiCloud);
133
+  lv_obj_t *buttonCloudValue = lv_imgbtn_create(scr, gCfgItems.cloud_enable ? "F:/bmp_enable.bin" : "F:/bmp_disable.bin", PARA_UI_STATE_POS_X, PARA_UI_POS_Y * 4 + PARA_UI_STATE_V, event_handler, ID_WIFI_CLOUD);
178 134
   labelCloudValue = lv_label_create_empty(buttonCloudValue);
179 135
 
180
-  line4 = lv_line_create(scr, NULL);
181
-  lv_ex_line(line4,line_points[3]);
136
+  lv_obj_t *line4 = lv_line_create(scr, nullptr);
137
+  lv_ex_line(line4, line_points[3]);
182 138
 
183
-  buttonConfig = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_WIFI_CONFIG);
184
-  labelConfig = lv_label_create_empty(buttonConfig);
139
+  lv_obj_t *buttonConfig = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_TURN_PAGE_POS_X, PARA_UI_TURN_PAGE_POS_Y, event_handler, ID_WIFI_CONFIG);
140
+  lv_obj_t *labelConfig = lv_label_create_empty(buttonConfig);
185 141
 
186
-  buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_WIFI_RETURN);
187
-  label_Back = lv_label_create_empty(buttonBack);
142
+  lv_obj_t *buttonBack = lv_imgbtn_create(scr, "F:/bmp_back70x40.bin", PARA_UI_BACL_POS_X, PARA_UI_BACL_POS_Y, event_handler, ID_WIFI_RETURN);
143
+  lv_obj_t *label_Back = lv_label_create_empty(buttonBack);
188 144
 
189 145
   if (gCfgItems.multiple_language) {
190 146
     if (gCfgItems.wifi_mode_sel == AP_MODEL) {
@@ -195,26 +151,24 @@ void lv_draw_wifi_settings(void) {
195 151
       lv_label_set_text(labelModelValue, WIFI_STA_TEXT);
196 152
       lv_obj_align(labelModelValue, buttonModelValue, LV_ALIGN_CENTER, 0, 0);
197 153
     }
198
-    memset(public_buf_m,0,sizeof(public_buf_m));
199
-    strcat(public_buf_m,machine_menu.wifiName);
200
-    strcat(public_buf_m,(const char *)uiCfg.wifi_name);
201
-    lv_label_set_text(labelNameText,public_buf_m);
154
+    strcat(public_buf_m, machine_menu.wifiName);
155
+    strcat(public_buf_m, (const char *)uiCfg.wifi_name);
156
+    lv_label_set_text(labelNameText, public_buf_m);
202 157
 
203
-    lv_label_set_text(labelNameValue,machine_menu.wifiEdit);
158
+    lv_label_set_text(labelNameValue, machine_menu.wifiEdit);
204 159
     lv_obj_align(labelNameValue, buttonNameValue, LV_ALIGN_CENTER, 0, 0);
205 160
 
206
-    memset(public_buf_m,0,sizeof(public_buf_m));
207
-    strcat(public_buf_m,machine_menu.wifiPassWord);
208
-    strcat(public_buf_m,(const char *)uiCfg.wifi_key);
209
-    lv_label_set_text(labelPassWordText,public_buf_m);
161
+    strcat(public_buf_m, machine_menu.wifiPassWord);
162
+    strcat(public_buf_m, (const char *)uiCfg.wifi_key);
163
+    lv_label_set_text(labelPassWordText, public_buf_m);
210 164
 
211
-    lv_label_set_text(labelPassWordValue,machine_menu.wifiEdit);
165
+    lv_label_set_text(labelPassWordValue, machine_menu.wifiEdit);
212 166
     lv_obj_align(labelPassWordValue, buttonPassWordValue, LV_ALIGN_CENTER, 0, 0);
213 167
 
214 168
     lv_label_set_text(labelCloudValue, gCfgItems.cloud_enable ? machine_menu.enable : machine_menu.disable);
215 169
     lv_obj_align(labelCloudValue, buttonCloudValue, LV_ALIGN_CENTER, 0, 0);
216 170
 
217
-    lv_label_set_text(labelConfig,machine_menu.wifiConfig);
171
+    lv_label_set_text(labelConfig, machine_menu.wifiConfig);
218 172
     lv_obj_align(labelConfig, buttonConfig, LV_ALIGN_CENTER, 0, 0);
219 173
 
220 174
     lv_label_set_text(label_Back, common_menu.text_back);

+ 7
- 11
Marlin/src/lcd/extui/lib/mks_ui/draw_wifi_tips.cpp View File

@@ -30,14 +30,14 @@
30 30
 
31 31
 #include "draw_ui.h"
32 32
 
33
-static lv_obj_t * scr;
33
+static lv_obj_t *scr;
34 34
 
35 35
 TIPS_TYPE wifi_tips_type;
36 36
 TIPS_DISP tips_disp;
37 37
 tips_menu_def tips_menu;
38 38
 
39 39
 void lv_draw_wifi_tips(void) {
40
-  static lv_obj_t * text_tips,*wifi_name;
40
+  static lv_obj_t *text_tips,*wifi_name;
41 41
 
42 42
   if (disp_state_stack._disp_state[disp_state_stack._disp_index] != WIFI_TIPS_UI) {
43 43
     disp_state_stack._disp_index++;
@@ -45,28 +45,24 @@ void lv_draw_wifi_tips(void) {
45 45
   }
46 46
   disp_state = WIFI_TIPS_UI;
47 47
 
48
-  scr = lv_obj_create(NULL, NULL);
49
-
50
-  lv_obj_set_style(scr, &tft_style_scr);
51
-  lv_scr_load(scr);
52
-  lv_obj_clean(scr);
48
+  scr = lv_screen_create();
53 49
   lv_refr_now(lv_refr_get_disp_refreshing());
54 50
 
55 51
   wifi_name = lv_label_create(scr, (const char *)wifi_list.wifiName[wifi_list.nameIndex]);
56
-  lv_obj_align(wifi_name, NULL, LV_ALIGN_CENTER, 0, -20);
52
+  lv_obj_align(wifi_name, nullptr, LV_ALIGN_CENTER, 0, -20);
57 53
 
58 54
   text_tips = lv_label_create_empty(scr);
59 55
   if (wifi_tips_type == TIPS_TYPE_JOINING) {
60 56
     lv_label_set_text(text_tips, tips_menu.joining);
61
-    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60);
57
+    lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
62 58
   }
63 59
   else if (wifi_tips_type == TIPS_TYPE_TAILED_JOIN) {
64 60
     lv_label_set_text(text_tips, tips_menu.failedJoin);
65
-    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60);
61
+    lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
66 62
   }
67 63
   else if (wifi_tips_type == TIPS_TYPE_WIFI_CONECTED) {
68 64
     lv_label_set_text(text_tips, tips_menu.wifiConected);
69
-    lv_obj_align(text_tips, NULL, LV_ALIGN_CENTER, 0, -60);
65
+    lv_obj_align(text_tips, nullptr, LV_ALIGN_CENTER, 0, -60);
70 66
   }
71 67
 
72 68
   tips_disp.timer = TIPS_TIMER_START;

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

@@ -62,7 +62,7 @@ static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t u
62 62
     memcpy(&__g_xbf_hd, p, sizeof(x_header_t));
63 63
   }
64 64
   if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min)
65
-    return NULL;
65
+    return nullptr;
66 66
   uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4;
67 67
   uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
68 68
   if (p_pos[0] != 0) {
@@ -72,7 +72,7 @@ static const uint8_t * __user_font_get_bitmap(const lv_font_t * font, uint32_t u
72 72
     //return __user_font_getdata(pos+2, gdsc->box_w*__g_xbf_hd.bpp/8);
73 73
     return __user_font_getdata(pos + 2, sizeof(__g_font_buf));
74 74
   }
75
-  return NULL;
75
+  return nullptr;
76 76
 }
77 77
 
78 78
 static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_t * dsc_out, uint32_t unicode_letter, uint32_t unicode_letter_next) {
@@ -81,7 +81,7 @@ static bool __user_font_get_glyph_dsc(const lv_font_t * font, lv_font_glyph_dsc_
81 81
     memcpy(&__g_xbf_hd, p, sizeof(x_header_t));
82 82
   }
83 83
   if (unicode_letter > __g_xbf_hd.max || unicode_letter < __g_xbf_hd.min)
84
-    return NULL;
84
+    return false;
85 85
   uint32_t unicode_offset = sizeof(x_header_t) + (unicode_letter - __g_xbf_hd.min) * 4;
86 86
   uint32_t *p_pos = (uint32_t *)__user_font_getdata(unicode_offset, 4);
87 87
   if (p_pos[0] != 0) {

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

@@ -637,7 +637,7 @@ void disp_string(uint16_t x, uint16_t y, const char * string, uint16_t charColor
637 637
   }
638 638
 }
639 639
 
640
-//static lv_obj_t * scr_test;
640
+//static lv_obj_t *scr_test;
641 641
 void disp_assets_update() {
642 642
   SPI_TFT.LCD_clear(0x0000);
643 643
   disp_string(100, 140, "Assets Updating...", 0xFFFF, 0x0000);

+ 0
- 7
Marlin/src/lcd/extui/lib/mks_ui/printer_operation.cpp View File

@@ -58,13 +58,11 @@ void printer_state_polling() {
58 58
 
59 59
         if (gCfgItems.pausePosZ != (float)-1) {
60 60
           gcode.process_subcommands_now_P(PSTR("G91"));
61
-          ZERO(public_buf_l);
62 61
           sprintf_P(public_buf_l, PSTR("G1 Z%.1f"), gCfgItems.pausePosZ);
63 62
           gcode.process_subcommands_now(public_buf_l);
64 63
           gcode.process_subcommands_now_P(PSTR("G90"));
65 64
         }
66 65
         if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) {
67
-          ZERO(public_buf_l);
68 66
           sprintf_P(public_buf_l, PSTR("G1 X%.1f Y%.1f"), gCfgItems.pausePosX, gCfgItems.pausePosY);
69 67
           gcode.process_subcommands_now(public_buf_l);
70 68
         }
@@ -88,13 +86,11 @@ void printer_state_polling() {
88 86
   if (uiCfg.print_state == RESUMING) {
89 87
     if (IS_SD_PAUSED()) {
90 88
       if (gCfgItems.pausePosX != (float)-1 && gCfgItems.pausePosY != (float)-1) {
91
-        ZERO(public_buf_m);
92 89
         sprintf_P(public_buf_m, PSTR("G1 X%.1f Y%.1f"), uiCfg.current_x_position_bak, uiCfg.current_y_position_bak);
93 90
         gcode.process_subcommands_now(public_buf_m);
94 91
       }
95 92
       if (gCfgItems.pausePosZ != (float)-1) {
96 93
         gcode.process_subcommands_now_P(PSTR("G91"));
97
-        ZERO(public_buf_l);
98 94
         sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
99 95
         gcode.process_subcommands_now(public_buf_l);
100 96
         gcode.process_subcommands_now_P(PSTR("G90"));
@@ -109,7 +105,6 @@ void printer_state_polling() {
109 105
   }
110 106
   #if ENABLED(POWER_LOSS_RECOVERY)
111 107
     if (uiCfg.print_state == REPRINTED) {
112
-      ZERO(public_buf_m);
113 108
       #if HAS_HOTEND
114 109
         HOTEND_LOOP() {
115 110
           const int16_t et = recovery.info.target_temperature[e];
@@ -128,7 +123,6 @@ void printer_state_polling() {
128 123
       #if 0
129 124
         // Move back to the saved XY
130 125
         char str_1[16], str_2[16];
131
-        ZERO(public_buf_m);
132 126
         sprintf_P(public_buf_m, PSTR("G1 X%s Y%s F2000"),
133 127
           dtostrf(recovery.info.current_position.x, 1, 3, str_1),
134 128
           dtostrf(recovery.info.current_position.y, 1, 3, str_2)
@@ -137,7 +131,6 @@ void printer_state_polling() {
137 131
 
138 132
         if (gCfgItems.pause_reprint && gCfgItems.pausePosZ != -1.0f) {
139 133
           gcode.process_subcommands_now_P(PSTR("G91"));
140
-          ZERO(public_buf_l);
141 134
           sprintf_P(public_buf_l, PSTR("G1 Z-%.1f"), gCfgItems.pausePosZ);
142 135
           gcode.process_subcommands_now(public_buf_l);
143 136
           gcode.process_subcommands_now_P(PSTR("G90"));

+ 13
- 17
Marlin/src/lcd/extui/lib/mks_ui/tft_lvgl_configuration.cpp View File

@@ -99,7 +99,7 @@ void SysTick_Callback() {
99 99
       uiCfg.filament_unloading_time_cnt  = 0;
100 100
       uiCfg.filament_unloading_time_flg  = 0;
101 101
       uiCfg.filament_unloading_completed = 1;
102
-      uiCfg.filament_rate                = 100;
102
+      uiCfg.filament_rate = 100;
103 103
     }
104 104
   }
105 105
 }
@@ -133,7 +133,7 @@ void tft_lvgl_init() {
133 133
 
134 134
   lv_init();
135 135
 
136
-  lv_disp_buf_init(&disp_buf, bmp_public_buf, NULL, LV_HOR_RES_MAX * 18); /*Initialize the display buffer*/
136
+  lv_disp_buf_init(&disp_buf, bmp_public_buf, nullptr, LV_HOR_RES_MAX * 18); /*Initialize the display buffer*/
137 137
 
138 138
   lv_disp_drv_t disp_drv;     /*Descriptor of a display driver*/
139 139
   lv_disp_drv_init(&disp_drv);    /*Basic initialization*/
@@ -199,7 +199,6 @@ void tft_lvgl_init() {
199 199
 
200 200
       uiCfg.print_state = REPRINTING;
201 201
 
202
-      ZERO(public_buf_m);
203 202
       strncpy(public_buf_m, recovery.info.sd_filename, sizeof(public_buf_m));
204 203
       card.printLongPath(public_buf_m);
205 204
 
@@ -216,15 +215,14 @@ void tft_lvgl_init() {
216 215
 }
217 216
 
218 217
 void my_disp_flush(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
219
-  uint16_t i, width, height;
220
-
221
-  width = area->x2 - area->x1 + 1;
222
-  height = area->y2 - area->y1 + 1;
218
+  uint16_t width = area->x2 - area->x1 + 1,
219
+          height = area->y2 - area->y1 + 1;
223 220
 
224 221
   SPI_TFT.setWindow((uint16_t)area->x1, (uint16_t)area->y1, width, height);
225
-  for (i = 0; i < height; i++) {
222
+
223
+  for (uint16_t i = 0; i < height; i++)
226 224
     SPI_TFT.tftio.WriteSequence((uint16_t*)(color_p + width * i), width);
227
-  }
225
+
228 226
   lv_disp_flush_ready(disp);       /* Indicate you are ready with the flushing*/
229 227
 
230 228
   W25QXX.init(SPI_QUARTER_SPEED);
@@ -310,10 +308,9 @@ extern uint8_t currentFlashPage;
310 308
 uint32_t pic_read_base_addr = 0, pic_read_addr_offset = 0;
311 309
 lv_fs_res_t spi_flash_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
312 310
   static char last_path_name[30];
313
-  if (strcasecmp(last_path_name,path) != 0) {
311
+  if (strcasecmp(last_path_name, path) != 0) {
314 312
     pic_read_base_addr = lv_get_pic_addr((uint8_t *)path);
315
-    ZERO(last_path_name);
316
-    strcpy(last_path_name,path);
313
+    strcpy(last_path_name, path);
317 314
   }
318 315
   else {
319 316
     W25QXX.init(SPI_QUARTER_SPEED);
@@ -362,11 +359,10 @@ uint32_t sd_read_base_addr = 0,sd_read_addr_offset = 0;
362 359
 lv_fs_res_t sd_open_cb (lv_fs_drv_t * drv, void * file_p, const char * path, lv_fs_mode_t mode) {
363 360
   //cur_namefff = strrchr(path, '/');
364 361
   char name_buf[100];
365
-  ZERO(name_buf);
366
-  strcat(name_buf,"/");
367
-  strcat(name_buf,path);
368
-  char *temp = strstr(name_buf,".bin");
369
-  if (temp) { strcpy(temp,".GCO"); }
362
+  *name_buf = '/';
363
+  strcpy(name_buf + 1, path);
364
+  char *temp = strstr(name_buf, ".bin");
365
+  if (temp) strcpy(temp, ".GCO");
370 366
   sd_read_base_addr = lv_open_gcode_file((char *)name_buf);
371 367
   sd_read_addr_offset = sd_read_base_addr;
372 368
   if (sd_read_addr_offset == 0) return LV_FS_RES_NOT_EX;

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

@@ -260,7 +260,7 @@ void WriteByteSlip(uint8_t b) {
260 260
 // Wait for a data packet to be returned.  If the body of the packet is
261 261
 // non-zero length, return an allocated buffer indirectly containing the
262 262
 // data and return the data length. Note that if the pointer for returning
263
-// the data buffer is NULL, the response is expected to be two bytes of zero.
263
+// the data buffer is nullptr, the response is expected to be two bytes of zero.
264 264
 //
265 265
 // If an error occurs, return a negative value.  Otherwise, return the number
266 266
 // of bytes in the response (or zero if the response was not the standard "two bytes of zero").
@@ -533,7 +533,7 @@ EspUploadResult flashFinish(signed char reboot) {
533 533
 
534 534
 // Compute the checksum of a block of data
535 535
 uint16_t checksum(const uint8_t *data, uint16_t dataLen, uint16_t cksum) {
536
-  if (data != NULL) {
536
+  if (data != nullptr) {
537 537
     while (dataLen--) {
538 538
       cksum ^= (uint16_t)*data++;
539 539
     }

+ 12
- 0
buildroot/tests/mks_robin_nano35-tests View File

@@ -53,5 +53,17 @@ opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240
53 53
 opt_enable TFT_INTERFACE_SPI TFT_RES_480x320
54 54
 exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI"
55 55
 
56
+#
57
+# MKS Robin v2 nano LVGL SPI + TMC
58
+# (Robin v2 nano has no FSMC interface)
59
+#
60
+use_example_configs Mks/Robin
61
+opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
62
+opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240
63
+opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320
64
+opt_set X_DRIVER_TYPE TMC2209
65
+opt_set Y_DRIVER_TYPE TMC2209
66
+exec_test $1 $2 "MKS Robin v2 nano LVGL SPI + TMC"
67
+
56 68
 # cleanup
57 69
 restore_configs

Loading…
Cancel
Save