diff --git a/src/logic/tool_change.cpp b/src/logic/tool_change.cpp index a599b8e..079117f 100644 --- a/src/logic/tool_change.cpp +++ b/src/logic/tool_change.cpp @@ -126,6 +126,14 @@ bool ToolChange::StepInner() { // However - if we run into "FSensor didn't trigger", the situation is exactly opposite - it is beneficial // to unload the filament and try the whole sequence again // Therefore we only switch to FeedingToFinda if FINDA is not pressed (we suppose the filament is unloaded completely) + // + // MMU-191: if FSENSOR_DIDNT_SWITCH_ON was caused by misaligned Idler, + // rehoming it may fix the issue when auto retrying -> no user intervention + // So first invalidate homing flags as the user may have moved the Idler or Selector accidentally. + // + // Beware: we may run into issues when FINDA or FSensor do not work correctly. Selector may rely on the presumed filament position and actually cut it accidentally when trying to rehome. + // It is yet to be seen if something like this can actually happen. + InvalidateHoming(); if (mf::finda.Pressed()) { Reset(mg::globals.ActiveSlot()); } else { @@ -201,7 +209,7 @@ ProgressCode ToolChange::State() const { case FeedToBondtech::DisengagingIdler: return ProgressCode::DisengagingIdler; } - // [[fallthrough]] // everything else is reported as FeedingToBondtech + [[fallthrough]]; // everything else is reported as is default: return state; } diff --git a/tests/unit/logic/tool_change/test_tool_change.cpp b/tests/unit/logic/tool_change/test_tool_change.cpp index 66212a1..fc8d4a4 100644 --- a/tests/unit/logic/tool_change/test_tool_change.cpp +++ b/tests/unit/logic/tool_change/test_tool_change.cpp @@ -230,23 +230,19 @@ void ToolChangeFailLoadToFindaMiddleBtn(logic::ToolChange &tc, uint8_t toSlot) { REQUIRE_FALSE(mui::userInput.AnyEvent()); PressButtonAndDebounce(tc, mb::Middle, true); - REQUIRE(WhileCondition( - tc, - [&](uint32_t step) -> bool { - if(step == 2000){ // on 2000th step make FINDA trigger - hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); - } - return tc.TopLevelState() == ProgressCode::UnloadingFilament; }, - 200000UL)); + REQUIRE_FALSE(mi::idler.HomingValid()); + REQUIRE_FALSE(ms::selector.HomingValid()); + SimulateIdlerAndSelectorHoming(tc); // failed load to FINDA = nothing blocking the selector - it can rehome + REQUIRE(VerifyState(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda)); ClearButtons(tc); // retry the whole operation // beware - the FeedToFinda state machine will leverage the already engaged Idler, - // so the necessary number of steps to reach the FINDA is quite low (~200 was lowest once tested) + // so the necessary number of steps to reach the FINDA is quite low (~250 was lowest once tested) // without running short of max distance of Pulley to travel - FeedingToFinda(tc, toSlot, 200); + FeedingToFinda(tc, toSlot, 250); FeedingToBondtech(tc, toSlot);