From 367cea0d0dfdf71464faf1422f46417388139306 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 17 Mar 2025 22:35:20 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Chamber=20Preheat=20completion?= =?UTF-8?q?=20(#26864)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #21156 Co-authored-by: Scott Lahteine --- Marlin/src/gcode/lcd/M145.cpp | 5 +++ Marlin/src/gcode/temp/M141_M191.cpp | 9 ++++- Marlin/src/lcd/extui/ui_api.cpp | 3 ++ Marlin/src/lcd/extui/ui_api.h | 3 ++ Marlin/src/lcd/language/language_en.h | 3 ++ Marlin/src/lcd/marlinui.cpp | 8 ++--- Marlin/src/lcd/marlinui.h | 3 ++ Marlin/src/lcd/menu/menu_configuration.cpp | 3 ++ Marlin/src/lcd/menu/menu_temperature.cpp | 39 +++++++++++++--------- Marlin/src/module/settings.cpp | 10 ++++-- Marlin/src/module/temperature.h | 2 +- 11 files changed, 64 insertions(+), 24 deletions(-) diff --git a/Marlin/src/gcode/lcd/M145.cpp b/Marlin/src/gcode/lcd/M145.cpp index 3cc6130dfd..a0aa340d0d 100644 --- a/Marlin/src/gcode/lcd/M145.cpp +++ b/Marlin/src/gcode/lcd/M145.cpp @@ -37,6 +37,7 @@ * S * H * B + * C * F */ void GcodeSuite::M145() { @@ -53,6 +54,10 @@ void GcodeSuite::M145() { if (parser.seenval('B')) mat.bed_temp = constrain(parser.value_int(), BED_MINTEMP, BED_MAX_TARGET); #endif + #if HAS_HEATED_CHAMBER + if (parser.seenval('C')) + mat.chamber_temp = constrain(parser.value_int(), CHAMBER_MINTEMP, CHAMBER_MAX_TARGET); + #endif #if HAS_FAN if (parser.seenval('F')) mat.fan_speed = constrain(parser.value_int(), 0, 255); diff --git a/Marlin/src/gcode/temp/M141_M191.cpp b/Marlin/src/gcode/temp/M141_M191.cpp index 81a078318a..3364fbc22e 100644 --- a/Marlin/src/gcode/temp/M141_M191.cpp +++ b/Marlin/src/gcode/temp/M141_M191.cpp @@ -39,9 +39,16 @@ */ void GcodeSuite::M141() { if (DEBUGGING(DRYRUN)) return; + // Accept 'I' if temperature presets are defined + #if HAS_PREHEAT + if (parser.seenval('I')) { + const uint8_t index = parser.value_byte(); + thermalManager.setTargetChamber(ui.material_preset[_MIN(index, PREHEAT_COUNT - 1)].chamber_temp); + return; + } + #endif if (parser.seenval('S')) { thermalManager.setTargetChamber(parser.value_celsius()); - #if ENABLED(PRINTJOB_TIMER_AUTOSTART) /** * Stop the timer at the end of print. Hotend, bed target, and chamber diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index a53b5f5dba..5b6caf378a 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -811,6 +811,9 @@ namespace ExtUI { #if HAS_HEATED_BED uint16_t getMaterial_preset_B(const uint16_t index) { return ui.material_preset[index].bed_temp; } #endif + #if HAS_HEATED_CHAMBER + uint16_t getMaterial_preset_C(const uint16_t index) { return ui.material_preset[index].chamber_temp; } + #endif #endif feedRate_t getFeedrate_mm_s() { return feedrate_mm_s; } diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 2676d72aea..dfe393e39a 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -214,6 +214,9 @@ namespace ExtUI { #if HAS_HEATED_BED uint16_t getMaterial_preset_B(const uint16_t); #endif + #if HAS_HEATED_CHAMBER + uint16_t getMaterial_preset_C(const uint16_t); + #endif #endif // IDEX Machine Mode diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index b033dc3c74..6076c6fb30 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -155,6 +155,7 @@ namespace LanguageNarrow_en { LSTR MSG_PREHEAT_M_END_E = _UxGT("Preheat $ End ~"); LSTR MSG_PREHEAT_M_ALL = _UxGT("Preheat $ All"); LSTR MSG_PREHEAT_M_BEDONLY = _UxGT("Preheat $ Bed"); + LSTR MSG_PREHEAT_M_CHAMBER = _UxGT("Preheat $ Chmb"); LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preheat $ Conf"); LSTR MSG_PREHEAT_HOTEND = _UxGT("Preheat Hotend"); @@ -1109,6 +1110,8 @@ namespace LanguageWide_en { LSTR MSG_HOMING_FEEDRATE_Y = _UxGT("Y Homing Feedrate"); LSTR MSG_HOMING_FEEDRATE_Z = _UxGT("Z Homing Feedrate"); LSTR MSG_EEPROM_INITIALIZED = _UxGT("Default Settings Restored"); + LSTR MSG_PREHEAT_M_CHAMBER = _UxGT("Preheat $ Chamber"); + LSTR MSG_PREHEAT_M_SETTINGS = _UxGT("Preheat $ Config"); #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index e8946edb28..bd974d8d0a 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -150,10 +150,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; void MarlinUI::apply_preheat(const uint8_t m, const uint8_t pmask, const uint8_t e/*=active_extruder*/) { const preheat_t &pre = material_preset[m]; - TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); - TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp)); - //TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetChamber(pre.chamber_temp)); - TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); + TERN_(HAS_HOTEND, if (TEST(pmask, PT_HOTEND)) thermalManager.setTargetHotend(pre.hotend_temp, e)); + TERN_(HAS_HEATED_BED, if (TEST(pmask, PT_BED)) thermalManager.setTargetBed(pre.bed_temp)); + TERN_(HAS_HEATED_CHAMBER, if (TEST(pmask, PT_CHAMBER)) thermalManager.setTargetChamber(pre.chamber_temp)); + TERN_(HAS_FAN, if (TEST(pmask, PT_FAN)) thermalManager.set_fan_speed(0, pre.fan_speed)); } #endif diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index a47096a3bf..26b559e6bc 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -118,6 +118,9 @@ typedef bool (*statusResetFunc_t)(); #if HAS_HEATED_BED celsius_t bed_temp; #endif + #if HAS_HEATED_CHAMBER + celsius_t chamber_temp; + #endif #if HAS_FAN uint16_t fan_speed; #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 65a2f222ce..c581bab4e3 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -451,6 +451,9 @@ void menu_advanced_settings(); #if HAS_HEATED_BED EDIT_ITEM(int3, MSG_BED, &ui.material_preset[m].bed_temp, BED_MINTEMP, BED_MAX_TARGET); #endif + #if HAS_HEATED_CHAMBER + EDIT_ITEM(int3, MSG_CHAMBER, &ui.material_preset[m].chamber_temp, CHAMBER_MINTEMP, CHAMBER_MAX_TARGET); + #endif #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); #endif diff --git a/Marlin/src/lcd/menu/menu_temperature.cpp b/Marlin/src/lcd/menu/menu_temperature.cpp index e8a7b25dcb..1a43b121ce 100644 --- a/Marlin/src/lcd/menu/menu_temperature.cpp +++ b/Marlin/src/lcd/menu/menu_temperature.cpp @@ -45,15 +45,17 @@ #if HAS_PREHEAT - void Temperature::lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb) { - UNUSED(e); UNUSED(indh); UNUSED(indb); + 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); #if HAS_HOTEND - if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) - setTargetHotend(_MIN(thermalManager.hotend_max_target(e), ui.material_preset[indh].hotend_temp), e); + if (indh >= 0 && ui.material_preset[indh].hotend_temp > 0) setTargetHotend(ui.material_preset[indh].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); #endif + #if HAS_HEATED_CHAMBER + if (indc >= 0 && ui.material_preset[indc].chamber_temp > 0) setTargetChamber(ui.material_preset[indc].chamber_temp); + #endif #if HAS_FAN if (indh >= 0) { const uint8_t fan_index = active_extruder < (FAN_COUNT) ? active_extruder : 0; @@ -68,30 +70,33 @@ } #if HAS_TEMP_HOTEND - inline void _preheat_end(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } - void do_preheat_end_m() { _preheat_end(editable.int8, 0); } + inline void _preheat_end(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(e, m); } + 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); } #endif + #if HAS_HEATED_CHAMBER + inline void _preheat_chamber(const uint8_t m) { thermalManager.lcd_preheat(0, -1, -1, m); } + #endif #if HAS_COOLER - inline void _precool_laser(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, -1); } - void do_precool_laser_m() { _precool_laser(editable.int8, thermalManager.temp_cooler.target); } + inline void _precool_laser(const uint8_t e, const uint8_t m) { thermalManager.lcd_preheat(e, m); } + void do_precool_laser_m() { _precool_laser(thermalManager.temp_cooler.target, editable.int8); } #endif - #if HAS_TEMP_HOTEND && HAS_HEATED_BED - inline void _preheat_both(const uint8_t m, const uint8_t e) { thermalManager.lcd_preheat(e, m, m); } + #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); } // Indexed "Preheat ABC" and "Heat Bed" items #define PREHEAT_ITEMS(M,E) do{ \ - ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_both(M, MenuItemBase::itemIndex); }); \ - ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(M, MenuItemBase::itemIndex); }); \ + ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_all(MenuItemBase::itemIndex, M); }); \ + ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_END_E, []{ _preheat_end(MenuItemBase::itemIndex, M); }); \ }while(0) #elif HAS_MULTI_HOTEND // No heated bed, so just indexed "Preheat ABC" items - #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(M, MenuItemBase::itemIndex); }) + #define PREHEAT_ITEMS(M,E) ACTION_ITEM_N_f(E, ui.get_preheat_label(M), MSG_PREHEAT_M_H, []{ _preheat_end(MenuItemBase::itemIndex, M); }) #endif @@ -107,8 +112,8 @@ #if HOTENDS == 1 - #if HAS_HEATED_BED - ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_both(editable.int8, 0); }); + #if HAS_HEATED_BED || HAS_HEATED_CHAMBER + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, []{ _preheat_all(0, editable.int8); }); ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_END, do_preheat_end_m); #else ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M, do_preheat_end_m); @@ -129,6 +134,10 @@ ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_BEDONLY, []{ _preheat_bed(editable.int8); }); #endif + #if HAS_HEATED_CHAMBER + ACTION_ITEM_f(ui.get_preheat_label(m), MSG_PREHEAT_M_CHAMBER, []{ _preheat_chamber(editable.int8); }); + #endif + END_MENU(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 485d01066a..8c33e73f00 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3564,13 +3564,17 @@ void MarlinSettings::reset() { #if HAS_HEATED_BED constexpr uint16_t bpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_BED) }; #endif + #if HAS_HEATED_CHAMBER + constexpr uint16_t cpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, TEMP_CHAMBER) }; + #endif #if HAS_FAN constexpr uint8_t fpre[] = { REPEAT2_S(1, INCREMENT(PREHEAT_COUNT), _PITEM, FAN_SPEED) }; #endif for (uint8_t i = 0; i < PREHEAT_COUNT; ++i) { - TERN_(HAS_HOTEND, ui.material_preset[i].hotend_temp = hpre[i]); - TERN_(HAS_HEATED_BED, ui.material_preset[i].bed_temp = bpre[i]); - TERN_(HAS_FAN, ui.material_preset[i].fan_speed = fpre[i]); + TERN_(HAS_HOTEND, ui.material_preset[i].hotend_temp = hpre[i]); + TERN_(HAS_HEATED_BED, ui.material_preset[i].bed_temp = bpre[i]); + TERN_(HAS_HEATED_CHAMBER, ui.material_preset[i].chamber_temp = cpre[i]); + TERN_(HAS_FAN, ui.material_preset[i].fan_speed = fpre[i]); } #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 27e28f07a8..cc25cfad14 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -1335,7 +1335,7 @@ class Temperature { #endif #if HAS_MARLINUI_MENU && HAS_TEMPERATURE && HAS_PREHEAT - static void lcd_preheat(const uint8_t e, const int8_t indh, const int8_t indb); + static void lcd_preheat(const uint8_t e, const int8_t indh=-1, const int8_t indb=-1, const int8_t indc=-1); #endif private: