diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-08-28 17:30:27 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-08-28 17:30:27 +0300 |
commit | 2f8c5b0e98747dc28974f56e084304df8b2e770b (patch) | |
tree | bfc7fa2647ed2a769158cf64faa846168ad35180 /src/GCodes/GCodeBuffer/StringParser.cpp | |
parent | ce3b93cd737f34c9206d6c42e3d277676c7f1f58 (diff) |
Added M584 R parameter; support T{expression}
Diffstat (limited to 'src/GCodes/GCodeBuffer/StringParser.cpp')
-rw-r--r-- | src/GCodes/GCodeBuffer/StringParser.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp index efbdc175..d7ee0e7b 100644 --- a/src/GCodes/GCodeBuffer/StringParser.cpp +++ b/src/GCodes/GCodeBuffer/StringParser.cpp @@ -705,36 +705,46 @@ void StringParser::DecodeCommand() noexcept commandLetter = cl; hasCommandNumber = false; commandNumber = -1; - parameterStart = commandStart + 1; - const bool negative = (gb.buffer[parameterStart] == '-'); - if (negative) + if (cl == 'T' && gb.buffer[commandStart + 1] == '{') { - ++parameterStart; + // It's a T command with an expression for the tool number. This will be treated as if it's "T T{...}. + commandLetter = cl; + hasCommandNumber = false; + parameterStart = commandStart; // so that 'Seen('T')' will return true } - if (isdigit(gb.buffer[parameterStart])) + else { - hasCommandNumber = true; - // Read the number after the command letter - commandNumber = 0; - do + parameterStart = commandStart + 1; + const bool negative = (gb.buffer[parameterStart] == '-'); + if (negative) { - commandNumber = (10 * commandNumber) + (gb.buffer[parameterStart] - '0'); ++parameterStart; } - while (isdigit(gb.buffer[parameterStart])); - if (negative) + if (isdigit(gb.buffer[parameterStart])) { - commandNumber = -commandNumber; - } + hasCommandNumber = true; + // Read the number after the command letter + commandNumber = 0; + do + { + commandNumber = (10 * commandNumber) + (gb.buffer[parameterStart] - '0'); + ++parameterStart; + } + while (isdigit(gb.buffer[parameterStart])); + if (negative) + { + commandNumber = -commandNumber; + } - // Read the fractional digit, if any - if (gb.buffer[parameterStart] == '.') - { - ++parameterStart; - if (isdigit(gb.buffer[parameterStart])) + // Read the fractional digit, if any + if (gb.buffer[parameterStart] == '.') { - commandFraction = gb.buffer[parameterStart] - '0'; ++parameterStart; + if (isdigit(gb.buffer[parameterStart])) + { + commandFraction = gb.buffer[parameterStart] - '0'; + ++parameterStart; + } } } } |