Преглед на файлове

🎨 Standard material presets behavior

Scott Lahteine преди 2 години
родител
ревизия
b09038fcc7

+ 113
- 98
Marlin/src/lcd/e3v2/creality/dwin.cpp Целия файл

@@ -166,8 +166,14 @@ typedef struct {
166 166
 
167 167
 select_t select_page{0}, select_file{0}, select_print{0}, select_prepare{0}
168 168
        , select_control{0}, select_axis{0}, select_temp{0}, select_motion{0}, select_tune{0}
169
-       , select_advset{0}, select_PLA{0}, select_ABS{0}
170
-       , select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0};
169
+       , select_advset{0}, select_speed{0}, select_acc{0}, select_jerk{0}, select_step{0}, select_item{0};
170
+
171
+#if HAS_PREHEAT
172
+  select_t select_PLA{0};
173
+  #if PREHEAT_COUNT > 1
174
+    select_t select_ABS{0};
175
+  #endif
176
+#endif
171 177
 
172 178
 uint8_t index_file     = MROWS,
173 179
         index_prepare  = MROWS,
@@ -492,8 +498,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
492 498
 #define PREPARE_CASE_DISA  2
493 499
 #define PREPARE_CASE_HOME  3
494 500
 #define PREPARE_CASE_ZOFF (PREPARE_CASE_HOME + ENABLED(HAS_ZOFFSET_ITEM))
495
-#define PREPARE_CASE_PLA  (PREPARE_CASE_ZOFF + ENABLED(HAS_HOTEND))
496
-#define PREPARE_CASE_ABS  (PREPARE_CASE_PLA + ENABLED(HAS_HOTEND))
501
+#define PREPARE_CASE_PLA  (PREPARE_CASE_ZOFF + ENABLED(HAS_PREHEAT))
502
+#define PREPARE_CASE_ABS  (PREPARE_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1)))
497 503
 #define PREPARE_CASE_COOL (PREPARE_CASE_ABS + EITHER(HAS_HOTEND, HAS_HEATED_BED))
498 504
 #define PREPARE_CASE_LANG (PREPARE_CASE_COOL + 1)
499 505
 #define PREPARE_CASE_TOTAL PREPARE_CASE_LANG
@@ -517,8 +523,8 @@ inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
517 523
 #define TEMP_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
518 524
 #define TEMP_CASE_BED  (TEMP_CASE_TEMP + ENABLED(HAS_HEATED_BED))
519 525
 #define TEMP_CASE_FAN  (TEMP_CASE_BED + ENABLED(HAS_FAN))
520
-#define TEMP_CASE_PLA  (TEMP_CASE_FAN + ENABLED(HAS_HOTEND))
521
-#define TEMP_CASE_ABS  (TEMP_CASE_PLA + ENABLED(HAS_HOTEND))
526
+#define TEMP_CASE_PLA  (TEMP_CASE_FAN + ENABLED(HAS_PREHEAT))
527
+#define TEMP_CASE_ABS  (TEMP_CASE_PLA + (TERN0(HAS_PREHEAT, PREHEAT_COUNT > 1)))
522 528
 #define TEMP_CASE_TOTAL TEMP_CASE_ABS
523 529
 
524 530
 #define PREHEAT_CASE_TEMP (0 + ENABLED(HAS_HOTEND))
@@ -785,6 +791,8 @@ void Draw_Prepare_Menu() {
785 791
     #if PREHEAT_COUNT > 1
786 792
       if (PVISI(PREPARE_CASE_ABS)) Item_Prepare_ABS(PSCROL(PREPARE_CASE_ABS));    // Preheat ABS
787 793
     #endif
794
+  #endif
795
+  #if HAS_HOTEND || HAS_HEATED_BED
788 796
     if (PVISI(PREPARE_CASE_COOL)) Item_Prepare_Cool(PSCROL(PREPARE_CASE_COOL));   // Cooldown
789 797
   #endif
790 798
   if (PVISI(PREPARE_CASE_LANG)) Item_Prepare_Lang(PSCROL(PREPARE_CASE_LANG));     // Language CN/EN
@@ -2664,10 +2672,10 @@ void HMI_Prepare() {
2664 2672
         // Draw "More" icon for sub-menus
2665 2673
         if (index_prepare < 7) Draw_More_Icon(MROWS - index_prepare + 1);
2666 2674
 
2667
-        #if HAS_HOTEND
2675
+        #if PREHEAT_COUNT > 1
2668 2676
           if (index_prepare == PREPARE_CASE_ABS) Item_Prepare_ABS(MROWS);
2669 2677
         #endif
2670
-        #if HAS_PREHEAT
2678
+        #if HAS_HOTEND || HAS_HEATED_BED
2671 2679
           if (index_prepare == PREPARE_CASE_COOL) Item_Prepare_Cool(MROWS);
2672 2680
         #endif
2673 2681
         if (index_prepare == PREPARE_CASE_LANG) Item_Prepare_Lang(MROWS);
@@ -2743,16 +2751,13 @@ void HMI_Prepare() {
2743 2751
           break;
2744 2752
       #endif
2745 2753
       #if HAS_PREHEAT
2746
-        case PREPARE_CASE_PLA:
2747
-          TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0));
2748
-          TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[0].bed_temp));
2749
-          TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed));
2750
-          break;
2751
-        case PREPARE_CASE_ABS:
2752
-          TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0));
2753
-          TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[1].bed_temp));
2754
-          TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed));
2755
-          break;
2754
+        case PREPARE_CASE_PLA: ui.preheat_all(0); break;
2755
+        #if PREHEAT_COUNT > 1
2756
+          case PREPARE_CASE_ABS: ui.preheat_all(1); break;
2757
+        #endif
2758
+      #endif
2759
+
2760
+      #if HAS_HOTEND || HAS_HEATED_BED
2756 2761
         case PREPARE_CASE_COOL:
2757 2762
           TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
2758 2763
           #if HAS_HOTEND || HAS_HEATED_BED
@@ -2760,6 +2765,7 @@ void HMI_Prepare() {
2760 2765
           #endif
2761 2766
           break;
2762 2767
       #endif
2768
+
2763 2769
       case PREPARE_CASE_LANG:
2764 2770
         HMI_ToggleLanguage();
2765 2771
         Draw_Prepare_Menu();
@@ -2784,9 +2790,11 @@ void Draw_Temperature_Menu() {
2784 2790
     #if HAS_FAN
2785 2791
       Item_AreaCopy(115, 134, 170, 146, TEMP_CASE_FAN);
2786 2792
     #endif
2787
-    #if HAS_HOTEND
2793
+    #if HAS_PREHEAT
2788 2794
       Item_AreaCopy(100, 89, 178, 101, TEMP_CASE_PLA);
2789
-      Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS);
2795
+      #if PREHEAT_COUNT > 1
2796
+        Item_AreaCopy(180, 89, 260, 100, TEMP_CASE_ABS);
2797
+      #endif
2790 2798
     #endif
2791 2799
   }
2792 2800
   else {
@@ -2805,30 +2813,33 @@ void Draw_Temperature_Menu() {
2805 2813
       #if HAS_FAN
2806 2814
         DWIN_Draw_Label(TEMP_CASE_FAN, GET_TEXT_F(MSG_FAN_SPEED));
2807 2815
       #endif
2808
-      #if HAS_HOTEND
2816
+      #if HAS_PREHEAT
2809 2817
         DWIN_Draw_Label(TEMP_CASE_PLA, F(PREHEAT_1_LABEL " Preheat Settings"));
2810
-        DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings"));
2818
+        #if PREHEAT_COUNT > 1
2819
+          DWIN_Draw_Label(TEMP_CASE_ABS, F(PREHEAT_2_LABEL " Preheat Settings"));
2820
+        #endif
2811 2821
       #endif
2812 2822
     #else
2813 2823
       #if HAS_HOTEND
2814
-        Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP);    // "Nozzle"
2815
-        Item_AreaCopy(1,  89,  83, 101, TEMP_CASE_TEMP, 44);  // "Temperature"
2824
+        Item_AreaCopy(197, 104, 238, 114, TEMP_CASE_TEMP);      // "Nozzle"
2825
+        Item_AreaCopy(1,  89,  83, 101, TEMP_CASE_TEMP, 44);    // "Temperature"
2816 2826
       #endif
2817 2827
       #if HAS_HEATED_BED
2818
-        Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED);     // "Bed"
2819
-        Item_AreaCopy(1,  89,  83, 101, TEMP_CASE_BED, 27);   // "Temperature"
2828
+        Item_AreaCopy(240, 104, 264, 114, TEMP_CASE_BED);       // "Bed"
2829
+        Item_AreaCopy(1,  89,  83, 101, TEMP_CASE_BED, 27);     // "Temperature"
2820 2830
       #endif
2821 2831
       #if HAS_FAN
2822
-        Item_AreaCopy(  1, 119,  61, 132, TEMP_CASE_FAN);     // "Fan speed"
2832
+        Item_AreaCopy(  1, 119,  61, 132, TEMP_CASE_FAN);       // "Fan speed"
2823 2833
       #endif
