Browse Source

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.
Guðni Már Gilbert 2 years ago
parent
commit
e9f5a95d4b
2 changed files with 13 additions and 2 deletions
  1. 8 2
      Firmware/mmu2.cpp
  2. 5 0
      Firmware/mmu2.h

+ 8 - 2
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;

+ 5 - 0
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.