Explorar el Código

MKS / E3V2 LCD code cleanup

Scott Lahteine hace 3 años
padre
commit
58f0330d3f

+ 3
- 3
Marlin/src/lcd/HD44780/marlinui_HD44780.cpp Ver fichero

571
 #if ENABLED(LCD_PROGRESS_BAR)
571
 #if ENABLED(LCD_PROGRESS_BAR)
572
 
572
 
573
   void MarlinUI::draw_progress_bar(const uint8_t percent) {
573
   void MarlinUI::draw_progress_bar(const uint8_t percent) {
574
-    const int16_t tix = (int16_t)(percent * (LCD_WIDTH) * 3) / 100,
575
-              cel = tix / 3,
576
-              rem = tix % 3;
574
+    const int16_t tix = int16_t(percent * (LCD_WIDTH) * 3) / 100,
575
+                  cel = tix / 3,
576
+                  rem = tix % 3;
577
     uint8_t i = LCD_WIDTH;
577
     uint8_t i = LCD_WIDTH;
578
     char msg[LCD_WIDTH + 1], b = ' ';
578
     char msg[LCD_WIDTH + 1], b = ' ';
579
     msg[LCD_WIDTH] = '\0';
579
     msg[LCD_WIDTH] = '\0';

+ 32
- 40
Marlin/src/lcd/dwin/e3v2/dwin.cpp Ver fichero

102
 #define DWIN_FONT_HEAD font10x20
102
 #define DWIN_FONT_HEAD font10x20
103
 
103
 
104
 #define MENU_CHAR_LIMIT  24
104
 #define MENU_CHAR_LIMIT  24
105
-#define STATUS_Y 360
106
-
107
-// Fan speed limit
108
-#define FANON           255
109
-#define FANOFF          0
105
+#define STATUS_Y        360
110
 
106
 
111
 // Print speed limit
107
 // Print speed limit
112
-#define MAX_PRINT_SPEED   999
113
-#define MIN_PRINT_SPEED   10
114
-
115
-#if HAS_HEATED_BED
116
-  #define MIN_BED_TEMP  BED_MINTEMP
117
-#endif
108
+#define MIN_PRINT_SPEED  10
109
+#define MAX_PRINT_SPEED 999
118
 
110
 
119
 // Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
111
 // Feedspeed limit (max feedspeed = DEFAULT_MAX_FEEDRATE * 2)
120
 #define MIN_MAXFEEDSPEED      1
112
 #define MIN_MAXFEEDSPEED      1
883
 
875
 
884
   #if HAS_HOTEND
876
   #if HAS_HOTEND
885
     Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp);
877
     Draw_Menu_Line(TUNE_CASE_TEMP, ICON_HotendTemp);
886
-    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.temp_hotend[0].target);
878
+    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_TEMP), thermalManager.degTargetHotend(0));
887
   #endif
879
   #endif
888
   #if HAS_HEATED_BED
880
   #if HAS_HEATED_BED
889
     Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp);
881
     Draw_Menu_Line(TUNE_CASE_BED, ICON_BedTemp);
890
-    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.temp_bed.target);
882
+    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(TUNE_CASE_BED), thermalManager.degTargetBed());
891
   #endif
883
   #endif
892
   #if HAS_FAN
884
   #if HAS_FAN
893
     Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed);
885
     Draw_Menu_Line(TUNE_CASE_FAN, ICON_FanSpeed);
1394
         return;
1386
         return;
1395
       }
1387
       }
1396
       // Bed_Temp limit
1388
       // Bed_Temp limit
1397
-      LIMIT(HMI_ValueStruct.Bed_Temp, MIN_BED_TEMP, BED_MAX_TARGET);
1389
+      LIMIT(HMI_ValueStruct.Bed_Temp, BED_MINTEMP, BED_MAX_TARGET);
1398
       // Bed_Temp value
1390
       // Bed_Temp value
1399
       DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
1391
       DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(bed_line), HMI_ValueStruct.Bed_Temp);
1400
     }
1392
     }
1438
         return;
1430
         return;
1439
       }
1431
       }
1440
       // Fan_speed limit
1432
       // Fan_speed limit
1441
-      LIMIT(HMI_ValueStruct.Fan_speed, FANOFF, FANON);
1433
+      LIMIT(HMI_ValueStruct.Fan_speed, 0, 255);
1442
       // Fan_speed value
1434
       // Fan_speed value
1443
       DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
1435
       DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(fan_line), HMI_ValueStruct.Fan_speed);
1444
     }
1436
     }
1882
 
1874
 
1883
   #if HAS_HOTEND
1875
   #if HAS_HOTEND
1884
     DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
1876
     DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
1885
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.temp_hotend[0].celsius);
1877
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 384, thermalManager.degHotend(0));
1886
     DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
1878
     DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
1887
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.temp_hotend[0].target);
1879
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 384, thermalManager.degTargetHotend(0));
1888
 
1880
 
1889
     DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
1881
     DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
1890
     DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
1882
     DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 116 + 2 * STAT_CHR_W, 417, planner.flow_percentage[0]);
1893
 
1885
 
1894
   #if HAS_HEATED_BED
1886
   #if HAS_HEATED_BED
1895
     DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
1887
     DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
1896
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.temp_bed.celsius);
1888
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 28, 417, thermalManager.degBed());
1897
     DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
1889
     DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
1898
-    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.temp_bed.target);
1890
+    DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_STAT, Color_White, Color_Bg_Black, 3, 25 + 4 * STAT_CHR_W + 6, 417, thermalManager.degTargetBed());
1899
   #endif
1891
   #endif
1900
 
1892
 
1901
   DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
1893
   DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
2157
       #if FAN_COUNT > 0
2149
       #if FAN_COUNT > 0
2158
         // All fans on for Ender 3 v2 ?
2150
         // All fans on for Ender 3 v2 ?
2159
         // The slicer should manage this for us.
2151
         // The slicer should manage this for us.
2160
-        // for (uint8_t i = 0; i < FAN_COUNT; i++)
2161
-        //  thermalManager.fan_speed[i] = FANON;
2152
+        //for (uint8_t i = 0; i < FAN_COUNT; i++)
2153
+        //  thermalManager.fan_speed[i] = 255;
2162
       #endif
2154
       #endif
2163
 
2155
 
2164
       Goto_PrintProcess();
2156
       Goto_PrintProcess();
2539
   #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1)
2531
   #define _TMENU_ICON(N) Draw_Menu_Line(++i, ICON_SetEndTemp + (N) - 1)
2540
   #if HAS_HOTEND
2532
   #if HAS_HOTEND
2541
     _TMENU_ICON(TEMP_CASE_TEMP);
2533
     _TMENU_ICON(TEMP_CASE_TEMP);
2542
-    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_hotend[0].target);
2534
+    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetHotend(0));
2543
   #endif
2535
   #endif
2544
   #if HAS_HEATED_BED
2536
   #if HAS_HEATED_BED
2545
     _TMENU_ICON(TEMP_CASE_BED);
2537
     _TMENU_ICON(TEMP_CASE_BED);
2546
-    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.temp_bed.target);
2538
+    DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Color_Bg_Black, 3, 216, MBASE(i), thermalManager.degTargetBed());
2547
   #endif
2539
   #endif
2548
   #if HAS_FAN
2540
   #if HAS_FAN
2549
     _TMENU_ICON(TEMP_CASE_FAN);
2541
     _TMENU_ICON(TEMP_CASE_FAN);
2711
           case 4: // Extruder
2703
           case 4: // Extruder
2712
             // window tips
2704
             // window tips
2713
             #ifdef PREVENT_COLD_EXTRUSION
2705
             #ifdef PREVENT_COLD_EXTRUSION
2714
-              if (thermalManager.temp_hotend[0].celsius < EXTRUDE_MINTEMP) {
2706
+              if (thermalManager.degHotend(0) < EXTRUDE_MINTEMP) {
2715
                 HMI_flag.ETempTooLow_flag = true;
2707
                 HMI_flag.ETempTooLow_flag = true;
2716
                 Popup_Window_ETempTooLow();
2708
                 Popup_Window_ETempTooLow();
2717
                 DWIN_UpdateLCD();
2709
                 DWIN_UpdateLCD();
2752
       #if HAS_HOTEND
2744
       #if HAS_HOTEND
2753
         case TEMP_CASE_TEMP: // Nozzle temperature
2745
         case TEMP_CASE_TEMP: // Nozzle temperature
2754
           checkkey = ETemp;
2746
           checkkey = ETemp;
2755
-          HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
2756
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), thermalManager.temp_hotend[0].target);
2747
+          HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0);
2748
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(1), HMI_ValueStruct.E_Temp);
2757
           EncoderRate.enabled = true;
2749
           EncoderRate.enabled = true;
2758
           break;
2750
           break;
2759
       #endif
2751
       #endif
2760
       #if HAS_HEATED_BED
2752
       #if HAS_HEATED_BED
2761
         case TEMP_CASE_BED: // Bed temperature
2753
         case TEMP_CASE_BED: // Bed temperature
2762
           checkkey = BedTemp;
2754
           checkkey = BedTemp;
2763
-          HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
2764
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), thermalManager.temp_bed.target);
2755
+          HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed();
2756
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(2), HMI_ValueStruct.Bed_Temp);
2765
           EncoderRate.enabled = true;
2757
           EncoderRate.enabled = true;
2766
           break;
2758
           break;
2767
       #endif
2759
       #endif
2769
         case TEMP_CASE_FAN: // Fan speed
2761
         case TEMP_CASE_FAN: // Fan speed
2770
           checkkey = FanSpeed;
2762
           checkkey = FanSpeed;
2771
           HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
2763
           HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
2772
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), thermalManager.fan_speed[0]);
2764
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(3), HMI_ValueStruct.Fan_speed);
2773
           EncoderRate.enabled = true;
2765
           EncoderRate.enabled = true;
2774
           break;
2766
           break;
2775
       #endif
2767
       #endif
2801
             #ifdef USE_STRING_HEADINGS
2793
             #ifdef USE_STRING_HEADINGS
2802
               Draw_Title("PLA Settings"); // TODO: GET_TEXT_F
2794
               Draw_Title("PLA Settings"); // TODO: GET_TEXT_F
2803
             #else
2795
             #else
2804
-              DWIN_Frame_TitleCopy(1, 56, 16, 141, 28);                                             // "PLA Settings"
2796
+              DWIN_Frame_TitleCopy(1, 56, 16, 141, 28);                                       // "PLA Settings"
2805
             #endif
2797
             #endif
2806
             #ifdef USE_STRING_TITLES
2798
             #ifdef USE_STRING_TITLES
2807
               DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp"));
2799
               DWIN_Draw_Label(MBASE(PREHEAT_CASE_TEMP), F("Nozzle Temp"));
2817
             #else
2809
             #else
2818
               DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP));
2810
               DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_TEMP));
2819
               DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP));
2811
               DWIN_Frame_AreaCopy(1, 197, 104, 238, 114, LBLX + 27, MBASE(PREHEAT_CASE_TEMP));
2820
-              DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP)); // PLA nozzle temp
2812
+              DWIN_Frame_AreaCopy(1, 1, 89, 83, 101, LBLX + 71, MBASE(PREHEAT_CASE_TEMP));      // PLA nozzle temp
2821
               #if HAS_HEATED_BED
2813
               #if HAS_HEATED_BED
2822
                 DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3);
2814
                 DWIN_Frame_AreaCopy(1, 157, 76, 181, 86, LBLX, MBASE(PREHEAT_CASE_BED) + 3);
2823
                 DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3);
2815
                 DWIN_Frame_AreaCopy(1, 240, 104, 264, 114, LBLX + 27, MBASE(PREHEAT_CASE_BED) + 3);
2828
                 DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN));    // PLA fan speed
2820
                 DWIN_Frame_AreaCopy(1, 0, 119, 64, 132, LBLX + 27, MBASE(PREHEAT_CASE_FAN));    // PLA fan speed
2829
               #endif
2821
               #endif
2830
               #if ENABLED(EEPROM_SETTINGS)
2822
               #if ENABLED(EEPROM_SETTINGS)
2831
-                DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE));          // Save PLA configuration
2823
+                DWIN_Frame_AreaCopy(1, 97, 165, 229, 177, LBLX, MBASE(PREHEAT_CASE_SAVE));      // Save PLA configuration
2832
               #endif
2824
               #endif
2833
             #endif
2825
             #endif
2834
           }
2826
           }
3285
       case TUNE_CASE_SPEED: // Print speed
3277
       case TUNE_CASE_SPEED: // Print speed
3286
         checkkey = PrintSpeed;
3278
         checkkey = PrintSpeed;
3287
         HMI_ValueStruct.print_speed = feedrate_percentage;
3279
         HMI_ValueStruct.print_speed = feedrate_percentage;
3288
-        DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), feedrate_percentage);
3280
+        DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_SPEED + MROWS - index_tune), HMI_ValueStruct.print_speed);
3289
         EncoderRate.enabled = true;
3281
         EncoderRate.enabled = true;
3290
         break;
3282
         break;
3291
       #if HAS_HOTEND
3283
       #if HAS_HOTEND
3292
         case TUNE_CASE_TEMP: // Nozzle temp
3284
         case TUNE_CASE_TEMP: // Nozzle temp
3293
           checkkey = ETemp;
3285
           checkkey = ETemp;
3294
-          HMI_ValueStruct.E_Temp = thermalManager.temp_hotend[0].target;
3295
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), thermalManager.temp_hotend[0].target);
3286
+          HMI_ValueStruct.E_Temp = thermalManager.degTargetHotend(0);
3287
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_TEMP + MROWS - index_tune), HMI_ValueStruct.E_Temp);
3296
           EncoderRate.enabled = true;
3288
           EncoderRate.enabled = true;
3297
           break;
3289
           break;
3298
       #endif
3290
       #endif
3299
       #if HAS_HEATED_BED
3291
       #if HAS_HEATED_BED
3300
         case TUNE_CASE_BED: // Bed temp
3292
         case TUNE_CASE_BED: // Bed temp
3301
           checkkey = BedTemp;
3293
           checkkey = BedTemp;
3302
-          HMI_ValueStruct.Bed_Temp = thermalManager.temp_bed.target;
3303
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), thermalManager.temp_bed.target);
3294
+          HMI_ValueStruct.Bed_Temp = thermalManager.degTargetBed();
3295
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_BED + MROWS - index_tune), HMI_ValueStruct.Bed_Temp);
3304
           EncoderRate.enabled = true;
3296
           EncoderRate.enabled = true;
3305
           break;
3297
           break;
3306
       #endif
3298
       #endif
3308
         case TUNE_CASE_FAN: // Fan speed
3300
         case TUNE_CASE_FAN: // Fan speed
3309
           checkkey = FanSpeed;
3301
           checkkey = FanSpeed;
3310
           HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
3302
           HMI_ValueStruct.Fan_speed = thermalManager.fan_speed[0];
3311
-          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), thermalManager.fan_speed[0]);
3303
+          DWIN_Draw_IntValue(true, true, 0, font8x16, Color_White, Select_Color, 3, 216, MBASE(TUNE_CASE_FAN + MROWS - index_tune), HMI_ValueStruct.Fan_speed);
3312
           EncoderRate.enabled = true;
3304
           EncoderRate.enabled = true;
3313
           break;
3305
           break;
3314
       #endif
3306
       #endif
3626
   if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
3618
   if (HMI_flag.pause_action && printingIsPaused() && !planner.has_blocks_queued()) {
3627
     HMI_flag.pause_action = false;
3619
     HMI_flag.pause_action = false;
3628
     #if ENABLED(PAUSE_HEAT)
3620
     #if ENABLED(PAUSE_HEAT)
3629
-      TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.temp_hotend[0].target);
3630
-      TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.temp_bed.target);
3621
+      TERN_(HAS_HOTEND, resume_hotend_temp = thermalManager.degTargetHotend(0));
3622
+      TERN_(HAS_HEATED_BED, resume_bed_temp = thermalManager.degTargetBed());
3631
       thermalManager.disable_all_heaters();
3623
       thermalManager.disable_all_heaters();
3632
     #endif
3624
     #endif
3633
     queue.inject_P(PSTR("G1 F1200 X0 Y0"));
3625
     queue.inject_P(PSTR("G1 F1200 X0 Y0"));

+ 6
- 7
Marlin/src/lcd/extui/lib/anycubic_i3mega/anycubic_i3mega_lcd.cpp Ver fichero

560
 
560
 