2824
-      #if HAS_HOTEND
2825
-        Item_AreaCopy(107,  76, 156,  86, TEMP_CASE_PLA);     // "Preheat"
2826
-        say_pla_en(52, TEMP_CASE_PLA);                        // "PLA"
2827
-        Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79); // "Settings"
2828
-
2829
-        Item_AreaCopy(107,  76, 156,  86, TEMP_CASE_ABS);     // "Preheat"
2830
-        say_abs_en(52, TEMP_CASE_ABS);                        // "ABS"
2831
-        Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings"
2834
+      #if HAS_PREHEAT
2835
+        Item_AreaCopy(107,  76, 156,  86, TEMP_CASE_PLA);       // "Preheat"
2836
+        say_pla_en(52, TEMP_CASE_PLA);                          // "PLA"
2837
+        Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_PLA, 79);   // "Settings"
2838
+        #if PREHEAT_COUNT > 1
2839
+          Item_AreaCopy(107,  76, 156,  86, TEMP_CASE_ABS);     // "Preheat"
2840
+          say_abs_en(52, TEMP_CASE_ABS);                        // "ABS"
2841
+          Item_AreaCopy(150, 135, 202, 148, TEMP_CASE_ABS, 81); // "Settings"
2842
+        #endif
2832 2843
       #endif
2833 2844
     #endif
2834 2845
   }
@@ -2851,12 +2862,12 @@ void Draw_Temperature_Menu() {
2851 2862
     _TMENU_ICON(TEMP_CASE_FAN);
2852 2863
     Draw_Edit_Integer3(i, thermalManager.fan_speed[0]);
2853 2864
   #endif
2854
-  #if HAS_HOTEND
2865
+  #if HAS_PREHEAT
2855 2866
     // PLA/ABS items have submenus
2856
-    _TMENU_ICON(TEMP_CASE_PLA);
2857
-    Draw_More_Icon(i);
2858
-    _TMENU_ICON(TEMP_CASE_ABS);
2859
-    Draw_More_Icon(i);
2867
+    _TMENU_ICON(TEMP_CASE_PLA); Draw_More_Icon(i);
2868
+    #if PREHEAT_COUNT > 1
2869
+      _TMENU_ICON(TEMP_CASE_ABS); Draw_More_Icon(i);
2870
+    #endif
2860 2871
   #endif
2861 2872
 }
2862 2873
 
