Commit 659cc031 authored by kliment's avatar kliment

Merge pull request #324 from Lenbok/experimental-gcoder-relative-e

Support M82/M83 for relative E
parents c527601f e2630df4
...@@ -40,6 +40,7 @@ class Line(object): ...@@ -40,6 +40,7 @@ class Line(object):
self.raw = l.upper().lstrip() self.raw = l.upper().lstrip()
self.imperial = False self.imperial = False
self.relative = False self.relative = False
self.relative_e = False
if ";" in self.raw: if ";" in self.raw:
self.raw = self.raw.split(";")[0] self.raw = self.raw.split(";")[0]
...@@ -145,6 +146,7 @@ class Layer(object): ...@@ -145,6 +146,7 @@ class Layer(object):
ymax = -999999999 ymax = -999999999
zmax = -999999999 zmax = -999999999
relative = False relative = False
relative_e = False
current_x = 0 current_x = 0
current_y = 0 current_y = 0
...@@ -200,6 +202,7 @@ class GCode(object): ...@@ -200,6 +202,7 @@ class GCode(object):
#checks for G20, G21, G90 and G91, sets imperial and relative flags #checks for G20, G21, G90 and G91, sets imperial and relative flags
imperial = False imperial = False
relative = False relative = False
relative_e = False
for line in self.lines: for line in self.lines:
if line.command() == "G20": if line.command() == "G20":
imperial = True imperial = True
...@@ -207,11 +210,18 @@ class GCode(object): ...@@ -207,11 +210,18 @@ class GCode(object):
imperial = False imperial = False
elif line.command() == "G90": elif line.command() == "G90":
relative = False relative = False
relative_e = False
elif line.command() == "G91": elif line.command() == "G91":
relative = True relative = True
relative_e = True
elif line.command() == "M82":
relative_e = False
elif line.command() == "M83":
relative_e = True
elif line.is_move(): elif line.is_move():
line.imperial = imperial line.imperial = imperial
line.relative = relative line.relative = relative
line.relative_e = relative_e
def _create_layers(self): def _create_layers(self):
self.layers = [] self.layers = []
...@@ -316,7 +326,7 @@ class GCode(object): ...@@ -316,7 +326,7 @@ class GCode(object):
total_e += cur_e total_e += cur_e
cur_e = line.e cur_e = line.e
elif line.is_move() and line.e: elif line.is_move() and line.e:
if line.relative: if line.relative_e:
cur_e += line.e cur_e += line.e
else: else:
cur_e = line.e cur_e = line.e
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment