If finda is ever pressed, don't move selector.

I moved the check higher.

This triggered a FINDA FLICKER failure in Load_filament.cpp
Now the test covers it :) (Didn't before)
pull/247/head
Guðni Már Gilbert 2022-12-17 15:18:42 +00:00
parent eaa89aebaa
commit 6223613167
3 changed files with 31 additions and 9 deletions

View File

@ -126,6 +126,7 @@ bool LoadFilament::StepInner() {
break; break;
case mui::Event::Middle: // try again the whole sequence case mui::Event::Middle: // try again the whole sequence
// however it depends on the state of FINDA - if it is on, we must perform unload first // however it depends on the state of FINDA - if it is on, we must perform unload first
InvalidateHoming();
if (!mf::finda.Pressed()) { if (!mf::finda.Pressed()) {
Reset2(false); Reset2(false);
} else { } else {

View File

@ -62,6 +62,12 @@ Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
} }
plannedSlot = slot; plannedSlot = slot;
if (mf::finda.Pressed()) {
// @@TODO not sure why (if) this happens, but anyway - we must not move the selector if FINDA is pressed
// That includes the CutFilament operation as well
return OperationResult::Refused;
}
// if we are homing right now, just record the desired planned slot and return Accepted // if we are homing right now, just record the desired planned slot and return Accepted
if (state == HomeBack) { if (state == HomeBack) {
return OperationResult::Accepted; return OperationResult::Accepted;
@ -73,12 +79,6 @@ Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
return OperationResult::Accepted; return OperationResult::Accepted;
} }
if (mf::finda.Pressed()) {
// @@TODO not sure why (if) this happens, but anyway - we must not move the selector if FINDA is pressed
// That includes the CutFilament operation as well
return OperationResult::Refused;
}
// coordinates invalid, first home, then engage // coordinates invalid, first home, then engage
if (!homingValid && mg::globals.FilamentLoaded() < mg::FilamentLoadState::InSelector) { if (!homingValid && mg::globals.FilamentLoaded() < mg::FilamentLoadState::InSelector) {
PlanHome(); PlanHome();

View File

@ -385,10 +385,31 @@ TEST_CASE("load_filament::unlimited_load_manual_stop", "[load_filament]") {
void LoadFilamentAlreadyPresentFilament(uint8_t slot, logic::LoadFilament &lf) { void LoadFilamentAlreadyPresentFilament(uint8_t slot, logic::LoadFilament &lf) {
//one of the first steps of the state machine should pick up the fact that FINDA is on and transfer into the retracting phase //one of the first steps of the state machine should pick up the fact that FINDA is on and transfer into the retracting phase
// Note that this will also trigger a FINDA FLICKERS error
REQUIRE(WhileTopState(lf, ProgressCode::FeedingToFinda, 5000)); REQUIRE(WhileTopState(lf, ProgressCode::FeedingToFinda, 5000));
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
REQUIRE(WhileCondition(lf, std::bind(SimulateRetractFromFINDA, _1, 100), 5000)); REQUIRE(mf::finda.Pressed());
REQUIRE(WhileTopState(lf, ProgressCode::RetractingFromFinda, 5000)); REQUIRE((int)mg::globals.FilamentLoaded() == (int)mg::FilamentLoadState::AtPulley);
REQUIRE(mm::PulleyEnabled() == false);
REQUIRE(ml::leds.Mode(slot, ml::green) == ml::off);
REQUIRE(ml::leds.Mode(slot, ml::red) == ml::blink0);
REQUIRE(lf.Error() == ErrorCode::RUNNING);
REQUIRE(lf.TopLevelState() == ProgressCode::ERRDisengagingIdler);
SimulateErrDisengagingIdler(lf, ErrorCode::FINDA_FLICKERS);
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, true, false, ml::off, ml::blink0, ErrorCode::FINDA_FLICKERS, ProgressCode::ERRWaitingForUser));
// Let's resolve the error
SetFINDAStateAndDebounce(false);
// Press middle button to resolve error
PressButtonAndDebounce(lf, mb::Middle, true);
// Re-home idler and selector
REQUIRE_FALSE(mi::idler.HomingValid());
REQUIRE_FALSE(ms::selector.HomingValid());
SimulateIdlerAndSelectorHoming(lf); // failed load to FINDA = nothing blocking the selector - it can rehome
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda)); REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
// make FINDA switch on again // make FINDA switch on again
REQUIRE(WhileCondition(lf, std::bind(SimulateFeedToFINDA, _1, 100), 5000)); REQUIRE(WhileCondition(lf, std::bind(SimulateFeedToFINDA, _1, 100), 5000));