Skip to content

Commit a7684ec

Browse files
committed
πŸ§‘β€πŸ’» Reuse MarlinUI::apply_preheat
1 parent fc49efc commit a7684ec

File tree

4 files changed

+25
-60
lines changed

4 files changed

+25
-60
lines changed

β€ŽMarlin/src/lcd/marlinui.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
153153
TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e));
154154
TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp));
155155
TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetChamber(pre.chamber_temp));
156-
TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed));
156+
TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(e, pre.fan_speed));
157+
#if HAS_FAN
158+
if (TEST(pmask, PT_FAN)) {
159+
const uint8_t fan_index = e < (FAN_COUNT) ? e : 0;
160+
if (true
161+
#if REDUNDANT_PART_COOLING_FAN
162+
&& fan_index != REDUNDANT_PART_COOLING_FAN
163+
#endif
164+
) thermalManager.set_fan_speed(fan_index, pre.fan_speed);
165+
}
166+
#endif
157167
}
158168
#endif
159169

@@ -1935,7 +1945,7 @@ uint8_t expand_u8str_P(char * const outstr, PGM_P const ptpl, const int8_t ind,
19351945
settings.reset();
19361946
completion_feedback();
19371947
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
1938-
if (touch_calibration.need_calibration()) ui.goto_screen(touch_screen_calibration);
1948+
if (touch_calibration.need_calibration()) goto_screen(touch_screen_calibration);
19391949
#endif
19401950
}
19411951

β€ŽMarlin/src/lcd/marlinui.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ class MarlinUI {
652652
static void preheat_hotend(const uint8_t m, const uint8_t e=active_extruder) { TERN_(HAS_HOTEND, apply_preheat(m, _BV(PT_HOTEND))); }
653653
static void preheat_hotend_and_fan(const uint8_t m, const uint8_t e=active_extruder) { preheat_hotend(m, e); preheat_set_fan(m); }
654654
static void preheat_bed(const uint8_t m) { TERN_(HAS_HEATED_BED, apply_preheat(m, _BV(PT_BED))); }
655-
static void preheat_all(const uint8_t m) { apply_preheat(m, PT_ALL); }
655+
static void preheat_chamber(const uint8_t m) { TERN_(HAS_HEATED_CHAMBER, apply_preheat(m, _BV(PT_CHAMBER))); }
656+
static void preheat_all(const uint8_t m, const uint8_t e=active_extruder) { apply_preheat(m, PT_ALL, e); }
656657
#endif
657658

658659
static void reset_status_timeout(const millis_t ms) {

β€ŽMarlin/src/lcd/menu/menu_temperature.cpp

Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,66 +45,34 @@
4545

4646
#if HAS_PREHEAT
4747

48-
/**
49-
* @fn Temperature::lcd_preheat
50-
* @brief Apply the "preheat" parameters for a material preset to the
51-
* hotend (or laser), bed, chamber, or all of the above.
52-
* @param m Material index
53-
* @param targets Bit mask of targets to "preheat" (or turn off)
54-
* @param e Extruder index (if needed)
55-
*/
56-
void Temperature::lcd_preheat(const uint8_t m, const uint8_t targets, const uint8_t e/*=0*/) {
57-
UNUSED(e);
58-
#if HAS_HOTEND
59-
if (targets & PreheatTarget::HOTEND) setTargetHotend(ui.material_preset[m].hotend_temp, e);
60-
#endif
61-
#if HAS_HEATED_BED
62-
if (targets & PreheatTarget::BED) setTargetBed(ui.material_preset[m].bed_temp);
63-
#endif
64-
#if HAS_HEATED_CHAMBER
65-
if (targets & PreheatTarget::CHAMBER) setTargetChamber(ui.material_preset[m].chamber_temp);
66-
#endif
67-
#if HAS_FAN
68-
if (targets & PreheatTarget::HOTEND) {
69-
const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0;
70-
if (true
71-
#if REDUNDANT_PART_COOLING_FAN
72-
&& fan_index != REDUNDANT_PART_COOLING_FAN
73-
#endif
74-
) set_fan_speed(fan_index, ui.material_preset[m].fan_speed);
75-
}
76-
#endif
77-
ui.return_to_status();
78-
}
79-
8048
#if HAS_TEMP_HOTEND
81-
inline void _preheat_end(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::HOTEND, e); }
82-
void do_preheat_end_m() { _preheat_end(0, editable.int8); }
49+
inline void _preheat_end(const uint8_t m, const uint8_t e) { ui.preheat_hotend(m, e); ui.return_to_status(); }
50+
void do_preheat_end_m() { _preheat_end(editable.int8, 0); }
8351
#endif
8452
#if HAS_HEATED_BED
85-
inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::BED); }
53+
inline void _preheat_bed(const uint8_t m) { ui.preheat_bed(m); ui.return_to_status(); }
8654
#endif
8755
#if HAS_HEATED_CHAMBER
88-
inline void _preheat_chamber(const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::CHAMBER); }
56+
inline void _preheat_chamber(const uint8_t m) { ui.preheat_chamber(m); ui.return_to_status(); }
8957
#endif
9058
#if HAS_COOLER
91-
inline void _precool_laser(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::HOTEND, e); }
92-
void do_precool_laser_m() { _precool_laser(thermalManager.temp_cooler.target, editable.int8); }
59+
inline void _precool_laser(const uint8_t m, const uint8_t e) { ui.preheat_hotend(m, e); ui.return_to_status(); }
60+
void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); }
9361
#endif
9462

