Browse Source

Encapsulate Temperature items

Scott Lahteine 5 years ago
parent
commit
3d45a4bd23

+ 0
- 2
Marlin/src/lcd/extui/ui_api.cpp View File

@@ -945,7 +945,6 @@ namespace ExtUI {
945 945
     #endif
946 946
       {
947 947
         #if HAS_HOTEND
948
-          static constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
949 948
           const int16_t e = heater - H0;
950 949
           thermalManager.setTargetHotend(LROUND(constrain(value, 0, heater_maxtemp[e] - 15)), e);
951 950
         #endif
@@ -957,7 +956,6 @@ namespace ExtUI {
957 956
       value *= TOUCH_UI_LCD_TEMP_SCALING;
958 957
     #endif
959 958
     #if HAS_HOTEND
960
-      constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
961 959
       const int16_t e = extruder - E0;
962 960
       enableHeater(extruder);
963 961
       thermalManager.setTargetHotend(LROUND(constrain(value, 0, heater_maxtemp[e] - 15)), e);

+ 0
- 4
Marlin/src/lcd/menu/menu.h View File

@@ -29,10 +29,6 @@
29 29
 
30 30
 extern int8_t encoderLine, encoderTopLine, screen_items;
31 31
 
32
-#if HAS_HOTEND
33
-  constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
34
-#endif
35
-
36 32
 void scroll_screen(const uint8_t limit, const bool is_menu);
37 33
 bool printer_busy();
38 34
 

+ 19
- 13
Marlin/src/lcd/menu/menu_temperature.cpp View File

@@ -47,21 +47,27 @@ uint8_t MarlinUI::preheat_fan_speed[2];
47 47
 // "Temperature" submenu items
48 48
 //
49 49
 
50
-void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
50
+
51
+void Temperature::lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb) {
51 52
   #if HAS_HOTEND
52
-    if (temph > 0) thermalManager.setTargetHotend(_MIN(heater_maxtemp[endnum] - 15, temph), endnum);
53
+    if (indh >= 0 && ui.preheat_hotend_temp[indh] > 0)
54
+      setTargetHotend(_MIN(heater_maxtemp[e] - 15, ui.preheat_hotend_temp[indh]), e);
55
+  #else
56
+    UNUSED(temph);
53 57
   #endif
54 58
   #if HAS_HEATED_BED
55
-    if (tempb >= 0) thermalManager.setTargetBed(tempb);
59
+    if (indb >= 0 && ui.preheat_bed_temp[indb] >= 0) setTargetBed(ui.preheat_bed_temp[indb]);
56 60
   #else
57
-    UNUSED(tempb);
61
+    UNUSED(indb);
58 62
   #endif
59
-  #if FAN_COUNT > 0
60
-    #if FAN_COUNT > 1
61
-      thermalManager.set_fan_speed(active_extruder < FAN_COUNT ? active_extruder : 0, fan);
62
-    #else
63
-      thermalManager.set_fan_speed(0, fan);
64
-    #endif
63
+  #if HAS_FAN
64
+    set_fan_speed((
65
+      #if FAN_COUNT > 1
66
+        active_extruder < FAN_COUNT ? active_extruder : 0
67
+      #else
68
+        0
69
+      #endif
70
+    ), fan);
65 71
   #else
66 72
     UNUSED(fan);
67 73
   #endif
@@ -70,17 +76,17 @@ void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb
70 76
 
71 77
 #if HAS_TEMP_HOTEND
72 78
   inline void _preheat_end(const uint8_t m, const uint8_t e) {
73
-    _lcd_preheat(e, ui.preheat_hotend_temp[m], -1, ui.preheat_fan_speed[m]);
79
+    thermalManager.lcd_preheat(e, m, -1);
74 80
   }
75 81
   #if HAS_HEATED_BED
76 82
     inline void _preheat_both(const uint8_t m, const uint8_t e) {
77
-      _lcd_preheat(e, ui.preheat_hotend_temp[m], ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
83
+      thermalManager.lcd_preheat(e, m, m);
78 84
     }
79 85
   #endif
80 86
 #endif
81 87
 #if HAS_HEATED_BED
82 88
   inline void _preheat_bed(const uint8_t m) {
83
-    _lcd_preheat(0, 0, ui.preheat_bed_temp[m], ui.preheat_fan_speed[m]);
89
+    thermalManager.lcd_preheat(-1, -1, m);
84 90
   }
85 91
 #endif
86 92
 

+ 7
- 14
Marlin/src/module/temperature.cpp View File

@@ -28,9 +28,10 @@
28 28
 #include "endstops.h"
29 29
 
30 30
 #include "../MarlinCore.h"
31
-#include "../lcd/ultralcd.h"
32 31
 #include "planner.h"
33 32
 #include "../HAL/shared/Delay.h"
33
+
34
+#include "../lcd/ultralcd.h"
34 35
 #if ENABLED(EXTENSIBLE_UI)
35 36
   #include "../lcd/extui/ui_api.h"
36 37
 #endif
@@ -2241,22 +2242,14 @@ void Temperature::readings_ready() {
2241 2242
   #if HAS_HOTEND
2242 2243
 
2243 2244
     static constexpr int8_t temp_dir[] = {
2244
-      #if ENABLED(HEATER_0_USES_MAX6675)
2245
-        0
2246
-      #else
2247
-        TEMPDIR(0)
2248
-      #endif
2245
+      TERN(HEATER_0_USES_MAX6675, 0, TEMPDIR(0))
2249 2246
       #if HAS_MULTI_HOTEND
2250
-        #define _TEMPDIR(N) , TEMPDIR(N)
2251
-        #if ENABLED(HEATER_1_USES_MAX6675)
2252
-          , 0
2253
-        #else
2254
-          _TEMPDIR(1)
2255
-        #endif
2247
+        , TERN(HEATER_1_USES_MAX6675, 0, TEMPDIR(1))
2256 2248
         #if HOTENDS > 2
2249
+          #define _TEMPDIR(N) , TEMPDIR(N)
2257 2250
           REPEAT_S(2, HOTENDS, _TEMPDIR)
2258
-        #endif // HOTENDS > 2
2259
-      #endif // HAS_MULTI_HOTEND
2251
+        #endif
2252
+      #endif
2260 2253
     };
2261 2254
 
2262 2255
     LOOP_L_N(e, COUNT(temp_dir)) {

+ 5
- 0
Marlin/src/module/temperature.h View File

@@ -322,6 +322,7 @@ class Temperature {
322 322
     #if HAS_HOTEND
323 323
       #define HOTEND_TEMPS (HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT))
324 324
       static hotend_info_t temp_hotend[HOTEND_TEMPS];
325
+      static constexpr int16_t heater_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP);
325 326
     #endif
326 327
     TERN_(HAS_HEATED_BED, static bed_info_t temp_bed);
327 328
     TERN_(HAS_TEMP_PROBE, static probe_info_t temp_probe);
@@ -779,6 +780,10 @@ class Temperature {
779 780
 
780 781
     TERN_(HAS_DISPLAY, static void set_heating_message(const uint8_t e));
781 782
 
783
+    #if HAS_LCD_MENU
784
+      static void lcd_preheat(const int16_t e, const int8_t indh, const int8_t indb);
785
+    #endif
786
+
782 787
   private:
783 788
     static void update_raw_temperatures();
784 789
     static void updateTemperaturesFromRawValues();

Loading…
Cancel
Save