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
gcode_parsed_args = ["x", "y", "e", "f", "z", "p", "i", "j"]
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"]
class Line(object):
......
......@@ -120,6 +120,7 @@ class PronterWindow(MainWindow, pronsole.pronsole):
self.f = None
self.skeinp = None
self.monitor_interval = 3
self.current_pos = [0, 0, 0]
self.paused = False
self.sentlines = Queue.Queue(0)
self.cpbuttons = [
......@@ -943,28 +944,35 @@ class PronterWindow(MainWindow, pronsole.pronsole):
e.Skip()
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
self.onecmd('home X')
if corner == 1: # upper-right
elif corner == 1: # upper-right
self.onecmd('home Y')
if corner == 2: # lower-right
elif corner == 2: # lower-right
self.onecmd('home Z')
if corner == 3: # lower-left
elif corner == 3: # lower-left
self.onecmd('home')
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals
self.zb.clearRepeat()
else:
return
self.onecmd('M114')
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:
self.onecmd('move X %s' % x)
if y != 0:
elif y != 0:
self.onecmd('move Y %s' % y)
# When user clicks on the XY control, the Z control no longer gets spacebar/repeat signals
self.zb.clearRepeat()
else:
return
self.onecmd('M114')
def moveZ(self, z):
if z != 0:
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
self.xyb.clearRepeat()
......@@ -1056,6 +1064,22 @@ class PronterWindow(MainWindow, pronsole.pronsole):
except:
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):
while self.statuscheck:
string = ""
......@@ -1113,7 +1137,10 @@ class PronterWindow(MainWindow, pronsole.pronsole):
return retval
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
wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", ""))
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