Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/DDA.cpp54
-rw-r--r--src/Movement/DDA.h2
-rw-r--r--src/Movement/Kinematics/CoreKinematics.cpp10
-rw-r--r--src/Movement/Kinematics/FiveBarScaraKinematics.cpp16
-rw-r--r--src/Movement/Kinematics/HangprinterKinematics.cpp19
-rw-r--r--src/Movement/Kinematics/Kinematics.cpp14
-rw-r--r--src/Movement/Kinematics/Kinematics.h4
-rw-r--r--src/Movement/Kinematics/LinearDeltaKinematics.cpp19
-rw-r--r--src/Movement/Kinematics/LinearDeltaKinematics.h2
-rw-r--r--src/Movement/Kinematics/PolarKinematics.cpp16
-rw-r--r--src/Movement/Kinematics/RotaryDeltaKinematics.cpp19
-rw-r--r--src/Movement/Kinematics/RotaryDeltaKinematics.h2
-rw-r--r--src/Movement/Kinematics/ScaraKinematics.cpp16
-rw-r--r--src/Movement/Move.cpp42
-rw-r--r--src/Movement/StepperDrivers/TMC2660.cpp12
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp4
-rw-r--r--src/Movement/StraightProbeSettings.cpp2
-rw-r--r--src/Movement/StraightProbeSettings.h2
18 files changed, 119 insertions, 136 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index 7e387e74..9041591b 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -308,7 +308,7 @@ bool DDA::InitStandardMove(DDARing& ring, const RawMove &nextMove, bool doMotorM
{
const float positionDelta = endCoordinates[drive] - prev->GetEndCoordinate(drive, false);
directionVector[drive] = positionDelta;
- if (positionDelta != 0.0 && (IsBitSet(Tool::GetXAxes(nextMove.tool), drive) || IsBitSet(Tool::GetYAxes(nextMove.tool), drive)))
+ if (positionDelta != 0.0 && (Tool::GetXAxes(nextMove.tool).IsBitSet(drive) || Tool::GetYAxes(nextMove.tool).IsBitSet(drive)))
{
flags.xyMoving = true;
}
@@ -1253,16 +1253,16 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
platform.EnableLocalDrivers(Z_AXIS); // ensure all Z motors are enabled
}
- AxesBitmap additionalAxisMotorsToEnable = 0, axisMotorsEnabled = 0;
+ AxesBitmap additionalAxisMotorsToEnable, axisMotorsEnabled;
#if SUPPORT_CAN_EXPANSION
- afterPrepare.drivesMoving = 0;
+ afterPrepare.drivesMoving.Clear();
#endif
for (size_t drive = 0; drive < MaxAxesPlusExtruders; ++drive)
{
if (flags.isLeadscrewAdjustmentMove)
{
#if SUPPORT_CAN_EXPANSION
- SetBit(afterPrepare.drivesMoving, Z_AXIS);
+ afterPrepare.drivesMoving.SetBit(Z_AXIS);
#endif
// For a leadscrew adjustment move, the first N elements of the direction vector are the adjustments to the N Z motors
const AxisDriversConfig& config = platform.GetAxisDriversConfig(Z_AXIS);
@@ -1330,7 +1330,7 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
}
#if SUPPORT_CAN_EXPANSION
- SetBit(afterPrepare.drivesMoving, drive);
+ afterPrepare.drivesMoving.SetBit(drive);
const AxisDriversConfig& config = platform.GetAxisDriversConfig(drive);
for (size_t i = 0; i < config.numDrivers; ++i)
{
@@ -1341,7 +1341,7 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
}
}
#endif
- SetBit(axisMotorsEnabled, drive);
+ axisMotorsEnabled.SetBit(drive);
}
else if (drive < reprap.GetGCodes().GetTotalAxes())
{
@@ -1386,7 +1386,7 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
}
#if SUPPORT_CAN_EXPANSION
- SetBit(afterPrepare.drivesMoving, drive);
+ afterPrepare.drivesMoving.SetBit(drive);
const AxisDriversConfig& config = platform.GetAxisDriversConfig(drive);
for (size_t i = 0; i < config.numDrivers; ++i)
{
@@ -1397,7 +1397,7 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
}
}
#endif
- SetBit(axisMotorsEnabled, drive);
+ axisMotorsEnabled.SetBit(drive);
additionalAxisMotorsToEnable |= reprap.GetMove().GetKinematics().GetConnectedAxes(drive);
}
}
@@ -1421,7 +1421,7 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
const size_t extruder = LogicalDriveToExtruder(drive);
#if SUPPORT_CAN_EXPANSION
- SetBit(afterPrepare.drivesMoving, drive);
+ afterPrepare.drivesMoving.SetBit(drive);
const DriverId driver = platform.GetExtruderDriver(extruder);
if (driver.IsRemote())
{
@@ -1468,27 +1468,25 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
// On CoreXY and similar architectures, we also need to enable the motors controlling any connected axes
additionalAxisMotorsToEnable &= ~axisMotorsEnabled;
- for (size_t drive = 0; additionalAxisMotorsToEnable != 0; ++drive)
+ while (additionalAxisMotorsToEnable.IsNonEmpty())
{
- if (IsBitSet(additionalAxisMotorsToEnable, drive))
+ const size_t drive = additionalAxisMotorsToEnable.LowestSetBit();
+ additionalAxisMotorsToEnable.ClearBit(drive);
+ if (platform.GetDriversBitmap(drive) != 0) // if any of the connected axis drives is local
{
- ClearBit(additionalAxisMotorsToEnable, drive);
- if (platform.GetDriversBitmap(drive) != 0) // if any of the connected axis drives is local
- {
- platform.EnableLocalDrivers(drive);
- }
+ platform.EnableLocalDrivers(drive);
+ }
#if SUPPORT_CAN_EXPANSION
- const AxisDriversConfig& config = platform.GetAxisDriversConfig(drive);
- for (size_t i = 0; i < config.numDrivers; ++i)
+ const AxisDriversConfig& config = platform.GetAxisDriversConfig(drive);
+ for (size_t i = 0; i < config.numDrivers; ++i)
+ {
+ const DriverId driver = config.driverNumbers[i];
+ if (driver.IsRemote())
{
- const DriverId driver = config.driverNumbers[i];
- if (driver.IsRemote())
- {
- CanMotion::AddMovement(*this, params, driver, 0, false);
- }
+ CanMotion::AddMovement(*this, params, driver, 0, false);
}
-#endif
}
+#endif
}
const DDAState st = prev->state;
@@ -1578,12 +1576,12 @@ float DDA::NormaliseXYZ() noexcept
const AxesBitmap yAxes = Tool::GetYAxes(tool);
for (size_t d = 0; d < MaxAxes; ++d)
{
- if (IsBitSet(xAxes, d))
+ if (xAxes.IsBitSet(d))
{
xMagSquared += fsquare(directionVector[d]);
++numXaxes;
}
- if (IsBitSet(yAxes, d))
+ if (yAxes.IsBitSet(d))
{
yMagSquared += fsquare(directionVector[d]);
++numYaxes;
@@ -1950,8 +1948,8 @@ void DDA::StopDrive(size_t drive) noexcept
}
#if SUPPORT_CAN_EXPANSION
- ClearBit(afterPrepare.drivesMoving, drive);
- if (afterPrepare.drivesMoving == 0)
+ afterPrepare.drivesMoving.ClearBit(drive);
+ if (afterPrepare.drivesMoving.IsEmpty())
{
state = completed;
}
diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h
index cc13fdff..48b54640 100644
--- a/src/Movement/DDA.h
+++ b/src/Movement/DDA.h
@@ -267,7 +267,7 @@ private:
int32_t cKc; // The Z movement fraction multiplied by Kc and converted to integer
#if SUPPORT_CAN_EXPANSION
- uint32_t drivesMoving; // bitmap of logical drives moving - needed to keep track of whether remote drives are moving
+ DriversBitmap drivesMoving; // bitmap of logical drives moving - needed to keep track of whether remote drives are moving
static_assert(MaxAxesPlusExtruders <= sizeof(drivesMoving) * CHAR_BIT);
#endif
} afterPrepare;
diff --git a/src/Movement/Kinematics/CoreKinematics.cpp b/src/Movement/Kinematics/CoreKinematics.cpp
index ac8a30e0..ad0a6e99 100644
--- a/src/Movement/Kinematics/CoreKinematics.cpp
+++ b/src/Movement/Kinematics/CoreKinematics.cpp
@@ -60,7 +60,7 @@ void CoreKinematics::Recalc()
{
firstMotor[i] = firstAxis[i] = MaxAxes;
lastMotor[i] = lastAxis[i] = 0;
- connectedAxes[i] = 0;
+ connectedAxes[i].Clear();
}
for (size_t axis = 0; axis < MaxAxes; ++axis)
@@ -77,7 +77,7 @@ void CoreKinematics::Recalc()
{
lastAxis[motor] = axis;
}
- SetBit(connectedAxes[axis], motor);
+ connectedAxes[axis].SetBit(motor);
}
if (forwardMatrix(motor, axis) != 0.0) // if this motor affects this axes
@@ -90,7 +90,7 @@ void CoreKinematics::Recalc()
{
lastMotor[axis] = motor;
}
- SetBit(connectedAxes[axis], motor);
+ connectedAxes[axis].SetBit(motor);
}
}
}
@@ -120,7 +120,7 @@ void CoreKinematics::Recalc()
// Return true if the axis doesn't have a single dedicated motor
inline bool CoreKinematics::HasSharedMotor(size_t axis) const
{
- return connectedAxes[axis] != MakeBitmap<AxesBitmap>(axis);
+ return connectedAxes[axis] != AxesBitmap::MakeFromBits(axis);
}
CoreKinematics::CoreKinematics(KinematicsType k) : ZLeadscrewKinematics(k), modified(false)
@@ -408,7 +408,7 @@ AxesBitmap CoreKinematics::GetConnectedAxes(size_t axis) const
// This is called to determine whether we can babystep the specified axis independently of regular motion.
AxesBitmap CoreKinematics::GetLinearAxes() const
{
- return LowestNBits<AxesBitmap>(reprap.GetGCodes().GetVisibleAxes()); // we can babystep all axes
+ return AxesBitmap::MakeLowestNBits(reprap.GetGCodes().GetVisibleAxes()); // we can babystep all axes
}
// End
diff --git a/src/Movement/Kinematics/FiveBarScaraKinematics.cpp b/src/Movement/Kinematics/FiveBarScaraKinematics.cpp
index 0a7e7a40..ea16329c 100644
--- a/src/Movement/Kinematics/FiveBarScaraKinematics.cpp
+++ b/src/Movement/Kinematics/FiveBarScaraKinematics.cpp
@@ -819,10 +819,9 @@ void FiveBarScaraKinematics::GetAssumedInitialPosition(size_t numAxes, float pos
AxesBitmap FiveBarScaraKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If both X and Y have been specified then we know the positions of both arm motors, otherwise we don't
- const AxesBitmap xyAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS);
- if ((g92Axes & xyAxes) != xyAxes)
+ if ((g92Axes & XyAxes) != XyAxes)
{
- g92Axes &= ~xyAxes;
+ g92Axes &= ~XyAxes;
}
return g92Axes;
}
@@ -830,10 +829,9 @@ AxesBitmap FiveBarScaraKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap FiveBarScaraKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((axesMoving & xyzAxes) != 0)
+ if (axesMoving.Intersects(XyzAxes))
{
- axesMoving |= xyzAxes;
+ axesMoving |= XyzAxes;
}
return axesMoving;
}
@@ -911,14 +909,14 @@ bool FiveBarScaraKinematics::IsContinuousRotationAxis(size_t axis) const
AxesBitmap FiveBarScaraKinematics::GetLinearAxes() const
{
- return MakeBitmap<AxesBitmap>(Z_AXIS);
+ return AxesBitmap::MakeFromBits(Z_AXIS);
}
AxesBitmap FiveBarScaraKinematics::GetConnectedAxes(size_t axis) const
{
return (axis == X_AXIS || axis == Y_AXIS)
- ? MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS)
- : MakeBitmap<AxesBitmap>(axis);
+ ? XyAxes
+ : AxesBitmap::MakeFromBits(axis);
}
// Recalculate the derived parameters
diff --git a/src/Movement/Kinematics/HangprinterKinematics.cpp b/src/Movement/Kinematics/HangprinterKinematics.cpp
index 54f431b9..5b11bf46 100644
--- a/src/Movement/Kinematics/HangprinterKinematics.cpp
+++ b/src/Movement/Kinematics/HangprinterKinematics.cpp
@@ -175,9 +175,8 @@ bool HangprinterKinematics::IsReachable(float x, float y, bool isCoordinated) co
// Limit the Cartesian position that the user wants to move to returning true if we adjusted the position
LimitPositionResult HangprinterKinematics::LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesHomed, bool isCoordinated, bool applyM208Limits) const
{
- const AxesBitmap allAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
bool limited = false;
- if ((axesHomed & allAxes) == allAxes)
+ if ((axesHomed & XyzAxes) == XyzAxes)
{
// If axes have been homed on a delta printer and this isn't a homing move, check for movements outside limits.
// Skip this check if axes have not been homed, so that extruder-only moves are allowed before homing
@@ -225,7 +224,7 @@ void HangprinterKinematics::GetAssumedInitialPosition(size_t numAxes, float posi
AxesBitmap HangprinterKinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
filename.copy("homeall.g");
- return 0;
+ return AxesBitmap();
}
// This function is called from the step ISR when an endstop switch is triggered during homing.
@@ -246,14 +245,13 @@ void HangprinterKinematics::OnHomingSwitchTriggered(size_t axis, bool highEnd, c
AxesBitmap HangprinterKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If all of X, Y and Z have been specified then we know the positions of all 4 spool motors, otherwise we don't
- const uint32_t xyzAxes = (1u << X_AXIS) | (1u << Y_AXIS) | (1u << Z_AXIS);
- if ((g92Axes & xyzAxes) == xyzAxes)
+ if ((g92Axes & XyzAxes) == XyzAxes)
{
- g92Axes |= (1u << D_AXIS);
+ g92Axes.SetBit(D_AXIS);
}
else
{
- g92Axes &= ~xyzAxes;
+ g92Axes &= ~XyzAxes;
}
return g92Axes;
}
@@ -261,10 +259,9 @@ AxesBitmap HangprinterKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap HangprinterKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((axesMoving & xyzAxes) != 0)
+ if (axesMoving.Intersects(XyzAxes))
{
- axesMoving |= xyzAxes;
+ axesMoving |= XyzAxes;
}
return axesMoving;
}
@@ -288,7 +285,7 @@ void HangprinterKinematics::LimitSpeedAndAcceleration(DDA& dda, const float *nor
// This is called to determine whether we can babystep the specified axis independently of regular motion.
AxesBitmap HangprinterKinematics::GetLinearAxes() const
{
- return 0;
+ return AxesBitmap();
}
#if HAS_MASS_STORAGE
diff --git a/src/Movement/Kinematics/Kinematics.cpp b/src/Movement/Kinematics/Kinematics.cpp
index 1a6a50bf..668eb4bf 100644
--- a/src/Movement/Kinematics/Kinematics.cpp
+++ b/src/Movement/Kinematics/Kinematics.cpp
@@ -70,7 +70,7 @@ bool Kinematics::LimitPositionFromAxis(float coords[], size_t firstAxis, size_t
bool limited = false;
for (size_t axis = firstAxis; axis < numVisibleAxes; axis++)
{
- if (IsBitSet(axesHomed, axis))
+ if (axesHomed.IsBitSet(axis))
{
float& f = coords[axis];
// When homing a printer we convert the M208 axis limit to motor positions, then back again to get the user position.
@@ -107,26 +107,26 @@ void Kinematics::GetAssumedInitialPosition(size_t numAxes, float positions[]) co
// This default is suitable for most kinematics.
AxesBitmap Kinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
- const AxesBitmap allAxes = LowestNBits<AxesBitmap>(numVisibleAxes);
+ const AxesBitmap allAxes = AxesBitmap::MakeLowestNBits(numVisibleAxes);
if ((toBeHomed & allAxes) == allAxes)
{
filename.copy(HomeAllFileName);
- return 0;
+ return AxesBitmap();
}
// If Z homing is done using a Z probe then X and Y must be homed before Z
- const bool homeZLast = (IsBitSet(toBeHomed, Z_AXIS) && reprap.GetPlatform().GetEndstops().HomingZWithProbe());
+ const bool homeZLast = (toBeHomed.IsBitSet(Z_AXIS) && reprap.GetPlatform().GetEndstops().HomingZWithProbe());
const AxesBitmap homeFirst = AxesToHomeBeforeProbing();
// Return the homing file for the lowest axis that we have been asked to home
for (size_t axis = 0; axis < numVisibleAxes; ++axis)
{
- if (IsBitSet(toBeHomed, axis) && (axis != Z_AXIS || !homeZLast || (alreadyHomed & homeFirst) == homeFirst))
+ if (toBeHomed.IsBitSet(axis) && (axis != Z_AXIS || !homeZLast || (alreadyHomed & homeFirst) == homeFirst))
{
filename.copy("home");
filename.cat(tolower(reprap.GetGCodes().GetAxisLetters()[axis]));
filename.cat(".g");
- return 0;
+ return AxesBitmap();
}
}
@@ -138,7 +138,7 @@ AxesBitmap Kinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alread
// Usually it is just the corresponding motor (hence this default implementation), but CoreXY and similar kinematics move multiple motors to home an individual axis.
AxesBitmap Kinematics::GetConnectedAxes(size_t axis) const
{
- return MakeBitmap<AxesBitmap>(axis);
+ return AxesBitmap::MakeFromBits(axis);
}
/*static*/ Kinematics *Kinematics::Create(KinematicsType k)
diff --git a/src/Movement/Kinematics/Kinematics.h b/src/Movement/Kinematics/Kinematics.h
index a8893c0b..57a9e031 100644
--- a/src/Movement/Kinematics/Kinematics.h
+++ b/src/Movement/Kinematics/Kinematics.h
@@ -131,7 +131,7 @@ public:
// Return the set of axes that must have been homed before bed probing is allowed
// The default implementation requires just X and Y, but some kinematics require additional axes to be homed (e.g. delta, CoreXZ)
- virtual AxesBitmap AxesToHomeBeforeProbing() const { return MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS); }
+ virtual AxesBitmap AxesToHomeBeforeProbing() const { return XyAxes; }
// Return the initial Cartesian coordinates we assume after switching to this kinematics
virtual void GetAssumedInitialPosition(size_t numAxes, float positions[]) const;
@@ -168,7 +168,7 @@ public:
// Return the set of axes that must be homed prior to regular movement of the specified axes
// This default is good for Cartesian and Core printers, but not deltas or SCARA
- virtual AxesBitmap MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const { return (disallowMovesBeforeHoming) ? axesMoving : 0; }
+ virtual AxesBitmap MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const { return (disallowMovesBeforeHoming) ? axesMoving : AxesBitmap(); }
#if HAS_MASS_STORAGE
// Write any calibration data that we need to resume a print after power fail, returning true if successful. Override where necessary.
diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.cpp b/src/Movement/Kinematics/LinearDeltaKinematics.cpp
index 1abdcd76..7e158927 100644
--- a/src/Movement/Kinematics/LinearDeltaKinematics.cpp
+++ b/src/Movement/Kinematics/LinearDeltaKinematics.cpp
@@ -206,12 +206,11 @@ bool LinearDeltaKinematics::IsReachable(float x, float y, bool isCoordinated) co
// Limit the Cartesian position that the user wants to move to returning true if we adjusted the position
LimitPositionResult LinearDeltaKinematics::LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesHomed, bool isCoordinated, bool applyM208Limits) const
{
- constexpr AxesBitmap allAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
bool limited = false;
// If axes have been homed on a delta printer and this isn't a homing move, check for movements outside limits.
// Skip this check if axes have not been homed, so that extruder-only moves are allowed before homing
- if ((axesHomed & allAxes) == allAxes)
+ if ((axesHomed & XyzAxes) == XyzAxes)
{
// Constrain the move to be within the build radius
const float diagonalSquared = fsquare(finalCoords[X_AXIS]) + fsquare(finalCoords[Y_AXIS]);
@@ -933,10 +932,9 @@ bool LinearDeltaKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, const
AxesBitmap LinearDeltaKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If all of X, Y and Z have been specified then we know the positions of all 3 tower motors, otherwise we don't
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((g92Axes & xyzAxes) != xyzAxes)
+ if ((g92Axes & XyzAxes) != XyzAxes)
{
- g92Axes &= ~xyzAxes;
+ g92Axes &= ~XyzAxes;
}
return g92Axes;
}
@@ -944,10 +942,9 @@ AxesBitmap LinearDeltaKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap LinearDeltaKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((axesMoving & xyzAxes) != 0)
+ if (axesMoving.Intersects(XyzAxes))
{
- axesMoving |= xyzAxes;
+ axesMoving |= XyzAxes;
}
return axesMoving;
}
@@ -958,10 +955,10 @@ AxesBitmap LinearDeltaKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool di
AxesBitmap LinearDeltaKinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
// If homing X, Y or Z we must home all the towers
- if ((toBeHomed & LowestNBits<AxesBitmap>(XYZ_AXES)) != 0)
+ if (toBeHomed.Intersects(XyzAxes))
{
filename.copy("homedelta.g");
- return 0;
+ return AxesBitmap();
}
return Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
@@ -1013,7 +1010,7 @@ void LinearDeltaKinematics::LimitSpeedAndAcceleration(DDA& dda, const float *nor
// The DDA class has special support for delta printers, so we can baystep the Z axis.
AxesBitmap LinearDeltaKinematics::GetLinearAxes() const
{
- return MakeBitmap<AxesBitmap>(Z_AXIS);
+ return AxesBitmap::MakeFromBits(Z_AXIS);
}
// End
diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.h b/src/Movement/Kinematics/LinearDeltaKinematics.h
index 1e203d6c..8a572e23 100644
--- a/src/Movement/Kinematics/LinearDeltaKinematics.h
+++ b/src/Movement/Kinematics/LinearDeltaKinematics.h
@@ -35,7 +35,7 @@ public:
bool IsReachable(float x, float y, bool isCoordinated) const override;
LimitPositionResult LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesHomed, bool isCoordinated, bool applyM208Limits) const override;
void GetAssumedInitialPosition(size_t numAxes, float positions[]) const override;
- AxesBitmap AxesToHomeBeforeProbing() const override { return MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS); }
+ AxesBitmap AxesToHomeBeforeProbing() const override { return XyzAxes; }
MotionType GetMotionType(size_t axis) const override;
size_t NumHomingButtons(size_t numVisibleAxes) const override { return 0; }
HomingMode GetHomingMode() const override { return HomingMode::homeIndividualMotors; }
diff --git a/src/Movement/Kinematics/PolarKinematics.cpp b/src/Movement/Kinematics/PolarKinematics.cpp
index 9f6446cb..44eb064d 100644
--- a/src/Movement/Kinematics/PolarKinematics.cpp
+++ b/src/Movement/Kinematics/PolarKinematics.cpp
@@ -184,10 +184,9 @@ void PolarKinematics::GetAssumedInitialPosition(size_t numAxes, float positions[
AxesBitmap PolarKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If both X and Y have been specified then we know the positions the radius motor and the turntable, otherwise we don't
- const AxesBitmap xyAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS);
- if ((g92Axes & xyAxes) != xyAxes)
+ if ((g92Axes & XyAxes) != XyAxes)
{
- g92Axes &= ~xyAxes;
+ g92Axes &= ~XyAxes;
}
return g92Axes;
}
@@ -195,10 +194,9 @@ AxesBitmap PolarKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap PolarKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((axesMoving & xyzAxes) != 0)
+ if (axesMoving.Intersects(XyzAxes))
{
- axesMoving |= xyzAxes;
+ axesMoving |= XyzAxes;
}
return axesMoving;
}
@@ -210,8 +208,8 @@ AxesBitmap PolarKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallow
AxesBitmap PolarKinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
// Ask the base class which homing file we should call first
- AxesBitmap ret = Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
- if (ret == 0)
+ const AxesBitmap ret = Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
+ if (ret.IsNonEmpty())
{
// Change the returned name if it is X or Y
if (StringEqualsIgnoreCase(filename.c_str(), "homex.g"))
@@ -293,7 +291,7 @@ bool PolarKinematics::IsContinuousRotationAxis(size_t axis) const
// This is called to determine whether we can babystep the specified axis independently of regular motion.
AxesBitmap PolarKinematics::GetLinearAxes() const
{
- return MakeBitmap<AxesBitmap>(Z_AXIS);
+ return AxesBitmap::MakeFromBits(Z_AXIS);
}
// Update the derived parameters after the master parameters have been changed
diff --git a/src/Movement/Kinematics/RotaryDeltaKinematics.cpp b/src/Movement/Kinematics/RotaryDeltaKinematics.cpp
index 60da78e5..72172997 100644
--- a/src/Movement/Kinematics/RotaryDeltaKinematics.cpp
+++ b/src/Movement/Kinematics/RotaryDeltaKinematics.cpp
@@ -242,9 +242,8 @@ bool RotaryDeltaKinematics::IsReachable(float x, float y, bool isCoordinated) co
// Limit the Cartesian position that the user wants to move to returning true if we adjusted the position
LimitPositionResult RotaryDeltaKinematics::LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesHomed, bool isCoordinated, bool applyM208Limits) const
{
- constexpr AxesBitmap allAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
bool limited = false;
- if ((axesHomed & allAxes) == allAxes)
+ if ((axesHomed & XyzAxes) == XyzAxes)
{
// If axes have been homed on a rotary delta printer and this isn't a homing move, check for movements outside limits.
// Skip this check if axes have not been homed, so that extruder-only moves are allowed before homing
@@ -293,10 +292,9 @@ void RotaryDeltaKinematics::GetAssumedInitialPosition(size_t numAxes, float posi
AxesBitmap RotaryDeltaKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If all of X, Y and Z have been specified then we know the positions of all 3 tower motors, otherwise we don't
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((g92Axes & xyzAxes) != xyzAxes)
+ if ((g92Axes & XyzAxes) != XyzAxes)
{
- g92Axes &= ~xyzAxes;
+ g92Axes &= ~XyzAxes;
}
return g92Axes;
}
@@ -304,10 +302,9 @@ AxesBitmap RotaryDeltaKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap RotaryDeltaKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyzAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS);
- if ((axesMoving & xyzAxes) != 0)
+ if (axesMoving.Intersects(XyzAxes))
{
- axesMoving |= xyzAxes;
+ axesMoving |= XyzAxes;
}
return axesMoving;
}
@@ -318,10 +315,10 @@ AxesBitmap RotaryDeltaKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool di
AxesBitmap RotaryDeltaKinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
// If homing X, Y or Z we must home all the towers
- if ((toBeHomed & LowestNBits<AxesBitmap>(DELTA_AXES)) != 0)
+ if (toBeHomed.Intersects(AxesBitmap::MakeLowestNBits(DELTA_AXES)))
{
filename.copy("homedelta.g");
- return 0;
+ return AxesBitmap();
}
return Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
@@ -384,7 +381,7 @@ void RotaryDeltaKinematics::LimitSpeedAndAcceleration(DDA& dda, const float *nor
// This is called to determine whether we can babystep the specified axis independently of regular motion.
AxesBitmap RotaryDeltaKinematics::GetLinearAxes() const
{
- return 0;
+ return AxesBitmap();
}
// Calculate the motor position for a single tower from a Cartesian coordinate.
diff --git a/src/Movement/Kinematics/RotaryDeltaKinematics.h b/src/Movement/Kinematics/RotaryDeltaKinematics.h
index 6fa2b595..380884df 100644
--- a/src/Movement/Kinematics/RotaryDeltaKinematics.h
+++ b/src/Movement/Kinematics/RotaryDeltaKinematics.h
@@ -30,7 +30,7 @@ public:
bool IsReachable(float x, float y, bool isCoordinated) const override;
LimitPositionResult LimitPosition(float finalCoords[], const float * null initialCoords, size_t numVisibleAxes, AxesBitmap axesHomed, bool isCoordinated, bool applyM208Limits) const override;
void GetAssumedInitialPosition(size_t numAxes, float positions[]) const override;
- AxesBitmap AxesToHomeBeforeProbing() const override { return MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS) | MakeBitmap<AxesBitmap>(Z_AXIS); }
+ AxesBitmap AxesToHomeBeforeProbing() const override { return XyzAxes; }
size_t NumHomingButtons(size_t numVisibleAxes) const override { return 0; }
HomingMode GetHomingMode() const override { return HomingMode::homeIndividualMotors; }
AxesBitmap AxesAssumedHomed(AxesBitmap g92Axes) const override;
diff --git a/src/Movement/Kinematics/ScaraKinematics.cpp b/src/Movement/Kinematics/ScaraKinematics.cpp
index b590bb58..cdd24c78 100644
--- a/src/Movement/Kinematics/ScaraKinematics.cpp
+++ b/src/Movement/Kinematics/ScaraKinematics.cpp
@@ -324,10 +324,9 @@ void ScaraKinematics::GetAssumedInitialPosition(size_t numAxes, float positions[
AxesBitmap ScaraKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
{
// If both X and Y have been specified then we know the positions of both arm motors, otherwise we don't
- const AxesBitmap xyAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS);
- if ((g92Axes & xyAxes) != xyAxes)
+ if ((g92Axes & XyAxes) != XyAxes)
{
- g92Axes &= ~xyAxes;
+ g92Axes &= ~XyAxes;
}
return g92Axes;
}
@@ -335,10 +334,9 @@ AxesBitmap ScaraKinematics::AxesAssumedHomed(AxesBitmap g92Axes) const
// Return the set of axes that must be homed prior to regular movement of the specified axes
AxesBitmap ScaraKinematics::MustBeHomedAxes(AxesBitmap axesMoving, bool disallowMovesBeforeHoming) const
{
- constexpr AxesBitmap xyAxes = MakeBitmap<AxesBitmap>(X_AXIS) | MakeBitmap<AxesBitmap>(Y_AXIS);
- if ((axesMoving & xyAxes) != 0)
+ if (axesMoving.Intersects(XyAxes))
{
- axesMoving |= xyAxes;
+ axesMoving |= XyAxes;
}
return axesMoving;
}
@@ -369,9 +367,9 @@ size_t ScaraKinematics::NumHomingButtons(size_t numVisibleAxes) const
AxesBitmap ScaraKinematics::GetHomingFileName(AxesBitmap toBeHomed, AxesBitmap alreadyHomed, size_t numVisibleAxes, const StringRef& filename) const
{
// Ask the base class which homing file we should call first
- AxesBitmap ret = Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
+ const AxesBitmap ret = Kinematics::GetHomingFileName(toBeHomed, alreadyHomed, numVisibleAxes, filename);
- if (ret == 0)
+ if (ret.IsEmpty())
{
// Change the returned name if it is X or Y
if (StringEqualsIgnoreCase(filename.c_str(), "homex.g"))
@@ -468,7 +466,7 @@ bool ScaraKinematics::IsContinuousRotationAxis(size_t axis) const
// This is called to determine whether we can babystep the specified axis independently of regular motion.
AxesBitmap ScaraKinematics::GetLinearAxes() const
{
- return (crosstalk[1] == 0.0 && crosstalk[2] == 0.0) ? MakeBitmap<AxesBitmap>(Z_AXIS) : 0;
+ return (crosstalk[1] == 0.0 && crosstalk[2] == 0.0) ? AxesBitmap::MakeFromBits(Z_AXIS) : AxesBitmap();
}
// Recalculate the derived parameters
diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp
index 56ccd6aa..49b1f954 100644
--- a/src/Movement/Move.cpp
+++ b/src/Movement/Move.cpp
@@ -80,24 +80,24 @@ constexpr ObjectModelTableEntry Move::objectModelTable[] =
{ "idle", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::none },
{ "initialDeviation", OBJECT_MODEL_FUNC(self, 5), ObjectModelEntryFlags::none },
{ "meshDeviation", OBJECT_MODEL_FUNC(self, 6), ObjectModelEntryFlags::none },
- { "printingAcceleration", OBJECT_MODEL_FUNC(self->maxPrintingAcceleration), ObjectModelEntryFlags::none },
- { "speedFactor", OBJECT_MODEL_FUNC_NOSELF(reprap.GetGCodes().GetSpeedFactor()), ObjectModelEntryFlags::live },
- { "travelAcceleration", OBJECT_MODEL_FUNC(self->maxTravelAcceleration), ObjectModelEntryFlags::none },
+ { "printingAcceleration", OBJECT_MODEL_FUNC(self->maxPrintingAcceleration, 1), ObjectModelEntryFlags::none },
+ { "speedFactor", OBJECT_MODEL_FUNC_NOSELF(reprap.GetGCodes().GetSpeedFactor(), 1), ObjectModelEntryFlags::live },
+ { "travelAcceleration", OBJECT_MODEL_FUNC(self->maxTravelAcceleration, 1), ObjectModelEntryFlags::none },
// 1. Move.Daa members
{ "enabled", OBJECT_MODEL_FUNC(self->drcEnabled), ObjectModelEntryFlags::none },
- { "minimumAcceleration", OBJECT_MODEL_FUNC(self->drcMinimumAcceleration), ObjectModelEntryFlags::none },
- { "period", OBJECT_MODEL_FUNC(self->drcPeriod), ObjectModelEntryFlags::none },
+ { "minimumAcceleration", OBJECT_MODEL_FUNC(self->drcMinimumAcceleration, 1), ObjectModelEntryFlags::none },
+ { "period", OBJECT_MODEL_FUNC(self->drcPeriod, 1), ObjectModelEntryFlags::none },
// 2. Move.Idle members
- { "factor", OBJECT_MODEL_FUNC_NOSELF(reprap.GetPlatform().GetIdleCurrentFactor()), ObjectModelEntryFlags::none },
- { "timeout", OBJECT_MODEL_FUNC(0.001f * (float)self->idleTimeout), ObjectModelEntryFlags::none },
+ { "factor", OBJECT_MODEL_FUNC_NOSELF(reprap.GetPlatform().GetIdleCurrentFactor(), 1), ObjectModelEntryFlags::none },
+ { "timeout", OBJECT_MODEL_FUNC(0.001f * (float)self->idleTimeout, 1), ObjectModelEntryFlags::none },
// 3. move.currentMove members
- { "acceleration", OBJECT_MODEL_FUNC(self->GetAcceleration()), ObjectModelEntryFlags::live },
- { "deceleration", OBJECT_MODEL_FUNC(self->GetDeceleration()), ObjectModelEntryFlags::live },
- { "requestedSpeed", OBJECT_MODEL_FUNC(self->GetRequestedSpeed()), ObjectModelEntryFlags::live },
- { "topSpeed", OBJECT_MODEL_FUNC(self->GetTopSpeed()), ObjectModelEntryFlags::live },
+ { "acceleration", OBJECT_MODEL_FUNC(self->GetAcceleration(), 1), ObjectModelEntryFlags::live },
+ { "deceleration", OBJECT_MODEL_FUNC(self->GetDeceleration(), 1), ObjectModelEntryFlags::live },
+ { "requestedSpeed", OBJECT_MODEL_FUNC(self->GetRequestedSpeed(), 1), ObjectModelEntryFlags::live },
+ { "topSpeed", OBJECT_MODEL_FUNC(self->GetTopSpeed(), 1), ObjectModelEntryFlags::live },
// 4. move.calibrationDeviation members
{ "deviation", OBJECT_MODEL_FUNC(self->latestCalibrationDeviation.GetDeviationFromMean(), 3), ObjectModelEntryFlags::none },
@@ -538,18 +538,18 @@ void Move::AxisTransform(float xyzPoint[MaxAxes], const Tool *tool) const noexce
// Identify the lowest Y axis
const size_t numVisibleAxes = reprap.GetGCodes().GetVisibleAxes();
const AxesBitmap yAxes = Tool::GetYAxes(tool);
- const size_t lowestYAxis = LowestSetBit(yAxes);
+ const size_t lowestYAxis = yAxes.LowestSetBit();
if (lowestYAxis < numVisibleAxes)
{
// Found a Y axis. Use this one when correcting the X coordinate.
const AxesBitmap xAxes = Tool::GetXAxes(tool);
for (size_t axis = 0; axis < numVisibleAxes; ++axis)
{
- if (IsBitSet(xAxes, axis))
+ if (xAxes.IsBitSet(axis))
{
xyzPoint[axis] += tanXY*xyzPoint[lowestYAxis] + tanXZ*xyzPoint[Z_AXIS];
}
- if (IsBitSet(yAxes, axis))
+ if (yAxes.IsBitSet(axis))
{
xyzPoint[axis] += tanYZ*xyzPoint[Z_AXIS];
}
@@ -569,18 +569,18 @@ void Move::InverseAxisTransform(float xyzPoint[MaxAxes], const Tool *tool) const
// Identify the lowest Y axis
const size_t numVisibleAxes = reprap.GetGCodes().GetVisibleAxes();
const AxesBitmap yAxes = Tool::GetYAxes(tool);
- const size_t lowestYAxis = LowestSetBit(yAxes);
+ const size_t lowestYAxis = yAxes.LowestSetBit();
if (lowestYAxis < numVisibleAxes)
{
// Found a Y axis. Use this one when correcting the X coordinate.
const AxesBitmap xAxes = Tool::GetXAxes(tool);
for (size_t axis = 0; axis < numVisibleAxes; ++axis)
{
- if (IsBitSet(yAxes, axis))
+ if (yAxes.IsBitSet(axis))
{
xyzPoint[axis] -= tanYZ*xyzPoint[Z_AXIS];
}
- if (IsBitSet(xAxes, axis))
+ if (xAxes.IsBitSet(axis))
{
xyzPoint[axis] -= (tanXY*xyzPoint[lowestYAxis] + tanXZ*xyzPoint[Z_AXIS]);
}
@@ -602,12 +602,12 @@ void Move::BedTransform(float xyzPoint[MaxAxes], const Tool *tool) const noexcep
// Transform the Z coordinate based on the average correction for each axis used as an X or Y axis.
for (uint32_t xAxis = 0; xAxis < numAxes; ++xAxis)
{
- if (IsBitSet(xAxes, xAxis))
+ if (xAxes.IsBitSet(xAxis))
{
const float xCoord = xyzPoint[xAxis] + Tool::GetOffset(tool, xAxis);
for (uint32_t yAxis = 0; yAxis < numAxes; ++yAxis)
{
- if (IsBitSet(yAxes, yAxis))
+ if (yAxes.IsBitSet(yAxis))
{
const float yCoord = xyzPoint[yAxis] + Tool::GetOffset(tool, yAxis);
zCorrection += GetInterpolatedHeightError(xCoord, yCoord);
@@ -639,12 +639,12 @@ void Move::InverseBedTransform(float xyzPoint[MaxAxes], const Tool *tool) const
// Transform the Z coordinate based on the average correction for each axis used as an X or Y axis.
for (uint32_t xAxis = 0; xAxis < numAxes; ++xAxis)
{
- if (IsBitSet(xAxes, xAxis))
+ if (xAxes.IsBitSet(xAxis))
{
const float xCoord = xyzPoint[xAxis] + Tool::GetOffset(tool, xAxis);
for (uint32_t yAxis = 0; yAxis < numAxes; ++yAxis)
{
- if (IsBitSet(yAxes, yAxis))
+ if (yAxes.IsBitSet(yAxis))
{
const float yCoord = xyzPoint[yAxis] + Tool::GetOffset(tool, yAxis);
zCorrection += GetInterpolatedHeightError(xCoord, yCoord);
diff --git a/src/Movement/StepperDrivers/TMC2660.cpp b/src/Movement/StepperDrivers/TMC2660.cpp
index fc85a64d..abc7a494 100644
--- a/src/Movement/StepperDrivers/TMC2660.cpp
+++ b/src/Movement/StepperDrivers/TMC2660.cpp
@@ -250,7 +250,7 @@ private:
uint32_t pin; // the pin number that drives the chip select pin of this driver
uint32_t configuredChopConfReg; // the configured chopper control register, in the Enabled state
volatile uint32_t registersToUpdate; // bitmap of register values that need to be sent to the driver chip
- uint32_t driverBit; // 1 << the driver number
+ DriversBitmap driverBit; // bitmap of just this driver number
uint32_t axisNumber; // the axis number of this driver as used to index the DriveMovements in the DDA
uint32_t microstepShiftFactor; // how much we need to shift 1 left by to get the current microstepping
uint32_t maxStallStepInterval; // maximum interval between full steps to take any notice of stall detection
@@ -401,7 +401,7 @@ void TmcDriverState::Init(uint32_t driverNumber, uint32_t p_pin) noexcept
pre(!driversPowered)
{
axisNumber = driverNumber; // assume straight through mapping at initialisation
- driverBit = 1ul << driverNumber;
+ driverBit = DriversBitmap::MakeFromBits(driverNumber);
pin = p_pin;
pinMode(pin, OUTPUT_HIGH);
enabled = false;
@@ -915,7 +915,7 @@ namespace SmartDrivers
#endif
driversPowered = false;
- EndstopOrZProbe::UpdateStalledDrivers(LowestNBits<DriversBitmap>(MaxSmartDrivers), false);
+ EndstopOrZProbe::UpdateStalledDrivers(DriversBitmap::MakeLowestNBits(MaxSmartDrivers), false);
for (size_t driver = 0; driver < numTmc2660Drivers; ++driver)
{
driverStates[driver].Init(driver, driverSelectPins[driver]); // axes are mapped straight through to drivers initially
@@ -1025,7 +1025,7 @@ namespace SmartDrivers
if (!wasPowered)
{
// Power to the drivers has been provided or restored, so we need to enable and re-initialise them
- EndstopOrZProbe::UpdateStalledDrivers(LowestNBits<DriversBitmap>(MaxSmartDrivers), false);
+ EndstopOrZProbe::UpdateStalledDrivers(DriversBitmap::MakeLowestNBits(MaxSmartDrivers), false);
digitalWrite(GlobalTmc2660EnablePin, LOW);
delayMicroseconds(10);
@@ -1044,7 +1044,7 @@ namespace SmartDrivers
else if (wasPowered)
{
digitalWrite(GlobalTmc2660EnablePin, HIGH); // disable the drivers
- EndstopOrZProbe::UpdateStalledDrivers(LowestNBits<DriversBitmap>(MaxSmartDrivers), false);
+ EndstopOrZProbe::UpdateStalledDrivers(DriversBitmap::MakeLowestNBits(MaxSmartDrivers), false);
}
}
@@ -1053,7 +1053,7 @@ namespace SmartDrivers
{
digitalWrite(GlobalTmc2660EnablePin, HIGH); // disable the drivers
driversPowered = false;
- EndstopOrZProbe::UpdateStalledDrivers(LowestNBits<DriversBitmap>(MaxSmartDrivers), false);
+ EndstopOrZProbe::UpdateStalledDrivers(DriversBitmap::MakeLowestNBits(MaxSmartDrivers), false);
}
void SetStallThreshold(size_t driver, int sgThreshold) noexcept
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index 798b27ea..f4298926 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -357,7 +357,7 @@ private:
volatile uint32_t newRegistersToUpdate; // bitmap of register indices whose values need to be sent to the driver chip
uint32_t registersToUpdate; // bitmap of register indices whose values need to be sent to the driver chip
- uint32_t driverBit; // 1 << the driver number
+ DriversBitmap driverBit; // bitmap of just this driver number
uint32_t axisNumber; // the axis number of this driver as used to index the DriveMovements in the DDA
uint32_t microstepShiftFactor; // how much we need to shift 1 left by to get the current microstepping
uint32_t motorCurrent; // the configured motor current in mA
@@ -404,7 +404,7 @@ void TmcDriverState::Init(uint32_t p_driverNumber) noexcept
pre(!driversPowered)
{
axisNumber = p_driverNumber; // axes are mapped straight through to drivers initially
- driverBit = 1ul << p_driverNumber;
+ driverBit = DriversBitmap::MakeFromBits(p_driverNumber);
enabled = false;
registersToUpdate = newRegistersToUpdate = 0;
motorCurrent = 0;
diff --git a/src/Movement/StraightProbeSettings.cpp b/src/Movement/StraightProbeSettings.cpp
index a1d90f64..a514cde8 100644
--- a/src/Movement/StraightProbeSettings.cpp
+++ b/src/Movement/StraightProbeSettings.cpp
@@ -15,7 +15,7 @@ StraightProbeSettings::StraightProbeSettings() noexcept
void StraightProbeSettings::Reset() noexcept
{
- movingAxes = (AxesBitmap) 0;
+ movingAxes = AxesBitmap();
type = StraightProbeType::unset;
for (size_t axis = 0; axis < MaxAxes; ++axis)
{
diff --git a/src/Movement/StraightProbeSettings.h b/src/Movement/StraightProbeSettings.h
index 05667dd6..e7c30762 100644
--- a/src/Movement/StraightProbeSettings.h
+++ b/src/Movement/StraightProbeSettings.h
@@ -52,7 +52,7 @@ private:
inline void StraightProbeSettings::AddMovingAxis(const size_t axis) noexcept
{
- SetBit(movingAxes, axis);
+ movingAxes.SetBit(axis);
}
inline const bool StraightProbeSettings::ProbingAway() const noexcept