Invalidate Idler+Selector homing flags when Retry from ToolChange Error

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.

MMU-191
pull/236/head
D.R.racer 2022-11-09 19:12:41 +01:00
parent 299a31b765
commit 6efe4ada15
2 changed files with 15 additions and 11 deletions

View File

@ -126,6 +126,14 @@ bool ToolChange::StepInner() {
// However - if we run into "FSensor didn't trigger", the situation is exactly opposite - it is beneficial // 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 // 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) // 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()) { if (mf::finda.Pressed()) {
Reset(mg::globals.ActiveSlot()); Reset(mg::globals.ActiveSlot());
} else { } else {
@ -201,7 +209,7 @@ ProgressCode ToolChange::State() const {
case FeedToBondtech::DisengagingIdler: case FeedToBondtech::DisengagingIdler:
return ProgressCode::DisengagingIdler; return ProgressCode::DisengagingIdler;
} }
// [[fallthrough]] // everything else is reported as FeedingToBondtech [[fallthrough]]; // everything else is reported as is
default: default:
return state; return state;
} }

View File

@ -230,23 +230,19 @@ void ToolChangeFailLoadToFindaMiddleBtn(logic::ToolChange &tc, uint8_t toSlot) {
REQUIRE_FALSE(mui::userInput.AnyEvent()); REQUIRE_FALSE(mui::userInput.AnyEvent());
PressButtonAndDebounce(tc, mb::Middle, true); PressButtonAndDebounce(tc, mb::Middle, true);
REQUIRE(WhileCondition( REQUIRE_FALSE(mi::idler.HomingValid());
tc, REQUIRE_FALSE(ms::selector.HomingValid());
[&](uint32_t step) -> bool { SimulateIdlerAndSelectorHoming(tc); // failed load to FINDA = nothing blocking the selector - it can rehome
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(VerifyState(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda)); REQUIRE(VerifyState(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
ClearButtons(tc); ClearButtons(tc);
// retry the whole operation // retry the whole operation
// beware - the FeedToFinda state machine will leverage the already engaged Idler, // 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 // without running short of max distance of Pulley to travel
FeedingToFinda(tc, toSlot, 200); FeedingToFinda(tc, toSlot, 250);
FeedingToBondtech(tc, toSlot); FeedingToBondtech(tc, toSlot);