diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-02-08 14:15:06 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-02-08 14:15:06 +0300 |
commit | 97afd197eb780889d6b5fbba5808a59e92d4ec84 (patch) | |
tree | 9989312f1ab238c26cd2bcd170e90d1e549e6d22 | |
parent | 4eea63308ada967932c3bc7803f7f82136bf9b7c (diff) |
Allow for more tools than extruders in filament usage array
-rw-r--r-- | src/Config/Configuration.h | 7 | ||||
-rw-r--r-- | src/GCodes/GCodeFileInfo.h | 2 | ||||
-rw-r--r-- | src/Storage/FileInfoParser.cpp | 15 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/Config/Configuration.h b/src/Config/Configuration.h index 08f43752..75680dfb 100644 --- a/src/Config/Configuration.h +++ b/src/Config/Configuration.h @@ -211,6 +211,13 @@ constexpr size_t MaxTrackedObjects = 20; // How many build plate objects we t constexpr size_t ObjectNamesStringSpace = 500; // How much space we reserve for the names of objects on the build plate #endif +// How many filaments we can return in the file information. Each one uses 4 bytes of statically-allocated RAM. +#if SAME70 || SAME5x +constexpr unsigned int MaxFilaments = 20; +#else +constexpr unsigned int MaxFilaments = 8; +#endif + // Move system constexpr float DefaultFeedRate = 3000.0; // The initial requested feed rate after resetting the printer, in mm/min constexpr float DefaultG0FeedRate = 18000.0; // The initial feed rate for G0 commands after resetting the printer, in mm/min diff --git a/src/GCodes/GCodeFileInfo.h b/src/GCodes/GCodeFileInfo.h index 190c0489..df527c8f 100644 --- a/src/GCodes/GCodeFileInfo.h +++ b/src/GCodes/GCodeFileInfo.h @@ -36,7 +36,7 @@ struct GCodeFileInfo float layerHeight; unsigned int numLayers; float objectHeight; - float filamentNeeded[MaxExtruders]; + float filamentNeeded[MaxFilaments]; uint32_t printTime; uint32_t simulatedTime; unsigned int numFilaments; diff --git a/src/Storage/FileInfoParser.cpp b/src/Storage/FileInfoParser.cpp index c18070ed..6b7f872e 100644 --- a/src/Storage/FileInfoParser.cpp +++ b/src/Storage/FileInfoParser.cpp @@ -676,22 +676,21 @@ void FileInfoParser::FindFilamentUsedEmbedded(const char* p, const char *s1, con unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept { unsigned int filamentsFound = 0; - const size_t maxFilaments = reprap.GetGCodes().GetNumExtruders(); // Look for filament usage as generated by Slic3r and Cura const char* const filamentUsedStr1 = "ilament used"; // comment string used by slic3r and Cura, followed by filament used and "mm" const char* p = bufp; - while (filamentsFound < maxFilaments && (p = strstr(p, filamentUsedStr1)) != nullptr) + while (filamentsFound < MaxFilaments && (p = strstr(p, filamentUsedStr1)) != nullptr) { p += strlen(filamentUsedStr1); while(strchr(" [m]:=\t", *p) != nullptr) // Prusa slicer now uses "; filament used [mm] = 4235.9" { ++p; // this allows for " = " from default slic3r comment and ": " from default Cura comment } - while (isDigit(*p) && filamentsFound < maxFilaments) + while (isDigit(*p) && filamentsFound < MaxFilaments) { const char* q; - float filamentLength = SafeStrtof(p, &q); + const float filamentLength = SafeStrtof(p, &q); p = q; if (!std::isnan(filamentLength) && !std::isinf(filamentLength)) { @@ -729,7 +728,7 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept { const char *filamentLengthStr = "ilament length"; // comment string used by S3D p = bufp; - while (filamentsFound < maxFilaments && (p = strstr(p, filamentLengthStr)) != nullptr) + while (filamentsFound < MaxFilaments && (p = strstr(p, filamentLengthStr)) != nullptr) { p += strlen(filamentLengthStr); while(strchr(" :=\t", *p) != nullptr) @@ -738,7 +737,7 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept } if (isDigit(*p)) { - float filamentLength = SafeStrtof(p, nullptr); + const float filamentLength = SafeStrtof(p, nullptr); if (!std::isnan(filamentLength) && !std::isinf(filamentLength)) { parsedFileInfo.filamentNeeded[filamentsFound] = filamentLength; @@ -753,7 +752,7 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept { const char *filamentLengthStr = "; Ext "; p = bufp; - while (filamentsFound < maxFilaments && (p = strstr(p, filamentLengthStr)) != nullptr) + while (filamentsFound < MaxFilaments && (p = strstr(p, filamentLengthStr)) != nullptr) { p += strlen(filamentLengthStr); if (*p == '#') @@ -771,7 +770,7 @@ unsigned int FileInfoParser::FindFilamentUsed(const char* bufp) noexcept if (isDigit(*p)) { - float filamentLength = SafeStrtof(p, nullptr); + const float filamentLength = SafeStrtof(p, nullptr); if (!std::isnan(filamentLength) && !std::isinf(filamentLength)) { parsedFileInfo.filamentNeeded[filamentsFound] = filamentLength; |