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.
This commit is contained in:
Guðni Már Gilbert 2022-09-11 08:39:09 +00:00 committed by D.R.racer
parent 94119744ad
commit e9f5a95d4b
2 changed files with 13 additions and 2 deletions

View File

@ -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;

View File

@ -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.