From d35bcd258a6b9c7be6c30edf9911202134c8eb3e Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Tue, 12 Oct 2021 19:15:01 +0200 Subject: [PATCH] Refactor after rebase onto main --- src/debug.h | 3 +-- src/logic/eject_filament.cpp | 2 +- src/logic/feed_to_bondtech.cpp | 4 ++-- src/logic/feed_to_finda.cpp | 4 ++-- src/logic/retract_from_finda.cpp | 4 ++-- src/modules/idler.cpp | 2 +- src/modules/motion.cpp | 2 +- src/modules/selector.cpp | 2 +- 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/debug.h b/src/debug.h index 6fe92b8..e5bc21b 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1,10 +1,9 @@ #pragma once #include #include "config/config.h" -#include /// Enable DEBUG_LOGIC to compile debugging and error messages (beware of code base size ;) ) for the logic layer -//#define DEBUG_LOGIC +#define DEBUG_LOGIC /// Enable DEBUG_LOGIC to compile debugging and error messages (beware of code base size ;) ) for the logic layer //#define DEBUG_MODULES diff --git a/src/logic/eject_filament.cpp b/src/logic/eject_filament.cpp index 324fff3..6515cb3 100644 --- a/src/logic/eject_filament.cpp +++ b/src/logic/eject_filament.cpp @@ -71,7 +71,7 @@ bool EjectFilament::StepInner() { } break; case ProgressCode::OK: - dbg_logic_sprintf_P(PSTR("FilamentLoadState after Eject %d"), mg::globals.FilamentLoaded()); + dbg_logic_fP(PSTR("FilamentLoadState after Eject %d"), mg::globals.FilamentLoaded()); return true; default: // we got into an unhandled state, better report it state = ProgressCode::ERRInternal; diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index 473e5e0..bd2deb6 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -23,7 +23,7 @@ bool FeedToBondtech::Step() { case EngagingIdler: if (mi::idler.Engaged()) { dbg_logic_P(PSTR("Feed to Bondtech --> Idler engaged")); - dbg_logic_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); state = PushingFilamentToFSensor; mm::motion.InitAxis(mm::Pulley); mm::motion.PlanMove(config::defaultBowdenLength, config::pulleyFeedrate); //@@TODO constants - there was some strange acceleration sequence in the original FW, @@ -56,7 +56,7 @@ bool FeedToBondtech::Step() { case DisengagingIdler: if (!mi::idler.Engaged()) { dbg_logic_P(PSTR("Feed to Bondtech --> Idler disengaged")); - dbg_logic_sprintf_P(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); state = OK; mm::motion.Disable(mm::Pulley); 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 760ab99..f8fff3b 100644 --- a/src/logic/feed_to_finda.cpp +++ b/src/logic/feed_to_finda.cpp @@ -25,7 +25,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_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); state = PushingFilament; mm::motion.InitAxis(mm::Pulley); if (mg::globals.FilamentLoaded() == mg::FilamentLoadState::NotLoaded) { // feed slowly filament to PTFE @@ -42,7 +42,7 @@ bool FeedToFinda::Step() { // FINDA triggered - that means it works and detected the filament tip mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InSelector); dbg_logic_P(PSTR("Feed to Finda --> Idler disengaged")); - dbg_logic_sprintf_P(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); state = OK; } else if (mm::motion.QueueEmpty()) { // all moves have been finished and FINDA didn't switch on state = Failed; diff --git a/src/logic/retract_from_finda.cpp b/src/logic/retract_from_finda.cpp index dc84129..d41c6e8 100644 --- a/src/logic/retract_from_finda.cpp +++ b/src/logic/retract_from_finda.cpp @@ -19,7 +19,7 @@ bool RetractFromFinda::Step() { switch (state) { case EngagingIdler: if (mi::idler.Engaged()) { - dbg_logic_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley)); state = UnloadBackToPTFE; mm::motion.PlanMove(-(config::cuttingEdgeToFindaMidpoint + config::cuttingEdgeRetract), config::pulleyFeedrate); } @@ -30,7 +30,7 @@ bool RetractFromFinda::Step() { if (!mf::finda.Pressed()) { // FINDA switched off correctly while the move was performed state = OK; mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley); - dbg_logic_sprintf_P(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); + dbg_logic_fP(PSTR("Pulley end steps %u"), mm::motion.CurPosition(mm::Pulley)); ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off); } else { // FINDA didn't switch off state = Failed; diff --git a/src/modules/idler.cpp b/src/modules/idler.cpp index 7657e5d..cf5a2f1 100644 --- a/src/modules/idler.cpp +++ b/src/modules/idler.cpp @@ -12,7 +12,7 @@ Idler idler; void Idler::PrepareMoveToPlannedSlot() { mm::motion.PlanMoveTo(SlotPosition(plannedSlot), mm::unitToAxisUnit(config::idlerFeedrate)); - dbg_logic_sprintf_P(PSTR("Prepare Move Idler slot %d"), plannedSlot); + dbg_logic_fP(PSTR("Prepare Move Idler slot %d"), plannedSlot); } void Idler::PlanHomingMove() { diff --git a/src/modules/motion.cpp b/src/modules/motion.cpp index 4d08011..8f2779e 100644 --- a/src/modules/motion.cpp +++ b/src/modules/motion.cpp @@ -46,7 +46,7 @@ void Motion::StallGuardReset(Axis axis) { } void Motion::PlanMoveTo(Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rate) { - dbg_logic_sprintf_P(PSTR("Move axis %d to %u"), axis, pos); + dbg_logic_fP(PSTR("Move axis %d to %u"), axis, pos); if (axisData[axis].ctrl.PlanMoveTo(pos, feed_rate, end_rate)) { // move was queued, prepare the axis diff --git a/src/modules/selector.cpp b/src/modules/selector.cpp index bbf124f..2a1428c 100644 --- a/src/modules/selector.cpp +++ b/src/modules/selector.cpp @@ -12,7 +12,7 @@ Selector selector; void Selector::PrepareMoveToPlannedSlot() { mm::motion.PlanMoveTo(SlotPosition(plannedSlot), mm::unitToAxisUnit(config::selectorFeedrate)); - dbg_logic_sprintf_P(PSTR("Prepare Move Selector slot %d"), plannedSlot); + dbg_logic_fP(PSTR("Prepare Move Selector slot %d"), plannedSlot); } void Selector::PlanHomingMove() {