diff --git a/src/logic/unload_to_finda.cpp b/src/logic/unload_to_finda.cpp index aaf3c1c..4a37e38 100644 --- a/src/logic/unload_to_finda.cpp +++ b/src/logic/unload_to_finda.cpp @@ -23,14 +23,19 @@ void UnloadToFinda::Reset(uint8_t maxTries) { bool UnloadToFinda::Step() { switch (state) { case EngagingIdler: + if (mg::globals.FilamentLoaded()) { + state = UnloadingToFinda; + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::blink0); + } else { + state = Failed; + } + return false; + case UnloadingToFinda: if (mi::idler.Engaged()) { state = WaitingForFINDA; int unloadSteps = mps::BowdenLength::get() + 1100; const int second_point = unloadSteps - 1300; - mm::motion.PlanMove(mm::Pulley, -1400, 6000); // @@TODO constants - mm::motion.PlanMove(mm::Pulley, -1800 + 1400, 2500); // @@TODO constants 1800-1400 = 400 - mm::motion.PlanMove(mm::Pulley, -second_point + 1800, 550); // @@TODO constants - ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); + mm::motion.PlanMove(-config::DefaultBowdenLength -config::FeedToFINDA -config::FilamentMinLoadedToMMU, config::pulleyFeedrate); // @@TODO constants } return false; case WaitingForFINDA: @@ -38,6 +43,7 @@ bool UnloadToFinda::Step() { // detected end of filament state = OK; mm::motion.AbortPlannedMoves(); // stop rotating the pulley + ml::leds.SetMode(mg::globals.ActiveSlot(), ml::Color::green, ml::Mode::off); } else if (/*tmc2130_read_gstat() &&*/ mm::motion.QueueEmpty()) { // we reached the end of move queue, but the FINDA didn't switch off // two possible causes - grinded filament or malfunctioning FINDA