Commit 4ab81175 authored by kliment's avatar kliment

Add skeinforge settings support. Make printing non-modal. Experimental pausing.

parent 7fd5c664
...@@ -19,6 +19,7 @@ class printcore(): ...@@ -19,6 +19,7 @@ class printcore():
self.queueindex=0 self.queueindex=0
self.lineno=0 self.lineno=0
self.resendfrom=-1 self.resendfrom=-1
self.paused=False
self.sentlines={} self.sentlines={}
self.log=[] self.log=[]
self.sent=[] self.sent=[]
...@@ -62,7 +63,7 @@ class printcore(): ...@@ -62,7 +63,7 @@ class printcore():
"""This function acts on messages from the firmware """This function acts on messages from the firmware
""" """
self.clear=True self.clear=True
time.sleep(1) time.sleep(0.5)
self.send_now("M105") self.send_now("M105")
while(True): while(True):
if(not self.printer or not self.printer.isOpen): if(not self.printer or not self.printer.isOpen):
...@@ -124,12 +125,14 @@ class printcore(): ...@@ -124,12 +125,14 @@ class printcore():
def pause(self): def pause(self):
"""Pauses the print, saving the current position. """Pauses the print, saving the current position.
""" """
self.paused=True
self.printing=False self.printing=False
time.sleep(1) time.sleep(1)
def resume(self): def resume(self):
"""Resumes a paused print. """Resumes a paused print.
""" """
self.paused=False
self.printing=True self.printing=True
Thread(target=self._print).start() Thread(target=self._print).start()
...@@ -194,6 +197,8 @@ class printcore(): ...@@ -194,6 +197,8 @@ class printcore():
self.queueindex+=1 self.queueindex+=1
else: else:
self.printing=False self.printing=False
self.clear=True
if(not self.paused):
self.queueindex=0 self.queueindex=0
self.lineno=0 self.lineno=0
self._send("M110",-1, True) self._send("M110",-1, True)
......
...@@ -291,17 +291,39 @@ class pronsole(cmd.Cmd): ...@@ -291,17 +291,39 @@ class pronsole(cmd.Cmd):
print "Not connected to printer." print "Not connected to printer."
return return
print("Printing "+self.filename) print("Printing "+self.filename)
print("Press Ctrl-C to interrupt print (you can resume it with the resume command)") print("You can monitor the print with the monitor command.")
self.p.startprint(self.f) self.p.startprint(self.f)
#self.p.pause()
#self.paused=True
#self.do_resume(None)
def do_pause(self,l):
if self.sdprinting:
self.p.send_now("M25")
else:
if(not self.p.printing):
print "Not printing, cannot pause."
return
self.p.pause() self.p.pause()
self.p.connect()# This seems to work, but is not a good solution.
self.paused=True self.paused=True
self.do_resume(None)
#self.do_resume(None)
def help_pause(self,l):
print "Pauses a running print"
def do_resume(self,l): def do_resume(self,l):
if not self.paused: if not self.paused:
print "Not paused, unable to resume. Start a print first." print "Not paused, unable to resume. Start a print first."
return return
self.paused=False self.paused=False
if self.sdprinting:
self.p.send_now("M24")
return
else:
self.p.resume()
return
try: try:
self.p.resume() self.p.resume()
#print self.p.printing #print self.p.printing
...@@ -652,6 +674,9 @@ class pronsole(cmd.Cmd): ...@@ -652,6 +674,9 @@ class pronsole(cmd.Cmd):
if(self.sdprinting): if(self.sdprinting):
self.p.send_now("M27") self.p.send_now("M27")
print (self.tempreadings.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","")) print (self.tempreadings.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ",""))
if(self.p.printing):
print "Print progress: ", 100*float(self.p.queueindex)/len(self.p.mainqueue), "%"
if(self.sdprinting): if(self.sdprinting):
print "SD print progress: ", self.percentdone,"%" print "SD print progress: ", self.percentdone,"%"
time.sleep(interval) time.sleep(interval)
...@@ -669,6 +694,10 @@ class pronsole(cmd.Cmd): ...@@ -669,6 +694,10 @@ class pronsole(cmd.Cmd):
if len(l)==0: if len(l)==0:
print "No file name given." print "No file name given."
return return
settings=0
if(l[0]=="set"):
settings=1
else:
print "Skeining file:"+l[0] print "Skeining file:"+l[0]
if not(os.path.exists(l[0])): if not(os.path.exists(l[0])):
print "File not found!" print "File not found!"
...@@ -681,6 +710,10 @@ class pronsole(cmd.Cmd): ...@@ -681,6 +710,10 @@ class pronsole(cmd.Cmd):
pass pass
try: try:
from skeinforge.skeinforge_application.skeinforge_utilities import skeinforge_craft from skeinforge.skeinforge_application.skeinforge_utilities import skeinforge_craft
from skeinforge.skeinforge_application import skeinforge
if(settings):
skeinforge.main()
else:
if(len(l)>1): if(len(l)>1):
if(l[1] == "view"): if(l[1] == "view"):
skeinforge_craft.writeOutput(l[0],True) skeinforge_craft.writeOutput(l[0],True)
...@@ -707,6 +740,7 @@ class pronsole(cmd.Cmd): ...@@ -707,6 +740,7 @@ class pronsole(cmd.Cmd):
print "Creates a gcode file from an stl model using skeinforge (with tab-completion)" print "Creates a gcode file from an stl model using skeinforge (with tab-completion)"
print "skein filename.stl - create gcode file" print "skein filename.stl - create gcode file"
print "skein filename.stl view - create gcode file and view using skeiniso" print "skein filename.stl view - create gcode file and view using skeiniso"
print "skein set - adjust skeinforge settings"
interp=pronsole() interp=pronsole()
......
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