From e9f5a95d4ba35a596b56387f0cf05ca653e45c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 11 Sep 2022 08:39:09 +0000 Subject: [PATCH] PFW-1362 Make sure FINDA runout is impossible with MMU disabled Since mmu_loop() is called in the main loop() function when the MMU is disabled, we need to utilise the MMU protocol layer to prevent FINDA runout from happening if MMU is disabled. We also need to keep in mind we probably can't trigger a FINDA runout in the middle of a Q0 query. So my solution now is to wait for the "Finished" state and check if the FINDA is off during printing. When "Finished" state appears, the FINDA value should be up to date. --- Firmware/mmu2.cpp | 10 ++++++++-- Firmware/mmu2.h | 5 +++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index d8bace241..9e23cc7d3 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -212,6 +212,11 @@ void MMU2::mmu_loop() { ReportErrorHook((uint16_t)lastErrorCode, mmu2.MMUCurrentErrorCode() == ErrorCode::OK ? ErrorSourcePrinter : ErrorSourceMMU); } + avoidRecursion = false; +} + +void MMU2::CheckFINDARunout() +{ // Check for FINDA filament runout if (!FindaDetectsFilament() && CHECK_FSENSOR) { SERIAL_ECHOLNPGM("FINDA filament runout!"); @@ -226,8 +231,6 @@ void MMU2::mmu_loop() { enquecommand_front_P(PSTR("M600")); //save print and run M600 command } } - - avoidRecursion = false; } struct ReportingRAII { @@ -731,6 +734,9 @@ StepStatus MMU2::LogicStep() { StepStatus ss = logic.Step(); switch (ss) { case Finished: + // At this point it is safe to trigger a runout and not interrupt the MMU protocol + CheckFINDARunout(); + break; case Processing: OnMMUProgressMsg(logic.Progress()); break; diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 4ebf78668..f459fa0cf 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -244,6 +244,11 @@ private: /// Check for any button/user input coming from the printer's UI void CheckUserInput(); + /// @brief Check whether to trigger a FINDA runout. If triggered this function will call M600 AUTO + /// if SpoolJoin is enabled, otherwise M600 is called without AUTO which will prompt the user + /// for the next filament slot to use + void CheckFINDARunout(); + /// Entry check of all external commands. /// It can wait until the MMU becomes ready. /// Optionally, it can also emit/display an error screen and the user can decide what to do next.