@@ -3076,6 +3087,7 @@ void HMI_Temperature() {
3076 3087
           EncoderRate.enabled = true;
3077 3088
           break;
3078 3089
       #endif
3090
+
3079 3091
       #if HAS_PREHEAT
3080 3092
         case TEMP_CASE_PLA: {
3081 3093
           checkkey = PLAPreheat;
@@ -3153,7 +3165,8 @@ void HMI_Temperature() {
3153 3165
             Draw_Menu_Line(++i, ICON_WriteEEPROM);
3154 3166
           #endif
3155 3167
         } break;
3156
-      #endif
3168
+      #endif // HAS_PREHEAT
3169
+
3157 3170
       #if PREHEAT_COUNT > 1
3158 3171
         case TEMP_CASE_ABS: { // ABS preheat setting
3159 3172
           checkkey = ABSPreheat;
@@ -3236,7 +3249,7 @@ void HMI_Temperature() {
3236 3249
 
3237 3250
         } break;
3238 3251
 
3239
-      #endif // HAS_HOTEND
3252
+      #endif // PREHEAT_COUNT > 1
3240 3253
     }
3241 3254
   }
3242 3255
   DWIN_UpdateLCD();
@@ -3579,14 +3592,12 @@ void HMI_AdvSet() {
3579 3592
 
3580 3593
       #if HAS_HOTEND
3581 3594
         case ADVSET_CASE_HEPID:
3582
-          thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
3583 3595
           thermalManager.PID_autotune(ui.material_preset[0].hotend_temp, H_E0, 10, true);
3584 3596
           break;
3585 3597
       #endif
3586 3598
 
3587 3599
       #if HAS_HEATED_BED
3588 3600
         case ADVSET_CASE_BEDPID:
3589
-          thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
3590 3601
           thermalManager.PID_autotune(ui.material_preset[0].bed_temp, H_BED, 10, true);
3591 3602
           break;
3592 3603
       #endif
@@ -3881,63 +3892,65 @@ void HMI_Tune() {
3881 3892
     DWIN_UpdateLCD();
3882 3893
   }
3883 3894
 
3884
-  // ABS Preheat
3885
-  void HMI_ABSPreheatSetting() {
3886
-    EncoderState encoder_diffState = get_encoder_state();
3887
-    if (encoder_diffState == ENCODER_DIFF_NO) return;
3888
-
3889
-    // Avoid flicker by updating only the previous menu
3890
-    if (encoder_diffState == ENCODER_DIFF_CW) {
3891
-      if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now);
3892
-    }
3893
-    else if (encoder_diffState == ENCODER_DIFF_CCW) {
3894
-      if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
3895
-    }
3896
-    else if (encoder_diffState == ENCODER_DIFF_ENTER) {
3897
-      switch (select_ABS.now) {
3898
-        case CASE_BACK:
3899
-          checkkey = TemperatureID;
3900
-          select_temp.now = TEMP_CASE_ABS;
3901
-          HMI_ValueStruct.show_mode = -1;
3902
-          Draw_Temperature_Menu();
3903
-          break;
3904
-        #if HAS_HOTEND
3905
-          case PREHEAT_CASE_TEMP:
3906
-            checkkey = ETemp;
3907
-            HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
3908
-            Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true);
3909
-            EncoderRate.enabled = true;
3910
-            break;
3911
-        #endif
3912
-        #if HAS_HEATED_BED
3913
-          case PREHEAT_CASE_BED:
3914
-            checkkey = BedTemp;
3915
-            HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
3916
-            Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true);
3917
-            EncoderRate.enabled = true;
3918
-            break;
3919
-        #endif
3920
-        #if HAS_FAN
3921
-          case PREHEAT_CASE_FAN:
3922
-            checkkey = FanSpeed;
3923
-            HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
3924
-            Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true);
3925
-            EncoderRate.enabled = true;
3895
+  #if PREHEAT_COUNT > 1
3896
+    // ABS Preheat
3897
+    void HMI_ABSPreheatSetting() {
3898
+      EncoderState encoder_diffState = get_encoder_state();
3899
+      if (encoder_diffState == ENCODER_DIFF_NO) return;
3900
+
3901
+      // Avoid flicker by updating only the previous menu
3902
+      if (encoder_diffState == ENCODER_DIFF_CW) {
3903
+        if (select_ABS.inc(1 + PREHEAT_CASE_TOTAL)) Move_Highlight(1, select_ABS.now);
3904
+      }
3905
+      else if (encoder_diffState == ENCODER_DIFF_CCW) {
3906
+        if (select_ABS.dec()) Move_Highlight(-1, select_ABS.now);
3907
+      }
3908
+      else if (encoder_diffState == ENCODER_DIFF_ENTER) {
3909
+        switch (select_ABS.now) {
3910
+          case CASE_BACK:
3911
+            checkkey = TemperatureID;
3912
+            select_temp.now = TEMP_CASE_ABS;
3913
+            HMI_ValueStruct.show_mode = -1;
3914
+            Draw_Temperature_Menu();
3926 3915
             break;
3927
-        #endif
3928
-        #if ENABLED(EEPROM_SETTINGS)
3929
-          case PREHEAT_CASE_SAVE: {
3930
-            const bool success = settings.save();
3931
-            HMI_AudioFeedback(success);
3932
-          } break;
3933
-        #endif
3934
-        default: break;
3916
+          #if HAS_HOTEND
3917
+            case PREHEAT_CASE_TEMP:
3918
+              checkkey = ETemp;
3919
+              HMI_ValueStruct.E_Temp = ui.material_preset[1].hotend_temp;
3920
+              Draw_Edit_Integer3(PREHEAT_CASE_TEMP, ui.material_preset[1].hotend_temp, true);
3921
+              EncoderRate.enabled = true;
3922
+              break;
3923
+          #endif
3924
+          #if HAS_HEATED_BED
3925
+            case PREHEAT_CASE_BED:
3926
+              checkkey = BedTemp;
3927
+              HMI_ValueStruct.Bed_Temp = ui.material_preset[1].bed_temp;
3928
+              Draw_Edit_Integer3(PREHEAT_CASE_BED, ui.material_preset[1].bed_temp, true);
3929
+              EncoderRate.enabled = true;
3930
+              break;
3931
+          #endif
3932
+          #if HAS_FAN
3933
+            case PREHEAT_CASE_FAN:
3934
+              checkkey = FanSpeed;
3935
+              HMI_ValueStruct.Fan_speed = ui.material_preset[1].fan_speed;
3936
+              Draw_Edit_Integer3(PREHEAT_CASE_FAN, ui.material_preset[1].fan_speed, true);
3937
+              EncoderRate.enabled = true;
3938
+              break;
3939
+          #endif
3940
+          #if ENABLED(EEPROM_SETTINGS)
3941
+            case PREHEAT_CASE_SAVE: {
3942
+              const bool success = settings.save();
3943
+              HMI_AudioFeedback(success);
3944
+            } break;
3945
+          #endif
3946
+          default: break;
3947
+        }
3935 3948
       }
3949
+      DWIN_UpdateLCD();
3936 3950
     }
3937
-    DWIN_UpdateLCD();
3938
-  }
3951
+  #endif // PREHEAT_COUNT > 1
3939 3952
 