561
         switch (a_command) {
561
         switch (a_command) {
562
           case 0: { // A0 GET HOTEND TEMP
562
           case 0: { // A0 GET HOTEND TEMP
563
-            float hotendActualTemp = getActualTemp_celsius((extruder_t) (extruder_t) E0);
563
+            const float hotendActualTemp = getActualTemp_celsius(E0);
564
             SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
564
             SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
565
           }
565
           }
566
           break;
566
           break;
567
 
567
 
568
           case 1: { // A1  GET HOTEND TARGET TEMP
568
           case 1: { // A1  GET HOTEND TARGET TEMP
569
-            float hotendTargetTemp = getTargetTemp_celsius((extruder_t) (extruder_t) E0);
569
+            const float hotendTargetTemp = getTargetTemp_celsius(E0);
570
             SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
570
             SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
571
           }
571
           }
572
           break;
572
           break;
573
 
573
 
574
           case 2: { // A2 GET HOTBED TEMP
574
           case 2: { // A2 GET HOTBED TEMP
575
-            float heatedBedActualTemp = getActualTemp_celsius((heater_t) BED);
575
+            const float heatedBedActualTemp = getActualTemp_celsius(BED);
576
             SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
576
             SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
577
           }
577
           }
578
           break;
578
           break;
579
 
579
 
580
           case 3: { // A3 GET HOTBED TARGET TEMP
580
           case 3: { // A3 GET HOTBED TARGET TEMP
581
-            float heatedBedTargetTemp = getTargetTemp_celsius((heater_t) BED);
581
+            const float heatedBedTargetTemp = getTargetTemp_celsius(BED);
582
             SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
582
             SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
583
           } break;
583
           } break;
584
 
584
 
585
           case 4: { // A4 GET FAN SPEED
585
           case 4: { // A4 GET FAN SPEED
586
-            float fanPercent = getActualFan_percent(FAN0);
587
-            fanPercent = constrain(fanPercent, 0, 100);
588
-            SEND_PGM_VAL("A4V ", int(fanPercent));
586
+            const float fanPercent = getActualFan_percent(FAN0);
587
+            SEND_PGM_VAL("A4V ", int(LIMIT(fanPercent, 0, 100)));
589
           } break;
588
           } break;
590
 
589
 
591
           case 5: { // A5 GET CURRENT COORDINATE
590
           case 5: { // A5 GET CURRENT COORDINATE

+ 2
- 2
Marlin/src/lcd/extui/lib/dgus/mks/DGUSDisplayDef.cpp Ver fichero

764
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
764
     VPHELPER(VP_SD_AbortPrintConfirmed, nullptr, ScreenHandler.DGUSLCD_SD_ReallyAbort, nullptr),
765
     VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
765
     VPHELPER(VP_SD_Print_Setting, nullptr, ScreenHandler.DGUSLCD_SD_PrintTune, nullptr),
766
     #if ENABLED(BABYSTEPPING)
766
     #if ENABLED(BABYSTEPPING)
767
-      VPHELPER(VP_SD_Print_LiveAdjustZ,nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
768
-      VPHELPER(VP_ZOffset_DE_DIS,&z_offset_add,nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
767
+      VPHELPER(VP_SD_Print_LiveAdjustZ, nullptr, ScreenHandler.HandleLiveAdjustZ, &ScreenHandler.DGUSLCD_SendFloatAsIntValueToDisplay<2>),
768
+      VPHELPER(VP_ZOffset_DE_DIS, &z_offset_add, nullptr, &ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
769
     #endif
769
     #endif
770
     #if HAS_BED_PROBE
770
     #if HAS_BED_PROBE
771
       VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),
771
       VPHELPER(VP_OFFSET_X, &probe.offset.x, ScreenHandler.GetOffsetValue,ScreenHandler.DGUSLCD_SendFloatAsLongValueToDisplay<2>),

+ 118
- 207
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.cpp Ver fichero

111
 
111
 
112
 void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
112
 void DGUSScreenHandler::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) {
113
   if (var.memadr) {
113
   if (var.memadr) {
114
-    uint16_t value = swap16(*(uint16_t*)val_ptr);
114
+    const uint16_t value = swap16(*(uint16_t*)val_ptr);
115
     DEBUG_ECHOLNPAIR("FAN value get:", value);
115
     DEBUG_ECHOLNPAIR("FAN value get:", value);
116
     *(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255);
116
     *(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255);
117
     DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr);
117
     DEBUG_ECHOLNPAIR("FAN value change:", *(uint8_t*)var.memadr);
314
 }
314
 }
315
 
315
 
316
 void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
316
 void DGUSScreenHandler::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) {
317
-  uint16_t target = swap16(*(uint16_t *)val_ptr);
317
+  const uint16_t target = swap16(*(uint16_t *)val_ptr);
318
   DEBUG_ECHOLNPAIR(" back = 0x%x", target);
318
   DEBUG_ECHOLNPAIR(" back = 0x%x", target);
319
   switch (target) {
319
   switch (target) {
320
   }
320
   }
330
 
330
 
331
 void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
331
 void DGUSScreenHandler::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) {
332
   DEBUG_ECHOLNPGM("ctrl turn off\n");
332
   DEBUG_ECHOLNPGM("ctrl turn off\n");
333
-  uint16_t value = swap16(*(uint16_t *)val_ptr);
333
+  const uint16_t value = swap16(*(uint16_t *)val_ptr);
334
   switch (value) {
334
   switch (value) {
335
     case 0 ... 1: DGUSAutoTurnOff = (bool)value; break;
335
     case 0 ... 1: DGUSAutoTurnOff = (bool)value; break;
336
     default: break;
336
     default: break;
339
 
339
 
340
 void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
340
 void DGUSScreenHandler::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) {
341
   DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange");
341
   DEBUG_ECHOLNPGM("MinExtrudeTempChange DistanceChange");
342
-  uint16_t value = swap16(*(uint16_t *)val_ptr);
342
+  const uint16_t value = swap16(*(uint16_t *)val_ptr);
343
   thermalManager.extrude_min_temp = value;
343
   thermalManager.extrude_min_temp = value;
344
   min_ex_temp = value;
344
   min_ex_temp = value;
345
   settings.save();
345
   settings.save();
347
 
347
 
348
 void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
348
 void DGUSScreenHandler::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) {
349
   DEBUG_ECHOLNPGM("Zoffset DistanceChange");
349
   DEBUG_ECHOLNPGM("Zoffset DistanceChange");
350
-  uint16_t value = swap16(*(uint16_t *)val_ptr);
350
+  const uint16_t value = swap16(*(uint16_t *)val_ptr);
351
   float val_distance = 0;
351
   float val_distance = 0;
352
   switch (value) {
352
   switch (value) {
353
     case 0: val_distance = 0.01; break;
353
     case 0: val_distance = 0.01; break;
365
 }
365
 }
366
 
366
 
367
 void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
367
 void DGUSScreenHandler::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) {
368
-  uint16_t eep_flag = swap16(*(uint16_t *)val_ptr);
368
+  const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr);
369
   switch (eep_flag) {
369
   switch (eep_flag) {
370
     case 0:
370
     case 0:
371
       settings.save();
371
       settings.save();
383
 }
383
 }
384
 
384
 
385
 void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
385
 void DGUSScreenHandler::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) {
386
-  uint16_t z_value = swap16(*(uint16_t *)val_ptr);
386
+  const uint16_t z_value = swap16(*(uint16_t *)val_ptr);
387
   switch (z_value) {
387
   switch (z_value) {
388
     case 0: Z_distance = 0.01; break;
388
     case 0: Z_distance = 0.01; break;
389
     case 1: Z_distance = 0.1; break;
389
     case 1: Z_distance = 0.1; break;
410
 }
410
 }
411
 
411
 
412
 void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
412
 void DGUSScreenHandler::LanguageChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
413
-  uint16_t lag_flag = swap16(*(uint16_t *)val_ptr);
413
+  const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr);
414
   switch (lag_flag) {
414
   switch (lag_flag) {
415
     case MKS_SimpleChinese:
415
     case MKS_SimpleChinese:
416
       DGUS_LanguageDisplay(MKS_SimpleChinese);
416
       DGUS_LanguageDisplay(MKS_SimpleChinese);
435
 #endif
435
 #endif
436
 
436
 
437
 void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
437
 void DGUSScreenHandler::Level_Ctrl_MKS(DGUS_VP_Variable &var, void *val_ptr) {
438
-  uint16_t lev_but = swap16(*(uint16_t *)val_ptr);
438
+  const uint16_t lev_but = swap16(*(uint16_t *)val_ptr);
439
   #if ENABLED(MESH_BED_LEVELING)
439
   #if ENABLED(MESH_BED_LEVELING)
440
     auto cs = getCurrentScreen();
440
     auto cs = getCurrentScreen();
441
   #endif
441
   #endif
482
 }
482
 }
483
 
483
 
484
 void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) {
484
 void DGUSScreenHandler::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) {
485
-  uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr);
485
+  const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr);
486
   switch (mesh_dist) {
486
   switch (mesh_dist) {
487
     case 0: mesh_adj_distance = 0.01; break;
487
     case 0: mesh_adj_distance = 0.01; break;
488
     case 1: mesh_adj_distance = 0.1; break;
488
     case 1: mesh_adj_distance = 0.1; break;
493
 
493
 
494
 void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
494
 void DGUSScreenHandler::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) {
495
   #if ENABLED(MESH_BED_LEVELING)
495
   #if ENABLED(MESH_BED_LEVELING)
496
-    uint16_t mesh_value = swap16(*(uint16_t *)val_ptr);
496
+    const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr);
497
     // static uint8_t a_first_level = 1;
497
     // static uint8_t a_first_level = 1;
498
     char cmd_buf[30];
498
     char cmd_buf[30];
499
     float offset = mesh_adj_distance;
499
     float offset = mesh_adj_distance;
586
 }
586
 }
587
 
587
 
588
 void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
588
 void DGUSScreenHandler::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) {
589
+  const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
589
 
590
 
590
-  uint16_t lcd_value = swap16(*(uint16_t *)val_ptr);
591
+  lcd_default_light = constrain(lcd_value, 10, 100);
591
 
592
 
592
-  if (lcd_value > 100) lcd_value = 100;
593
-  else if (lcd_value < 10) lcd_value = 10;
594
-
595
-  lcd_default_light = lcd_value;
596
-
597
-  const uint16_t lcd_data[2] = {lcd_default_light, lcd_default_light};
593
+  const uint16_t lcd_data[2] = { lcd_default_light, lcd_default_light };
598
   dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true);
594
   dgusdisplay.WriteVariable(0x0082, &lcd_data, 5, true);
599
 }
595
 }
