diff options
author | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:32 +0300 |
---|---|---|
committer | Christian Hammacher <bmasterc@gmail.com> | 2021-10-28 14:58:32 +0300 |
commit | 4f218659e714355d7d2c79bc5d455323ab463081 (patch) | |
tree | 36ec0b7ddaaa04726095095afa9a1dcc52fa9d05 | |
parent | 8207b22cc13e7893ae1cb43f4aef4a7632cac5b3 (diff) | |
parent | c2073e0b5177dd0bd111f40bdff7adf6bd9d38de (diff) |
Merge remote-tracking branch 'origin/3.4-dev' into v3-chrishamm
-rw-r--r-- | src/Fans/LedStripDriver.cpp | 4 | ||||
-rw-r--r-- | src/FilamentMonitors/FilamentMonitor.cpp | 16 | ||||
-rw-r--r-- | src/FilamentMonitors/LaserFilamentMonitor.cpp | 10 | ||||
-rw-r--r-- | src/FilamentMonitors/PulsedFilamentMonitor.cpp | 10 | ||||
-rw-r--r-- | src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp | 12 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/ExpressionParser.cpp | 2 | ||||
-rw-r--r-- | src/Heating/Heat.cpp | 2 | ||||
-rw-r--r-- | src/Heating/LocalHeater.cpp | 4 | ||||
-rw-r--r-- | src/Movement/AxisShaper.cpp | 13 | ||||
-rw-r--r-- | src/Movement/AxisShaper.h | 1 | ||||
-rw-r--r-- | src/Movement/DDA.cpp | 46 | ||||
-rw-r--r-- | src/Movement/DDA.h | 1 | ||||
-rw-r--r-- | src/Movement/DDARing.cpp | 17 | ||||
-rw-r--r-- | src/Movement/Move.cpp | 7 | ||||
-rw-r--r-- | src/Movement/Move.h | 7 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.cpp | 14 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 2 |
17 files changed, 118 insertions, 50 deletions
diff --git a/src/Fans/LedStripDriver.cpp b/src/Fans/LedStripDriver.cpp index 4ebc7306..f098e6eb 100644 --- a/src/Fans/LedStripDriver.cpp +++ b/src/Fans/LedStripDriver.cpp @@ -641,9 +641,9 @@ GCodeResult LedStripDriver::SetColours(GCodeBuffer& gb, const StringRef& reply) # if USE_16BIT_SPI // Swap bytes for 16-bit SPI - const uint32_t data = ((brightness << 5) | (0xE0 << 8)) | ((blue & 255)) | ((green & 255) << 24) | ((red & 255) << 16); + const uint32_t data = ((brightness & 0xF8) << 5) | (0xE0 << 8) | ((blue & 255)) | ((green & 255) << 24) | ((red & 255) << 16); # else - const uint32_t data = ((brightness >> 3) | 0xE0) | ((blue & 255) << 8) | ((green & 255) << 16) | ((red & 255) << 24); + const uint32_t data = (brightness >> 3) | 0xE0 | ((blue & 255) << 8) | ((green & 255) << 16) | ((red & 255) << 24); # endif return SendDotStarData(data, numLeds, following); } diff --git a/src/FilamentMonitors/FilamentMonitor.cpp b/src/FilamentMonitors/FilamentMonitor.cpp index 99ae6b18..f44871a6 100644 --- a/src/FilamentMonitors/FilamentMonitor.cpp +++ b/src/FilamentMonitors/FilamentMonitor.cpp @@ -76,9 +76,8 @@ void FilamentMonitor::Disable() noexcept port.Release(); } -// Do the configuration that is -// Try to get the pin number from the GCode command in the buffer, setting Seen if a pin number was provided and returning true if error. -// Also attaches the ISR. +// Do the configuration that is common to all types of filament monitor +// Try to get the pin number from the GCode command in the buffer, setting Seen if a pin number was provided. Also attaches the ISR. // For a remote filament monitor, this does the full configuration or query of the remote object instead, and we always return seen true because we don't need to report local status. GCodeResult FilamentMonitor::CommonConfigure(GCodeBuffer& gb, const StringRef& reply, InterruptMode interruptMode, bool& seen) THROWS(GCodeException) { @@ -199,27 +198,28 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept // Factory function to create a filament monitor /*static*/ FilamentMonitor *FilamentMonitor::Create(unsigned int extruder, unsigned int monitorType, GCodeBuffer& gb, const StringRef& reply) noexcept { + const size_t drv = ExtruderToLogicalDrive(extruder); const DriverId did = reprap.GetPlatform().GetExtruderDriver(extruder); FilamentMonitor *fm; switch (monitorType) { case 1: // active high switch case 2: // active low switch - fm = new SimpleFilamentMonitor(extruder, monitorType, did); + fm = new SimpleFilamentMonitor(drv, monitorType, did); break; case 3: // duet3d rotating magnet, no switch case 4: // duet3d rotating magnet + switch - fm = new RotatingMagnetFilamentMonitor(extruder, monitorType, did); + fm = new RotatingMagnetFilamentMonitor(drv, monitorType, did); break; case 5: // duet3d laser, no switch case 6: // duet3d laser + switch - fm = new LaserFilamentMonitor(extruder, monitorType, did); + fm = new LaserFilamentMonitor(drv, monitorType, did); break; case 7: // simple pulse output sensor - fm = new PulsedFilamentMonitor(extruder, monitorType, did); + fm = new PulsedFilamentMonitor(drv, monitorType, did); break; default: // no sensor, or unknown sensor @@ -293,8 +293,8 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept } else { - IrqEnable(); extruderStepsCommanded = reprap.GetMove().GetAccumulatedExtrusion(fs.driveNumber, isPrinting); // get and clear the net extrusion commanded + IrqEnable(); fromIsr = false; locIsrMillis = 0; } diff --git a/src/FilamentMonitors/LaserFilamentMonitor.cpp b/src/FilamentMonitors/LaserFilamentMonitor.cpp index 6731442c..4021e8dd 100644 --- a/src/FilamentMonitors/LaserFilamentMonitor.cpp +++ b/src/FilamentMonitors/LaserFilamentMonitor.cpp @@ -37,7 +37,7 @@ constexpr ObjectModelTableEntry LaserFilamentMonitor::objectModelTable[] = #ifdef DUET3_ATE { "brightness", OBJECT_MODEL_FUNC((int32_t)self->brightness), ObjectModelEntryFlags::live }, #endif - { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->dataReceived && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::none }, + { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->dataReceived && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::live }, { "configured", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::none }, { "enabled", OBJECT_MODEL_FUNC(self->comparisonEnabled), ObjectModelEntryFlags::none }, #ifdef DUET3_ATE @@ -48,10 +48,10 @@ constexpr ObjectModelTableEntry LaserFilamentMonitor::objectModelTable[] = { "type", OBJECT_MODEL_FUNC_NOSELF("laser"), ObjectModelEntryFlags::none }, // 1. LaserFilamentMonitor.calibrated members - { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio)), ObjectModelEntryFlags::none }, - { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio)), ObjectModelEntryFlags::none }, - { "sensitivity", OBJECT_MODEL_FUNC(ConvertToPercent(self->MeasuredSensitivity())), ObjectModelEntryFlags::none }, - { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::none }, + { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio)), ObjectModelEntryFlags::live }, + { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio)), ObjectModelEntryFlags::live }, + { "sensitivity", OBJECT_MODEL_FUNC(ConvertToPercent(self->MeasuredSensitivity())), ObjectModelEntryFlags::live }, + { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::live }, // 2. LaserFilamentMonitor.configured members { "calibrationFactor", OBJECT_MODEL_FUNC(self->calibrationFactor, 3), ObjectModelEntryFlags::none }, diff --git a/src/FilamentMonitors/PulsedFilamentMonitor.cpp b/src/FilamentMonitors/PulsedFilamentMonitor.cpp index de9c26ed..b111f891 100644 --- a/src/FilamentMonitors/PulsedFilamentMonitor.cpp +++ b/src/FilamentMonitors/PulsedFilamentMonitor.cpp @@ -34,17 +34,17 @@ constexpr ObjectModelTableEntry PulsedFilamentMonitor::objectModelTable[] = { // Within each group, these entries must be in alphabetical order // 0. PulsedFilamentMonitor members - { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->DataReceived() && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::none }, + { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->DataReceived() && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::live }, { "configured", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::none }, { "enabled", OBJECT_MODEL_FUNC(self->comparisonEnabled), ObjectModelEntryFlags::none }, { "status", OBJECT_MODEL_FUNC(self->GetStatusText()), ObjectModelEntryFlags::live }, { "type", OBJECT_MODEL_FUNC_NOSELF("pulsed"), ObjectModelEntryFlags::none }, // 1. PulsedFilamentMonitor.calibrated members - { "mmPerPulse", OBJECT_MODEL_FUNC(self->MeasuredSensitivity(), 3), ObjectModelEntryFlags::none }, - { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio)), ObjectModelEntryFlags::none }, - { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio)), ObjectModelEntryFlags::none }, - { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::none }, + { "mmPerPulse", OBJECT_MODEL_FUNC(self->MeasuredSensitivity(), 3), ObjectModelEntryFlags::live }, + { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio)), ObjectModelEntryFlags::live }, + { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio)), ObjectModelEntryFlags::live }, + { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::live }, // 2. PulsedFilamentMonitor.configured members { "mmPerPulse", OBJECT_MODEL_FUNC(self->mmPerPulse, 3), ObjectModelEntryFlags::none }, diff --git a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp index c2f7cac1..3c361c2c 100644 --- a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp +++ b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp @@ -37,7 +37,7 @@ constexpr ObjectModelTableEntry RotatingMagnetFilamentMonitor::objectModelTable[ #ifdef DUET3_ATE { "agc", OBJECT_MODEL_FUNC((int32_t)self->agc), ObjectModelEntryFlags::live }, #endif - { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->dataReceived && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::none }, + { "calibrated", OBJECT_MODEL_FUNC_IF(self->IsLocal() && self->dataReceived && self->HaveCalibrationData(), self, 1), ObjectModelEntryFlags::live }, { "configured", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::none }, { "enabled", OBJECT_MODEL_FUNC(self->comparisonEnabled), ObjectModelEntryFlags::none }, #ifdef DUET3_ATE @@ -48,10 +48,10 @@ constexpr ObjectModelTableEntry RotatingMagnetFilamentMonitor::objectModelTable[ { "type", OBJECT_MODEL_FUNC_NOSELF("rotatingMagnet"), ObjectModelEntryFlags::none }, // 1. RotatingMagnetFilamentMonitor.calibrated members - { "mmPerRev", OBJECT_MODEL_FUNC(self->MeasuredSensitivity(), 2), ObjectModelEntryFlags::none }, - { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio * self->MeasuredSensitivity())), ObjectModelEntryFlags::none }, - { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio * self->MeasuredSensitivity())), ObjectModelEntryFlags::none }, - { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::none }, + { "mmPerRev", OBJECT_MODEL_FUNC(self->MeasuredSensitivity(), 2), ObjectModelEntryFlags::live }, + { "percentMax", OBJECT_MODEL_FUNC(ConvertToPercent(self->maxMovementRatio * self->MeasuredSensitivity())), ObjectModelEntryFlags::live }, + { "percentMin", OBJECT_MODEL_FUNC(ConvertToPercent(self->minMovementRatio * self->MeasuredSensitivity())), ObjectModelEntryFlags::live }, + { "totalDistance", OBJECT_MODEL_FUNC(self->totalExtrusionCommanded, 1), ObjectModelEntryFlags::live }, // 2. RotatingMagnetFilamentMonitor.configured members { "mmPerRev", OBJECT_MODEL_FUNC(self->mmPerRev, 2), ObjectModelEntryFlags::none }, @@ -374,7 +374,7 @@ void RotatingMagnetFilamentMonitor::HandleIncomingData() noexcept // Call the following at intervals to check the status. This is only called when printing is in progress. // 'filamentConsumed' is the net amount of extrusion commanded since the last call to this function. -// 'hadNonPrintingMove' is true if filamentConsumed includes extruder movement from non-printing moves. +// 'isPrinting' is true if the current movement is not a non-printing extruder move. // 'fromIsr' is true if this measurement was taken at the end of the ISR because a potential start bit was seen FilamentSensorStatus RotatingMagnetFilamentMonitor::Check(bool isPrinting, bool fromIsr, uint32_t isrMillis, float filamentConsumed) noexcept { diff --git a/src/GCodes/GCodeBuffer/ExpressionParser.cpp b/src/GCodes/GCodeBuffer/ExpressionParser.cpp index c4231e4e..315f3e09 100644 --- a/src/GCodes/GCodeBuffer/ExpressionParser.cpp +++ b/src/GCodes/GCodeBuffer/ExpressionParser.cpp @@ -384,7 +384,7 @@ void ExpressionParser::ParseInternal(ExpressionValue& val, bool evaluate, uint8_ ConvertToFloat(val, evaluate); ConvertToFloat(val2, evaluate); val.fVal /= val2.fVal; - val.param = 0; + val.param = MaxFloatDigitsDisplayedAfterPoint; break; case '>': diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index 93df38e2..f07ffb31 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -367,7 +367,9 @@ void Heat::SendHeatersStatus(CanMessageBuffer& buf) noexcept unsigned int sensorsFound = 0; #endif { +#if SUPPORT_CAN_EXPANSION unsigned int nextUnreportedSensor = 0; +#endif ReadLocker lock(sensorsLock); TemperatureSensor *currentSensor = sensorsRoot; while (currentSensor != nullptr) diff --git a/src/Heating/LocalHeater.cpp b/src/Heating/LocalHeater.cpp index 1e2192f8..f84b3aee 100644 --- a/src/Heating/LocalHeater.cpp +++ b/src/Heating/LocalHeater.cpp @@ -294,8 +294,8 @@ void LocalHeater::Spin() noexcept ++heatingFaultCount; if (heatingFaultCount * HeatSampleIntervalMillis > GetMaxHeatingFaultTime() * SecondsToMillis) { - RaiseHeaterFault("Heater %u fault: temperature rising much more slowly than the expected %.1f" DEGREE_SYMBOL "C/sec\n", - GetHeaterNumber(), (double)expectedRate); + RaiseHeaterFault("Heater %u fault: at %.1f" DEGREE_SYMBOL "C temperature is rising at %.1f" DEGREE_SYMBOL "C/sec, well below the expected %.1f" DEGREE_SYMBOL "C/sec\n", + GetHeaterNumber(), (double)temperature, (double)derivative, (double)expectedRate); } } else if (heatingFaultCount != 0) diff --git a/src/Movement/AxisShaper.cpp b/src/Movement/AxisShaper.cpp index f7dc64b9..55de9ad0 100644 --- a/src/Movement/AxisShaper.cpp +++ b/src/Movement/AxisShaper.cpp @@ -210,6 +210,18 @@ GCodeResult AxisShaper::Configure(GCodeBuffer& gb, const StringRef& reply) THROW numExtraImpulses = 3; break; + case InputShaperType::zvddd: + { + const float j = fsquare(fsquare(1.0 + k)); + coefficients[0] = 1.0/j; + coefficients[1] = coefficients[0] + 4.0 * k/j; + coefficients[2] = coefficients[1] + 6.0 * fsquare(k)/j; + coefficients[3] = coefficients[2] + 4.0 * fcube(k)/j; + } + durations[0] = durations[1] = durations[2] = durations[3] = 0.5 * dampedPeriod; + numExtraImpulses = 4; + break; + case InputShaperType::ei2: // see http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.465.1337&rep=rep1&type=pdf. United States patent #4,916,635. { const float zetaSquared = fsquare(zeta); @@ -491,6 +503,7 @@ void AxisShaper::PlanShaping(DDA& dda, PrepParams& params, bool shapingEnabled) case InputShaperType::zvd: case InputShaperType::mzv: case InputShaperType::zvdd: + case InputShaperType::zvddd: case InputShaperType::ei2: case InputShaperType::ei3: params.SetFromDDA(dda); // set up the provisional parameters diff --git a/src/Movement/AxisShaper.h b/src/Movement/AxisShaper.h index 18ee9e02..d4740a5f 100644 --- a/src/Movement/AxisShaper.h +++ b/src/Movement/AxisShaper.h @@ -27,6 +27,7 @@ NamedEnum(InputShaperType, uint8_t, none, zvd, zvdd, + zvddd, ); class DDA; diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index 69626146..6c08ce0f 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -388,7 +388,7 @@ bool DDA::InitStandardMove(DDARing& ring, const RawMove &nextMove, bool doMotorM // It's an extruder drive. We defer calculating the steps because they may be affected by nonlinear extrusion, which we can't calculate until we // know the speed of the move, and because extruder movement is relative so we need to accumulate fractions of a whole step between moves. const float movement = nextMove.coords[drive]; - directionVector[drive] = movement; + endCoordinates[drive] = directionVector[drive] = movement; // for an extruder, endCoordinates is the amount of movement if (movement != 0.0) { extrudersMoving = true; @@ -2326,6 +2326,50 @@ void DDA::LimitSpeedAndAcceleration(float maxSpeed, float maxAcceleration) noexc } } +// Update the movement accumulators to account for the move that has just finished. +// Only drives that correspond to extruders need to be updated, but it doesn't matter if we update them all. +// This is called with interrupts disabled. +void DDA::UpdateMovementAccumulators(volatile int32_t *accumulators) const noexcept +{ + // To identify all the extruder movement, we can either loop through extruder numbers and search both DM lists for a DM for that drive, + // or we can iterate through both DM lists, checking whether the drive it is for is an extruder. +#if 1 + // Loop through DMs, checking whether each associated drive is an extruder and updating the movement accumulator if so. + // We could omit the check that the drive is an accumulator so that we update all accumulators, but we would still need to check for leadscrew adjustment moves. + const unsigned int firstExtruderDrive = ExtruderToLogicalDrive(reprap.GetGCodes().GetNumExtruders() - 1); + for (const DriveMovement* dm = activeDMs; dm != nullptr; ) + { + const uint8_t drv = dm->drive; + if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) + && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move + ) + { + accumulators[drv] += dm->GetNetStepsTaken(); + } + dm = dm->nextDM; + } + for (const DriveMovement* dm = completedDMs; dm != nullptr; ) + { + const uint8_t drv = dm->drive; + if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) + && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move + ) + { + accumulators[drv] += dm->GetNetStepsTaken(); + } + dm = dm->nextDM; + } +#else + // Loop through extruders + const size_t numExtruders = reprap.GetGCodes().GetNumExtruders(); + for (size_t extruder = 0; extruder < numExtruders; ++extruder) + { + const size_t drv = ExtruderToLogicalDrive(extruder); + accumulators[drv] += GetStepsTaken(drv); + } +#endif +} + #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 2c693d98..035b8f42 100644 --- a/src/Movement/DDA.h +++ b/src/Movement/DDA.h @@ -160,6 +160,7 @@ public: uint32_t GetClocksNeeded() const noexcept { return clocksNeeded; } bool IsGoodToPrepare() const noexcept; bool IsNonPrintingExtruderMove() const noexcept { return flags.isNonPrintingExtruderMove; } + void UpdateMovementAccumulators(volatile int32_t *accumulators) const noexcept; #if SUPPORT_LASER || SUPPORT_IOBITS LaserPwmOrIoBits GetLaserPwmOrIoBits() const noexcept { return laserPwmOrIoBits; } diff --git a/src/Movement/DDARing.cpp b/src/Movement/DDARing.cpp index 23270b35..4aeb39a7 100644 --- a/src/Movement/DDARing.cpp +++ b/src/Movement/DDARing.cpp @@ -572,18 +572,12 @@ void DDARing::CurrentMoveCompleted() noexcept liveCoordinatesValid = cdda->FetchEndPosition(const_cast<int32_t*>(liveEndPoints), const_cast<float *>(liveCoordinates)); liveCoordinatesChanged = true; - // In the following it doesn't currently matter whether we process all drives or just the extruders - // Instead of looping through extruders, we could loop through DMs. + // Disable interrupts before we touch any extrusion accumulators until after we set currentDda to null, in case the filament monitor interrupt has higher priority than ours { - const size_t numExtruders = reprap.GetGCodes().GetNumExtruders(); - for (size_t extruder = 0; extruder < numExtruders; ++extruder) - { - const size_t drv = ExtruderToLogicalDrive(extruder); - movementAccumulators[drv] += cdda->GetStepsTaken(drv); - } + AtomicCriticalSectionLocker lock; + cdda->UpdateMovementAccumulators(movementAccumulators); + currentDda = nullptr; } - - currentDda = nullptr; if (cdda->IsCheckingEndstops()) { Move::WakeMoveTaskFromISR(); // wake the Move task if we were checking endstops @@ -607,13 +601,12 @@ bool DDARing::SetWaitingToEmpty() noexcept int32_t DDARing::GetAccumulatedMovement(size_t drive, bool& isPrinting) noexcept { - const uint32_t basepri = ChangeBasePriority(NvicPriorityStep); + AtomicCriticalSectionLocker lock; const int32_t ret = movementAccumulators[drive]; const DDA * const cdda = currentDda; // capture volatile variable const int32_t adjustment = (cdda == nullptr) ? 0 : cdda->GetStepsTaken(drive); movementAccumulators[drive] = -adjustment; isPrinting = extrudersPrinting; - RestoreBasePriority(basepri); return ret + adjustment; } diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index 04781a55..08f167e0 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -894,13 +894,6 @@ void Move::GetCurrentUserPosition(float m[MaxAxes], uint8_t moveType, const Tool } } -// Get the accumulated extruder motor steps taken by an extruder since the last call. Used by the filament monitoring code. -// Returns the number of motor steps moves since the last call, and sets isPrinting true unless we are currently executing an extruding but non-printing move -int32_t Move::GetAccumulatedExtrusion(size_t drive, bool& isPrinting) noexcept -{ - return mainDDARing.GetAccumulatedMovement(drive, isPrinting); -} - void Move::SetXYBedProbePoint(size_t index, float x, float y) noexcept { if (index >= MaxProbePoints) diff --git a/src/Movement/Move.h b/src/Movement/Move.h index 239e8ea6..4caf011f 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -343,6 +343,13 @@ inline float Move::GetPressureAdvanceClocks(size_t extruder) const noexcept return (extruder < MaxExtruders) ? extruderShapers[extruder].GetKclocks() : 0.0; } +// Get the accumulated extruder motor steps taken by an extruder since the last call. Used by the filament monitoring code. +// Returns the number of motor steps moves since the last call, and sets isPrinting true unless we are currently executing an extruding but non-printing move +inline int32_t Move::GetAccumulatedExtrusion(size_t drive, bool& isPrinting) noexcept +{ + return mainDDARing.GetAccumulatedMovement(drive, isPrinting); +} + #if HAS_SMART_DRIVERS // Get the current step interval for this axis or extruder, or 0 if it is not moving diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp index 165431e4..938479ae 100644 --- a/src/ObjectModel/ObjectModel.cpp +++ b/src/ObjectModel/ObjectModel.cpp @@ -193,6 +193,20 @@ void ExpressionValue::Release() noexcept } } +// Get the format string to use assuming this is a floating point number +const char *ExpressionValue::GetFloatFormatString() const noexcept +{ + float f = 1.0; + unsigned int digitsAfterPoint = param; + while (digitsAfterPoint > 1 && fVal > f) + { + f *= 10.0; + --digitsAfterPoint; + } + + return ::GetFloatFormatString(digitsAfterPoint); +} + #if SUPPORT_CAN_EXPANSION // Given that this is a CanExpansionBoardDetails value, extract the part requested according to the parameter and append it to the string diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 3202aa54..9ae99e80 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -194,7 +194,7 @@ struct ExpressionValue #endif // Get the format string to use assuming this is a floating point number - const char *GetFloatFormatString() const noexcept { return ::GetFloatFormatString(param); } + const char *GetFloatFormatString() const noexcept; // Append a string representation of this value to a string void AppendAsString(const StringRef& str) const noexcept; |