Commit 8013ac86 authored by Guillaume Seguin's avatar Guillaume Seguin

Implement coordinate tracking for manual moves (#343)

This change needs testing : M114 is unbuffered, and thus might break lookahead
for Marlin and results in laggy jogging. We need to see how bad this is and
find some smart way to do it (like to send the M114 only when the user stopped
clicking everywhere, by using some timer callbacks).
parent d94ba0de
...@@ -21,6 +21,7 @@ import datetime ...@@ -21,6 +21,7 @@ import datetime
gcode_parsed_args = ["x", "y", "e", "f", "z", "p", "i", "j"] gcode_parsed_args = ["x", "y", "e", "f", "z", "p", "i", "j"]
gcode_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|[a-z][-+]?[0-9]*\.?[0-9]*") gcode_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|[a-z][-+]?[0-9]*\.?[0-9]*")
m114_exp = re.compile("\([^\(\)]*\)|[/\*].*\n|[A-Z]:?[-+]?[0-9]*\.?[0-9]*")
move_gcodes = ["G0", "G1", "G2", "G3"] move_gcodes = ["G0", "G1", "G2", "G3"]
class Line(object): class Line(object):
......
...@@ -120,6 +120,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -120,6 +120,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.f = None self.f = None
self.skeinp = None self.skeinp = None
self.monitor_interval = 3 self.monitor_interval = 3
self.current_pos = [0, 0, 0]
self.paused = False self.paused = False
self.sentlines = Queue.Queue(0) self.sentlines = Queue.Queue(0)
self.cpbuttons = [ self.cpbuttons = [
...@@ -943,28 +944,35 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -943,28 +944,35 @@ class PronterWindow(MainWindow, pronsole.pronsole):
e.Skip() e.Skip()
def homeButtonClicked(self, corner): def homeButtonClicked(self, corner):
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals
self.zb.clearRepeat()
if corner == 0: # upper-left if corner == 0: # upper-left
self.onecmd('home X') self.onecmd('home X')
if corner == 1: # upper-right elif corner == 1: # upper-right
self.onecmd('home Y') self.onecmd('home Y')
if corner == 2: # lower-right elif corner == 2: # lower-right
self.onecmd('home Z') self.onecmd('home Z')
if corner == 3: # lower-left elif corner == 3: # lower-left
self.onecmd('home') self.onecmd('home')
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals else:
self.zb.clearRepeat() return
self.onecmd('M114')
def moveXY(self, x, y): def moveXY(self, x, y):
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals
self.zb.clearRepeat()
if x != 0: if x != 0:
self.onecmd('move X %s' % x) self.onecmd('move X %s' % x)
if y != 0: elif y != 0:
self.onecmd('move Y %s' % y) self.onecmd('move Y %s' % y)
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals else:
self.zb.clearRepeat() return
self.onecmd('M114')
def moveZ(self, z): def moveZ(self, z):
if z != 0: if z != 0:
self.onecmd('move Z %s' % z) self.onecmd('move Z %s' % z)
self.onecmd('M114')
# When user clicks on the Z control, the XY control no longer gets spacebar/repeat signals # When user clicks on the Z control, the XY control no longer gets spacebar/repeat signals
self.xyb.clearRepeat() self.xyb.clearRepeat()
...@@ -1056,6 +1064,22 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1056,6 +1064,22 @@ class PronterWindow(MainWindow, pronsole.pronsole):
except: except:
traceback.print_exc() traceback.print_exc()
def update_pos(self, l):
bits = gcoder.m114_exp.findall(l)
x = None
y = None
z = None
for bit in bits:
if not x and bit.startswith("X"):
x = float(bit[1:].replace(":",""))
elif not y and bit.startswith("Y"):
y = float(bit[1:].replace(":",""))
elif not z and bit.startswith("Z"):
z = float(bit[1:].replace(":",""))
if x: self.current_pos[0] = x
if y: self.current_pos[1] = y
if z: self.current_pos[2] = z
def statuschecker(self): def statuschecker(self):
while self.statuscheck: while self.statuscheck:
string = "" string = ""
...@@ -1113,7 +1137,10 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1113,7 +1137,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
return retval return retval
def recvcb(self, l): def recvcb(self, l):
if "T:" in l: if "ok C:" in l:
self.posreport = l
self.update_pos()
if "ok T:" in l:
self.tempreport = l self.tempreport = l
wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", "")) wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", ""))
self.update_tempdisplay() self.update_tempdisplay()
......
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