diff --git a/src/logic/idle_mode.cpp b/src/logic/idle_mode.cpp index 03eeb71..c401929 100644 --- a/src/logic/idle_mode.cpp +++ b/src/logic/idle_mode.cpp @@ -61,7 +61,7 @@ void IdleMode::CheckManualOperation() { case mui::Event::Middle: // plan load if (mg::globals.ActiveSlot() < config::toolCount) { // do we have a meaningful selector position? - loadFilament.ResetUnlimited(mg::globals.ActiveSlot()); + loadFilament.Reset(mg::globals.ActiveSlot()); currentCommand = &loadFilament; } break; diff --git a/src/logic/load_filament.cpp b/src/logic/load_filament.cpp index 10d2f4e..17d8306 100644 --- a/src/logic/load_filament.cpp +++ b/src/logic/load_filament.cpp @@ -21,16 +21,16 @@ void LoadFilament::Reset(uint8_t param) { } dbg_logic_P(PSTR("Load Filament")); mg::globals.SetFilamentLoaded(param, mg::FilamentLoadState::AtPulley); // still at pulley, haven't moved yet - Reset2(true); + Reset2(false); } -void LoadFilament::ResetUnlimited(uint8_t param) { +void LoadFilament::ResetLimited(uint8_t param) { if (!CheckToolIndex(param)) { return; } dbg_logic_P(PSTR("Load Filament")); mg::globals.SetFilamentLoaded(param, mg::FilamentLoadState::AtPulley); // still at pulley, haven't moved yet - Reset2(false); + Reset2(true); } void logic::LoadFilament::Reset2(bool feedPhaseLimited) { diff --git a/src/logic/load_filament.h b/src/logic/load_filament.h index 865a22f..dda07c9 100644 --- a/src/logic/load_filament.h +++ b/src/logic/load_filament.h @@ -13,13 +13,13 @@ public: inline LoadFilament() : CommandBase() {} - /// Restart the automaton + /// Restart the automaton - performs unlimited rotation of the Pulley /// @param param index of filament slot to load void Reset(uint8_t param) override; - /// Restart the automaton for unlimited rotation of the Pulley + /// Restart the automaton for a limited rotation of the Pulley /// @param param index of filament slot to load - void ResetUnlimited(uint8_t param); + void ResetLimited(uint8_t param); /// @returns true if the state machine finished its job, false otherwise bool StepInner() override; diff --git a/tests/unit/logic/load_filament/test_load_filament.cpp b/tests/unit/logic/load_filament/test_load_filament.cpp index 228276e..2953386 100644 --- a/tests/unit/logic/load_filament/test_load_filament.cpp +++ b/tests/unit/logic/load_filament/test_load_filament.cpp @@ -23,7 +23,7 @@ using namespace std::placeholders; #include "../helpers/helpers.ipp" -void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf, bool feedUnlimited) { +void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf, bool feedLimited) { ForceReinitAllAutomata(); // change the startup to what we need here @@ -33,8 +33,8 @@ void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf, bool feedUnl REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK)); // restart the automaton - if (feedUnlimited) { - lf.ResetUnlimited(slot); + if (feedLimited) { + lf.ResetLimited(slot); } else { lf.Reset(slot); } @@ -81,7 +81,7 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) { TEST_CASE("load_filament::regular_load_to_slot_0-4", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); LoadFilamentSuccessful(slot, lf); } } @@ -212,7 +212,7 @@ void FailedLoadToFindaResolveTryAgain(uint8_t slot, logic::LoadFilament &lf) { TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_help_second_ok", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); FailedLoadToFinda(slot, lf); FailedLoadToFindaResolveHelp(slot, lf); FailedLoadToFindaResolveHelpFindaTriggered(slot, lf); @@ -222,7 +222,7 @@ TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_help_second_ok", "[lo TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_help_second_fail", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); FailedLoadToFinda(slot, lf); FailedLoadToFindaResolveHelp(slot, lf); FailedLoadToFindaResolveHelpFindaDidntTrigger(slot, lf); @@ -245,7 +245,7 @@ TEST_CASE("load_filament::state_machine_reusal", "[load_filament]") { if (toSlot >= config::toolCount) { InvalidSlot(lf, fromSlot, toSlot); } else { - LoadFilamentCommonSetup(toSlot, lf, false); + LoadFilamentCommonSetup(toSlot, lf, true); LoadFilamentSuccessful(toSlot, lf); } } @@ -255,7 +255,7 @@ TEST_CASE("load_filament::state_machine_reusal", "[load_filament]") { TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_manual", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); FailedLoadToFinda(slot, lf); FailedLoadToFindaResolveManual(slot, lf); } @@ -264,7 +264,7 @@ TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_manual", "[load_filam TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_manual_no_FINDA", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); FailedLoadToFinda(slot, lf); FailedLoadToFindaResolveManualNoFINDA(slot, lf); } @@ -273,7 +273,7 @@ TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_manual_no_FINDA", "[l TEST_CASE("load_filament::failed_load_to_finda_0-4_try_again", "[load_filament]") { for (uint8_t slot = 0; slot < config::toolCount; ++slot) { logic::LoadFilament lf; - LoadFilamentCommonSetup(slot, lf, false); + LoadFilamentCommonSetup(slot, lf, true); FailedLoadToFinda(slot, lf); FailedLoadToFindaResolveTryAgain(slot, lf); }