Skip to content

Commit

Permalink
Merge pull request #1114 from volconst/resume-rel-extr
Browse files Browse the repository at this point in the history
Resume file with relative extrusion
  • Loading branch information
kliment authored Sep 28, 2020
2 parents 79559b2 + 0fbc69a commit 9fb322b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
56 changes: 24 additions & 32 deletions printrun/printcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,12 @@ def pause(self):
self.paused = True
self.printing = False

# try joining the print thread: enclose it in try/except because we
# might be calling it from the thread itself
try:
self.print_thread.join()
except RuntimeError as e:
if e.message == "cannot join current thread":
pass
else:
# ';@pause' in the gcode file calls pause from the print thread
if not threading.current_thread() is self.print_thread:
try:
self.print_thread.join()
except:
self.logError(traceback.format_exc())
except:
self.logError(traceback.format_exc())

self.print_thread = None

Expand All @@ -551,31 +546,28 @@ def pause(self):
self.pauseE = self.analyzer.abs_e
self.pauseF = self.analyzer.current_f
self.pauseRelative = self.analyzer.relative
self.pauseRelativeE = self.analyzer.relative_e

def resume(self):
"""Resumes a paused print.
"""
"""Resumes a paused print."""
if not self.paused: return False
if self.paused:
# restores the status
self.send_now("G90") # go to absolute coordinates

xyFeedString = ""
zFeedString = ""
if self.xy_feedrate is not None:
xyFeedString = " F" + str(self.xy_feedrate)
if self.z_feedrate is not None:
zFeedString = " F" + str(self.z_feedrate)

self.send_now("G1 X%s Y%s%s" % (self.pauseX, self.pauseY,
xyFeedString))
self.send_now("G1 Z" + str(self.pauseZ) + zFeedString)
self.send_now("G92 E" + str(self.pauseE))

# go back to relative if needed
if self.pauseRelative: self.send_now("G91")
# reset old feed rate
self.send_now("G1 F" + str(self.pauseF))
# restores the status
self.send_now("G90") # go to absolute coordinates

xyFeed = '' if self.xy_feedrate is None else ' F' + str(self.xy_feedrate)
zFeed = '' if self.z_feedrate is None else ' F' + str(self.z_feedrate)

self.send_now("G1 X%s Y%s%s" % (self.pauseX, self.pauseY, xyFeed))
self.send_now("G1 Z" + str(self.pauseZ) + zFeed)
self.send_now("G92 E" + str(self.pauseE))

# go back to relative if needed
if self.pauseRelative:
self.send_now("G91")
if self.pauseRelativeE:
self.send_now('M83')
# reset old feed rate
self.send_now("G1 F" + str(self.pauseF))

self.paused = False
self.printing = True
Expand Down
10 changes: 10 additions & 0 deletions testfiles/pause-restore-rel-e.gcode
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; test restoring of relative extrusion mode
; after pause https://github.com/kliment/Printrun/issues/1083
G28
G90 ; abs all, including E
M83 ; relative E
;@!print('Please press Resume and check for M 83')
;@!self.p.loud = True
;@pause
;@!self.p.loud = False
;@!threading.Timer(2, lambda logbox: print('PASSED. Seen M 83' if 'M' + '83' in logbox.Value else 'FAILED: M 83 not seen'), (self.logbox,)).start()

0 comments on commit 9fb322b

Please sign in to comment.