diff options
Diffstat (limited to 'src/GCodes/GCodeBuffer.cpp')
-rw-r--r-- | src/GCodes/GCodeBuffer.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/GCodes/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer.cpp index 1db905bb..ee852627 100644 --- a/src/GCodes/GCodeBuffer.cpp +++ b/src/GCodes/GCodeBuffer.cpp @@ -170,7 +170,6 @@ bool GCodeBuffer::IsEmpty() const // Is 'c' in the G Code string? // Leave the pointer there for a subsequent read. - bool GCodeBuffer::Seen(char c) { readPointer = 0; @@ -185,6 +184,24 @@ bool GCodeBuffer::Seen(char c) return false; } +// Return the first G, M or T command letter. Needed so that we don't pick up a spurious command letter form inside a string parameter. +char GCodeBuffer::GetCommandLetter() +{ + readPointer = 0; + for (;;) + { + const char b = gcodeBuffer[readPointer]; + if (b == 0 || b == ';') break; + if (b == 'G' || b == 'M' || b == 'T') + { + return b; + } + ++readPointer; + } + readPointer = -1; + return 0; +} + // Get a float after a G Code letter found by a call to Seen() float GCodeBuffer::GetFValue() { |