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)
pull/110/head
Yuri D'Elia 2021-09-02 11:24:40 +02:00 committed by DRracer
parent e7cba346da
commit 6f3540a14d
2 changed files with 8 additions and 1 deletions

View File

@ -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) {

View File

@ -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);