diff options
author | dc42 <dcrocker@eschertech.com> | 2021-02-16 17:57:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 17:57:56 +0300 |
commit | e86f9472eda30820714d3965bffbd36574e0e62d (patch) | |
tree | 0c6d0b451eecab8993e6bd5cbe1883bb827bf112 /src/Endstops | |
parent | 88f1a6d5defd8d0649238006cae797a3ca12c728 (diff) |
Wil mesh any two axes (#476)
* Open mesh compenastion for any-two axes
* Fix reboot loop on Duet 3
* Fix typos
Skip Z axis where not appropriate
Add version to HeightMapHeader
* Fix compiler errors
* Make compatible with pre 3.3-beta2 format again
Minor simplifications
* Revert changes to SBC interface (implement that later)
* Also prevent sending a none-XY grid to SBC for now
* Rename variables and no longer persist axis numbers
* Use common parent class for Kinematics with round bed
Co-authored-by: Manuel Coenen <manuel@duet3d.com>
Diffstat (limited to 'src/Endstops')
-rw-r--r-- | src/Endstops/ZProbe.cpp | 47 | ||||
-rw-r--r-- | src/Endstops/ZProbe.h | 5 |
2 files changed, 38 insertions, 14 deletions
diff --git a/src/Endstops/ZProbe.cpp b/src/Endstops/ZProbe.cpp index cbdc39e3..eed8a791 100644 --- a/src/Endstops/ZProbe.cpp +++ b/src/Endstops/ZProbe.cpp @@ -24,10 +24,9 @@ constexpr ObjectModelArrayDescriptor ZProbe::offsetsArrayDescriptor = { - nullptr, - [] (const ObjectModel *self, const ObjectExplorationContext&) noexcept -> size_t { return 2; }, - [] (const ObjectModel *self, ObjectExplorationContext& context) noexcept -> ExpressionValue - { return ExpressionValue((context.GetLastIndex() == 0) ? ((const ZProbe*)self)->xOffset : ((const ZProbe*)self)->yOffset, 1); } + nullptr, // no lock needed + [] (const ObjectModel *self, const ObjectExplorationContext&) noexcept -> size_t { return reprap.GetGCodes().GetVisibleAxes(); }, + [] (const ObjectModel *self, ObjectExplorationContext& context) noexcept -> ExpressionValue { return ExpressionValue(((const ZProbe*)self)->offsets[context.GetLastIndex()], 2); } }; constexpr ObjectModelArrayDescriptor ZProbe::valueArrayDescriptor = @@ -90,7 +89,10 @@ ZProbe::ZProbe(unsigned int num, ZProbeType p_type) noexcept : EndstopOrZProbe() void ZProbe::SetDefaults() noexcept { adcValue = DefaultZProbeADValue; - xOffset = yOffset = 0.0; + for (float& offset : offsets) + { + offset = 0.0; + } triggerHeight = DefaultZProbeTriggerHeight; calibTemperature = DefaultZProbeTemperature; for (float& tc : temperatureCoefficients) @@ -127,8 +129,18 @@ float ZProbe::GetActualTriggerHeight() const noexcept bool ZProbe::WriteParameters(FileStore *f, unsigned int probeNumber) const noexcept { - String<StringLength100> scratchString; - scratchString.printf("G31 K%u P%d X%.1f Y%.1f Z%.2f\n", probeNumber, adcValue, (double)xOffset, (double)yOffset, (double)triggerHeight); + const char* axisLetters = reprap.GetGCodes().GetAxisLetters(); + const size_t numTotalAxes = reprap.GetGCodes().GetTotalAxes(); + String<StringLength256> scratchString; + scratchString.printf("G31 K%u P%d", probeNumber, adcValue); + for (size_t i = 0; i < numTotalAxes; ++i) + { + if (axisLetters[i] != 'Z') + { + scratchString.catf(" %c%.1f", axisLetters[i], (double)offsets[i]); + } + } + scratchString.catf(" Z%.2f\n", (double)triggerHeight); return f->Write(scratchString.c_str()); } @@ -261,7 +273,7 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC newSensor = sensor; } - if (gb.Seen('C')) + if (gb.Seen('T')) { seen = true; for (float& tc : temperatureCoefficients) @@ -310,8 +322,14 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC // After this we don't return notFinished, so it is safe to amend values directly const char* axisLetters = reprap.GetGCodes().GetAxisLetters(); - gb.TryGetFValue(axisLetters[X_AXIS], xOffset, seen); - gb.TryGetFValue(axisLetters[Y_AXIS], yOffset, seen); + const size_t numTotalAxes = reprap.GetGCodes().GetTotalAxes(); + for (size_t i = 0; i < numTotalAxes; ++i) + { + if (axisLetters[i] != 'Z') + { + gb.TryGetFValue(axisLetters[i], offsets[i], seen); + } + } gb.TryGetFValue(axisLetters[Z_AXIS], triggerHeight, seen); if (gb.Seen('P')) @@ -344,7 +362,14 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC reply.catf(" at %.1f" DEGREE_SYMBOL "C, temperature coefficients [%.1f/" DEGREE_SYMBOL "C, %.1f/" DEGREE_SYMBOL "C^2]", (double)calibTemperature, (double)temperatureCoefficients[0], (double)temperatureCoefficients[1]); } - reply.catf(", offsets X%.1f Y%.1f", (double)xOffset, (double)yOffset); + reply.cat(", offsets"); + for (size_t i = 0; i < numTotalAxes; ++i) + { + if (axisLetters[i] != 'Z') + { + reply.catf(" %c%.1f", axisLetters[i], (double)offsets[i]); + } + } } return err; } diff --git a/src/Endstops/ZProbe.h b/src/Endstops/ZProbe.h index 0e583f70..cf0144d3 100644 --- a/src/Endstops/ZProbe.h +++ b/src/Endstops/ZProbe.h @@ -35,8 +35,7 @@ public: void SetDefaults() noexcept; ZProbeType GetProbeType() const noexcept { return type; } - float GetXOffset() const noexcept { return xOffset; } - float GetYOffset() const noexcept { return yOffset; } + float GetOffset(size_t axisNumber) const noexcept { return offsets[axisNumber]; } float GetConfiguredTriggerHeight() const noexcept { return triggerHeight; } float GetActualTriggerHeight() const noexcept; float GetDiveHeight() const noexcept { return diveHeight; } @@ -88,7 +87,7 @@ protected: } parts; uint16_t all; } misc; - float xOffset, yOffset; // the offset of the probe relative to the print head + float offsets[MaxAxes]; // the offset of the probe relative to the print head float triggerHeight; // the nozzle height at which the target ADC value is returned float calibTemperature; // the temperature at which we did the calibration float temperatureCoefficients[2]; // the variation of height with bed temperature and with the square of temperature |