From 4ad6fa59df95d175c0acb49c33c2cf83fee5d449 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 18 Mar 2025 18:22:22 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20More=20exte?= =?UTF-8?q?nsible=20Temperature::lcd=5Fpreheat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_temperature.cpp | 32 +++++++++++++++--------- Marlin/src/module/temperature.h | 12 ++++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index 1a43b121ce..0a376494e5 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -45,47 +45,55 @@ #if HAS_PREHEAT - void Temperature::lcd_preheat(const uint8_t e, const int8_t indh/*=-1*/, const int8_t indb/*=-1*/, const int8_t indc/*=-1*/) { - UNUSED(e); UNUSED(indh); UNUSED(indb); UNUSED(indc); + /** + * @fn Temperature::lcd_preheat + * @brief Apply the "preheat" parameters for a material preset to the + * hotend (or laser), bed, chamber, or all of the above. + * @param m Material index + * @param targets Bit mask of targets to "preheat" (or turn off) + * @param e Extruder index (if needed) + */ + void Temperature::lcd_preheat(const uint8_t m, const uint8_t targets, const uint8_t e/*=0*/) { + UNUSED(e); #if HAS_HOTEND - if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) setTargetHotend(ui.material_preset[indh].hotend_temp, e); + if (targets & PreheatTarget::HOTEND) setTargetHotend(ui.material_preset[m].hotend_temp, e); #endif #if HAS_HEATED_BED - if (indb >= 0 && ui.material_preset[indb].bed_temp > 0) setTargetBed(ui.material_preset[indb].bed_temp); + if (targets & PreheatTarget::BED) setTargetBed(ui.material_preset[m].bed_temp); #endif #if HAS_HEATED_CHAMBER - if (indc >= 0 && ui.material_preset[indc].chamber_temp > 0) setTargetChamber(ui.material_preset[indc].chamber_temp); + if (targets & PreheatTarget::CHAMBER) setTargetChamber(ui.material_preset[m].chamber_temp); #endif #if HAS_FAN - if (indh >= 0) { + if (targets & PreheatTarget::HOTEND) { const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; if (true #if REDUNDANT_PART_COOLING_FAN && fan_index != REDUNDANT_PART_COOLING_FAN #endif - ) set_fan_speed(fan_index, ui.material_preset[indh].fan_speed); + ) set_fan_speed(fan_index, ui.material_preset[m].fan_speed); } #endif ui.return_to_status(); } #if HAS_TEMP_HOTEND - inline void _preheat_end(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(e, m); } + inline void _preheat_end(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::HOTEND, e); } void do_preheat_end_m() { _preheat_end(0, editable.int8); } #endif #if HAS_HEATED_BED - inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(0, -1, m); } + inline void _preheat_bed(const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::BED); } #endif #if HAS_HEATED_CHAMBER - inline void _preheat_chamber(const uint8_t m) { thermalManager.lcd_preheat(0, -1, -1, m); } + inline void _preheat_chamber(const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::CHAMBER); } #endif #if HAS_COOLER - inline void _precool_laser(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(e, m); } + inline void _precool_laser(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::HOTEND, e); } void do_precool_laser_m() { _precool_laser(thermalManager.temp_cooler.target, editable.int8); } #endif #if HAS_TEMP_HOTEND && (HAS_HEATED_BED || HAS_HEATED_CHAMBER) - inline void _preheat_all(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(e, m, m, m); } + inline void _preheat_all(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(m, PreheatTarget::ALL, e); } // Indexed "Preheat ABC" and "Heat Bed" items #define PREHEAT_ITEMS(M,E) do{ \ diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index cc25cfad14..5f7ea8daf4 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -599,6 +599,15 @@ typedef struct { raw_adc_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ #define HAS_FAN_LOGIC 1 #endif +#if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT + enum PreheatTarget : uint8_t { + HOTEND = (1 << 0), + BED = (1 << 1), + CHAMBER = (1 << 2), + ALL = 0xFF + }; +#endif + class Temperature { public: @@ -1335,7 +1344,8 @@ class Temperature { #endif #if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT - static void lcd_preheat(const uint8_t e, const int8_t indh=-1, const int8_t indb=-1, const int8_t indc=-1); + // Apply the "preheat" parameters for a material preset to the hotend (or laser), bed, chamber, or all of the above + static void lcd_preheat(const uint8_t m, const uint8_t targets, const uint8_t e=0); #endif private: