diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-01-19 02:03:39 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-01-19 02:03:39 +0300 |
commit | c812ce5e14cf476526d955edbce2effa9d922902 (patch) | |
tree | da67dc55e46efdd38a0647318977a342da730345 /src/Movement/Kinematics | |
parent | e0bbf71357b07c22e6d43be3cca5c7422163be32 (diff) |
Major refactoring, bug fixes in function evaluation
Changed all bitmaps to use the bitmap class from RRFLibraries
Fixed bugs in functoin evaluation
Diffstat (limited to 'src/Movement/Kinematics')
-rw-r--r-- | src/Movement/Kinematics/CoreKinematics.cpp | 10 | ||||
-rw-r--r-- | src/Movement/Kinematics/FiveBarScaraKinematics.cpp | 16 | ||||
-rw-r--r-- | src/Movement/Kinematics/HangprinterKinematics.cpp | 19 | ||||
-rw-r--r-- | src/Movement/Kinematics/Kinematics.cpp | 14 | ||||
-rw-r--r-- | src/Movement/Kinematics/Kinematics.h | 4 | ||||
-rw-r--r-- | src/Movement/Kinematics/LinearDeltaKinematics.cpp | 19 | ||||
-rw-r--r-- | src/Movement/Kinematics/LinearDeltaKinematics.h | 2 | ||||
-rw-r--r-- | src/Movement/Kinematics/PolarKinematics.cpp | 16 | ||||
-rw-r--r-- | src/Movement/Kinematics/RotaryDeltaKinematics.cpp | 19 | ||||
-rw-r--r-- | src/Movement/Kinematics/RotaryDeltaKinematics.h | 2 | ||||
-rw-r--r-- | src/Movement/Kinematics/ScaraKinematics.cpp | 16 |
11 files changed, 61 insertions, 76 deletions
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 |