From 6f19070a1236ce1729385101808def391536f2a5 Mon Sep 17 00:00:00 2001 From: Katelyn Schiesser Date: Tue, 22 Nov 2022 21:39:12 -0800 Subject: [PATCH 1/6] Implement an LCD Menu for editing HOTEND_IDLE_TIMEOUT settings. --- Marlin/src/feature/hotend_idle.cpp | 18 ++++++---- Marlin/src/feature/hotend_idle.h | 2 +- Marlin/src/lcd/language/language_de.h | 2 +- Marlin/src/lcd/language/language_en.h | 4 ++- Marlin/src/lcd/language/language_it.h | 2 +- Marlin/src/lcd/language/language_sk.h | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 24 ++++++++++++++ Marlin/src/lcd/menu/menu_main.cpp | 4 +++ Marlin/src/module/settings.cpp | 38 ++++++++++++++++++++-- 9 files changed, 82 insertions(+), 14 deletions(-) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 4b137f42da7b..40195f4298e4 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -40,17 +40,21 @@ extern HotendIdleProtection hotend_idle; millis_t HotendIdleProtection::next_protect_ms = 0; +uint16_t HotendIdleProtection::timeout = HOTEND_IDLE_TIMEOUT_SEC, + HotendIdleProtection::trigger = HOTEND_IDLE_MIN_TRIGGER, + HotendIdleProtection::nozzle_target = HOTEND_IDLE_NOZZLE_TARGET, + HotendIdleProtection::bed_target = HOTEND_IDLE_BED_TARGET; void HotendIdleProtection::check_hotends(const millis_t &ms) { bool do_prot = false; HOTEND_LOOP() { const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); - if (thermalManager.degHotend(e) >= (HOTEND_IDLE_MIN_TRIGGER) && !busy) { + if (thermalManager.degHotend(e) >= (trigger) && !busy) { do_prot = true; break; } } if (bool(next_protect_ms) != do_prot) - next_protect_ms = do_prot ? ms + hp_interval : 0; + next_protect_ms = do_prot ? ms + (timeout * 1000) : 0; } void HotendIdleProtection::check_e_motion(const millis_t &ms) { @@ -58,7 +62,7 @@ void HotendIdleProtection::check_e_motion(const millis_t &ms) { if (old_e_position != current_position.e) { old_e_position = current_position.e; // Track filament motion if (next_protect_ms) // If some heater is on then... - next_protect_ms = ms + hp_interval; // ...delay the timeout till later + next_protect_ms = ms + (timeout * 1000); // ...delay the timeout till later } } @@ -79,12 +83,12 @@ void HotendIdleProtection::timed_out() { SERIAL_ECHOLNPGM("Hotend Idle Timeout"); LCD_MESSAGE(MSG_HOTEND_IDLE_TIMEOUT); HOTEND_LOOP() { - if ((HOTEND_IDLE_NOZZLE_TARGET) < thermalManager.degTargetHotend(e)) - thermalManager.setTargetHotend(HOTEND_IDLE_NOZZLE_TARGET, e); + if (nozzle_target < thermalManager.degTargetHotend(e)) + thermalManager.setTargetHotend(nozzle_target, e); } #if HAS_HEATED_BED - if ((HOTEND_IDLE_BED_TARGET) < thermalManager.degTargetBed()) - thermalManager.setTargetBed(HOTEND_IDLE_BED_TARGET); + if (bed_target < thermalManager.degTargetBed()) + thermalManager.setTargetBed(bed_target); #endif } diff --git a/Marlin/src/feature/hotend_idle.h b/Marlin/src/feature/hotend_idle.h index 40f557d5ed4c..4390e68b608f 100644 --- a/Marlin/src/feature/hotend_idle.h +++ b/Marlin/src/feature/hotend_idle.h @@ -26,8 +26,8 @@ class HotendIdleProtection { public: static void check(); + static uint16_t timeout, trigger, nozzle_target, bed_target; private: - static constexpr millis_t hp_interval = SEC_TO_MS(HOTEND_IDLE_TIMEOUT_SEC); static millis_t next_protect_ms; static void check_hotends(const millis_t &ms); static void check_e_motion(const millis_t &ms); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 9939ea3f4429..bacb313247e8 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -344,7 +344,7 @@ namespace Language_de { LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune fehlge.!"); LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("ungültiger Extruder."); LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperatur zu hoch."); - LSTR MSG_TIMEOUT = _UxGT("Timeout."); + LSTR MSG_TIMEOUT = _UxGT("Timeout"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune fehlge.! Ungültiger Extruder"); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune fehlge.! Temperatur zu hoch."); LSTR MSG_PID_TIMEOUT = _UxGT("Autotune fehlge.! Timeout."); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c888207ed123..6ffa3ac70835 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -359,7 +359,7 @@ namespace Language_en { LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("PID Autotune failed!"); LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Bad extruder."); LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temperature too high."); - LSTR MSG_TIMEOUT = _UxGT("Timeout."); + LSTR MSG_TIMEOUT = _UxGT("Timeout"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Autotune failed! Bad extruder."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Autotune failed! Temperature too high."); LSTR MSG_PID_TIMEOUT = _UxGT("Autotune failed! Timeout."); @@ -643,6 +643,8 @@ namespace Language_en { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); + LSTR MSG_HOTEND_IDLE_NOZZLE_TARGET = _UxGT("Nozzle Target"); + LSTR MSG_HOTEND_IDLE_BED_TARGET = _UxGT("Bed Target"); LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fan speed fault"); LSTR MSG_CASE_LIGHT = _UxGT("Case Light"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 1fcf07dbc79d..076739e32c0d 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -356,7 +356,7 @@ namespace Language_it { LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("Calibr.PID fallito!"); LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Estrusore invalido."); LSTR MSG_TEMP_TOO_HIGH = _UxGT("Temp.troppo alta."); - LSTR MSG_TIMEOUT = _UxGT("Tempo scaduto."); + LSTR MSG_TIMEOUT = _UxGT("Tempo scaduto"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Calibrazione fallita! Estrusore errato."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Calibrazione fallita! Temperatura troppo alta."); LSTR MSG_PID_TIMEOUT = _UxGT("Calibrazione fallita! Tempo scaduto."); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index bb332f4b1ff2..da43399372e5 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -356,7 +356,7 @@ namespace Language_sk { LSTR MSG_PID_AUTOTUNE_FAILED = _UxGT("Kal. PID zlyhala!"); LSTR MSG_BAD_EXTRUDER_NUM = _UxGT("Zlý extrudér"); LSTR MSG_TEMP_TOO_HIGH = _UxGT("Príliš vysoká tepl."); - LSTR MSG_TIMEOUT = _UxGT("Čas vypršal."); + LSTR MSG_TIMEOUT = _UxGT("Čas vypršal"); LSTR MSG_PID_BAD_EXTRUDER_NUM = _UxGT("Auto-kal. zlyhala! Zlý extrúder."); LSTR MSG_PID_TEMP_TOO_HIGH = _UxGT("Auto-kal. zlyhala! Príliš vysoká tepl."); LSTR MSG_PID_TIMEOUT = _UxGT("Auto-kal. zlyhala! Čas vypršal."); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 1ac12656dd36..cf58ee935625 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -55,6 +55,10 @@ #include "../../libs/buzzer.h" #endif +#if ENABLED(HOTEND_IDLE_TIMEOUT) + #include "../../feature/hotend_idle.h" +#endif + #include "../../core/debug_out.h" #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST) @@ -192,6 +196,22 @@ void menu_advanced_settings(); } #endif +#if ENABLED(HOTEND_IDLE_TIMEOUT) + + void menu_hotend_idle(){ + START_MENU(); + BACK_ITEM(MSG_BACK); + + EDIT_ITEM(uint16_3, MSG_TIMEOUT, &hotend_idle.timeout, 0, 999); + EDIT_ITEM(uint16_3, MSG_TEMPERATURE, &hotend_idle.trigger, 0, 999); + EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &hotend_idle.nozzle_target, 0, 999); + EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_BED_TARGET, &hotend_idle.bed_target, 0, 999); + + END_MENU(); + } + +#endif + #if ENABLED(DUAL_X_CARRIAGE) void menu_idex() { @@ -528,6 +548,10 @@ void menu_configuration() { #endif } + #if ENABLED(HOTEND_IDLE_TIMEOUT) + SUBMENU(MSG_HOTEND_IDLE_TIMEOUT, menu_hotend_idle); + #endif + // // Set single nozzle filament retract and prime length // diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 8c8c4758b73d..7989bd1f9195 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -100,6 +100,10 @@ void menu_configuration(); void menu_preheat_only(); #endif +#if ENABLED(HOTEND_IDLE_TIMEOUT) + void menu_hotend_idle(); +#endif + #if HAS_MULTI_LANGUAGE void menu_language(); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index a090b140adee..5b547d3ff71a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V87" +#define EEPROM_VERSION "V88" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -171,6 +171,10 @@ #include "../lcd/extui/dgus/DGUSDisplayDef.h" #endif +#if ENABLED(HOTEND_IDLE_TIMEOUT) + #include "../feature/hotend_idle.h" +#endif + #pragma pack(push, 1) // No padding between variables #if HAS_ETHERNET @@ -589,6 +593,16 @@ typedef struct SettingsDataStruct { shaping_y_zeta; // M593 Y D #endif + // + // HOTEND_IDLE_TIMEOUT Settings + // + #if ENABLED(HOTEND_IDLE_TIMEOUT) + uint16_t hotend_idle_timeout, + hotend_idle_trigger, + hotend_idle_nozzle_target, + hotend_idle_bed_target; + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -1616,7 +1630,7 @@ void MarlinSettings::postprocess() { // // Input Shaping - /// + // #if ENABLED(INPUT_SHAPING) #if HAS_SHAPING_X EEPROM_WRITE(stepper.get_shaping_frequency(X_AXIS)); @@ -1628,6 +1642,16 @@ void MarlinSettings::postprocess() { #endif #endif + // + // HOTEND_IDLE_TIMEOUT + // + #if ENABLED(HOTEND_IDLE_TIMEOUT) + EEPROM_WRITE(hotend_idle.timeout); + EEPROM_WRITE(hotend_idle.trigger); + EEPROM_WRITE(hotend_idle.nozzle_target); + EEPROM_WRITE(hotend_idle.bed_target); + #endif + // // Report final CRC and Data Size // @@ -2620,6 +2644,16 @@ void MarlinSettings::postprocess() { } #endif + // + // HOTEND_IDLE_TIMEOUT + // + #if ENABLED(HOTEND_IDLE_TIMEOUT) + EEPROM_READ(hotend_idle.timeout); + EEPROM_READ(hotend_idle.trigger); + EEPROM_READ(hotend_idle.nozzle_target); + EEPROM_READ(hotend_idle.bed_target); + #endif + // // Validate Final Size and CRC // From 3d5d4bc1f9e9d8586216312f54c0b230009b2556 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 7 Jun 2023 23:45:00 -0500 Subject: [PATCH 2/6] Use a struct --- Marlin/src/feature/hotend_idle.cpp | 19 ++++++++----------- Marlin/src/feature/hotend_idle.h | 18 ++++++++++++++++-- Marlin/src/lcd/menu/menu_configuration.cpp | 8 ++++---- Marlin/src/module/settings.cpp | 22 +++++++++------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index 40195f4298e4..a7777c40b49e 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -40,21 +40,18 @@ extern HotendIdleProtection hotend_idle; millis_t HotendIdleProtection::next_protect_ms = 0; -uint16_t HotendIdleProtection::timeout = HOTEND_IDLE_TIMEOUT_SEC, - HotendIdleProtection::trigger = HOTEND_IDLE_MIN_TRIGGER, - HotendIdleProtection::nozzle_target = HOTEND_IDLE_NOZZLE_TARGET, - HotendIdleProtection::bed_target = HOTEND_IDLE_BED_TARGET; +hotend_idle_settings_t HotendIdleProtection::cfg; // Initialized by settings.load() void HotendIdleProtection::check_hotends(const millis_t &ms) { bool do_prot = false; HOTEND_LOOP() { const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); - if (thermalManager.degHotend(e) >= (trigger) && !busy) { + if (thermalManager.degHotend(e) >= cfg.trigger && !busy) { do_prot = true; break; } } if (bool(next_protect_ms) != do_prot) - next_protect_ms = do_prot ? ms + (timeout * 1000) : 0; + next_protect_ms = do_prot ? ms + cfg.timeout * 1000 : 0; } void HotendIdleProtection::check_e_motion(const millis_t &ms) { @@ -62,7 +59,7 @@ void HotendIdleProtection::check_e_motion(const millis_t &ms) { if (old_e_position != current_position.e) { old_e_position = current_position.e; // Track filament motion if (next_protect_ms) // If some heater is on then... - next_protect_ms = ms + (timeout * 1000); // ...delay the timeout till later + next_protect_ms = ms + cfg.timeout * 1000; // ...delay the timeout till later } } @@ -83,12 +80,12 @@ void HotendIdleProtection::timed_out() { SERIAL_ECHOLNPGM("Hotend Idle Timeout"); LCD_MESSAGE(MSG_HOTEND_IDLE_TIMEOUT); HOTEND_LOOP() { - if (nozzle_target < thermalManager.degTargetHotend(e)) - thermalManager.setTargetHotend(nozzle_target, e); + if (cfg.nozzle_target < thermalManager.degTargetHotend(e)) + thermalManager.setTargetHotend(cfg.nozzle_target, e); } #if HAS_HEATED_BED - if (bed_target < thermalManager.degTargetBed()) - thermalManager.setTargetBed(bed_target); + if (cfg.bed_target < thermalManager.degTargetBed()) + thermalManager.setTargetBed(cfg.bed_target); #endif } diff --git a/Marlin/src/feature/hotend_idle.h b/Marlin/src/feature/hotend_idle.h index 4390e68b608f..1bffe7e17c42 100644 --- a/Marlin/src/feature/hotend_idle.h +++ b/Marlin/src/feature/hotend_idle.h @@ -21,12 +21,26 @@ */ #pragma once -#include "../core/millis_t.h" +#include "../inc/MarlinConfig.h" + +typedef struct { + uint16_t timeout; + uint16_t trigger, nozzle_target; + #if HAS_HEATED_BED + uint16_t bed_target; + #endif + void set_defaults() { + timeout = HOTEND_IDLE_TIMEOUT_SEC; + trigger = HOTEND_IDLE_MIN_TRIGGER; + nozzle_target = HOTEND_IDLE_NOZZLE_TARGET; + bed_target = HOTEND_IDLE_BED_TARGET; + } +} hotend_idle_settings_t; class HotendIdleProtection { public: static void check(); - static uint16_t timeout, trigger, nozzle_target, bed_target; + static hotend_idle_settings_t cfg; private: static millis_t next_protect_ms; static void check_hotends(const millis_t &ms); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index a285ffce5559..ec76c58f9908 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -287,10 +287,10 @@ void menu_advanced_settings(); START_MENU(); BACK_ITEM(MSG_BACK); - EDIT_ITEM(uint16_3, MSG_TIMEOUT, &hotend_idle.timeout, 0, 999); - EDIT_ITEM(uint16_3, MSG_TEMPERATURE, &hotend_idle.trigger, 0, 999); - EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &hotend_idle.nozzle_target, 0, 999); - EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_BED_TARGET, &hotend_idle.bed_target, 0, 999); + EDIT_ITEM(uint16_3, MSG_TIMEOUT, &hotend_idle.cfg.timeout, 0, 999); + EDIT_ITEM(uint16_3, MSG_TEMPERATURE, &hotend_idle.cfg.trigger, 0, 999); + EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &hotend_idle.cfg.nozzle_target, 0, 999); + EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_BED_TARGET, &hotend_idle.cfg.bed_target, 0, 999); END_MENU(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 58319b5deba9..d0757c3c84a3 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -628,13 +628,10 @@ typedef struct SettingsDataStruct { #endif // - // HOTEND_IDLE_TIMEOUT Settings + // HOTEND_IDLE_TIMEOUT // #if ENABLED(HOTEND_IDLE_TIMEOUT) - uint16_t hotend_idle_timeout, - hotend_idle_trigger, - hotend_idle_nozzle_target, - hotend_idle_bed_target; + hotend_idle_settings_t hotend_idle_config; #endif } SettingsData; @@ -1732,10 +1729,7 @@ void MarlinSettings::postprocess() { // HOTEND_IDLE_TIMEOUT // #if ENABLED(HOTEND_IDLE_TIMEOUT) - EEPROM_WRITE(hotend_idle.timeout); - EEPROM_WRITE(hotend_idle.trigger); - EEPROM_WRITE(hotend_idle.nozzle_target); - EEPROM_WRITE(hotend_idle.bed_target); + EEPROM_WRITE(hotend_idle.cfg); #endif // @@ -2809,10 +2803,7 @@ void MarlinSettings::postprocess() { // HOTEND_IDLE_TIMEOUT // #if ENABLED(HOTEND_IDLE_TIMEOUT) - EEPROM_READ(hotend_idle.timeout); - EEPROM_READ(hotend_idle.trigger); - EEPROM_READ(hotend_idle.nozzle_target); - EEPROM_READ(hotend_idle.bed_target); + EEPROM_READ(hotend_idle.cfg); #endif // @@ -3624,6 +3615,11 @@ void MarlinSettings::reset() { #endif #endif + // + // Hotend Idle Timeout + // + TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.cfg.set_defaults()); + postprocess(); #if ANY(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) From d37f91ab5f529573c757ec3332ddcd929fc2688c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Jun 2023 02:32:29 -0500 Subject: [PATCH 3/6] Misc. fixes --- Marlin/src/feature/hotend_idle.cpp | 18 +++++++++++------- Marlin/src/feature/hotend_idle.h | 5 ++--- Marlin/src/lcd/language/language_en.h | 5 +++-- Marlin/src/lcd/menu/menu_configuration.cpp | 12 +++++++----- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Marlin/src/feature/hotend_idle.cpp b/Marlin/src/feature/hotend_idle.cpp index a7777c40b49e..f64fe7e3cf67 100644 --- a/Marlin/src/feature/hotend_idle.cpp +++ b/Marlin/src/feature/hotend_idle.cpp @@ -37,21 +37,25 @@ #include "../module/planner.h" #include "../lcd/marlinui.h" -extern HotendIdleProtection hotend_idle; +HotendIdleProtection hotend_idle; millis_t HotendIdleProtection::next_protect_ms = 0; hotend_idle_settings_t HotendIdleProtection::cfg; // Initialized by settings.load() void HotendIdleProtection::check_hotends(const millis_t &ms) { + const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); bool do_prot = false; - HOTEND_LOOP() { - const bool busy = (TERN0(HAS_RESUME_CONTINUE, wait_for_user) || planner.has_blocks_queued()); - if (thermalManager.degHotend(e) >= cfg.trigger && !busy) { - do_prot = true; break; + if (!busy && cfg.timeout != 0) { + HOTEND_LOOP() { + if (thermalManager.degHotend(e) >= cfg.trigger) { + do_prot = true; break; + } } } - if (bool(next_protect_ms) != do_prot) - next_protect_ms = do_prot ? ms + cfg.timeout * 1000 : 0; + if (!do_prot) + next_protect_ms = 0; // No hotends are hot so cancel timeout + else if (!next_protect_ms) // Timeout is possible? + next_protect_ms = ms + cfg.timeout * 1000; // Start timeout if not already set } void HotendIdleProtection::check_e_motion(const millis_t &ms) { diff --git a/Marlin/src/feature/hotend_idle.h b/Marlin/src/feature/hotend_idle.h index 1bffe7e17c42..a4229153c966 100644 --- a/Marlin/src/feature/hotend_idle.h +++ b/Marlin/src/feature/hotend_idle.h @@ -24,10 +24,9 @@ #include "../inc/MarlinConfig.h" typedef struct { - uint16_t timeout; - uint16_t trigger, nozzle_target; + int16_t timeout, trigger, nozzle_target; #if HAS_HEATED_BED - uint16_t bed_target; + int16_t bed_target; #endif void set_defaults() { timeout = HOTEND_IDLE_TIMEOUT_SEC; diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index bf721c75caa5..7593ec02ca52 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -670,8 +670,9 @@ namespace Language_en { LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF"); LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON"); LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout"); - LSTR MSG_HOTEND_IDLE_NOZZLE_TARGET = _UxGT("Nozzle Target"); - LSTR MSG_HOTEND_IDLE_BED_TARGET = _UxGT("Bed Target"); + LSTR MSG_HOTEND_IDLE_DISABLE = _UxGT("Disable Timeout"); + LSTR MSG_HOTEND_IDLE_NOZZLE_TARGET = _UxGT("Nozzle Idle Temp"); + LSTR MSG_HOTEND_IDLE_BED_TARGET = _UxGT("Bed Idle Temp"); LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fan speed fault"); LSTR MSG_CASE_LIGHT = _UxGT("Case Light"); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index ec76c58f9908..42caa049d8f4 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -283,14 +283,16 @@ void menu_advanced_settings(); #if ENABLED(HOTEND_IDLE_TIMEOUT) - void menu_hotend_idle(){ + void menu_hotend_idle() { + hotend_idle_settings_t &c = hotend_idle.cfg; START_MENU(); BACK_ITEM(MSG_BACK); - EDIT_ITEM(uint16_3, MSG_TIMEOUT, &hotend_idle.cfg.timeout, 0, 999); - EDIT_ITEM(uint16_3, MSG_TEMPERATURE, &hotend_idle.cfg.trigger, 0, 999); - EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &hotend_idle.cfg.nozzle_target, 0, 999); - EDIT_ITEM(uint16_3, MSG_HOTEND_IDLE_BED_TARGET, &hotend_idle.cfg.bed_target, 0, 999); + if (c.timeout) GCODES_ITEM(MSG_HOTEND_IDLE_DISABLE, F("M87")); + EDIT_ITEM(int3, MSG_TIMEOUT, &c.timeout, 0, 999); + EDIT_ITEM(int3, MSG_TEMPERATURE, &c.trigger, 0, HEATER_0_MAXTEMP); + EDIT_ITEM(int3, MSG_HOTEND_IDLE_NOZZLE_TARGET, &c.nozzle_target, 0, HEATER_0_MAXTEMP); + EDIT_ITEM(int3, MSG_HOTEND_IDLE_BED_TARGET, &c.bed_target, 0, BED_MAXTEMP); END_MENU(); } From faece2fda1829f30f56b85a2e4e8fede41b8db5a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Jun 2023 02:31:53 -0500 Subject: [PATCH 4/6] Add G-codes M86, M87 --- Marlin/src/gcode/gcode.cpp | 7 +++ Marlin/src/gcode/gcode.h | 7 +++ Marlin/src/gcode/temp/M86-M87.cpp | 79 +++++++++++++++++++++++++++++++ Marlin/src/module/settings.cpp | 7 ++- ini/features.ini | 2 +- 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 Marlin/src/gcode/temp/M86-M87.cpp diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 01b48a4af92b..be87ba68493f 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -659,8 +659,15 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 82: M82(); break; // M82: Set E axis normal mode (same as other axes) case 83: M83(); break; // M83: Set E axis relative mode #endif + case 18: case 84: M18_M84(); break; // M18/M84: Disable Steppers / Set Timeout case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout + + #if ENABLED(HOTEND_IDLE_TIMEOUT) + case 86: M86(); break; // M86: Set Hotend Idle Timeout + case 87: M87(); break; // M87: Cancel Hotend Idle Timeout + #endif + case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes case 114: M114(); break; // M114: Report current position case 115: M115(); break; // M115: Report capabilities diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 73729491adab..17c84c8dd6a3 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -711,6 +711,13 @@ class GcodeSuite { #endif static void M85(); + + #if ENABLED(HOTEND_IDLE_TIMEOUT) + static void M86(); + static void M86_report(const bool forReplay=true); + static void M87(); + #endif + static void M92(); static void M92_report(const bool forReplay=true, const int8_t e=-1); diff --git a/Marlin/src/gcode/temp/M86-M87.cpp b/Marlin/src/gcode/temp/M86-M87.cpp new file mode 100644 index 000000000000..7fb446196123 --- /dev/null +++ b/Marlin/src/gcode/temp/M86-M87.cpp @@ -0,0 +1,79 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * gcode/temp/M86-M87.cpp + * + * Hotend Idle Timeout + */ + +#include "../../inc/MarlinConfigPre.h" + +#if ENABLED(HOTEND_IDLE_TIMEOUT) + +#include "../gcode.h" +#include "../../feature/hotend_idle.h" + +void GcodeSuite::M86_report(const bool forReplay/*=true*/) { + hotend_idle_settings_t &c = hotend_idle.cfg; + report_heading(forReplay, F("Hotend Idle Timeout")); + SERIAL_ECHOLNPGM(" M86" + #if HAS_HEATED_BED + " B", c.bed_target, + #endif + " E", c.nozzle_target, + " S", c.timeout, + " T", c.trigger + ); +} + +/** + * M86: Set / Report Hotend Idle Timeout + * + * Parameters + * S : Idle timeout. Set to 0 to disable. + * E : Extruder idle temperature to set on timeout + * B : Bed idle temperature to set on timeout + * T : Minimum extruder temperature to consider for timeout (> idle temperature) + */ +void GcodeSuite::M86() { + if (!parser.seen_any()) return M86_report(); + hotend_idle_settings_t &c = hotend_idle.cfg; + if (parser.seenval('S')) c.timeout = parser.value_ushort(); + if (parser.seenval('T')) c.trigger = parser.value_celsius(); + if (parser.seenval('E')) c.nozzle_target = parser.value_celsius(); + #if HAS_HEATED_BED + if (parser.seenval('B')) c.bed_target = parser.value_celsius(); + #endif + const celsius_t min_trigger = c.nozzle_target + TEMP_HYSTERESIS; + if (c.trigger <= min_trigger) + SERIAL_ECHOLNPGM("?Idle Timeout (T) trigger temperature should be over ", min_trigger, "C."); +} + +/** + * M86: Cancel Hotend Idle Timeout (by setting the timeout period to 0) + */ +void GcodeSuite::M87() { + hotend_idle.cfg.timeout = 0; +} + +#endif // HOTEND_IDLE_TIMEOUT diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d0757c3c84a3..6bd2a8f1e523 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -631,7 +631,7 @@ typedef struct SettingsDataStruct { // HOTEND_IDLE_TIMEOUT // #if ENABLED(HOTEND_IDLE_TIMEOUT) - hotend_idle_settings_t hotend_idle_config; + hotend_idle_settings_t hotend_idle_config; // M86 S T E B #endif } SettingsData; @@ -3877,6 +3877,11 @@ void MarlinSettings::reset() { // TERN_(HAS_ZV_SHAPING, gcode.M593_report(forReplay)); + // + // Hotend Idle Timeout + // + TERN_(HOTEND_IDLE_TIMEOUT, gcode.M86_report(forReplay)); + // // Linear Advance // diff --git a/ini/features.ini b/ini/features.ini index 86e7d2e396bd..63da77cf76c5 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -140,7 +140,7 @@ HAS_FANMUX = build_src_filter=+ + FWRETRACT = build_src_filter=+ + HOST_ACTION_COMMANDS = build_src_filter=+ -HOTEND_IDLE_TIMEOUT = build_src_filter=+ +HOTEND_IDLE_TIMEOUT = build_src_filter=+ + JOYSTICK = build_src_filter=+ BLINKM = build_src_filter=+ HAS_COLOR_LEDS = build_src_filter=+ + From f99d5ecaeb9b787ceb72321f100bd9985ef203cd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Jun 2023 19:18:59 -0500 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=94=A8=20Update=20STM32Hxx=20boards/v?= =?UTF-8?q?ariants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #25934 --- buildroot/share/PlatformIO/boards/marlin_STM32H723ZE.json | 2 +- buildroot/share/PlatformIO/boards/marlin_STM32H743VI.json | 2 +- .../variants/{MARLIN_H723Zx => MARLIN_H723ZE}/PeripheralPins.c | 0 .../variants/{MARLIN_H723Zx => MARLIN_H723ZE}/PinNamesVar.h | 0 .../variants/{MARLIN_H723Zx => MARLIN_H723ZE}/ldscript.ld | 0 .../variant_MARLIN_STM32H723ZE.cpp} | 0 .../variant_MARLIN_STM32H723ZE.h} | 0 .../variants/{MARLIN_H743Vx => MARLIN_H743VI}/PeripheralPins.c | 0 .../variants/{MARLIN_H743Vx => MARLIN_H743VI}/PinNamesVar.h | 0 .../variants/{MARLIN_H743Vx => MARLIN_H743VI}/ldscript.ld | 0 .../variant_MARLIN_STM32H743VI.cpp} | 0 .../variant_MARLIN_STM32H743VI.h} | 0 12 files changed, 2 insertions(+), 2 deletions(-) rename buildroot/share/PlatformIO/variants/{MARLIN_H723Zx => MARLIN_H723ZE}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H723Zx => MARLIN_H723ZE}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H723Zx => MARLIN_H723ZE}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.cpp => MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.cpp} (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h => MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.h} (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H743Vx => MARLIN_H743VI}/PeripheralPins.c (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H743Vx => MARLIN_H743VI}/PinNamesVar.h (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H743Vx => MARLIN_H743VI}/ldscript.ld (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp => MARLIN_H743VI/variant_MARLIN_STM32H743VI.cpp} (100%) rename buildroot/share/PlatformIO/variants/{MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h => MARLIN_H743VI/variant_MARLIN_STM32H743VI.h} (100%) diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H723ZE.json b/buildroot/share/PlatformIO/boards/marlin_STM32H723ZE.json index 8525793c4e01..f4bb75b5dae9 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STM32H723ZE.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H723ZE.json @@ -6,7 +6,7 @@ "f_cpu": "550000000L", "mcu": "stm32h723zet6", "product_line": "STM32H723xx", - "variant": "MARLIN_H723Zx" + "variant": "MARLIN_H723ZE" }, "connectivity": [ "can", diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H743VI.json b/buildroot/share/PlatformIO/boards/marlin_STM32H743VI.json index 4ec34e5b3502..56e853cad43e 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STM32H743VI.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H743VI.json @@ -6,7 +6,7 @@ "f_cpu": "480000000L", "mcu": "stm32h743vit6", "product_line": "STM32H743xx", - "variant": "MARLIN_H743Vx" + "variant": "MARLIN_H743VI" }, "connectivity": [ "can", diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H723ZE/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_H723ZE/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_H723ZE/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H723Zx/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_H723ZE/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H723ZE/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H723Zx/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_H723ZE/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.cpp diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h b/buildroot/share/PlatformIO/variants/MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H723Zx/variant_MARLIN_STM32H723ZX.h rename to buildroot/share/PlatformIO/variants/MARLIN_H723ZE/variant_MARLIN_STM32H723ZE.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H743VI/PeripheralPins.c similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c rename to buildroot/share/PlatformIO/variants/MARLIN_H743VI/PeripheralPins.c diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_H743VI/PinNamesVar.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PinNamesVar.h rename to buildroot/share/PlatformIO/variants/MARLIN_H743VI/PinNamesVar.h diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H743VI/ldscript.ld similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld rename to buildroot/share/PlatformIO/variants/MARLIN_H743VI/ldscript.ld diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H743VI/variant_MARLIN_STM32H743VI.cpp similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp rename to buildroot/share/PlatformIO/variants/MARLIN_H743VI/variant_MARLIN_STM32H743VI.cpp diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h b/buildroot/share/PlatformIO/variants/MARLIN_H743VI/variant_MARLIN_STM32H743VI.h similarity index 100% rename from buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h rename to buildroot/share/PlatformIO/variants/MARLIN_H743VI/variant_MARLIN_STM32H743VI.h From f19e74061bc01c2516b75a9da7d37995897d2242 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 8 Jun 2023 19:22:17 -0500 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=94=A8=20Fix=20serial=20port=20#error?= =?UTF-8?q?=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/STM32/HAL.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index dc36cc1eca33..24589d0fcc36 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -71,7 +71,7 @@ #if WITHIN(SERIAL_PORT_2, 1, 6) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #elif !defined(USBCON) - #error "SERIAL_PORT must be from 1 to 6." + #error "SERIAL_PORT_2 must be from 1 to 6." #elif SERIAL_PORT_2 == -1 #define MYSERIAL2 MSerialUSB #else @@ -83,7 +83,7 @@ #if WITHIN(SERIAL_PORT_3, 1, 6) #define MYSERIAL3 MSERIAL(SERIAL_PORT_3) #elif !defined(USBCON) - #error "SERIAL_PORT must be from 1 to 6." + #error "SERIAL_PORT_3 must be from 1 to 6." #elif SERIAL_PORT_3 == -1 #define MYSERIAL3 MSerialUSB #else @@ -95,7 +95,7 @@ #if WITHIN(MMU2_SERIAL_PORT, 1, 6) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #elif !defined(USBCON) - #error "SERIAL_PORT must be from 1 to 6." + #error "MMU2_SERIAL_PORT must be from 1 to 6." #elif MMU2_SERIAL_PORT == -1 #define MMU2_SERIAL MSerialUSB #else @@ -107,7 +107,7 @@ #if WITHIN(LCD_SERIAL_PORT, 1, 6) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #elif !defined(USBCON) - #error "SERIAL_PORT must be from 1 to 6." + #error "LCD_SERIAL_PORT must be from 1 to 6." #elif LCD_SERIAL_PORT == -1 #define LCD_SERIAL MSerialUSB #else