diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-10-06 11:20:58 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-10-06 11:20:58 +0300 |
commit | 71c6aad181789d2f316112c0dfcd815967064000 (patch) | |
tree | c19172f7a34741fe0261a496681df92fea3dc311 | |
parent | 3581498e63d35aa7b828a67617d8ff063f60181a (diff) |
Added move.currentmove.extrusionRate to object model
-rw-r--r-- | src/Movement/DDA.cpp | 10 | ||||
-rw-r--r-- | src/Movement/DDA.h | 2 | ||||
-rw-r--r-- | src/Movement/DDARing.cpp | 6 | ||||
-rw-r--r-- | src/Movement/DDARing.h | 1 | ||||
-rw-r--r-- | src/Movement/Move.cpp | 3 | ||||
-rw-r--r-- | src/Movement/Move.h | 1 |
6 files changed, 22 insertions, 1 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index 9b99f0bb..2621020e 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -2374,6 +2374,16 @@ void DDA::UpdateMovementAccumulators(volatile int32_t *accumulators) const noexc #endif } +float DDA::GetTotalExtrusionRate() const noexcept +{ + float fraction = 0.0; + for (size_t i = MaxAxesPlusExtruders - reprap.GetGCodes().GetNumExtruders(); i < MaxAxesPlusExtruders; ++i) + { + fraction += directionVector[i]; + } + return fraction * InverseConvertSpeedToMmPerSec(topSpeed); +} + #if SUPPORT_LASER // Manage the laser power. Return the number of ticks until we should be called again, or 0 to be called at the start of the next move. diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h index fe37aee3..d9d2143e 100644 --- a/src/Movement/DDA.h +++ b/src/Movement/DDA.h @@ -147,6 +147,8 @@ public: float GetAccelerationMmPerSecSquared() const noexcept { return InverseConvertAcceleration(acceleration); } float GetDecelerationMmPerSecSquared() const noexcept { return InverseConvertAcceleration(deceleration); } float GetVirtualExtruderPosition() const noexcept { return virtualExtruderPosition; } + float GetTotalExtrusionRate() const noexcept; + float AdvanceBabyStepping(DDARing& ring, size_t axis, float amount) noexcept; // Try to push babystepping earlier in the move queue const Tool *GetTool() const noexcept { return tool; } float GetTotalDistance() const noexcept { return totalDistance; } diff --git a/src/Movement/DDARing.cpp b/src/Movement/DDARing.cpp index 66d8d759..5297f924 100644 --- a/src/Movement/DDARing.cpp +++ b/src/Movement/DDARing.cpp @@ -780,6 +780,12 @@ float DDARing::GetDecelerationMmPerSecSquared() const noexcept return (cdda != nullptr) ? cdda->GetDecelerationMmPerSecSquared() : 0.0; } +float DDARing::GetTotalExtrusionRate() const noexcept +{ + const DDA* const cdda = currentDda; // capture volatile variable + return (cdda != nullptr) ? cdda->GetTotalExtrusionRate() : 0.0; +} + // Pause the print as soon as we can, returning true if we are able to skip any moves and updating 'rp' to the first move we skipped. // Called from GCodes by the Main task bool DDARing::PauseMoves(RestorePoint& rp) noexcept diff --git a/src/Movement/DDARing.h b/src/Movement/DDARing.h index 3cf6b641..ea15bf34 100644 --- a/src/Movement/DDARing.h +++ b/src/Movement/DDARing.h @@ -60,6 +60,7 @@ public: float GetTopSpeedMmPerSec() const noexcept; float GetAccelerationMmPerSecSquared() const noexcept; float GetDecelerationMmPerSecSquared() const noexcept; + float GetTotalExtrusionRate() const noexcept; int32_t GetEndPoint(size_t drive) const noexcept { return liveEndPoints[drive]; } // Get the current position of a motor void GetCurrentMachinePosition(float m[MaxAxes], bool disableMotorMapping) const noexcept; // Get the current position in untransformed coords diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index f73987a6..c8aed193 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -127,6 +127,7 @@ constexpr ObjectModelTableEntry Move::objectModelTable[] = // 2. move.currentMove members { "acceleration", OBJECT_MODEL_FUNC(self->GetAccelerationMmPerSecSquared(), 1), ObjectModelEntryFlags::live }, { "deceleration", OBJECT_MODEL_FUNC(self->GetDecelerationMmPerSecSquared(), 1), ObjectModelEntryFlags::live }, + { "extrusionRate", OBJECT_MODEL_FUNC(self->GetTotalExtrusionRate(), 2), ObjectModelEntryFlags::live }, # if SUPPORT_LASER { "laserPwm", OBJECT_MODEL_FUNC_IF_NOSELF(reprap.GetGCodes().GetMachineType() == MachineType::laser, reprap.GetPlatform().GetLaserPwm(), 2), ObjectModelEntryFlags::live }, @@ -180,7 +181,7 @@ constexpr uint8_t Move::objectModelTableDescriptor[] = 9 + SUPPORT_COORDINATE_ROTATION, 17 + SUPPORT_WORKPLACE_COORDINATES, 2, - 4 + SUPPORT_LASER, + 5 + SUPPORT_LASER, 3, 2, 2, diff --git a/src/Movement/Move.h b/src/Movement/Move.h index 554b0977..27726ea5 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -166,6 +166,7 @@ public: float GetRequestedSpeedMmPerSec() const noexcept { return rings[0].GetRequestedSpeedMmPerSec(); } float GetAccelerationMmPerSecSquared() const noexcept { return rings[0].GetAccelerationMmPerSecSquared(); } float GetDecelerationMmPerSecSquared() const noexcept { return rings[0].GetDecelerationMmPerSecSquared(); } + float GetTotalExtrusionRate() const noexcept { return rings[0].GetTotalExtrusionRate(); } void AdjustLeadscrews(const floatc_t corrections[]) noexcept; // Called by some Kinematics classes to adjust the leadscrews |