3940
-#endif
3953
+#endif // HAS_PREHEAT
3941 3954
 
3942 3955
 // Max Speed
3943 3956
 void HMI_MaxSpeed() {
@@ -4241,7 +4254,9 @@ void DWIN_HandleScreen() {
4241 4254
     case Tune:            HMI_Tune(); break;
4242 4255
     #if HAS_PREHEAT
4243 4256
       case PLAPreheat:    HMI_PLAPreheatSetting(); break;
4244
-      case ABSPreheat:    HMI_ABSPreheatSetting(); break;
4257
+      #if PREHEAT_COUNT > 1
4258
+        case ABSPreheat:  HMI_ABSPreheatSetting(); break;
4259
+      #endif
4245 4260
     #endif
4246 4261
     case MaxSpeed:        HMI_MaxSpeed(); break;
4247 4262
     case MaxAcceleration: HMI_MaxAcceleration(); break;

+ 6
- 12
Marlin/src/lcd/e3v2/enhanced/dwin.cpp Целия файл

@@ -2116,21 +2116,15 @@ void SetHome() {
2116 2116
 #endif
2117 2117
 
2118 2118
 #if HAS_PREHEAT
2119
-  void SetPreheat(const uint8_t i) {
2120
-    TERN_(HAS_HOTEND,     thermalManager.setTargetHotend(ui.material_preset[i].hotend_temp, 0));
2121
-    TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(ui.material_preset[i].bed_temp));
2122
-    TERN_(HAS_FAN,        thermalManager.set_fan_speed(0, ui.material_preset[i].fan_speed));
2123
-  }
2124
-  void SetPreheat0() { SetPreheat(0); }
2125
-  void SetPreheat1() { SetPreheat(1); }
2126
-  void SetPreheat2() { SetPreheat(2); }
2127
-
2128 2119
   void SetCoolDown() {
2129 2120
     TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
2130 2121
     #if HAS_HOTEND || HAS_HEATED_BED
2131 2122
       thermalManager.disable_all_heaters();
2132 2123
     #endif
2133 2124
   }
2125
+  void DoPreheat0() { ui.preheat_all(0); }
2126
+  void DoPreheat1() { ui.preheat_all(1); }
2127
+  void DoPreheat2() { ui.preheat_all(2); }
2134 2128
 #endif
2135 2129
 
2136 2130
 void SetLanguage() {
@@ -3125,12 +3119,12 @@ void Draw_Prepare_Menu() {
3125 3119
       #endif
3126 3120
     #endif
3127 3121
     #if HAS_PREHEAT
3128
-      ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, SetPreheat0);
3122
+      ADDMENUITEM(ICON_PLAPreheat, GET_TEXT_F(MSG_PREHEAT_1), onDrawPreheat1, DoPreheat0);
3129 3123
       #if PREHEAT_COUNT > 1
3130
-        ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, SetPreheat1);
3124
+        ADDMENUITEM(ICON_ABSPreheat, PSTR("Preheat " PREHEAT_2_LABEL), onDrawPreheat2, DoPreheat1);
3131 3125
       #endif
3132 3126
       #if PREHEAT_COUNT > 2
3133
-        ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, SetPreheat2);
3127
+        ADDMENUITEM(ICON_CustomPreheat, GET_TEXT_F(MSG_PREHEAT_CUSTOM), onDrawMenuItem, DoPreheat2);
3134 3128
       #endif
3135 3129
       ADDMENUITEM(ICON_Cool, GET_TEXT_F(MSG_COOLDOWN), onDrawCooldown, SetCoolDown);
3136 3130
     #endif

+ 31
- 79
Marlin/src/lcd/e3v2/jyersui/dwin.cpp Целия файл

@@ -1584,9 +1584,9 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1584 1584
         }
1585 1585
         break;
1586 1586
     #endif
1587
-    #if HAS_PREHEAT
1588
-      case Preheat:
1589 1587
 
