From 7ab56b98122540a225ae48fa041078f51a4322d7 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 1 Mar 2023 08:07:28 +0100 Subject: [PATCH] Cleanup HoldOn-Resume code in movables --- src/logic/command_base.cpp | 7 ------- src/modules/movable_base.cpp | 8 ++++++++ src/modules/movable_base.h | 6 ++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/logic/command_base.cpp b/src/logic/command_base.cpp index 5fe0236..6bbd06a 100644 --- a/src/logic/command_base.cpp +++ b/src/logic/command_base.cpp @@ -179,15 +179,8 @@ void CommandBase::InvalidateHomingAndFilamentState() { } void CommandBase::HoldIdlerSelector() { - mm::motion.AbortPlannedMoves(mm::Idler); mi::idler.HoldOn(); - mm::motion.AbortPlannedMoves(mm::Selector); ms::selector.HoldOn(); - - // Force turn off motors - prevent overheating and allow servicing during and error state. - // And don't worry about TMC2130 creep after axis enabled - we'll rehome both axes later when needed. - mm::motion.Disable(mm::Idler); - mm::motion.Disable(mm::Selector); } void CommandBase::ResumeIdlerSelector() { diff --git a/src/modules/movable_base.cpp b/src/modules/movable_base.cpp index 7a91e7c..1505221 100644 --- a/src/modules/movable_base.cpp +++ b/src/modules/movable_base.cpp @@ -31,6 +31,14 @@ void __attribute__((noinline)) MovableBase::SetCurrents(uint8_t iRun, uint8_t iH mm::motion.DriverForAxis(axis).SetCurrents(mm::axisParams[axis].params, tempCurrent); } +void MovableBase::HoldOn() { + state = OnHold; + mm::motion.AbortPlannedMoves(axis); + // Force turn off motors - prevent overheating and allow servicing during an error state. + // And don't worry about TMC2130 creep after axis enabled - we'll rehome both axes later when needed. + mm::motion.Disable(axis); +} + MovableBase::OperationResult MovableBase::InitMovement() { if (motion.InitAxis(axis)) { return InitMovementNoReinitAxis(); diff --git a/src/modules/movable_base.h b/src/modules/movable_base.h index 273e850..c32aae7 100644 --- a/src/modules/movable_base.h +++ b/src/modules/movable_base.h @@ -75,8 +75,10 @@ public: void SetCurrents(uint8_t iRun, uint8_t iHold); /// Puts the movable on-hold - void HoldOn() { state = OnHold; } - /// Allows the movable to move/home again + /// Also, disables the axis + void HoldOn(); + + /// Allows the movable to move/home again after begin suspended by HoldOn void Resume() { state = Ready; } #ifndef UNITTEST