From 66aa848b2f3238093d9038bed9f31738bddf0144 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Sep 2025 23:39:52 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20Trigger=20instant=20runout=20?= =?UTF-8?q?on=20filament=20jam=20(#28074)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/runout.cpp | 1 - Marlin/src/feature/runout.h | 32 ++++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Marlin/src/feature/runout.cpp b/Marlin/src/feature/runout.cpp index aa64ed9b93..f0b94d0de8 100644 --- a/Marlin/src/feature/runout.cpp +++ b/Marlin/src/feature/runout.cpp @@ -51,7 +51,6 @@ bool FilamentMonitorBase::enabled = true, #if ENABLED(FILAMENT_MOTION_SENSOR) uint8_t FilamentSensorEncoder::motion_detected; #endif - #if ENABLED(FILAMENT_SWITCH_AND_MOTION) bool RunoutResponseDelayed::ignore_motion = false; float RunoutResponseDelayed::motion_distance_mm = FILAMENT_MOTION_DISTANCE_MM; diff --git a/Marlin/src/feature/runout.h b/Marlin/src/feature/runout.h index 35d0bff85b..1cd90b0bb2 100644 --- a/Marlin/src/feature/runout.h +++ b/Marlin/src/feature/runout.h @@ -375,7 +375,9 @@ class FilamentSensorBase { class RunoutResponseDelayed { private: static countdown_t mm_countdown; - static bool ignore_motion; // Flag to ignore the encoder + #if ENABLED(FILAMENT_SWITCH_AND_MOTION) + static bool ignore_motion; // Flag to ignore the encoder + #endif public: static float runout_distance_mm; @@ -384,7 +386,10 @@ class FilamentSensorBase { static float motion_distance_mm; #endif - static void set_ignore_motion(const bool ignore=true) { ignore_motion = ignore; } + static void set_ignore_motion(const bool ignore=true) { + UNUSED(ignore); + TERN_(FILAMENT_SWITCH_AND_MOTION, ignore_motion = ignore); + } static void reset() { for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) filament_present(i); @@ -413,13 +418,24 @@ class FilamentSensorBase { // Get runout status for all presence sensors and motion sensors static runout_flags_t has_run_out() { runout_flags_t runout_flags{0}; - // Runout based on filament presence - for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) if (mm_countdown.runout[i] < 0) runout_flags.set(i); - // Runout based on filament motion + #if ENABLED(FILAMENT_SWITCH_AND_MOTION) - if (!ignore_motion) - for (uint8_t i = 0; i < NUM_MOTION_SENSORS; ++i) if (mm_countdown.motion[i] < 0) runout_flags.set(i); + // Runout based on filament motion + if (!ignore_motion) { + for (uint8_t i = 0; i < NUM_MOTION_SENSORS; ++i) { + if (mm_countdown.motion[i] < 0) { + runout_flags.set(i); + mm_countdown.runout[i] = -1; // For a filament jam don't wait for runout_distance_mm! + } + } + } #endif + + // Runout based on filament presence + for (uint8_t i = 0; i < NUM_RUNOUT_SENSORS; ++i) + if (mm_countdown.runout[i] < 0) + runout_flags.set(i); + return runout_flags; } @@ -471,8 +487,8 @@ class FilamentSensorBase { if (mm_countdown.runout_reset[e]) filament_present(e); // Reset pending. Try to reset. } - // Apply E distance to motion countdown, reset if flagged #if ENABLED(FILAMENT_SWITCH_AND_MOTION) + // Apply E distance to motion countdown, reset if flagged if (!ignore_motion && e < NUM_MOTION_SENSORS) { mm_countdown.motion[e] -= mm; if (mm_countdown.motion_reset[e]) filament_motion_present(e); // Reset pending. Try to reset.