1588
+    #if HAS_PREHEAT
1589
+      case Preheat: {
1590 1590
         #define PREHEAT_BACK 0
1591 1591
         #define PREHEAT_MODE (PREHEAT_BACK + 1)
1592 1592
         #define PREHEAT_1 (PREHEAT_MODE + 1)
@@ -1596,6 +1596,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1596 1596
         #define PREHEAT_5 (PREHEAT_4 + (PREHEAT_COUNT >= 5))
1597 1597
         #define PREHEAT_TOTAL PREHEAT_5
1598 1598
 
1599
+        auto do_preheat = [](const uint8_t m) {
1600
+          thermalManager.disable_all_heaters();
1601
+          TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1602
+          if (preheatmode == 0 || preheatmode == 1) { ui.preheat_hotend_and_fan(m); }
1603
+          if (preheatmode == 0 || preheatmode == 2) ui.preheat_bed(m);
1604
+        };
1605
+
1599 1606
         switch (item) {
1600 1607
           case PREHEAT_BACK:
1601 1608
             if (draw)
@@ -1616,17 +1623,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1616 1623
             case PREHEAT_1:
1617 1624
               if (draw)
1618 1625
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
1619
-              else {
1620
-                thermalManager.disable_all_heaters();
1621
-                TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1622
-                if (preheatmode == 0 || preheatmode == 1) {
1623
-                  TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0));
1624
-                  TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed));
1625
-                }
1626
-                #if HAS_HEATED_BED
1627
-                  if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[0].bed_temp);
1628
-                #endif
1629
-              }
1626
+              else
1627
+                do_preheat(0);
1630 1628
               break;
1631 1629
           #endif
1632 1630
 
@@ -1634,17 +1632,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1634 1632
             case PREHEAT_2:
1635 1633
               if (draw)
1636 1634
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
1637
-              else {
1638
-                thermalManager.disable_all_heaters();
1639
-                TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1640
-                if (preheatmode == 0 || preheatmode == 1) {
1641
-                  TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0));
1642
-                  TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed));
1643
-                }
1644
-                #if HAS_HEATED_BED
1645
-                  if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[1].bed_temp);
1646
-                #endif
1647
-              }
1635
+              else
1636
+                do_preheat(1);
1648 1637
               break;
1649 1638
           #endif
1650 1639
 
@@ -1652,17 +1641,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1652 1641
             case PREHEAT_3:
1653 1642
               if (draw)
1654 1643
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
1655
-              else {
1656
-                thermalManager.disable_all_heaters();
1657
-                TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1658
-                if (preheatmode == 0 || preheatmode == 1) {
1659
-                  TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0));
1660
-                  TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed));
1661
-                }
1662
-                #if HAS_HEATED_BED
1663
-                  if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[2].bed_temp);
1664
-                #endif
1665
-              }
1644
+              else
1645
+                do_preheat(2);
1666 1646
               break;
1667 1647
           #endif
1668 1648
 
@@ -1670,17 +1650,8 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1670 1650
             case PREHEAT_4:
1671 1651
               if (draw)
1672 1652
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
1673
-              else {
1674
-                thermalManager.disable_all_heaters();
1675
-                TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1676
-                if (preheatmode == 0 || preheatmode == 1) {
1677
-                  TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0));
1678
-                  TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed));
1679
-                }
1680
-                #if HAS_HEATED_BED
1681
-                  if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[3].bed_temp);
1682
-                #endif
1683
-              }
1653
+              else
1654
+                do_preheat(3);
1684 1655
               break;
1685 1656
           #endif
1686 1657
 
@@ -1688,22 +1659,13 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
1688 1659
             case PREHEAT_5:
1689 1660
               if (draw)
1690 1661
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
1691
-              else {
1692
-                thermalManager.disable_all_heaters();
1693
-                TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1694
-                if (preheatmode == 0 || preheatmode == 1) {
1695
-                  TERN_(HAS_HOTEND, thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0));
1696
-                  TERN_(HAS_FAN, thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed));
1697
-                }
1698
-                #if HAS_HEATED_BED
1699
-                  if (preheatmode == 0 || preheatmode == 2) thermalManager.setTargetBed(ui.material_preset[4].bed_temp);
1700
-                #endif
1701
-              }
1662
+              else
1663
+                do_preheat(4);
1702 1664
               break;
1703 1665
           #endif
1704 1666
         }
1705
-        break;
1706
-    #endif
1667
+      } break;
1668
+    #endif // HAS_PREHEAT
1707 1669
 
1708 1670
     #if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
1709 1671
       case ChangeFilament:
@@ -3964,50 +3926,40 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
3964 3926
             case PREHEATHOTEND_1:
3965 3927
               if (draw)
3966 3928
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_1_LABEL));
3967
-              else {
3968
-                thermalManager.setTargetHotend(ui.material_preset[0].hotend_temp, 0);
3969
-                thermalManager.set_fan_speed(0, ui.material_preset[0].fan_speed);
3970
-              }
3929
+              else
3930
+                ui.preheat_hotend_and_fan(0);
3971 3931
               break;
3972 3932
           #endif
3973 3933
           #if PREHEAT_COUNT >= 2
3974 3934
             case PREHEATHOTEND_2:
3975 3935
               if (draw)
3976 3936
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_2_LABEL));
3977
-              else {
3978
-                thermalManager.setTargetHotend(ui.material_preset[1].hotend_temp, 0);
3979
-                thermalManager.set_fan_speed(0, ui.material_preset[1].fan_speed);
3980
-              }
3937
+              else
3938
+                ui.preheat_hotend_and_fan(1);
3981 3939
               break;
3982 3940
           #endif
3983 3941
           #if PREHEAT_COUNT >= 3
3984 3942
             case PREHEATHOTEND_3:
3985 3943
               if (draw)
3986 3944
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_3_LABEL));
3987
-              else {
3988
-                thermalManager.setTargetHotend(ui.material_preset[2].hotend_temp, 0);
3989
-                thermalManager.set_fan_speed(0, ui.material_preset[2].fan_speed);
3990
-              }
3945
+              else
3946
+                ui.preheat_hotend_and_fan(2);
3991 3947
               break;
3992 3948
           #endif
3993 3949
           #if PREHEAT_COUNT >= 4
3994 3950
             case PREHEATHOTEND_4:
3995 3951
               if (draw)
3996 3952
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_4_LABEL));
3997
-              else {
3998
-                thermalManager.setTargetHotend(ui.material_preset[3].hotend_temp, 0);
3999
-                thermalManager.set_fan_speed(0, ui.material_preset[3].fan_speed);
4000
-              }
3953
+              else
3954
+                ui.preheat_hotend_and_fan(3);
4001 3955
               break;
4002 3956
           #endif
4003 3957
           #if PREHEAT_COUNT >= 5
4004 3958
             case PREHEATHOTEND_5:
4005 3959
               if (draw)
4006 3960
                 Draw_Menu_Item(row, ICON_Temperature, F(PREHEAT_5_LABEL));
4007
-              else {
4008
-                thermalManager.setTargetHotend(ui.material_preset[4].hotend_temp, 0);
4009
-                thermalManager.set_fan_speed(0, ui.material_preset[4].fan_speed);
4010
-              }
3961
+              else
3962
+                ui.preheat_hotend_and_fan(4);
4011 3963
               break;
4012 3964
           #endif
4013 3965
           case PREHEATHOTEND_CUSTOM:

+ 9
- 45
Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp Целия файл

@@ -621,55 +621,19 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr
621 621
   void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) {
622 622
     DEBUG_ECHOLNPGM("HandlePreheat");
623 623
 
624
-    uint8_t e_temp = 0;
625
-    #if HAS_HEATED_BED
626
-      uint8_t bed_temp = 0;
627
-    #endif
628 624
     const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr);
629 625
     switch (preheat_option) {
630 626
       default:
631
-      case 0: // Preheat PLA
632
-        #if defined(PREHEAT_1_TEMP_HOTEND) && defined(PREHEAT_1_TEMP_BED)
633
-          e_temp = PREHEAT_1_TEMP_HOTEND;
634
-          TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_1_TEMP_BED);
635
-        #endif
636
-        break;
637
-      case 1: // Preheat ABS
638
-        #if defined(PREHEAT_2_TEMP_HOTEND) && defined(PREHEAT_2_TEMP_BED)
639
-          e_temp = PREHEAT_2_TEMP_HOTEND;
640
-          TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_2_TEMP_BED);
641
-        #endif
642
-        break;
643
-      case 2: // Preheat PET
644
-        #if defined(PREHEAT_3_TEMP_HOTEND) && defined(PREHEAT_3_TEMP_BED)
645
-          e_temp = PREHEAT_3_TEMP_HOTEND;
646
-          TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_3_TEMP_BED);
647
-        #endif
648
-        break;
649
-      case 3: // Preheat FLEX
650
-        #if defined(PREHEAT_4_TEMP_HOTEND) && defined(PREHEAT_4_TEMP_BED)
651
-          e_temp = PREHEAT_4_TEMP_HOTEND;
652
-          TERN_(HAS_HEATED_BED, bed_temp = PREHEAT_4_TEMP_BED);
653
-        #endif
654
-        break;
627
+      switch (var.VP) {
628
+        default: return;
629
+        case VP_E0_BED_PREHEAT: TERN_(HAS_HOTEND, ui.preheat_all(0)); break;
630
+        case VP_E1_BED_PREHEAT: TERN_(HAS_MULTI_HOTEND, ui.preheat_all(1)); break;
631
+      }
655 632
       case 7: break; // Custom preheat
