Commit d706b876 authored by D1plo1d's avatar D1plo1d

Merge branch 'master' of github.com:kliment/Printrun

parents 5bfee16a 46379470
...@@ -398,12 +398,14 @@ class GCode(object): ...@@ -398,12 +398,14 @@ class GCode(object):
self.height = self.zmax - self.zmin self.height = self.zmax - self.zmin
def estimate_duration(self): def estimate_duration(self):
lastx = lasty = laste = lastf = 0.0 lastx = lasty = lastz = laste = lastf = 0.0
lastdx = 0
lastdy = 0
x = y = e = f = 0.0 x = y = e = f = 0.0
currenttravel = 0.0 currenttravel = 0.0
moveduration = 0.0 moveduration = 0.0
totalduration = 0.0 totalduration = 0.0
acceleration = 1500.0 # mm/s/s ASSUMING THE DEFAULT FROM SPRINTER !!! acceleration = 2000.0 # mm/s^2
layerbeginduration = 0.0 layerbeginduration = 0.0
#TODO: #TODO:
# get device caps from firmware: max speed, acceleration/axis # get device caps from firmware: max speed, acceleration/axis
...@@ -422,6 +424,7 @@ class GCode(object): ...@@ -422,6 +424,7 @@ class GCode(object):
else: else:
x = line.x if line.x is not None else lastx x = line.x if line.x is not None else lastx
y = line.y if line.y is not None else lasty y = line.y if line.y is not None else lasty
z = line.z if line.z is not None else lastz
e = line.e if line.e is not None else laste e = line.e if line.e is not None else laste
# mm/s vs mm/m => divide by 60 # mm/s vs mm/m => divide by 60
f = line.f / 60.0 if line.f is not None else lastf f = line.f / 60.0 if line.f is not None else lastf
...@@ -438,10 +441,20 @@ class GCode(object): ...@@ -438,10 +441,20 @@ class GCode(object):
# subsquent moves are in opposite directions, as requested # subsquent moves are in opposite directions, as requested
# speed is constant but printer has to fully decellerate # speed is constant but printer has to fully decellerate
# and reaccelerate # and reaccelerate
# The following code tries to fix it by forcing a full
currenttravel = math.hypot(x - lastx, y - lasty) # reacceleration if this move is in the opposite direction
if currenttravel == 0 and line.e is not None: # of the previous one
currenttravel = abs(line.e) if line.relative_e else abs(line.e - laste) dx = x - lastx
dy = y - lasty
if dx * lastdx + dy * lastdy <= 0:
lastf = 0
currenttravel = math.hypot(dx, dy)
if currenttravel == 0:
if line.z is not None:
currenttravel = abs(line.z) if line.relative else abs(line.z - lastz)
elif line.e is not None:
currenttravel = abs(line.e) if line.relative_e else abs(line.e - laste)
# Feedrate hasn't changed, no acceleration/decceleration planned # Feedrate hasn't changed, no acceleration/decceleration planned
if f == lastf: if f == lastf:
moveduration = currenttravel / f if f != 0 else 0. moveduration = currenttravel / f if f != 0 else 0.
...@@ -458,10 +471,14 @@ class GCode(object): ...@@ -458,10 +471,14 @@ class GCode(object):
# FIXME: probably a little bit optimistic, but probably a much better estimate than the previous one: # FIXME: probably a little bit optimistic, but probably a much better estimate than the previous one:
# moveduration = math.sqrt(2 * distance / acceleration) # probably buggy : not taking actual travel into account # moveduration = math.sqrt(2 * distance / acceleration) # probably buggy : not taking actual travel into account
lastdx = dx
lastdy = dy
totalduration += moveduration totalduration += moveduration
lastx = x lastx = x
lasty = y lasty = y
lastz = z
laste = e laste = e
lastf = f lastf = f
......
...@@ -33,7 +33,7 @@ def iconfile(filename): ...@@ -33,7 +33,7 @@ def iconfile(filename):
if hasattr(sys, "frozen") and sys.frozen == "windows_exe": if hasattr(sys, "frozen") and sys.frozen == "windows_exe":
return sys.executable return sys.executable
else: else:
return pixmapfile("plater.ico") return pixmapfile(filename)
def imagefile(filename): def imagefile(filename):
for prefix in ['/usr/local/share/pronterface/images', for prefix in ['/usr/local/share/pronterface/images',
......
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