MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / InitAsyncMove

Method InitAsyncMove

src/Movement/DDA.cpp:638–688  ·  view source on GitHub ↗

Set up an async motor move returning true if the move does anything. All async moves are relative and linear.

Source from the content-addressed store, hash-verified

636// Set up an async motor move returning true if the move does anything.
637// All async moves are relative and linear.
638bool DDA::InitAsyncMove(DDARing& ring, const AsyncMove& nextMove) noexcept
639{
640 // 1. Compute the new endpoints and the movement vector
641 bool realMove = false;
642
643 const Move& move = reprap.GetMove();
644 for (size_t drive = 0; drive < MaxAxesPlusExtruders; drive++)
645 {
646 // Note, the correspondence between endCoordinates and endPoint will not be exact because of rounding error.
647 // This doesn't matter for the current application because we don't use either of these fields.
648
649 // If it's a delta then we can only do async tower moves in the Z direction and on any additional linear axes
650 const size_t axisToUse = (move.GetKinematics().GetKinematicsType() == KinematicsType::linearDelta && drive <= Z_AXIS) ? Z_AXIS : drive;
651 directionVector[drive] = nextMove.movements[axisToUse];
652 const int32_t delta = lrintf(nextMove.movements[axisToUse] * move.DriveStepsPerMm(drive));
653 endPoint[drive] = prev->endPoint[drive] + delta;
654 if (delta != 0)
655 {
656 realMove = true;
657 }
658 }
659
660 // 2. Throw it away if there's no real movement.
661 if (!realMove)
662 {
663 return false;
664 }
665
666 // 3. Store some values
667 flags.all = 0;
668 virtualExtruderPosition = 0;
669 tool = nullptr;
670 filePos = noFilePosition;
671 originalFeedRate = 0.0;
672
673 startSpeed = nextMove.startSpeed;
674 endSpeed = nextMove.endSpeed;
675 requestedSpeed = nextMove.requestedSpeed;
676 maxAcceleration = maxDeceleration = nextMove.accelDecel;
677
678# if SUPPORT_LASER || SUPPORT_IOBITS
679 laserPwmOrIoBits.Clear();
680# endif
681
682 // Currently we normalise the vector sum of all motor movements to unit length.
683 totalDistance = Normalise(directionVector);
684
685 RecalculateMove(ring);
686 SetState(provisional);
687 return true;
688}
689
690#endif
691

Callers 1

AddAsyncMoveMethod · 0.80

Calls 2

SetStateFunction · 0.85
ClearMethod · 0.45

Tested by

no test coverage detected