From a408651e628840f3d251dc7f407388b944e1b579 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Mon, 17 Jan 2022 10:17:54 +0100 Subject: [PATCH] CurrentPositionPulley_mm->CurrentPosition_mm and use it in debug prints --- src/logic/feed_to_bondtech.cpp | 4 ++-- src/logic/feed_to_finda.cpp | 4 ++-- src/logic/retract_from_finda.cpp | 4 ++-- src/logic/unload_to_finda.cpp | 2 +- src/modules/pulley.cpp | 2 +- src/modules/pulley.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index 9494ce3..8d273a6 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -33,7 +33,7 @@ bool FeedToBondtech::Step() { case EngagingIdler: if (mi::idler.Engaged()) { dbg_logic_P(PSTR("Feed to Bondtech --> Idler engaged")); - dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mpu::pulley.CurrentPositionPulley_mm()); state = PushingFilamentToFSensor; mpu::pulley.InitAxis(); mpu::pulley.PlanMove(config::defaultBowdenLength, config::pulleyLoadFeedrate, config::pulleySlowFeedrate); @@ -63,7 +63,7 @@ bool FeedToBondtech::Step() { case DisengagingIdler: if (!mi::idler.Engaged()) { dbg_logic_P(PSTR("Feed to Bondtech --> Idler disengaged")); - dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPositionPulley_mm()); state = OK; mpu::pulley.Disable(); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on); diff --git a/src/logic/feed_to_finda.cpp b/src/logic/feed_to_finda.cpp index 83f714b..17cdd4b 100644 --- a/src/logic/feed_to_finda.cpp +++ b/src/logic/feed_to_finda.cpp @@ -28,7 +28,7 @@ bool FeedToFinda::Step() { case EngagingIdler: if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) { dbg_logic_P(PSTR("Feed to Finda --> Idler engaged")); - dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mpu::pulley.CurrentPositionPulley_mm()); state = PushingFilament; mpu::pulley.InitAxis(); // @@TODO this may never happen as load filament always assumes the filament is at least at the pulley @@ -46,7 +46,7 @@ bool FeedToFinda::Step() { // FINDA triggered - that means it works and detected the filament tip mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector); dbg_logic_P(PSTR("Feed to Finda --> Idler disengaged")); - dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPositionPulley_mm()); state = OK; return true; // return immediately to allow for a seamless planning of another move (like feeding to bondtech) } else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on diff --git a/src/logic/retract_from_finda.cpp b/src/logic/retract_from_finda.cpp index 9c1cb27..6660347 100644 --- a/src/logic/retract_from_finda.cpp +++ b/src/logic/retract_from_finda.cpp @@ -21,7 +21,7 @@ bool RetractFromFinda::Step() { switch (state) { case EngagingIdler: if (mi::idler.Engaged()) { - dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mpu::pulley.CurrentPositionPulley_mm()); state = UnloadBackToPTFE; mpu::pulley.PlanMove(-(config::cuttingEdgeToFindaMidpoint + config::cuttingEdgeRetract), config::pulleyUnloadFeedrate); } @@ -32,7 +32,7 @@ bool RetractFromFinda::Step() { if (!mf::finda.Pressed()) { // FINDA switched off correctly while the move was performed state = OK; mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::AtPulley); - dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPositionPulley_mm()); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); } else { // FINDA didn't switch off state = Failed; diff --git a/src/logic/unload_to_finda.cpp b/src/logic/unload_to_finda.cpp index c78ee24..725e065 100644 --- a/src/logic/unload_to_finda.cpp +++ b/src/logic/unload_to_finda.cpp @@ -43,7 +43,7 @@ bool UnloadToFinda::Step() { if (mi::idler.Engaged()) { state = WaitingForFINDA; mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InSelector); - unloadStart_mm = mpu::pulley.CurrentPositionPulley_mm(); + unloadStart_mm = mpu::pulley.CurrentPosition_mm(); mpu::pulley.PlanMove(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, config::pulleyUnloadFeedrate); } return false; diff --git a/src/modules/pulley.cpp b/src/modules/pulley.cpp index f6eb4c9..e3678d8 100644 --- a/src/modules/pulley.cpp +++ b/src/modules/pulley.cpp @@ -38,7 +38,7 @@ void Pulley::PlanMove(unit::U_mm delta, unit::U_mm_s feed_rate, unit::U_mm_s end state = Moving; } -int32_t Pulley::CurrentPositionPulley_mm() { +int32_t Pulley::CurrentPosition_mm() { return mm::stepsToUnit(mm::P_pos_t({ mm::motion.CurPosition(mm::Pulley) })); } diff --git a/src/modules/pulley.h b/src/modules/pulley.h index 38918cc..8f3f217 100644 --- a/src/modules/pulley.h +++ b/src/modules/pulley.h @@ -29,7 +29,7 @@ public: /// @returns rounded current position (rotation) of the Pulley /// This exists purely to avoid expensive float (long double) computations of distance traveled by the filament - int32_t CurrentPositionPulley_mm(); + int32_t CurrentPosition_mm(); void InitAxis(); void Disable();