diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index 0c482f9..2bbae02 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -17,7 +17,7 @@ void FeedToBondtech::Reset(uint8_t maxRetries) { dbg_logic_P(PSTR("\nFeed to Bondtech\n\n")); state = EngagingIdler; this->maxRetries = maxRetries; - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); + ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off); mi::idler.Engage(mg::globals.ActiveSlot()); } diff --git a/src/logic/unload_filament.cpp b/src/logic/unload_filament.cpp index dbf5ef4..03ac132 100644 --- a/src/logic/unload_filament.cpp +++ b/src/logic/unload_filament.cpp @@ -30,7 +30,6 @@ bool UnloadFilament::Reset(uint8_t /*param*/) { error = ErrorCode::RUNNING; skipDisengagingIdler = false; unl.Reset(maxRetries); - ml::leds.SetAllOff(); return true; } diff --git a/src/logic/unload_to_finda.cpp b/src/logic/unload_to_finda.cpp index b0734e2..75f1400 100644 --- a/src/logic/unload_to_finda.cpp +++ b/src/logic/unload_to_finda.cpp @@ -22,6 +22,7 @@ void UnloadToFinda::Reset(uint8_t maxTries) { state = EngagingIdler; mi::idler.PartiallyDisengage(mg::globals.ActiveSlot()); // basically prepare before the active slot - saves ~1s started_ms = mt::timebase.Millis(); + ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off); } } @@ -46,7 +47,6 @@ bool UnloadToFinda::Step() { if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) { state = UnloadingToFinda; mpu::pulley.InitAxis(); - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); mi::idler.Engage(mg::globals.ActiveSlot()); // slow move for the first few millimeters - help the printer relieve the filament while engaging the Idler fully diff --git a/tests/unit/logic/failing_tmc/test_failing_tmc.cpp b/tests/unit/logic/failing_tmc/test_failing_tmc.cpp index 9a2fd4f..83b7595 100644 --- a/tests/unit/logic/failing_tmc/test_failing_tmc.cpp +++ b/tests/unit/logic/failing_tmc/test_failing_tmc.cpp @@ -51,7 +51,7 @@ void FailingMovableUnload(hal::tmc2130::ErrorFlags ef, ErrorCode ec, config::Axi // UnloadFilament starts by engaging the idler (through the UnloadToFinda state machine) uf.Reset(0); - REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); + REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); REQUIRE(WhileCondition( uf, diff --git a/tests/unit/logic/tool_change/test_tool_change.cpp b/tests/unit/logic/tool_change/test_tool_change.cpp index 046fbd2..d23872f 100644 --- a/tests/unit/logic/tool_change/test_tool_change.cpp +++ b/tests/unit/logic/tool_change/test_tool_change.cpp @@ -328,7 +328,7 @@ void ToolChangeFailFSensor(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSl // restart the automaton tc.Reset(toSlot); - REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament)); + REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament)); // simulate unload to finda but fail the fsensor test REQUIRE(WhileCondition(tc, std::bind(SimulateUnloadToFINDA, _1, 500'000, 10'000), 200'000)); REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), fromSlot, false, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_OFF, ProgressCode::UnloadingFilament)); @@ -528,7 +528,7 @@ void ToolChangeFSENSOR_TOO_EARLY(logic::ToolChange &tc, uint8_t slot) { // make AutoRetry PressButtonAndDebounce(tc, mb::Middle, true); - REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament)); + REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament)); SimulateIdlerHoming(tc); diff --git a/tests/unit/logic/unload_filament/test_unload_filament.cpp b/tests/unit/logic/unload_filament/test_unload_filament.cpp index 4319b04..ccbd29b 100644 --- a/tests/unit/logic/unload_filament/test_unload_filament.cpp +++ b/tests/unit/logic/unload_filament/test_unload_filament.cpp @@ -53,16 +53,10 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf, uint8_t en REQUIRE(VerifyState(uf, (mg::FilamentLoadState)(mg::FilamentLoadState::InNozzle | mg::FilamentLoadState::InSelector), entryIdlerSlotIndex, slot, true, true, entryGreenLED, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); - // run the automaton - // Stage 1 - unloading to FINDA - REQUIRE(WhileCondition( - uf, - [&](uint32_t step) -> bool { - if(step == 100){ // on 100th step make FINDA trigger - hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low); - } - return uf.TopLevelState() == ProgressCode::UnloadingToFinda; }, - 50000)); + REQUIRE(WhileCondition(uf, std::bind(SimulateUnloadToFINDA, _1, 100, 2'000), 200'000)); + + main_loop(); + uf.Step(); // we still think we have filament loaded at this stage // idler should have been activated by the underlying automaton @@ -100,7 +94,7 @@ TEST_CASE("unload_filament::regular_unload_from_slot_0-4", "[unload_filament]") for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::UnloadFilament uf; RegularUnloadFromSlot04Init(slot, uf); - RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::off); + RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::blink0); } } @@ -130,7 +124,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) { // FINDA triggered off // green LED should be off // no error so far - REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); + REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); // run the automaton // Stage 1 - unloading to FINDA - do NOT let it trigger - keep it pressed, the automaton should finish all moves with the pulley @@ -177,7 +171,7 @@ void FindaDidntTriggerResolveTryAgain(uint8_t slot, logic::UnloadFilament &uf) { // no change in selector's position // FINDA still on // red LED should blink, green LED should be off - REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); + REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda)); ClearButtons(uf);