From 63aead0ab80b5bf8b38656f364885dbcc68d756b Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 6 Oct 2021 11:12:13 +0200 Subject: [PATCH] Update eject to use FilamentLoadState NotLoaded --- src/logic/eject_filament.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/logic/eject_filament.cpp b/src/logic/eject_filament.cpp index ca75b35..324fff3 100644 --- a/src/logic/eject_filament.cpp +++ b/src/logic/eject_filament.cpp @@ -7,6 +7,7 @@ #include "../modules/motion.h" #include "../modules/permanent_storage.h" #include "../modules/selector.h" +#include "../debug.h" namespace logic { @@ -20,7 +21,10 @@ void EjectFilament::Reset(uint8_t param) { error = ErrorCode::RUNNING; slot = param; - if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) { + if (mg::globals.FilamentLoaded() == mg::FilamentLoadState::NotLoaded) { + state = ProgressCode::OK; + dbg_logic_P(PSTR("Already ejected")); + } else if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::AtPulley) { state = ProgressCode::UnloadingFilament; unl.Reset(param); //@@TODO probably act on active extruder only } else { @@ -39,7 +43,7 @@ bool EjectFilament::StepInner() { switch (state) { case ProgressCode::UnloadingFilament: if (unl.StepInner()) { - // unloading sequence finished - basically, no errors can occurr here + // unloading sequence finished - basically, no errors can occur here // as UnloadFilament should handle all the possible error states on its own // There is no way the UnloadFilament to finish in an error state MoveSelectorAside(); @@ -49,7 +53,7 @@ bool EjectFilament::StepInner() { if (mm::motion.QueueEmpty()) { // selector parked aside state = ProgressCode::EjectingFilament; mm::motion.InitAxis(mm::Pulley); - mm::motion.PlanMove(-config::filamentMinLoadedToMMU, config::pulleyFeedrate); + mm::motion.PlanMove(-config::filamentMinLoadedToMMU, config::pulleySlowFeedrate); } break; case ProgressCode::EjectingFilament: @@ -61,11 +65,13 @@ bool EjectFilament::StepInner() { case ProgressCode::DisengagingIdler: if (!mi::idler.Engaged()) { // idler disengaged mm::motion.Disable(mm::Pulley); + mg::globals.SetFilamentLoaded(mg::FilamentLoadState::NotLoaded); state = ProgressCode::OK; error = ErrorCode::OK; } break; case ProgressCode::OK: + dbg_logic_sprintf_P(PSTR("FilamentLoadState after Eject %d"), mg::globals.FilamentLoaded()); return true; default: // we got into an unhandled state, better report it state = ProgressCode::ERRInternal;