Commit b335a4cf authored by fsantini's avatar fsantini

G-codes and relevant M-codes implemented (check for tabs/spaces)

parent 60158d5e
...@@ -71,6 +71,7 @@ class GCodeAnalyzer(): ...@@ -71,6 +71,7 @@ class GCodeAnalyzer():
def Analyze(self, gcode): def Analyze(self, gcode):
code_g = self.findCode(gcode, "G") code_g = self.findCode(gcode, "G")
code_m = self.findCode(gcode, "M")
# we have a g_code # we have a g_code
if code_g != None: if code_g != None:
...@@ -122,4 +123,55 @@ class GCodeAnalyzer(): ...@@ -122,4 +123,55 @@ class GCodeAnalyzer():
code_e = self.findCode(gcode, "E") code_e = self.findCode(gcode, "E")
homeAll = False homeAll = False
if code_x == None and code_y == None and code_z == None: homeAll = True if code_x == None and code_y == None and code_z == None: homeAll = True
if code_x != None or homeAll:
self.xOffset = 0
self.x = self.homeX
if code_y != None or homeAll:
self.yOffset = 0
self.y = self.homeY
if code_z != None or homeAll:
self.zOffset = 0
self.z = self.homeZ
if code_e != None:
self.eOffset = 0
self.e = 0
elif code_g == 162:
code_x = self.findCode(gcode, "X")
code_y = self.findCode(gcode, "Y")
code_z = self.findCode(gcode, "Z")
homeAll = False
if code_x == None and code_y == None and code_z == None: homeAll = True
if code_x != None or homeAll:
self.xOffset = 0
self.x = self.maxX
if code_y != None or homeAll:
self.yOffset = 0
self.y = self.maxY
if code_z != None or homeAll:
self.zOffset = 0
self.z = self.maxZ
elif code_g == 90: self.relative = False
elif code_g == 91: self.relative = True
elif code_g == 92:
code_x = self.findCode(gcode, "X")
code_y = self.findCode(gcode, "Y")
code_z = self.findCode(gcode, "Z")
code_e = self.findCode(gcode, "E")
if code_x != None:
self.xOffset = self.x - float(code_x)
self.x = self.xOffset
if code_y != None:
self.yOffset = self.y - float(code_y)
self.y = self.yOffset
if code_z != None:
self.zOffset = self.z - float(code_z)
self.z = self.zOffset
if code_e != None:
self.xOffset = self.e - float(code_e)
self.e = self.eOffset
#End code_g != None
if code_m != None:
code_m = int(code_m)
if code_m == 82: self.eRelative = False
elif code_m == 83: self.eRelative = True
\ No newline at end of file
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