diff options
author | Christian Hammacher <bmasterc@gmail.com> | 2021-11-02 23:03:41 +0300 |
---|---|---|
committer | Christian Hammacher <bmasterc@gmail.com> | 2021-11-02 23:03:41 +0300 |
commit | aa850feea05f552cc915abbc13e6870df31df3f2 (patch) | |
tree | 9d95b49fa54268cbf849b76141390b324731187f /src/SBC | |
parent | e7892b8a2d4609a687fe9acde367fe2ce07e33e2 (diff) |
Removed heightmap code for SBC mode
Removed various bits that were previously needed for heightmap handling in SBC mode
Diffstat (limited to 'src/SBC')
-rw-r--r-- | src/SBC/DataTransfer.cpp | 78 | ||||
-rw-r--r-- | src/SBC/DataTransfer.h | 2 | ||||
-rw-r--r-- | src/SBC/SbcInterface.cpp | 35 | ||||
-rw-r--r-- | src/SBC/SbcMessageFormats.h | 6 |
4 files changed, 4 insertions, 117 deletions
diff --git a/src/SBC/DataTransfer.cpp b/src/SBC/DataTransfer.cpp index 2902da8b..967134f4 100644 --- a/src/SBC/DataTransfer.cpp +++ b/src/SBC/DataTransfer.cpp @@ -601,48 +601,6 @@ GCodeChannel DataTransfer::ReadMacroCompleteInfo(bool &error) noexcept return GCodeChannel(header->channel); } -bool DataTransfer::ReadHeightMap() noexcept -{ - // Read height map header - const HeightMapHeader * const header = ReadDataHeader<HeightMapHeader>(); - char axesLetter[2] = { 'X', 'Y' }; - float axis0Range[2] = { header->xMin, header->xMax }; - float axis1Range[2] = { header->yMin, header->yMax }; - float spacing[2] = { header->xSpacing, header->ySpacing }; - const bool ok = reprap.GetGCodes().AssignGrid(axesLetter, axis0Range, axis1Range, header->radius, spacing); - if (ok) - { - // Read Z coordinates - const size_t numPoints = header->numX * header->numY; - const float *points = reinterpret_cast<const float *>(ReadData(sizeof(float) * numPoints)); - - HeightMap& map = reprap.GetMove().AccessHeightMap(); - map.ClearGridHeights(); - for (size_t i = 0; i < numPoints; i++) - { - if (!std::isnan(points[i])) - { - map.SetGridHeight(i, points[i]); - } - } - - map.ExtrapolateMissing(); - - // Activate it - reprap.GetGCodes().ActivateHeightmap(true); - - // Recalculate the deviations - float minError, maxError; - Deviation deviation; - const uint32_t numPointsProbed = reprap.GetMove().AccessHeightMap().GetStatistics(deviation, minError, maxError); - if (numPointsProbed >= 4) - { - reprap.GetMove().SetLatestMeshDeviation(deviation); - } - } - return ok; -} - GCodeChannel DataTransfer::ReadCodeChannel() noexcept { const CodeChannelHeader *header = ReadDataHeader<CodeChannelHeader>(); @@ -1192,42 +1150,6 @@ bool DataTransfer::WritePrintPaused(FilePosition position, PrintPausedReason rea return true; } -bool DataTransfer::WriteHeightMap() noexcept -{ - const GridDefinition& grid = reprap.GetMove().GetGrid(); - - size_t numPoints = reprap.GetMove().AccessHeightMap().UsingHeightMap() ? grid.NumPoints() : 0; - size_t bytesToWrite = sizeof(HeightMapHeader) + numPoints * sizeof(float); - if (!CanWritePacket(bytesToWrite)) - { - return false; - } - - // Write packet header - (void)WritePacketHeader(FirmwareRequest::HeightMap, bytesToWrite); - - // Write heightmap header - HeightMapHeader *header = WriteDataHeader<HeightMapHeader>(); - header->xMin = grid.GetMin(0); - header->xMax = grid.GetMax(0); - header->xSpacing = grid.GetSpacing(0); - header->yMin = grid.GetMin(1); - header->yMax = grid.GetMax(1); - header->ySpacing = grid.GetSpacing(1); - header->radius = grid.radius; - header->numX = grid.NumAxisPoints(0); - header->numY = grid.NumAxisPoints(1); - - // Write Z points - if (numPoints != 0) - { - float *zPoints = reinterpret_cast<float*>(txBuffer + txPointer); - reprap.GetMove().SaveHeightMapToArray(zPoints); - txPointer += numPoints * sizeof(float); - } - return true; -} - bool DataTransfer::WriteLocked(GCodeChannel channel) noexcept { if (!CanWritePacket(sizeof(CodeChannelHeader))) diff --git a/src/SBC/DataTransfer.h b/src/SBC/DataTransfer.h index 4882b703..bdc87bc9 100644 --- a/src/SBC/DataTransfer.h +++ b/src/SBC/DataTransfer.h @@ -55,7 +55,6 @@ public: void ReadPrintStartedInfo(size_t packetLength, const StringRef& filename, GCodeFileInfo &info) noexcept; // Read info about the started file print PrintStoppedReason ReadPrintStoppedInfo() noexcept; // Read info about why the print has been stopped GCodeChannel ReadMacroCompleteInfo(bool &error) noexcept; // Read info about a completed macro file - bool ReadHeightMap() noexcept; // Read heightmap parameters GCodeChannel ReadCodeChannel() noexcept; // Read a code channel void ReadFileChunk(char *buffer, int32_t& dataLength, uint32_t& fileLength) noexcept; // Read another chunk of a file GCodeChannel ReadEvaluateExpression(size_t packetLength, const StringRef& expression) noexcept; // Read an expression request @@ -73,7 +72,6 @@ public: bool WriteAbortFileRequest(GCodeChannel channel, bool abortAll) noexcept; bool WriteMacroFileClosed(GCodeChannel channel) noexcept; bool WritePrintPaused(FilePosition position, PrintPausedReason reason) noexcept; - bool WriteHeightMap() noexcept; bool WriteLocked(GCodeChannel channel) noexcept; bool WriteFileChunkRequest(const char *filename, uint32_t offset, uint32_t maxLength) noexcept; bool WriteEvaluationResult(const char *expression, const ExpressionValue& value) noexcept; diff --git a/src/SBC/SbcInterface.cpp b/src/SBC/SbcInterface.cpp index d4bbb5a5..2230d2ec 100644 --- a/src/SBC/SbcInterface.cpp +++ b/src/SBC/SbcInterface.cpp @@ -431,39 +431,6 @@ void SbcInterface::ExchangeData() noexcept break; } - // Return heightmap as generated by G29 S0 - case SbcRequest::GetHeightMap: - { - ConditionalReadLocker locker(reprap.GetMove().heightMapLock); - if (locker.IsLocked()) - { - packetAcknowledged = transfer.WriteHeightMap(); - } - else - { - packetAcknowledged = false; - } - break; - } - - // Set heightmap via G29 S1 - case SbcRequest::SetHeightMap: - { - ConditionalWriteLocker locker(reprap.GetMove().heightMapLock); - if (locker.IsLocked()) - { - if (!transfer.ReadHeightMap()) - { - reprap.GetPlatform().Message(ErrorMessage, "Failed to set height map - bad data?\n"); - } - } - else - { - packetAcknowledged = false; - } - break; - } - // Lock movement and wait for standstill case SbcRequest::LockMovementAndWaitForStandstill: { @@ -887,7 +854,7 @@ void SbcInterface::ExchangeData() noexcept } break; - // Invalid request + // Invalid request default: REPORT_INTERNAL_ERROR; break; diff --git a/src/SBC/SbcMessageFormats.h b/src/SBC/SbcMessageFormats.h index 11991fb7..c536f881 100644 --- a/src/SBC/SbcMessageFormats.h +++ b/src/SBC/SbcMessageFormats.h @@ -207,7 +207,7 @@ enum class FirmwareRequest : uint16_t AbortFile = 5, // Request the current file to be closed StackEvent_Obsolete = 6, // Stack has been changed (unused) PrintPaused = 7, // Print has been paused - HeightMap = 8, // Response to a heightmap request + HeightMap_Obsolete = 8, // Response to a heightmap request (no longer used) Locked = 9, // Movement has been locked and machine is in standstill FileChunk = 10, // Request another chunk of a file (only used by CAN expansion board updates) EvaluationResult = 11, // Response to an expression evaluation request @@ -257,8 +257,8 @@ enum class SbcRequest : uint16_t SetPrintFileInfo = 5, // Print is about to be started, set file print information PrintStopped = 6, // Print has been stopped, reset file print information MacroCompleted = 7, // Notification that a macro file has been fully processed - GetHeightMap = 8, // Request the heightmap coordinates as generated by G29 S0 - SetHeightMap = 9, // Set the heightmap coordinates via G29 S1 + GetHeightMap_deprecated = 8, // Request the heightmap coordinates as generated by G29 S0 (no longer used) + SetHeightMap_deprecated = 9, // Set the heightmap coordinates via G29 S1 (no longer used) LockMovementAndWaitForStandstill = 10, // Lock movement and wait for standstill Unlock = 11, // Unlock occupied resources WriteIap = 12, // Write another chunk of the IAP binary |