Commit 483ae2a5 authored by Guillaume Seguin's avatar Guillaume Seguin

Cleanup

parent 6c90b106
...@@ -75,77 +75,63 @@ class GCodeAnalyzer(): ...@@ -75,77 +75,63 @@ class GCodeAnalyzer():
self.lastY = self.y self.lastY = self.y
self.lastZ = self.z self.lastZ = self.z
self.lastE = self.e self.lastE = self.e
code_f = gline.f if gline.f is not None:
if code_f is not None: self.f = gline.f
self.f = code_f
code_x = gline.x
code_y = gline.y
code_z = gline.z
code_e = gline.e
if self.gcoder.relative: if self.gcoder.relative:
if code_x is not None: self.x += code_x if gline.x is not None: self.x += gline.x
if code_y is not None: self.y += code_y if gline.y is not None: self.y += gline.y
if code_z is not None: self.z += code_z if gline.z is not None: self.z += gline.z
if code_e is not None: if gline.e is not None:
if code_e != 0: if gline.e != 0:
self.e += code_e self.e += gline.e
else: else:
# absolute coordinates # absolute coordinates
if code_x is not None: self.x = self.xOffset + code_x if gline.x is not None: self.x = self.xOffset + gline.x
if code_y is not None: self.y = self.yOffset + code_y if gline.y is not None: self.y = self.yOffset + gline.y
if code_z is not None: self.z = self.zOffset + code_z if gline.z is not None: self.z = self.zOffset + gline.z
if code_e is not None: if gline.e is not None:
if self.gcoder.relative_e: if self.gcoder.relative_e:
if code_e != 0: if gline.e != 0:
self.e += code_e self.e += gline.e
else: else:
# e is absolute. Is it changed? # e is absolute. Is it changed?
if self.e != self.eOffset + code_e: if self.e != self.eOffset + gline.e:
self.e = self.eOffset + code_e self.e = self.eOffset + gline.e
elif code_g == 28 or code_g == 161: elif code_g == 28 or code_g == 161:
self.lastX = self.x self.lastX = self.x
self.lastY = self.y self.lastY = self.y
self.lastZ = self.z self.lastZ = self.z
self.lastE = self.e self.lastE = self.e
code_x = gline.x
code_y = gline.y
code_z = gline.z
code_e = gline.e
homeAll = False homeAll = False
if code_x is None and code_y is None and code_z is None: homeAll = True if gline.x is None and gline.y is None and gline.z is None: homeAll = True
if code_x is not None or homeAll: if gline.x is not None or homeAll:
self.hasHomeX = True self.hasHomeX = True
self.xOffset = 0 self.xOffset = 0
self.x = self.homeX self.x = self.homeX
if code_y is not None or homeAll: if gline.y is not None or homeAll:
self.hasHomeY = True self.hasHomeY = True
self.yOffset = 0 self.yOffset = 0
self.y = self.homeY self.y = self.homeY
if code_z is not None or homeAll: if gline.z is not None or homeAll:
self.hasHomeZ = True self.hasHomeZ = True
self.zOffset = 0 self.zOffset = 0
self.z = self.homeZ self.z = self.homeZ
if code_e is not None: if gline.e is not None:
self.eOffset = 0 self.eOffset = 0
self.e = 0 self.e = 0
elif code_g == 92: elif code_g == 92:
code_x = gline.x if gline.x is not None:
code_y = gline.y self.xOffset = self.x - float(gline.x)
code_z = gline.z
code_e = gline.e
if code_x is not None:
self.xOffset = self.x - float(code_x)
self.x = self.xOffset self.x = self.xOffset
if code_y is not None: if gline.y is not None:
self.yOffset = self.y - float(code_y) self.yOffset = self.y - float(gline.y)
self.y = self.yOffset self.y = self.yOffset
if code_z is not None: if gline.z is not None:
self.zOffset = self.z - float(code_z) self.zOffset = self.z - float(gline.z)
self.z = self.zOffset self.z = self.zOffset
if code_e is not None: if gline.e is not None:
self.xOffset = self.e - float(code_e) self.xOffset = self.e - float(gline.e)
self.e = self.eOffset self.e = self.eOffset
def print_status(self): def print_status(self):
......
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