656
-      case 9: break; // Cool down
657
-    }
658
-
659
-    switch (var.VP) {
660
-      default: return;
661
-        #if HAS_HOTEND
662
-          case VP_E0_BED_PREHEAT:
663
-            thermalManager.setTargetHotend(e_temp, 0);
664
-            TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
665
-            break;
666
-        #endif
667
-        #if HOTENDS >= 2
668
-          case VP_E1_BED_PREHEAT:
669
-            thermalManager.setTargetHotend(e_temp, 1);
670
-            TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(bed_temp));
671
-            break;
672
-        #endif
633
+      case 9: // Cool down
634
+        thermalManager.zero_fan_speeds();
635
+        thermalManager.disable_all_heaters();
636
+        break;
673 637
     }
674 638
 
675 639
     // Go to the preheat screen to show the heating progress

+ 1
- 4
Marlin/src/lcd/extui/ui_api.cpp Целия файл

@@ -1035,10 +1035,7 @@ namespace ExtUI {
1035 1035
   void setFeedrate_percent(const_float_t value) { feedrate_percentage = constrain(value, 10, 500); }
1036 1036
 
1037 1037
   void coolDown() {
1038
-    #if HAS_HOTEND
1039
-      HOTEND_LOOP() thermalManager.setTargetHotend(0, e);
1040
-    #endif
1041
-    TERN_(HAS_HEATED_BED, thermalManager.setTargetBed(0));
1038
+    thermalManager.disable_all_heaters();
1042 1039
     TERN_(HAS_FAN, thermalManager.zero_fan_speeds());
1043 1040
   }
1044 1041
 

+ 11
- 0
Marlin/src/lcd/marlinui.cpp Целия файл

@@ -135,7 +135,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
135 135
 #endif
136 136
 
137 137
 #if HAS_PREHEAT
138
+  #include "../module/temperature.h"
139
+
138 140
   preheat_t MarlinUI::material_preset[PREHEAT_COUNT];  // Initialized by settings.load()
141
+
139 142
   PGM_P MarlinUI::get_preheat_label(const uint8_t m) {
140 143
     #define _PDEF(N) static PGMSTR(preheat_##N##_label, PREHEAT_##N##_LABEL);
141 144
     #define _PLBL(N) preheat_##N##_label,
@@ -143,6 +146,14 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
143 146
     static PGM_P const preheat_labels[PREHEAT_COUNT] PROGMEM = { REPEAT_1(PREHEAT_COUNT, _PLBL) };
144 147
     return (PGM_P)pgm_read_ptr(&preheat_labels[m]);
145 148
   }
149
+
150
+  void MarlinUI::apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e/*=active_extruder*/) {
151
+    const preheat_t &pre = material_preset[m];
152
+    TERN_(HAS_HOTEND,           if (TEST(pmask, PM_HOTEND))  thermalManager.setTargetHotend(pre.hotend_temp, e));
153
+    TERN_(HAS_HEATED_BED,       if (TEST(pmask, PM_BED))     thermalManager.setTargetBed(pre.bed_temp));
154
+    //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PM_CHAMBER)) thermalManager.setTargetBed(pre.chamber_temp));
155
+    TERN_(HAS_FAN,              if (TEST(pmask, PM_FAN))     thermalManager.set_fan_speed(0, pre.fan_speed));
156
+  }
146 157
 #endif
147 158
 
148 159
 #if EITHER(HAS_LCD_MENU, EXTENSIBLE_UI)

+ 7
- 1
Marlin/src/lcd/marlinui.h Целия файл

@@ -56,7 +56,6 @@
56 56
 
57 57
 #if ENABLED(ADVANCED_PAUSE_FEATURE) && ANY(HAS_LCD_MENU, EXTENSIBLE_UI, HAS_DWIN_E3V2)
58 58
   #include "../feature/pause.h"
59
-  #include "../module/motion.h" // for active_extruder
60 59
 #endif
61 60
 
62 61
 #if ENABLED(DWIN_CREALITY_LCD)
@@ -498,8 +497,15 @@ public:
498 497
   #endif
499 498
 
500 499
   #if HAS_PREHEAT
500
+    enum PreheatMask : uint8_t { PM_HOTEND = _BV(0), PM_BED = _BV(1), PM_FAN = _BV(2), PM_CHAMBER = _BV(3) };
501 501
     static preheat_t material_preset[PREHEAT_COUNT];
502 502
     static PGM_P get_preheat_label(const uint8_t m);
503
+    static void apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e=active_extruder);
504
+    static inline void preheat_set_fan(const uint8_t m) { TERN_(HAS_FAN, apply_preheat(m, PM_FAN)); }
505
+    static inline void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, PM_HOTEND)); }
506
+    static inline void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); }
507
+    static inline void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, PM_BED)); }
508
+    static inline void preheat_all(const uint8_t m) { apply_preheat(m, 0xFF); }
503 509
   #endif
504 510
 
505 511
   #if SCREENS_CAN_TIME_OUT

Loading…
Отказ
Запис