600
 
596
 
601
 void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
597
 void DGUSScreenHandler::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) {
602
-  int16_t point_value = swap16(*(uint16_t *)val_ptr);
598
+  const int16_t point_value = swap16(*(uint16_t *)val_ptr);
603
 
599
 
604
   int16_t level_x_pos, level_y_pos;
600
   int16_t level_x_pos, level_y_pos;
605
   char buf_level[32] = {0};
601
   char buf_level[32] = {0};
686
 #define mks_max(a, b) ((a) > (b)) ? (a) : (b)
682
 #define mks_max(a, b) ((a) > (b)) ? (a) : (b)
687
 void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
683
 void DGUSScreenHandler::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) {
688
   #if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP)
684
   #if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP)
689
-    uint16_t tmc_value = swap16(*(uint16_t*)val_ptr);
685
+    const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr);
690
   #endif
686
   #endif
691
 
687
 
692
   switch (var.VP) {
688
   switch (var.VP) {
930
 }
926
 }
931
 
927
 
932
 void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
928
 void DGUSScreenHandler::GetParkPos_MKS(DGUS_VP_Variable &var, void *val_ptr) {
933
-  int16_t value_pos = swap16(*(int16_t*)val_ptr);
929
+  const int16_t value_pos = swap16(*(int16_t*)val_ptr);
934
 
930
 
935
   switch (var.VP) {
931
   switch (var.VP) {
936
     case VP_X_PARK_POS: x_park_pos = value_pos; break;
932
     case VP_X_PARK_POS: x_park_pos = value_pos; break;
939
     default: break;
935
     default: break;
940
   }
936
   }
941
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
937
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
942
-  return;
943
 }
938
 }
944
 
939
 
945
 void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) {
940
 void DGUSScreenHandler::HandleChangeLevelPoint_MKS(DGUS_VP_Variable &var, void *val_ptr) {
946
   DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
941
   DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
947
 
942
 
948
-  int16_t value_raw = swap16(*(int16_t*)val_ptr);
949
-
950
-  DEBUG_ECHOLNPAIR_F("value:", value_raw);
943
+  const int16_t value_raw = swap16(*(int16_t*)val_ptr);
944
+  DEBUG_ECHOLNPAIR_F("value_raw:", value_raw);
951
 
945
 
952
   *(int16_t*)var.memadr = value_raw;
946
   *(int16_t*)var.memadr = value_raw;
953
 
947
 
954
   settings.save();
948
   settings.save();
955
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
949
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
956
-  return;
957
 }
950
 }
958
 
951
 
959
 void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
952
 void DGUSScreenHandler::HandleStepPerMMChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
960
   DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
953
   DEBUG_ECHOLNPGM("HandleStepPerMMChanged");
961
 
954
 
962
-  uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
955
+  const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
956
+  const float value = (float)value_raw;
963
 
957
 
964
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
958
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
965
-  float value = (float)value_raw;
959
+  DEBUG_ECHOLNPAIR_F("value:", value);
960
+
966
   ExtUI::axis_t axis;
961
   ExtUI::axis_t axis;
967
   switch (var.VP) {
962
   switch (var.VP) {
963
+    default: return;
968
     case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break;
964
     case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break;
969
     case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break;
965
     case VP_Y_STEP_PER_MM: axis = ExtUI::axis_t::Y; break;
970
     case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break;
966
     case VP_Z_STEP_PER_MM: axis = ExtUI::axis_t::Z; break;
971
-    default: return;
972
   }
967
   }
973
-  DEBUG_ECHOLNPAIR_F("value:", value);
974
   ExtUI::setAxisSteps_per_mm(value, axis);
968
   ExtUI::setAxisSteps_per_mm(value, axis);
975
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis));
969
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(axis));
976
   settings.save();
970
   settings.save();
977
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
971
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
978
-  return;
979
 }
972
 }
980
 
973
 
981
 void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
974
 void DGUSScreenHandler::HandleStepPerMMExtruderChanged_MKS(DGUS_VP_Variable &var, void *val_ptr) {
982
   DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
975
   DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged");
983
 
976
 
984
-  uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
977
+  const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
978
+  const float value = (float)value_raw;
979
+
985
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
980
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
986
-  float value = (float)value_raw;
981
+  DEBUG_ECHOLNPAIR_F("value:", value);
982
+
987
   ExtUI::extruder_t extruder;
983
   ExtUI::extruder_t extruder;
988
   switch (var.VP) {
984
   switch (var.VP) {
989
     default: return;
985
     default: return;
990
-      #if HOTENDS >= 1
991
-        case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
992
-      #endif
993
-      #if HOTENDS >= 2
994
-      #endif
995
-    case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
986
+    #if HAS_HOTEND
987
+      case VP_E0_STEP_PER_MM: extruder = ExtUI::extruder_t::E0; break;
988
+    #endif
989
+    #if HAS_MULTI_HOTEND
990
+      case VP_E1_STEP_PER_MM: extruder = ExtUI::extruder_t::E1; break;
991
+    #endif
996
   }
992
   }
997
-  DEBUG_ECHOLNPAIR_F("value:", value);
998
   ExtUI::setAxisSteps_per_mm(value, extruder);
993
   ExtUI::setAxisSteps_per_mm(value, extruder);
999
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
994
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisSteps_per_mm(extruder));
1000
   settings.save();
995
   settings.save();
1001
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
996
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1002
-  return;
1003
 }
997
 }
1004
 
998
 
1005
 void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
999
 void DGUSScreenHandler::HandleMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1006
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1000
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1007
 
1001
 
1008
-  uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1002
+  const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1003
+  const float value = (float)value_raw;
1004
+
1009
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1005
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1010
-  float value = (float)value_raw;
1006
+  DEBUG_ECHOLNPAIR_F("value:", value);
1007
+
1011
   ExtUI::axis_t axis;
1008
   ExtUI::axis_t axis;
