Disengage Idler after retracted from FINDA

Add some dbg_logic output
pull/126/head
3d-gussner 2021-09-29 20:11:29 +02:00 committed by DRracer
parent b752c5c4e7
commit 5cfb0887d0
1 changed files with 10 additions and 0 deletions

View File

@ -4,10 +4,12 @@
#include "../modules/idler.h" #include "../modules/idler.h"
#include "../modules/leds.h" #include "../modules/leds.h"
#include "../modules/motion.h" #include "../modules/motion.h"
#include "../debug.h"
namespace logic { namespace logic {
void RetractFromFinda::Reset() { void RetractFromFinda::Reset() {
dbg_logic_P(PSTR("\nRetract from FINDA\n\n"));
state = EngagingIdler; state = EngagingIdler;
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
mi::idler.Engage(mg::globals.ActiveSlot()); mi::idler.Engage(mg::globals.ActiveSlot());
@ -17,21 +19,29 @@ bool RetractFromFinda::Step() {
switch (state) { switch (state) {
case EngagingIdler: case EngagingIdler:
if (mi::idler.Engaged()) { if (mi::idler.Engaged()) {
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::pulleyFeedrate);
} }
return false; return false;
case UnloadBackToPTFE: case UnloadBackToPTFE:
dbg_logic_P(PSTR("Unload back to PTFE --> Pulling"));
if (mm::motion.QueueEmpty()) { // all moves have been finished if (mm::motion.QueueEmpty()) { // all moves have been finished
if (!mf::finda.Pressed()) { // FINDA switched off correctly while the move was performed if (!mf::finda.Pressed()) { // FINDA switched off correctly while the move was performed
state = OK; state = OK;
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley); mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley);
dbg_logic_sprintf_P(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley));
dbg_logic_P(PSTR("Retract from FINDA --> DisengagingIdler"));
mi::idler.Disengage();
} else { // FINDA didn't switch off } else { // FINDA didn't switch off
state = Failed; state = Failed;
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0);
} }
} }
if (!mi::idler.Engaged()) {
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
}
return false; return false;
case OK: case OK:
case Failed: case Failed: