Browse Source

🚸 MKS UI extrusion speed/steps config (#22656)

DvoraNoob 3 years ago
parent
commit
3a2eb574e2
No account linked to committer's email address

+ 36
- 54
Marlin/src/lcd/extui/mks_ui/draw_extrusion.cpp View File

@@ -89,20 +89,18 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) {
89 89
       disp_extru_amount();
90 90
       break;
91 91
     case ID_E_STEP:
92
-      switch (ABS(uiCfg.extruStep)) {
93
-        case  1: uiCfg.extruStep = 5; break;
94
-        case  5: uiCfg.extruStep = 10; break;
95
-        case 10: uiCfg.extruStep = 1; break;
96
-        default: break;
92
+      switch (uiCfg.extruStep) {
93
+        case uiCfg.eStepMin: uiCfg.extruStep = uiCfg.eStepMed; break;
94
+        case uiCfg.eStepMed: uiCfg.extruStep = uiCfg.eStepMax; break;
95
+        case uiCfg.eStepMax: uiCfg.extruStep = uiCfg.eStepMin; break;
97 96
       }
98 97
       disp_ext_step();
99 98
       break;
100 99
     case ID_E_SPEED:
101 100
       switch (uiCfg.extruSpeed) {
102
-        case  1: uiCfg.extruSpeed = 10; break;
103
-        case 10: uiCfg.extruSpeed = 20; break;
104
-        case 20: uiCfg.extruSpeed = 1; break;
105
-        default: break;
101
+        case uiCfg.eSpeedL: uiCfg.extruSpeed = uiCfg.eSpeedN; break;
102
+        case uiCfg.eSpeedN: uiCfg.extruSpeed = uiCfg.eSpeedH; break;
103
+        case uiCfg.eSpeedH: uiCfg.extruSpeed = uiCfg.eSpeedL; break;
106 104
       }
107 105
       disp_ext_speed();
108 106
       break;
@@ -155,41 +153,30 @@ void lv_draw_extrusion() {
155 153
 void disp_ext_type() {
156 154
   if (uiCfg.extruderIndex == 1) {
157 155
     lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru2.bin");
158
-    if (gCfgItems.multiple_language) {
159
-      lv_label_set_text(labelType, extrude_menu.ext2);
160
-      lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
161
-    }
156
+    if (gCfgItems.multiple_language) lv_label_set_text(labelType, extrude_menu.ext2);
162 157
   }
163 158
   else {
164 159
     lv_imgbtn_set_src_both(buttonType, "F:/bmp_extru1.bin");
165
-    if (gCfgItems.multiple_language) {
166
-      lv_label_set_text(labelType, extrude_menu.ext1);
167
-      lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
168
-    }
160
+    if (gCfgItems.multiple_language) lv_label_set_text(labelType, extrude_menu.ext1);
169 161
   }
162
+  if (gCfgItems.multiple_language)
163
+    lv_obj_align(labelType, buttonType, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
170 164
 }
171 165
 
172 166
 void disp_ext_speed() {
173
-  if (uiCfg.extruSpeed == 20)
174
-    lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_high.bin");
175
-  else if (uiCfg.extruSpeed == 1)
176
-    lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_slow.bin");
177
-  else
178
-    lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_normal.bin");
167
+  switch (uiCfg.extruSpeed) {
168
+    case uiCfg.eSpeedH: lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_high.bin");   break;
169
+    case uiCfg.eSpeedL: lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_slow.bin");   break;
170
+    case uiCfg.eSpeedN: lv_imgbtn_set_src_both(buttonSpeed, "F:/bmp_speed_normal.bin"); break;
171
+  }
179 172
 
180 173
   if (gCfgItems.multiple_language) {
181
-    if (uiCfg.extruSpeed == 20) {
182
-      lv_label_set_text(labelSpeed, extrude_menu.high);
183
-      lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
184
-    }
185
-    else if (uiCfg.extruSpeed == 1) {
186
-      lv_label_set_text(labelSpeed, extrude_menu.low);
187
-      lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
188
-    }
189
-    else {
190
-      lv_label_set_text(labelSpeed, extrude_menu.normal);
191
-      lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
174
+    switch (uiCfg.extruSpeed) {
175
+      case uiCfg.eSpeedH: lv_label_set_text(labelSpeed, extrude_menu.high);   break;
176
+      case uiCfg.eSpeedL: lv_label_set_text(labelSpeed, extrude_menu.low);    break;
177
+      case uiCfg.eSpeedN: lv_label_set_text(labelSpeed, extrude_menu.normal); break;
192 178
     }
179
+    lv_obj_align(labelSpeed, buttonSpeed, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
193 180
   }
194 181
 }
195 182
 
@@ -221,33 +208,28 @@ void disp_extru_amount() {
221 208
 }
222 209
 
223 210
 void disp_ext_step() {
224
-  if (uiCfg.extruStep == 1)
225
-    lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step1_mm.bin");
226
-  else if (uiCfg.extruStep == 5)
227
-    lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step5_mm.bin");
228
-  else if (uiCfg.extruStep == 10)
229
-    lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step10_mm.bin");
211
+  char buf3[12];
212
+  sprintf_P(buf3, PSTR("%dmm"), uiCfg.extruStep);
213
+
214
+  switch (uiCfg.extruStep) {
215
+    case uiCfg.eStepMin: lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step1_mm.bin");  break;
216
+    case uiCfg.eStepMed: lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step5_mm.bin");  break;
217
+    case uiCfg.eStepMax: lv_imgbtn_set_src_both(buttonStep, "F:/bmp_step10_mm.bin"); break;
218
+  }
230 219
 
231 220
   if (gCfgItems.multiple_language) {
232
-    if (uiCfg.extruStep == 1) {
233
-      lv_label_set_text(labelStep, extrude_menu.step_1mm);
234
-      lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
235
-    }
236
-    else if (uiCfg.extruStep == 5) {
237
-      lv_label_set_text(labelStep, extrude_menu.step_5mm);
238
-      lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
239
-    }
240
-    else if (uiCfg.extruStep == 10) {
241
-      lv_label_set_text(labelStep, extrude_menu.step_10mm);
242
-      lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
221
+    switch (uiCfg.extruStep) {
222
+      case uiCfg.eStepMin: lv_label_set_text(labelStep, buf3); break;
223
+      case uiCfg.eStepMed: lv_label_set_text(labelStep, buf3); break;
224
+      case uiCfg.eStepMax: lv_label_set_text(labelStep, buf3); break;
243 225
     }
226
+    lv_obj_align(labelStep, buttonStep, LV_ALIGN_IN_BOTTOM_MID, 0, BUTTON_TEXT_Y_OFFSET);
244 227
   }
245 228
 }
246 229
 
247 230
 void lv_clear_extrusion() {
248
-  #if HAS_ROTARY_ENCODER
249
-    if (gCfgItems.encoder_enable) lv_group_remove_all_objs(g);
250
-  #endif
231
+  if (TERN0(HAS_ROTARY_ENCODER, gCfgItems.encoder_enable))
232
+    lv_group_remove_all_objs(g);
251 233
   lv_obj_del(scr);
252 234
 }
253 235
 

+ 6
- 9
Marlin/src/lcd/extui/mks_ui/draw_ui.cpp View File

@@ -186,10 +186,10 @@ void ui_cfg_init() {
186 186
   uiCfg.stepHeat            = 10;
187 187
   uiCfg.leveling_first_time = false;
188 188
   uiCfg.para_ui_page        = false;
189
-  uiCfg.extruStep           = 5;
190
-  uiCfg.extruSpeed          = 10;
189
+  uiCfg.extruStep           = uiCfg.eStepMed;
190
+  uiCfg.extruSpeed          = uiCfg.eSpeedN;
191 191
   uiCfg.move_dist           = 1;
192
-  uiCfg.moveSpeed           = 3000;
192
+  uiCfg.moveSpeed           = 1000;
193 193
   uiCfg.stepPrintSpeed      = 10;
194 194
   uiCfg.command_send        = false;
195 195
   uiCfg.dialogType          = 0;
@@ -609,9 +609,9 @@ char *creat_title_text() {
609 609
             gPicturePreviewStart += (uintptr_t)p1 - (uintptr_t)((uint32_t *)(&public_buf[0]));
610 610
             break;
611 611
           }
612
-          else {
612
+          else
613 613
             gPicturePreviewStart += br;
614
-          }
614
+
615 615
           if (br < 400) break;
616 616
         }
617 617
       }
@@ -623,11 +623,8 @@ char *creat_title_text() {
623 623
 
624 624
       while (1) {
625 625
         card.read(public_buf, 400);
626
-        for (i = 0; i < 400;) {
626
+        for (i = 0; i < 400; i += 2, j++)
627 627
           bmp_public_buf[j] = ascii2dec_test((char*)&public_buf[i]) << 4 | ascii2dec_test((char*)&public_buf[i + 1]);
628
-          i                += 2;
629
-          j++;
630
-        }
631 628
         if (j >= 400) break;
632 629
       }
633 630
       for (i = 0; i < 400; i += 2) {

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

@@ -208,7 +208,7 @@ typedef struct {
208 208
   uint32_t  curFilesize;
209 209
 } CFG_ITMES;
210 210
 
211
-typedef struct {
211
+typedef struct UI_Config_Struct {
212 212
   uint8_t curTempType:1,
213 213
           extruderIndex:3,
214 214
           stepHeat:4,
@@ -228,8 +228,16 @@ typedef struct {
228 228
   uint8_t wifi_name[32];
229 229
   uint8_t wifi_key[64];
230 230
   uint8_t cloud_hostUrl[96];
231
+  // Extruder Steps distances (mm)
231 232
   uint8_t extruStep;
233
+  static constexpr uint8_t eStepMin =  1,
234
+                           eStepMed =  5,
235
+                           eStepMax = 10;
236
+  // Extruder speed (mm/s)
232 237
   uint8_t extruSpeed;
238
+  static constexpr uint8_t eSpeedH =  1,
239
+                           eSpeedN = 10,
240
+                           eSpeedL = 20;
233 241
   uint8_t print_state;
234 242
   uint8_t stepPrintSpeed;
235 243
   uint8_t waitEndMoves;

+ 7
- 13
Marlin/src/lcd/extui/mks_ui/wifi_module.cpp View File

@@ -1445,16 +1445,12 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1445 1445
 
1446 1446
   ZERO(FileName_unicode);
1447 1447
 
1448
-  while (1) {
1448
+  for (;;) {
1449 1449
     char_byte_num = source[i] & 0xF0;
1450
-    if (source[i] < 0x80) {
1451
-      //ASCII --1byte
1452
-      FileName_unicode[char_i] = source[i];
1453
-      i += 1;
1454
-      char_i += 1;
1450
+    if (source[i] < 0x80) { // ASCII -- 1 byte
1451
+      FileName_unicode[char_i++] = source[i++];
1455 1452
     }
1456
-    else if (char_byte_num == 0xC0 || char_byte_num == 0xD0) {
1457
-      //--2byte
1453
+    else if (char_byte_num == 0xC0 || char_byte_num == 0xD0) { // -- 2 byte
1458 1454
       u16_h = (((uint16_t)source[i] << 8) & 0x1F00) >> 2;
1459 1455
       u16_l = ((uint16_t)source[i + 1] & 0x003F);
1460 1456
       u16_value = (u16_h | u16_l);
@@ -1463,8 +1459,7 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1463 1459
       i += 2;
1464 1460
       char_i += 2;
1465 1461
     }
1466
-    else if (char_byte_num == 0xE0) {
1467
-      //--3byte
1462
+    else if (char_byte_num == 0xE0) { // -- 3 byte
1468 1463
       u16_h = (((uint16_t)source[i] << 8) & 0x0F00) << 4;
1469 1464
       u16_m = (((uint16_t)source[i + 1] << 8) & 0x3F00) >> 2;
1470 1465
       u16_l = ((uint16_t)source[i + 2] & 0x003F);
@@ -1474,8 +1469,7 @@ void utf8_2_unicode(uint8_t *source, uint8_t Len) {
1474 1469
       i += 3;
1475 1470
       char_i += 2;
1476 1471
     }
1477
-    else if (char_byte_num == 0xF0) {
1478
-      //--4byte
1472
+    else if (char_byte_num == 0xF0) { // -- 4 byte
1479 1473
       i += 4;
1480 1474
       //char_i += 3;
1481 1475
     }
@@ -1510,7 +1504,7 @@ static void file_first_msg_handle(uint8_t * msg, uint16_t msgLen) {
1510 1504
     TERN_(SDSUPPORT, card.mount());
1511 1505
   }
1512 1506
   else if (gCfgItems.fileSysType == FILE_SYS_USB) {
1513
-
1507
+    // nothing
1514 1508
   }
1515 1509
   file_writer.write_index = 0;
1516 1510
   lastFragment = -1;

+ 1
- 1
buildroot/bin/mftest View File

@@ -133,7 +133,7 @@ lp9|lpc9) TESTENV='LPC1769' ;;
133 133
      t36) TESTENV='teensy35' ;;
134 134
      t40) TESTENV='teensy41' ;;
135 135
      t41) TESTENV='teensy41' ;;
136
-[1-9][1-9]|[1-9]) TESTNUM=$TESTENV ; TESTENV=- ;;
136
+[1-9]|[1-9][0-9]) TESTNUM=$TESTENV ; TESTENV=- ;;
137 137
 esac
138 138
 
139 139
 if ((AUTO_BUILD)); then

+ 16
- 16
buildroot/tests/mks_robin_nano35 View File

@@ -15,15 +15,15 @@ opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO
15 15
 exec_test $1 $2 "MKS Robin nano v1.2 Emulated DOGM FSMC" "$3"
16 16
 
17 17
 #
18
-# MKS Robin v2 nano Emulated DOGM SPI
19
-# (Robin v2 nano has no FSMC interface)
18
+# MKS Robin nano v2 Emulated DOGM SPI
19
+# (Robin nano v2 has no FSMC interface)
20 20
 #
21 21
 use_example_configs Mks/Robin
22 22
 opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
23 23
 opt_disable TFT_INTERFACE_FSMC
24 24
 opt_enable TFT_INTERFACE_SPI MKS_WIFI_MODULE
25 25
 opt_add MKS_TEST
26
-exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI, MKS_WIFI_MODULE" "$3"
26
+exec_test $1 $2 "MKS Robin nano v2 Emulated DOGM SPI, MKS_WIFI_MODULE" "$3"
27 27
 
28 28
 #
29 29
 # MKS Robin nano v1.2 LVGL FSMC
@@ -35,34 +35,34 @@ exec_test $1 $2 "MKS Robin v2 nano Emulated DOGM SPI, MKS_WIFI_MODULE" "$3"
35 35
 # exec_test $1 $2 "MKS Robin nano v1.2 LVGL FSMC" "$3"
36 36
 
37 37
 #
38
-# MKS Robin v2 nano LVGL SPI
39
-# (Robin v2 nano has no FSMC interface)
38
+# MKS Robin nano v2 LVGL SPI
39
+# (Robin nano v2 has no FSMC interface)
40 40
 #
41 41
 # use_example_configs Mks/Robin
42 42
 # opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
43 43
 # opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240
44 44
 # opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320
45
-# exec_test $1 $2 "MKS Robin v2 nano LVGL SPI" "$3"
45
+# exec_test $1 $2 "MKS Robin nano v2 LVGL SPI" "$3"
46 46
 
47 47
 #
48
-# MKS Robin v2 nano New Color UI 480x320 SPI
49
-# (Robin v2 nano has no FSMC interface)
48
+# MKS Robin nano v2 New Color UI 480x320 SPI
49
+# (Robin nano v2 has no FSMC interface)
50 50
 #
51 51
 use_example_configs Mks/Robin
52 52
 opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2
53 53
 opt_disable TFT_INTERFACE_FSMC TFT_RES_320x240
54 54
 opt_enable TFT_INTERFACE_SPI TFT_RES_480x320
55
-exec_test $1 $2 "MKS Robin v2 nano New Color UI 480x320 SPI" "$3"
55
+exec_test $1 $2 "MKS Robin nano v2 with New Color UI 480x320 SPI" "$3"
56 56
 
57 57
 #
58
-# MKS Robin v2 nano LVGL SPI + TMC
59
-# (Robin v2 nano has no FSMC interface)
58
+# MKS Robin nano v2 LVGL SPI + TMC
59
+# (Robin nano v2 has no FSMC interface)
60 60
 #
61
-# use_example_configs Mks/Robin
62
-# opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209
63
-# opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240
64
-# opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320
65
-# exec_test $1 $2 "MKS Robin v2 nano LVGL SPI + TMC" "$3"
61
+use_example_configs Mks/Robin
62
+opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V2 X_DRIVER_TYPE TMC2209 Y_DRIVER_TYPE TMC2209
63
+opt_disable TFT_INTERFACE_FSMC TFT_COLOR_UI TOUCH_SCREEN TFT_RES_320x240
64
+opt_enable TFT_INTERFACE_SPI TFT_LVGL_UI TFT_RES_480x320
65
+exec_test $1 $2 "MKS Robin nano v2 LVGL SPI + TMC" "$3"
66 66
 
67 67
 # cleanup
68 68
 restore_configs

Loading…
Cancel
Save