1012
   switch (var.VP) {
1009
   switch (var.VP) {
1013
     case VP_X_MAX_SPEED: axis = ExtUI::axis_t::X; break;
1010
     case VP_X_MAX_SPEED: axis = ExtUI::axis_t::X; break;
1015
     case VP_Z_MAX_SPEED: axis = ExtUI::axis_t::Z; break;
1012
     case VP_Z_MAX_SPEED: axis = ExtUI::axis_t::Z; break;
1016
     default: return;
1013
     default: return;
1017
   }
1014
   }
1018
-  DEBUG_ECHOLNPAIR_F("value:", value);
1019
-  // ExtUI::setAxisSteps_per_mm(value,extruder);
1020
   ExtUI::setAxisMaxFeedrate_mm_s(value, axis);
1015
   ExtUI::setAxisMaxFeedrate_mm_s(value, axis);
1021
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis));
1016
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(axis));
1022
   settings.save();
1017
   settings.save();
1023
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1018
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1024
-  return;
1025
 }
1019
 }
1026
 
1020
 
1027
 void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1021
 void DGUSScreenHandler::HandleExtruderMaxSpeedChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1028
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1022
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1029
 
1023
 
1030
-  uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1024
+  const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1025
+  const float value = (float)value_raw;
1026
+
1031
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1027
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1032
-  float value = (float)value_raw;
1028
+  DEBUG_ECHOLNPAIR_F("value:", value);
1029
+
1033
   ExtUI::extruder_t extruder;
1030
   ExtUI::extruder_t extruder;
1034
   switch (var.VP) {
1031
   switch (var.VP) {
1035
     default: return;
1032
     default: return;
1036
-      #if HOTENDS >= 1
1033
+      #if HAS_HOTEND
1037
         case VP_E0_MAX_SPEED: extruder = ExtUI::extruder_t::E0; break;
1034
         case VP_E0_MAX_SPEED: extruder = ExtUI::extruder_t::E0; break;
1038
       #endif
1035
       #endif
1039
-      #if HOTENDS >= 2
1036
+      #if HAS_MULTI_HOTEND
1040
       #endif
1037
       #endif
1041
     case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break;
1038
     case VP_E1_MAX_SPEED: extruder = ExtUI::extruder_t::E1; break;
1042
   }
1039
   }
1043
-  DEBUG_ECHOLNPAIR_F("value:", value);
1044
-  // ExtUI::setAxisSteps_per_mm(value,extruder);
1045
   ExtUI::setAxisMaxFeedrate_mm_s(value, extruder);
1040
   ExtUI::setAxisMaxFeedrate_mm_s(value, extruder);
1046
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder));
1041
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxFeedrate_mm_s(extruder));
1047
   settings.save();
1042
   settings.save();
1048
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1043
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1049
-  return;
1050
 }
1044
 }
1051
 
1045
 
1052
 void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1046
 void DGUSScreenHandler::HandleMaxAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1053
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1047
   DEBUG_ECHOLNPGM("HandleMaxSpeedChange_MKS");
1054
 
1048
 
1055
-  uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1049
+  const uint16_t value_raw = swap16(*(uint16_t*)val_ptr);
1050
+  const float value = (float)value_raw;
1051
+
1056
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1052
   DEBUG_ECHOLNPAIR("value_raw:", value_raw);
1057
-  float value = (float)value_raw;
1053
+  DEBUG_ECHOLNPAIR_F("value:", value);
1054
+
1058
   ExtUI::axis_t axis;
1055
   ExtUI::axis_t axis;
1059
   switch (var.VP) {
1056
   switch (var.VP) {
1057
+    default: return;
1060
     case VP_X_ACC_MAX_SPEED: axis = ExtUI::axis_t::X;  break;
1058
     case VP_X_ACC_MAX_SPEED: axis = ExtUI::axis_t::X;  break;
1061
     case VP_Y_ACC_MAX_SPEED: axis = ExtUI::axis_t::Y;  break;
1059
     case VP_Y_ACC_MAX_SPEED: axis = ExtUI::axis_t::Y;  break;
1062
     case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z;  break;
1060
     case VP_Z_ACC_MAX_SPEED: axis = ExtUI::axis_t::Z;  break;
1063
-    default: return;
1064
   }
1061
   }
1065
-  DEBUG_ECHOLNPAIR_F("value:", value);
1066
   ExtUI::setAxisMaxAcceleration_mm_s2(value, axis);
1062
   ExtUI::setAxisMaxAcceleration_mm_s2(value, axis);
1067
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis));
1063
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(axis));
1068
   settings.save();
1064
   settings.save();
1069
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1065
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1070
-  return;
1071
 }
1066
 }
1072
 
1067
 
1073
 void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1068
 void DGUSScreenHandler::HandleExtruderAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1079
   ExtUI::extruder_t extruder;
1074
   ExtUI::extruder_t extruder;
1080
   switch (var.VP) {
1075
   switch (var.VP) {
1081
     default: return;
1076
     default: return;
1082
-      #if HOTENDS >= 1
1083
-        case VP_E0_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E0; settings.load(); break;
1084
-      #endif
1085
-      #if HOTENDS >= 2
1086
-      #endif
1087
-    case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break;
1077
+    #if HAS_HOTEND
1078
+      case VP_E0_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E0; settings.load(); break;
1079
+    #endif
1080
+    #if HAS_MULTI_HOTEND
1081
+      case VP_E1_ACC_MAX_SPEED: extruder = ExtUI::extruder_t::E1; settings.load(); break;
1082
+    #endif
1088
   }
1083
   }
1089
   DEBUG_ECHOLNPAIR_F("value:", value);
1084
   DEBUG_ECHOLNPAIR_F("value:", value);
1090
-  // ExtUI::setAxisSteps_per_mm(value,extruder);
1091
   ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder);
1085
   ExtUI::setAxisMaxAcceleration_mm_s2(value, extruder);
1092
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder));
1086
   DEBUG_ECHOLNPAIR_F("value_set:", ExtUI::getAxisMaxAcceleration_mm_s2(extruder));
1093
   settings.save();
1087
   settings.save();
1094
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1088
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1095
-  return;
1096
 }
1089
 }
1097
 
1090
 
1098
 void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1091
 void DGUSScreenHandler::HandleTravelAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1099
   uint16_t value_travel = swap16(*(uint16_t*)val_ptr);
1092
   uint16_t value_travel = swap16(*(uint16_t*)val_ptr);
1100
-  float value = (float)value_travel;
1101
-  planner.settings.travel_acceleration = value;
1093
+  planner.settings.travel_acceleration = (float)value_travel;
1102
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1094
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1103
-  return;
1104
 }
1095
 }
1105
 
1096
 
1106
 void DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1097
 void DGUSScreenHandler::HandleFeedRateMinChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1107
   uint16_t value_t = swap16(*(uint16_t*)val_ptr);
1098
   uint16_t value_t = swap16(*(uint16_t*)val_ptr);
1108
-  float value = (float)value_t;
1109
-  planner.settings.min_feedrate_mm_s = value;
1099
+  planner.settings.min_feedrate_mm_s = (float)value_t;
1110
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1100
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1111
-  return;
1112
 }
1101
 }
1113
 
1102
 
1114
 void DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1103
 void DGUSScreenHandler::HandleMin_T_F_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1115
   uint16_t value_t_f = swap16(*(uint16_t*)val_ptr);
1104
   uint16_t value_t_f = swap16(*(uint16_t*)val_ptr);
1116
-  float value = (float)value_t_f;
1117
-  planner.settings.min_travel_feedrate_mm_s = value;
1105
+  planner.settings.min_travel_feedrate_mm_s = (float)value_t_f;
1118
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1106
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1119
-  return;
1120
 }
1107
 }
1121
 
1108
 
1122
 void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1109
 void DGUSScreenHandler::HandleAccChange_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1123
   uint16_t value_acc = swap16(*(uint16_t*)val_ptr);
1110
   uint16_t value_acc = swap16(*(uint16_t*)val_ptr);
1124
-  float value = (float)value_acc;
1125
-  planner.settings.acceleration = value;
1111
+  planner.settings.acceleration = (float)value_acc;
1126
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1112
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1127
-  return;
1128
 }
1113
 }
1129
 
1114
 
1130
 void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1115
 void DGUSScreenHandler::HandleGetExMinTemp_MKS(DGUS_VP_Variable &var, void *val_ptr) {
1131
-  uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr);
1116
+  const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr);
1132
   thermalManager.extrude_min_temp = value_ex_min_temp;
