Rework pause/resume
parent
eaab285912
commit
898a43e5e5
|
@ -66,6 +66,7 @@ class printcore():
|
||||||
self.wait = 0 # default wait period for send(), send_now()
|
self.wait = 0 # default wait period for send(), send_now()
|
||||||
self.read_thread = None
|
self.read_thread = None
|
||||||
self.stop_read_thread = False
|
self.stop_read_thread = False
|
||||||
|
self.print_thread = None
|
||||||
if port is not None and baud is not None:
|
if port is not None and baud is not None:
|
||||||
#print port, baud
|
#print port, baud
|
||||||
self.connect(port, baud)
|
self.connect(port, baud)
|
||||||
|
@ -207,7 +208,8 @@ class printcore():
|
||||||
if len(data)==0:
|
if len(data)==0:
|
||||||
return True
|
return True
|
||||||
self.clear=False
|
self.clear=False
|
||||||
Thread(target=self._print).start()
|
self.print_thread = Thread(target = self._print)
|
||||||
|
self.print_thread.start()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def pause(self):
|
def pause(self):
|
||||||
|
@ -215,14 +217,16 @@ class printcore():
|
||||||
"""
|
"""
|
||||||
self.paused = True
|
self.paused = True
|
||||||
self.printing = False
|
self.printing = False
|
||||||
time.sleep(1)
|
self.print_thread.join()
|
||||||
|
self.print_thread = None
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
"""Resumes a paused print.
|
"""Resumes a paused print.
|
||||||
"""
|
"""
|
||||||
self.paused = False
|
self.paused = False
|
||||||
self.printing = True
|
self.printing = True
|
||||||
Thread(target=self._print).start()
|
self.print_thread = Thread(target = self._print)
|
||||||
|
self.print_thread.start()
|
||||||
|
|
||||||
def send(self,command,wait=0):
|
def send(self,command,wait=0):
|
||||||
"""Adds a command to the checksummed main command queue if printing, or sends the command immediately if not printing
|
"""Adds a command to the checksummed main command queue if printing, or sends the command immediately if not printing
|
||||||
|
@ -290,7 +294,7 @@ class printcore():
|
||||||
def _sendnext(self):
|
def _sendnext(self):
|
||||||
if(not self.printer):
|
if(not self.printer):
|
||||||
return
|
return
|
||||||
while not self.clear:
|
while self.printer and self.printing and not self.clear:
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
self.clear=False
|
self.clear=False
|
||||||
if not (self.printing and self.printer and self.online):
|
if not (self.printing and self.printer and self.online):
|
||||||
|
|
Loading…
Reference in New Issue