Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/GCodeParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ SOFTWARE.
void GCodeParser::Initialize()
{
lineCharCount = 0;
lastPointer = -1;
lastWord = '\0';
line[lineCharCount] = '\0';
comments = line;
lastComment = comments;
Expand Down Expand Up @@ -367,9 +369,11 @@ bool GCodeParser::HasWord(char letter)
{
return false;
}
lastPointer = pointer;
lastWord = letter;
return true;
}

return true;
return false;
}

char wordLetter[] = { 'A', 'B', 'C', 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '\0' };
Expand Down Expand Up @@ -470,7 +474,14 @@ bool GCodeParser::NoWords()
/// </remarks>
double GCodeParser::GetWordValue(char letter)
{
int pointer = FindWord(letter);
int pointer = 0;
if(lastWord == letter && lastPointer >= 0) pointer = lastPointer;
else
{
pointer = FindWord(letter);
lastWord = letter;
lastPointer = pointer;
}

if (line[pointer] != '\0')
return (double)strtod(&line[pointer + 1], NULL);
Expand Down
2 changes: 2 additions & 0 deletions src/GCodeParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class GCodeParser
{
private:
int lineCharCount;
int lastPointer = -1;
char lastWord = '\0';

public:
char line[MAX_LINE_SIZE + 2];
Expand Down