1117
   thermalManager.extrude_min_temp = value_ex_min_temp;
1133
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1118
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1134
 }
1119
 }
1135
 
1120
 
1136
 #if HAS_PID_HEATING
1121
 #if HAS_PID_HEATING
1137
   void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
1122
   void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) {
1138
-    uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
1123
+    const uint16_t rawvalue = swap16(*(uint16_t*)val_ptr);
1139
     DEBUG_ECHOLNPAIR("V1:", rawvalue);
1124
     DEBUG_ECHOLNPAIR("V1:", rawvalue);
1140
-    float value = (float)rawvalue / 10;
1125
+    const float value = 1.0f * rawvalue;
1141
     DEBUG_ECHOLNPAIR("V2:", value);
1126
     DEBUG_ECHOLNPAIR("V2:", value);
1142
     float newvalue = 0;
1127
     float newvalue = 0;
1143
 
1128
 
1144
     switch (var.VP) {
1129
     switch (var.VP) {
1145
       default: return;
1130
       default: return;
1146
-        #if HOTENDS >= 1
1131
+        #if HAS_HOTEND
1147
           case VP_E0_PID_P: newvalue = value; break;
1132
           case VP_E0_PID_P: newvalue = value; break;
1148
           case VP_E0_PID_I: newvalue = scalePID_i(value); break;
1133
           case VP_E0_PID_I: newvalue = scalePID_i(value); break;
1149
           case VP_E0_PID_D: newvalue = scalePID_d(value); break;
1134
           case VP_E0_PID_D: newvalue = scalePID_d(value); break;
1150
         #endif
1135
         #endif
1151
-        #if HOTENDS >= 2
1136
+        #if HAS_MULTI_HOTEND
1152
           case VP_E1_PID_P: newvalue = value; break;
1137
           case VP_E1_PID_P: newvalue = value; break;
1153
           case VP_E1_PID_I: newvalue = scalePID_i(value); break;
1138
           case VP_E1_PID_I: newvalue = scalePID_i(value); break;
1154
           case VP_E1_PID_D: newvalue = scalePID_d(value); break;
1139
           case VP_E1_PID_D: newvalue = scalePID_d(value); break;
1224
   distanceFilament = value;
1209
   distanceFilament = value;
1225
 
1210
 
1226
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1211
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1227
-  return;
1228
 }
1212
 }
1229
 
1213
 
1230
 void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
1214
 void DGUSScreenHandler::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) {
1237
   FilamentSpeed = value_len;
1221
   FilamentSpeed = value_len;
1238
 
1222
 
1239
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1223
   skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel
1240
-  return;
1241
 }
1224
 }
1242
 
1225
 
1243
-void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
1244
-  DEBUG_ECHOLNPGM("Load Filament");
1245
-  char buf[40];
1246
-
1247
-  uint16_t val_t = swap16(*(uint16_t*)val_ptr);
1226
+void DGUSScreenHandler::MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir) {
1227
+  #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1228
+    uint8_t swap_tool = 0;
1229
+  #endif
1230
+  #if HAS_HOTEND
1231
+    uint8_t hotend_too_cold = 0;
1232
+  #endif
1248
 
1233
 
1249
   if (!print_job_timer.isPaused() && !queue.ring_buffer.empty())
1234
   if (!print_job_timer.isPaused() && !queue.ring_buffer.empty())
1250
     return;
1235
     return;
1251
 
1236
 
1237
+  char buf[40];
1238
+  const uint16_t val_t = swap16(*(uint16_t*)val_ptr);
1252
   switch (val_t) {
1239
   switch (val_t) {
1240
+    default: break;
1253
     case 0:
1241
     case 0:
1254
-      #if HOTENDS >= 1
1255
-        if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
1256
-          if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
1257
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
1258
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1259
-          SetupConfirmAction(nullptr);
1260
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1261
-        }
1262
-        else {
1263
-          queue.enqueue_now_P(PSTR("T0"));
1264
-          queue.enqueue_now_P(PSTR("G91"));
1265
-          snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1266
-          queue.enqueue_one_now(buf);
1267
-          queue.enqueue_now_P(PSTR("G90"));
1268
-        }
1242
+      #if HAS_HOTEND
1243
+        if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 1;
1269
       #endif
1244
       #endif
1270
       break;
1245
       break;
1271
-
1272
     case 1:
1246
     case 1:
1273
-      #if HOTENDS >= 2
1274
-        if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
1275
-          if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
1276
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
1277
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1278
-          SetupConfirmAction(nullptr);
1279
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1280
-        }
1281
-        else {
1282
-          queue.enqueue_now_P(PSTR("T1"));
1283
-          queue.enqueue_now_P(PSTR("G91"));
1284
-          snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1285
-          queue.enqueue_one_now(buf);
1286
-          queue.enqueue_now_P(PSTR("G90"));
1287
-        }
1288
-      #endif
1289
-      #if ENABLED(SINGLENOZZLE)
1290
-        if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
1291
-          if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
1292
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
1293
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1294
-          SetupConfirmAction(nullptr);
1295
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1296
-        }
1297
-        else {
1298
-          queue.enqueue_now_P(PSTR("T1"));
1299
-          queue.enqueue_now_P(PSTR("G91"));
1300
-          snprintf_P(buf,40,PSTR("G1 E%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1301
-          queue.enqueue_one_now(buf);
1302
-          queue.enqueue_now_P(PSTR("G90"));
1303
-        }
1247
+      #if HAS_MULTI_HOTEND
1248
+        if (thermalManager.tooColdToExtrude(1)) hotend_too_cold = 2; else swap_tool = 2;
1249
+      #elif ENABLED(SINGLENOZZLE)
1250
+        if (thermalManager.tooColdToExtrude(0)) hotend_too_cold = 1; else swap_tool = 2;
1304
       #endif
1251
       #endif
1305
       break;
1252
       break;
1306
-
1307
-    default:
1308
-      break;
1309
   }
1253
   }
1254
+
1255
+  #if HAS_HOTEND
1256
+    if (hotend_too_cold) {
1257
+      if (thermalManager.targetTooColdToExtrude(hotend_too_cold - 1)) thermalManager.setTargetHotend(thermalManager.extrude_min_temp, hotend_too_cold - 1);
1258
+      sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1259
+      SetupConfirmAction(nullptr);
1260
+      GotoScreen(DGUSLCD_SCREEN_POPUP);
1261
+    }
1262
+  #endif
1263
+
1264
+  #if EITHER(HAS_MULTI_HOTEND, SINGLENOZZLE)
1265
+    if (swap_tool) {
1266
+      queue.enqueue_now_P(swap_tool == 2 ? PSTR("T1") : PSTR("T0"));
1267
+      queue.enqueue_now_P(PSTR("G91"));
1268
+      snprintf_P(buf, 40, PSTR("G1 E%d F%d"), (int)distanceFilament * filamentDir, FilamentSpeed * 60);
1269
+      queue.enqueue_one_now(buf);
1270
+      queue.enqueue_now_P(PSTR("G90"));
1271
+    }
1272
+  #endif
1273
+}
1274
+
1275
+void DGUSScreenHandler::MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr) {
1276
+  DEBUG_ECHOLNPGM("Load Filament");
1277
+   MKS_FilamentLoadUnload(var, val_ptr, 1);
1310
 }
1278
 }
1311
 
1279
 
1312
 void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
