From 6f3540a14d784d64270632a552b3fd589705631a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 2 Sep 2021 11:24:40 +0200 Subject: [PATCH] Fix Motion::SetMode(axis, mode) and introduce SetMode(mode) Motion::SetMode(axis, mode) was incorrectly looping through all axes, setting the same axis three times. Fix this and introduce Motion::SetMode(mode) which actually loops through all axes (see PR #110) --- src/modules/motion.cpp | 6 +++++- src/modules/motion.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/motion.cpp b/src/modules/motion.cpp index 879ffea..94bd9af 100644 --- a/src/modules/motion.cpp +++ b/src/modules/motion.cpp @@ -28,8 +28,12 @@ void Motion::SetEnabled(Axis axis, bool enabled) { } void Motion::SetMode(Axis axis, MotorMode mode) { + axisData[axis].drv.SetMode(axisParams[axis].params, mode); +} + +void Motion::SetMode(MotorMode mode) { for (uint8_t i = 0; i != NUM_AXIS; ++i) - axisData[axis].drv.SetMode(axisParams[axis].params, mode); + axisData[i].drv.SetMode(axisParams[i].params, mode); } bool Motion::StallGuard(Axis axis) { diff --git a/src/modules/motion.h b/src/modules/motion.h index 472b9b7..d78924b 100644 --- a/src/modules/motion.h +++ b/src/modules/motion.h @@ -92,6 +92,9 @@ public: /// being performed by calling QueueEmpty(). void SetMode(Axis axis, MotorMode mode); + /// Set the same mode of TMC/motors operation for all axes. @see SetMode + void SetMode(MotorMode mode); + /// @returns true if a stall guard event occurred recently on the axis bool StallGuard(Axis axis);