Actually fix retract filament from finda

pull/126/head
Alex Voinea 2021-09-30 21:44:41 +02:00 committed by DRracer
parent 6071257973
commit 0a1290102c
3 changed files with 16 additions and 12 deletions

View File

@ -21,7 +21,7 @@ bool RetractFromFinda::Step() {
if (mi::idler.Engaged()) { if (mi::idler.Engaged()) {
dbg_logic_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); dbg_logic_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley));
state = UnloadBackToPTFE; state = UnloadBackToPTFE;
mm::motion.PlanMove<mm::Pulley>(-config::cuttingEdgeToFindaMidpoint, config::pulleyFeedrate); mm::motion.PlanMove<mm::Pulley>(-(config::cuttingEdgeToFindaMidpoint + config::cuttingEdgeRetract), config::pulleyFeedrate);
} }
return false; return false;
case UnloadBackToPTFE: case UnloadBackToPTFE:

View File

@ -35,20 +35,22 @@ bool UnloadFilament::StepInner() {
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0);
mi::idler.Disengage(); mi::idler.Disengage();
} else { } else {
state = ProgressCode::UnloadingToPulley; state = ProgressCode::RetractingFromFinda;
mm::motion.PlanMove<mm::Pulley>(-config::cuttingEdgeToFindaMidpoint, config::pulleyFeedrate); retract.Reset();
} }
} }
return false; return false;
case ProgressCode::UnloadingToPulley: case ProgressCode::RetractingFromFinda:
if (mm::motion.QueueEmpty()) { if (retract.Step()) {
state = ProgressCode::DisengagingIdler; if (retract.State() == RetractFromFinda::Failed) {
mi::idler.Disengage(); state = ProgressCode::ERRDisengagingIdler;
} error = ErrorCode::FINDA_DIDNT_SWITCH_OFF;
return false; mi::idler.Disengage();
case ProgressCode::DisengagingIdler: ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
if (mm::motion.QueueEmpty()) { ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); // signal loading error
state = ProgressCode::FinishingMoves; } else {
state = ProgressCode::FinishingMoves;
}
} }
return false; return false;
case ProgressCode::FinishingMoves: case ProgressCode::FinishingMoves:

View File

@ -2,6 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include "command_base.h" #include "command_base.h"
#include "unload_to_finda.h" #include "unload_to_finda.h"
#include "retract_from_finda.h"
namespace logic { namespace logic {
@ -21,6 +22,7 @@ public:
private: private:
constexpr static const uint8_t maxRetries = 3; constexpr static const uint8_t maxRetries = 3;
UnloadToFinda unl; UnloadToFinda unl;
RetractFromFinda retract;
}; };
/// The one and only instance of UnloadFilament state machine in the FW /// The one and only instance of UnloadFilament state machine in the FW