1280
 void DGUSScreenHandler::MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) {
1313
   DEBUG_ECHOLNPGM("UnLoad Filament");
1281
   DEBUG_ECHOLNPGM("UnLoad Filament");
1314
-  char buf[40];
1315
-  uint16_t val_t = swap16(*(uint16_t*)val_ptr);
1316
-  switch (val_t) {
1317
-    case 0:
1318
-      #if HOTENDS >= 1
1319
-        if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
1320
-          if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
1321
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
1322
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1323
-          SetupConfirmAction(nullptr);
1324
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1325
-        }
1326
-        else {
1327
-          queue.enqueue_now_P(PSTR("T0"));
1328
-          queue.enqueue_now_P(PSTR("G91"));
1329
-          snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1330
-          queue.enqueue_one_now(buf);
1331
-          queue.enqueue_now_P(PSTR("G90"));
1332
-        }
1333
-      #endif
1334
-      break;
1335
-    case 1:
1336
-      #if HOTENDS >= 2
1337
-        if (thermalManager.degHotend(1) < thermalManager.extrude_min_temp) {
1338
-          if (thermalManager.degTargetHotend(1) < thermalManager.extrude_min_temp)
1339
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 1);
1340
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1341
-          SetupConfirmAction(nullptr);
1342
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1343
-        }
1344
-        else {
1345
-          queue.enqueue_now_P(PSTR("T1"));
1346
-          queue.enqueue_now_P(PSTR("G91"));
1347
-          snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1348
-          queue.enqueue_one_now(buf);
1349
-          queue.enqueue_now_P(PSTR("G90"));
1350
-        }
1351
-      #endif
1352
-
1353
-      #if ENABLED(SINGLENOZZLE)
1354
-        if (thermalManager.degHotend(0) < thermalManager.extrude_min_temp) {
1355
-          if (thermalManager.degTargetHotend(0) < thermalManager.extrude_min_temp)
1356
-            thermalManager.setTargetHotend(thermalManager.extrude_min_temp, 0);
1357
-          sendinfoscreen(PSTR("NOTICE"), nullptr, PSTR("Please wait."), PSTR("Nozzle heating!"), true, true, true, true);
1358
-          SetupConfirmAction(nullptr);
1359
-          GotoScreen(DGUSLCD_SCREEN_POPUP);
1360
-        }
1361
-        else {
1362
-          queue.enqueue_now_P(PSTR("T1"));
1363
-          queue.enqueue_now_P(PSTR("G91"));
1364
-          snprintf_P(buf,40,PSTR("G1 E-%d F%d"),(int)distanceFilament,FilamentSpeed * 60);
1365
-          queue.enqueue_one_now(buf);
1366
-          queue.enqueue_now_P(PSTR("G90"));
1367
-        }
1368
-      #endif
1369
-      break;
1370
-  }
1282
+  MKS_FilamentLoadUnload(var, val_ptr, -1);
1371
 }
1283
 }
1372
 
1284
 
1373
 #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
1285
 #if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
1378
     uint8_t e_temp = 0;
1290
     uint8_t e_temp = 0;
1379
     filament_data.heated = false;
1291
     filament_data.heated = false;
1380
     uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
1292
     uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
1381
-    if (preheat_option <= 8) {      // Load filament type
1382
-      filament_data.action = 1;
1383
-    }
1384
-    else if (preheat_option >= 10) { // Unload filament type
1293
+    if (preheat_option >= 10) {     // Unload filament type
1385
       preheat_option -= 10;
1294
       preheat_option -= 10;
1386
       filament_data.action = 2;
1295
       filament_data.action = 2;
1387
       filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
1296
       filament_data.purge_length = DGUS_FILAMENT_PURGE_LENGTH;
1388
     }
1297
     }
1389
-    else {                          // Cancel filament operation
1298
+    else if (preheat_option <= 8)   // Load filament type
1299
+      filament_data.action = 1;
1300
+    else                            // Cancel filament operation
1390
       filament_data.action = 0;
1301
       filament_data.action = 0;
1391
-    }
1392
 
1302
 
1393
     switch (preheat_option) {
1303
     switch (preheat_option) {
1394
       case 0: // Load PLA
1304
       case 0: // Load PLA
1416
     }
1326
     }
1417
 
1327
 
1418
     if (filament_data.action == 0) { // Go back to utility screen
1328
     if (filament_data.action == 0) { // Go back to utility screen
1419
-      #if HOTENDS >= 1
1329
+      #if HAS_HOTEND
1420
         thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
1330
         thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E0);
1421
       #endif
1331
       #endif
1422
-      #if HOTENDS >= 2
1332
+      #if HAS_MULTI_HOTEND
1423
         thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
1333
         thermalManager.setTargetHotend(e_temp, ExtUI::extruder_t::E1);
1424
       #endif
1334
       #endif
1425
       GotoScreen(DGUSLCD_SCREEN_UTILITY);
1335
       GotoScreen(DGUSLCD_SCREEN_UTILITY);
1427
     else { // Go to the preheat screen to show the heating progress
1337
     else { // Go to the preheat screen to show the heating progress
1428
       switch (var.VP) {
1338
       switch (var.VP) {
1429
         default: return;
1339
         default: return;
1430
-          #if HOTENDS >= 1
1340
+          #if HAS_HOTEND
1431
             case VP_E0_FILAMENT_LOAD_UNLOAD:
1341
             case VP_E0_FILAMENT_LOAD_UNLOAD:
1432
               filament_data.extruder = ExtUI::extruder_t::E0;
1342
               filament_data.extruder = ExtUI::extruder_t::E0;
1433
               thermalManager.setTargetHotend(e_temp, filament_data.extruder);
1343
               thermalManager.setTargetHotend(e_temp, filament_data.extruder);
1434
               break;
1344
               break;
1435
           #endif
1345
           #endif
1436
-          #if HOTENDS >= 2
1346
+          #if HAS_MULTI_HOTEND
1437
             case VP_E1_FILAMENT_LOAD_UNLOAD:
1347
             case VP_E1_FILAMENT_LOAD_UNLOAD:
1438
               filament_data.extruder = ExtUI::extruder_t::E1;
1348
               filament_data.extruder = ExtUI::extruder_t::E1;
1439
               thermalManager.setTargetHotend(e_temp, filament_data.extruder);
1349
               thermalManager.setTargetHotend(e_temp, filament_data.extruder);
1475
       ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
1385
       ExtUI::setAxisPosition_mm(movevalue, filament_data.extruder);
1476
     }
1386
     }
1477
   }
1387
   }
1388
+
1478
 #endif // DGUS_FILAMENT_LOADUNLOAD
1389
 #endif // DGUS_FILAMENT_LOADUNLOAD
1479
 
1390
 
1480
 bool DGUSScreenHandler::loop() {
1391
 bool DGUSScreenHandler::loop() {

+ 1
- 0
Marlin/src/lcd/extui/lib/dgus/mks/DGUSScreenHandler.h Ver fichero

149
     // Hook for filament load and unload
149
     // Hook for filament load and unload
150
     static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
150
     static void HandleFilamentLoadUnload(DGUS_VP_Variable &var);
151
 
151
 
152
+    static void MKS_FilamentLoadUnload(DGUS_VP_Variable &var, void *val_ptr, const int filamentDir);
152
     static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
153
     static void MKS_FilamentLoad(DGUS_VP_Variable &var, void *val_ptr);
153
     static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
154
     static void MKS_FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr);
154
     static void MKS_LOAD_UNLOAD_IDLE();
155
     static void MKS_LOAD_UNLOAD_IDLE();

+ 15
- 14
Marlin/src/lcd/extui/lib/mks_ui/draw_dialog.cpp Ver fichero

514
     queue.inject(public_buf_m);
514
     queue.inject(public_buf_m);
515
   }
515
   }
516
 
516
 
517
-  if ( ((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
518
-        || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
519
-    && uiCfg.filament_load_heat_flg
520
-  ) {
521
-    uiCfg.filament_load_heat_flg = false;
522
-    lv_clear_dialog();
523
-    lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
517
+  if (uiCfg.filament_load_heat_flg) {
518
+    const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
519
+    if (abs(diff) < 2 || diff > 0) {
520
+      uiCfg.filament_load_heat_flg = false;
521
+      lv_clear_dialog();
522
+      lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
523
+    }
524
   }
524
   }
525
 
525
 
526
   if (uiCfg.filament_loading_completed) {
526
   if (uiCfg.filament_loading_completed) {
529
     lv_clear_dialog();
529
     lv_clear_dialog();
530
     lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
530
     lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_COMPLETED);
531
   }
531
   }
532
-  if (((abs((int)((int)thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temper)) <= 1)
533
-     || ((int)thermalManager.degHotend(uiCfg.extruderIndex) > gCfgItems.filament_limit_temper))
534
-     && uiCfg.filament_unload_heat_flg
535
-  ) {
536
-    uiCfg.filament_unload_heat_flg = false;
537
-    lv_clear_dialog();
538
-    lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
532
+
533
+  if (uiCfg.filament_unload_heat_flg) {
534
+    const int16_t diff = thermalManager.degHotend(uiCfg.extruderIndex) - gCfgItems.filament_limit_temp;
535
+    if (abs(diff) < 2 || diff > 0) {
536
+      uiCfg.filament_unload_heat_flg = false;
537
+      lv_clear_dialog();
538
+      lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
539
+    }
539
   }
540
   }
540
 
541
 
541
   if (uiCfg.filament_unloading_completed) {
542
   if (uiCfg.filament_unloading_completed) {

+ 6
- 6
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_change.cpp Ver fichero

51
     case ID_FILAMNT_IN:
51
     case ID_FILAMNT_IN:
52
       uiCfg.filament_load_heat_flg = true;
52
       uiCfg.filament_load_heat_flg = true;
53
       if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1)
53
       if ((abs(thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex)) <= 1)
54
-          || (gCfgItems.filament_limit_temper <= thermalManager.degHotend(uiCfg.extruderIndex))) {
54
+          || (gCfgItems.filament_limit_temp <= thermalManager.degHotend(uiCfg.extruderIndex))) {
55
         lv_clear_filament_change();
55
         lv_clear_filament_change();
56
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
56
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_LOAD_COMPLETED);
57
       }
57
       }
58
       else {
58
       else {
59
         lv_clear_filament_change();
59
         lv_clear_filament_change();
60
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
60
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_LOAD_HEAT);
61
-        if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
62
-          thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
61
+        if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
62
+          thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
63
           thermalManager.start_watching_hotend(uiCfg.extruderIndex);
63
           thermalManager.start_watching_hotend(uiCfg.extruderIndex);
64
         }
64
         }
65
       }
65
       }
68
       uiCfg.filament_unload_heat_flg = true;
68
       uiCfg.filament_unload_heat_flg = true;
69
       if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
69
       if (thermalManager.degTargetHotend(uiCfg.extruderIndex)
70
           && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1)
70
           && ((abs((int)((int)thermalManager.degTargetHotend(uiCfg.extruderIndex) - thermalManager.degHotend(uiCfg.extruderIndex))) <= 1)
71
-              || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temper))
71
+              || ((int)thermalManager.degHotend(uiCfg.extruderIndex) >= gCfgItems.filament_limit_temp))
72
       ) {
72
       ) {
73
         lv_clear_filament_change();
73
         lv_clear_filament_change();
74
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
74
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_HEAT_UNLOAD_COMPLETED);
76
       else {
76
       else {
77
         lv_clear_filament_change();
77
         lv_clear_filament_change();
78
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
78
         lv_draw_dialog(DIALOG_TYPE_FILAMENT_UNLOAD_HEAT);
79
-        if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temper) {
80
-          thermalManager.setTargetHotend(gCfgItems.filament_limit_temper, uiCfg.extruderIndex);
79
+        if (thermalManager.degTargetHotend(uiCfg.extruderIndex) < gCfgItems.filament_limit_temp) {
80
+          thermalManager.setTargetHotend(gCfgItems.filament_limit_temp, uiCfg.extruderIndex);
81
           thermalManager.start_watching_hotend(uiCfg.extruderIndex);
81
           thermalManager.start_watching_hotend(uiCfg.extruderIndex);
82
         }
82
         }
83
         filament_sprayer_temp();
83
         filament_sprayer_temp();

+ 1
- 1
Marlin/src/lcd/extui/lib/mks_ui/draw_filament_settings.cpp Ver fichero

107
     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);
107
     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);
108
   }
108
   }
109
   else {
109
   else {
110
-    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temper);
110
+    sprintf_P(public_buf_l, PSTR("%d"), gCfgItems.filament_limit_temp);
111
     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);
111
     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);
112
 
112
 
113
     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);
113
     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);

+ 2
- 2
Marlin/src/lcd/extui/lib/mks_ui/draw_number_key.cpp Ver fichero

261
       sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
261
       sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filamentchange_unload_speed);
262
       break;
262
       break;
263
     case filament_temp:
263
     case filament_temp:
264
-      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temper);
264
+      sprintf_P(public_buf_m, PSTR("%d"), gCfgItems.filament_limit_temp);
265
       break;
265
       break;
266
     case x_sensitivity:
266
     case x_sensitivity:
267
       #if X_SENSORLESS
267
       #if X_SENSORLESS
505
       update_spi_flash();
505
       update_spi_flash();
506
       break;
506
       break;
507
     case filament_temp:
507
     case filament_temp:
508
-      gCfgItems.filament_limit_temper = atoi(key_value);
508
+      gCfgItems.filament_limit_temp = atoi(key_value);
509
       update_spi_flash();
509
       update_spi_flash();
510
       break;
510
       break;
511
     case x_sensitivity:
511
     case x_sensitivity:

+ 3
- 3
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.cpp Ver fichero

143
   gCfgItems.filamentchange_load_speed    = 1000;
143
   gCfgItems.filamentchange_load_speed    = 1000;
144
   gCfgItems.filamentchange_unload_length = 200;
144
   gCfgItems.filamentchange_unload_length = 200;
145
   gCfgItems.filamentchange_unload_speed  = 1000;
145
   gCfgItems.filamentchange_unload_speed  = 1000;
146
-  gCfgItems.filament_limit_temper        = 200;
146
+  gCfgItems.filament_limit_temp          = 200;
147
 
147
 
148
   gCfgItems.encoder_enable = true;
148
   gCfgItems.encoder_enable = true;
149
 
149
 
226
     uiCfg.cloud_port = 10086;
226
     uiCfg.cloud_port = 10086;
227
   #endif
227
   #endif
228
 
228
 
229
-  uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0 / gCfgItems.filamentchange_load_speed) + 0.5);
230
-  uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0 / gCfgItems.filamentchange_unload_speed) + 0.5);
229
+  uiCfg.filament_loading_time = (uint32_t)((gCfgItems.filamentchange_load_length * 60.0f / gCfgItems.filamentchange_load_speed) + 0.5f);
230
+  uiCfg.filament_unloading_time = (uint32_t)((gCfgItems.filamentchange_unload_length * 60.0f / gCfgItems.filamentchange_unload_speed) + 0.5f);
231
 }
231
 }
232
 
232
 
233
 void update_spi_flash() {
233
 void update_spi_flash() {

+ 21
- 23
Marlin/src/lcd/extui/lib/mks_ui/draw_ui.h Ver fichero

184
 extern char public_buf_l[30];
184
 extern char public_buf_l[30];
185
 
185
 
186
 typedef struct {
186
 typedef struct {
187
-  uint32_t spi_flash_flag;
188
-  uint8_t disp_rotation_180;
189
-  bool multiple_language;
190
-  uint8_t language;
191
-  uint8_t leveling_mode;
192
-  bool from_flash_pic;
193
-  bool finish_power_off;
194
-  bool pause_reprint;
195
-  uint8_t wifi_mode_sel;
196
-  uint8_t fileSysType;
197
-  uint8_t wifi_type;
198
-  bool  cloud_enable,
199
-        encoder_enable;
200
-  int   levelingPos[5][2];
201
-  int   filamentchange_load_length,
202
-        filamentchange_load_speed,
203
-        filamentchange_unload_length,
204
-        filamentchange_unload_speed,
205
-        filament_limit_temper;
206
-  float pausePosX,
207
-        pausePosY,
208
-        pausePosZ;
209
-  uint32_t curFilesize;
187
+  uint32_t  spi_flash_flag;
188
+  uint8_t   disp_rotation_180;
189
+  bool      multiple_language;
190
+  uint8_t   language;
191
+  uint8_t   leveling_mode;
192
+  bool      from_flash_pic;
193
+  bool      finish_power_off;
194
+  bool      pause_reprint;
195
+  uint8_t   wifi_mode_sel;
196
+  uint8_t   fileSysType;
197
+  uint8_t   wifi_type;
198
+  bool      cloud_enable,
199
+            encoder_enable;
200
+  int       levelingPos[5][2];
201
+  int       filamentchange_load_length,
202
+            filamentchange_load_speed,
203
+            filamentchange_unload_length,
204
+            filamentchange_unload_speed;
205
+  int16_t   filament_limit_temp;
206
+  float     pausePosX, pausePosY, pausePosZ;
207
+  uint32_t  curFilesize;
210
 } CFG_ITMES;
208
 } CFG_ITMES;
211
 
209
 
212
 typedef struct {
210
 typedef struct {

Loading…
Cancelar
Guardar