9563
#if HAS_TEMP_HOTEND && (HAS_HEATED_BED || HAS_HEATED_CHAMBER)
96-
inline void _preheat_all(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::ALL, e); }
64+
inline void _preheat_all(const uint8_t m, const uint8_t e) { ui.preheat_all(m, e); ui.return_to_status(); }
9765

9866
// Indexed "Preheat ABC" and "Heat Bed" items
9967
#define PREHEAT_ITEMS(M,E) do{ \
100-
ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_all(MenuItemBase::itemIndex, M); }); \
101-
ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(MenuItemBase::itemIndex, M); }); \
68+
ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_all(M, MenuItemBase::itemIndex); }); \
69+
ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \
10270
}while(0)
10371

10472
#elif HAS_MULTI_HOTEND
10573

10674
// No heated bed, so just indexed "Preheat ABC" items
107-
#define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(MenuItemBase::itemIndex, M); })
75+
#define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); })
10876

10977
#endif
11078

@@ -121,7 +89,7 @@
12189
#if HOTENDS == 1
12290

12391
#if HAS_HEATED_BED || HAS_HEATED_CHAMBER
124-
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_all(0, editable.int8); });
92+
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_all(editable.int8, 0); });
12593
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m);
12694
#else
12795
ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m);

β€ŽMarlin/src/module/temperature.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,6 @@ typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_
599599
#define HAS_FAN_LOGIC 1
600600
#endif
601601

602-
#if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT
603-
enum PreheatTarget : uint8_t {
604-
HOTEND = (1 << 0),
605-
BED = (1 << 1),
606-
CHAMBER = (1 << 2),
607-
ALL = 0xFF
608-
};
609-
#endif
610-
611602
class Temperature {
612603

613604
public:
@@ -1343,11 +1334,6 @@ class Temperature {
13431334
static void set_heating_message(const uint8_t, const bool=false) {}
13441335
#endif
13451336

1346-
#if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT
1347-
// Apply the "preheat" parameters for a material preset to the hotend (or laser), bed, chamber, or all of the above
1348-
static void lcd_preheat(const uint8_t m, const uint8_t targets, const uint8_t e=0);
1349-
#endif
1350-
13511337
private:
13521338

13531339
// Reading raw temperatures and converting to Celsius when ready

0 commit comments

Comments
Β (0)