Commit 5a059961 authored by Francesco Santini's avatar Francesco Santini

Indentation fixes, limit calculations

parent 360b4f60
...@@ -68,7 +68,7 @@ class GCodeAnalyzer(): ...@@ -68,7 +68,7 @@ class GCodeAnalyzer():
# find a code in a gstring line # find a code in a gstring line
def findCode(self, gcode, codeStr): def findCode(self, gcode, codeStr):
pattern = re.compile(codeStr + "\\s*([\d.-]*)",re.I) pattern = re.compile(codeStr + "\\s*(-?[\d.]*)",re.I)
m=re.search(pattern, gcode) m=re.search(pattern, gcode)
if m == None: if m == None:
return None return None
...@@ -76,7 +76,8 @@ class GCodeAnalyzer(): ...@@ -76,7 +76,8 @@ class GCodeAnalyzer():
return m.group(1) return m.group(1)
def Analyze(self, gcode): def Analyze(self, gcode):
gcode = gcode[:gcode.find(";")] # remove comments gcode = gcode[:gcode.find(";")].lstrip() # remove comments
if gcode.startswith("@"): return # code is a host command
code_g = self.findCode(gcode, "G") code_g = self.findCode(gcode, "G")
code_m = self.findCode(gcode, "M") code_m = self.findCode(gcode, "M")
# we have a g_code # we have a g_code
......
...@@ -31,7 +31,7 @@ class Line(object): ...@@ -31,7 +31,7 @@ class Line(object):
self.relative = False self.relative = False
#ignore host commands #ignore host commands
if "@" in self.raw: if self.raw.startswith("@"):
self.raw = "" self.raw = ""
if ";" in self.raw: if ";" in self.raw:
......
...@@ -250,7 +250,8 @@ class printcore(): ...@@ -250,7 +250,8 @@ class printcore():
try: try:
self.print_thread.join() self.print_thread.join()
except: pass except:
pass
self.print_thread = None self.print_thread = None
...@@ -349,6 +350,7 @@ class printcore(): ...@@ -349,6 +350,7 @@ class printcore():
#now only "pause" is implemented as host command #now only "pause" is implemented as host command
def processHostCommand(self, command): def processHostCommand(self, command):
command = command.lstrip()
if command == "@pause": if command == "@pause":
if self.pronterface != None: if self.pronterface != None:
self.pronterface.pause(None) self.pronterface.pause(None)
...@@ -376,7 +378,7 @@ class printcore(): ...@@ -376,7 +378,7 @@ class printcore():
if self.printing and self.queueindex < len(self.mainqueue): if self.printing and self.queueindex < len(self.mainqueue):
tline = self.mainqueue[self.queueindex] tline = self.mainqueue[self.queueindex]
#check for host command #check for host command
if tline.startswith("@"): if tline.lstrip().startswith("@"):
#it is a host command: pop it from the list #it is a host command: pop it from the list
self.mainqueue.pop(self.queueindex) self.mainqueue.pop(self.queueindex)
self.processHostCommand(tline) self.processHostCommand(tline)
......
...@@ -134,14 +134,17 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -134,14 +134,17 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions) self.build_dimensions_list = self.get_build_dimensions(self.settings.build_dimensions)
#initialize the code analyzer with the correct sizes. There must be a more general way to do so #initialize the code analyzer with the correct sizes. There must be a more general way to do so
self.p.analyzer.maxX = self.build_dimensions_list[0] if self.build_dimensions_list[0] >= self.build_dimensions_list[6] else self.build_dimensions_list[6] # maximum x is maximum x if maximum X > home X, else it is home X
self.p.analyzer.maxY = self.build_dimensions_list[1] if self.build_dimensions_list[1] >= self.build_dimensions_list[7] else self.build_dimensions_list[7]
self.p.analyzer.maxZ = self.build_dimensions_list[2] if self.build_dimensions_list[2] >= self.build_dimensions_list[8] else self.build_dimensions_list[8]
# minimum = offset
self.p.analyzer.minX = self.build_dimensions_list[3] self.p.analyzer.minX = self.build_dimensions_list[3]
self.p.analyzer.minY = self.build_dimensions_list[4] self.p.analyzer.minY = self.build_dimensions_list[4]
self.p.analyzer.minZ = self.build_dimensions_list[5] self.p.analyzer.minZ = self.build_dimensions_list[5]
#max = offset + bedsize
self.p.analyzer.maxX = self.build_dimensions_list[3] + self.build_dimensions_list[0]
self.p.analyzer.maxY = self.build_dimensions_list[4] + self.build_dimensions_list[1]
self.p.analyzer.maxZ = self.build_dimensions_list[5] + self.build_dimensions_list[2]
self.p.analyzer.homeX = self.build_dimensions_list[6] self.p.analyzer.homeX = self.build_dimensions_list[6]
self.p.analyzer.homeY = self.build_dimensions_list[7] self.p.analyzer.homeY = self.build_dimensions_list[7]
self.p.analyzer.homeZ = self.build_dimensions_list[8] self.p.analyzer.homeZ = self.build_dimensions_list[8]
......
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