diff --git a/src/modules/idler.cpp b/src/modules/idler.cpp index 3dbc8c6..2312a21 100644 --- a/src/modules/idler.cpp +++ b/src/modules/idler.cpp @@ -15,10 +15,11 @@ bool Idler::Disengage() { if (state == Moving) return false; + plannedEngage = false; + if (!Engaged()) return true; - plannedEngage = false; mm::motion.InitAxis(mm::Idler); // plan move to idle position // mm::motion.PlanMove(0, idle_position, 0, 1000, 0, 0); // @@TODO @@ -30,11 +31,12 @@ bool Idler::Engage(uint8_t slot) { if (state == Moving) return false; + plannedSlot = slot; + plannedEngage = true; + if (Engaged()) return true; - plannedSlot = slot; - plannedEngage = true; mm::motion.InitAxis(mm::Idler); // mm::motion.PlanMove(0, slotPositions[slot], 0, 1000, 0, 0); // @@TODO state = Moving; diff --git a/src/modules/selector.cpp b/src/modules/selector.cpp index d518d4d..59dc9be 100644 --- a/src/modules/selector.cpp +++ b/src/modules/selector.cpp @@ -15,10 +15,11 @@ bool Selector::MoveToSlot(uint8_t slot) { if (state == Moving) return false; + plannedSlot = slot; + if (currentSlot == slot) return true; - plannedSlot = slot; mm::motion.InitAxis(mm::Selector); // mm::motion.PlanMove(1, slotPositions[slot], 0, 1000, 0, 0); // @@TODO state = Moving; diff --git a/tests/unit/logic/cut_filament/test_cut_filament.cpp b/tests/unit/logic/cut_filament/test_cut_filament.cpp index 6b96038..d0ce989 100644 --- a/tests/unit/logic/cut_filament/test_cut_filament.cpp +++ b/tests/unit/logic/cut_filament/test_cut_filament.cpp @@ -49,10 +49,15 @@ TEST_CASE("cut_filament::cut0", "[cut_filament]") { // idler and selector reached their target positions and the CF automaton will start feeding to FINDA as the next step REQUIRE(cf.State() == ProgressCode::FeedingToFinda); + // prepare for simulated finda trigger + hal::adc::ReinitADC(1, hal::adc::TADCData({ 0, 0, 0, 0, 600, 700, 800, 900 }), 10); REQUIRE(WhileCondition([&]() { return cf.State() == ProgressCode::FeedingToFinda; }, 50000)); // filament fed into FINDA, cutting... REQUIRE(cf.State() == ProgressCode::PreparingBlade); + REQUIRE(WhileCondition([&]() { return cf.State() == ProgressCode::PreparingBlade; }, 5000)); + + REQUIRE(cf.State() == ProgressCode::EngagingIdler); REQUIRE(WhileCondition([&]() { return cf.State() == ProgressCode::EngagingIdler; }, 5000)); // the idler should be at the active slot @@TODO