diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-07-07 21:00:32 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-07-07 21:00:32 +0300 |
commit | 9d401643e434c299e82d9b6c249efe967e2b0f23 (patch) | |
tree | 4be2908df789de28e7a9a457885038d496e54779 /src/CAN | |
parent | d5ea81b32e23cd9ca8bb33188bc6ab2d229c25f5 (diff) |
Fixes for input shaping + CAN
Diffstat (limited to 'src/CAN')
-rw-r--r-- | src/CAN/CanMotion.cpp | 12 | ||||
-rw-r--r-- | src/CAN/CanMotion.h | 6 | ||||
-rw-r--r-- | src/CAN/CommandProcessor.cpp | 8 |
3 files changed, 21 insertions, 5 deletions
diff --git a/src/CAN/CanMotion.cpp b/src/CAN/CanMotion.cpp index 662cf8da..c98efcec 100644 --- a/src/CAN/CanMotion.cpp +++ b/src/CAN/CanMotion.cpp @@ -73,7 +73,7 @@ CanMessageBuffer *GetBuffer(const PrepParams& params, DriverId canDriver) noexce if (buf == nullptr) { reprap.GetPlatform().Message(ErrorMessage, "Out of CAN buffers\n"); - return nullptr; //TODO error handling + return nullptr; //TODO error handling } buf->next = movementBufferList; @@ -115,7 +115,9 @@ CanMessageBuffer *GetBuffer(const PrepParams& params, DriverId canDriver) noexce move->shaperAccelPhasesMinusOne = params.shapingPlan.accelSegments - 1; move->shaperDecelPhasesMinusOne = params.shapingPlan.decelSegments - 1; #else + move->pressureAdvanceDrives = 0; move->numDrivers = canDriver.localDriver + 1; + move->zero = 0; #endif // Clear out the per-drive fields. Can't use a range-based FOR loop on a packed struct. @@ -139,7 +141,11 @@ CanMessageBuffer *GetBuffer(const PrepParams& params, DriverId canDriver) noexce } // This is called by DDA::Prepare for each active CAN DM in the move +#if USE_REMOTE_INPUT_SHAPING void CanMotion::AddMovement(const PrepParams& params, DriverId canDriver, int32_t steps) noexcept +#else +void CanMotion::AddMovement(const PrepParams& params, DriverId canDriver, int32_t steps, bool usePressureAdvance) noexcept +#endif { CanMessageBuffer * const buf = GetBuffer(params, canDriver); if (buf != nullptr) @@ -148,6 +154,10 @@ void CanMotion::AddMovement(const PrepParams& params, DriverId canDriver, int32_ buf->msg.moveLinearShaped.perDrive[canDriver.localDriver].iSteps = steps; #else buf->msg.moveLinear.perDrive[canDriver.localDriver].steps = steps; + if (usePressureAdvance) + { + buf->msg.moveLinear.pressureAdvanceDrives |= 1u << canDriver.localDriver; + } #endif } } diff --git a/src/CAN/CanMotion.h b/src/CAN/CanMotion.h index 1edddd10..e14aadcf 100644 --- a/src/CAN/CanMotion.h +++ b/src/CAN/CanMotion.h @@ -14,15 +14,15 @@ #include <Movement/DDA.h> -#define USE_REMOTE_INPUT_SHAPING (0) - namespace CanMotion { void Init() noexcept; void StartMovement() noexcept; - void AddMovement(const PrepParams& params, DriverId canDriver, int32_t steps) noexcept; #if USE_REMOTE_INPUT_SHAPING + void AddMovement(const PrepParams& params, DriverId canDriver, int32_t steps) noexcept; void AddExtruderMovement(const PrepParams& params, DriverId canDriver, float extrusion, bool usePressureAdvance) noexcept; +#else + void AddMovement(const PrepParams& params, DriverId canDriver, int32_t steps, bool usePressureAdvance = false) noexcept; #endif uint32_t FinishMovement(uint32_t moveStartTime) noexcept; bool CanPrepareMove() noexcept; diff --git a/src/CAN/CommandProcessor.cpp b/src/CAN/CommandProcessor.cpp index e68a3a33..05307526 100644 --- a/src/CAN/CommandProcessor.cpp +++ b/src/CAN/CommandProcessor.cpp @@ -403,9 +403,15 @@ void CommandProcessor::ProcessReceivedMessage(CanMessageBuffer *buf) noexcept StepTimer::ProcessTimeSyncMessage(buf->msg.sync, buf->dataLength, buf->timeStamp); return; // no reply needed + case CanMessageType::movementLinear: + reprap.GetMove().AddMoveFromRemote(buf->msg.moveLinear); + return; // no reply needed + +#if USE_REMOTE_INPUT_SHAPING case CanMessageType::movementLinearShaped: - reprap.GetMove().AddMoveFromRemote(buf->msg.moveLinearShaped); + reprap.GetMove().AddShapedMoveFromRemote(buf->msg.moveLinearShaped); return; // no reply needed +#endif case CanMessageType::returnInfo: requestId = buf->msg.getInfo.requestId; |