Commit fd6eb8ac authored by kliment's avatar kliment

Add reset command. Make gettemp and monitor less misleading

parent 69b0eed1
...@@ -59,6 +59,14 @@ class printcore(): ...@@ -59,6 +59,14 @@ class printcore():
self.printer=Serial(self.port,self.baud,timeout=5) self.printer=Serial(self.port,self.baud,timeout=5)
Thread(target=self._listen).start() Thread(target=self._listen).start()
def reset(self):
"""Reset the printer
"""
if(self.printer):
self.printer.setDTR(1)
self.printer.setDTR(0)
def _listen(self): def _listen(self):
"""This function acts on messages from the firmware """This function acts on messages from the firmware
""" """
...@@ -78,7 +86,7 @@ class printcore(): ...@@ -78,7 +86,7 @@ class printcore():
print "RECV: ",line print "RECV: ",line
if(line.startswith('start') or line.startswith('ok') or "T:" in line): if(line.startswith('start') or line.startswith('ok') or "T:" in line):
self.clear=True self.clear=True
if not self.online and self.onlinecb is not None: if (not self.online or line.startswith('start')) and self.onlinecb is not None:
self.onlinecb() self.onlinecb()
self.online=True self.online=True
if(line.startswith('ok')): if(line.startswith('ok')):
......
...@@ -401,6 +401,12 @@ class pronsole(cmd.Cmd): ...@@ -401,6 +401,12 @@ class pronsole(cmd.Cmd):
except: except:
pass pass
def do_reset(self,l):
self.p.reset()
def help_reset(self):
print "Resets the printer."
def do_sdprint(self,l): def do_sdprint(self,l):
if not self.p.online: if not self.p.online:
print "Printer is not online. Try connect to it first." print "Printer is not online. Try connect to it first."
...@@ -466,14 +472,14 @@ class pronsole(cmd.Cmd): ...@@ -466,14 +472,14 @@ class pronsole(cmd.Cmd):
def tempcb(self,l): def tempcb(self,l):
if "T:" in l: if "T:" in l:
print l.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","") print l.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ","")
self.recvlisteners.remove(self.tempcb)
def do_gettemp(self,l): def do_gettemp(self,l):
if self.p.online: if self.p.online:
self.recvlisteners+=[self.tempcb] self.recvlisteners+=[self.tempcb]
self.p.send_now("M105") self.p.send_now("M105")
time.sleep(0.5) time.sleep(0.75)
self.recvlisteners.remove(self.tempcb)
def help_gettemp(self): def help_gettemp(self):
print "Read the extruder and bed temperature." print "Read the extruder and bed temperature."
...@@ -678,13 +684,14 @@ class pronsole(cmd.Cmd): ...@@ -678,13 +684,14 @@ class pronsole(cmd.Cmd):
self.p.send_now("M105") self.p.send_now("M105")
if(self.sdprinting): if(self.sdprinting):
self.p.send_now("M27") self.p.send_now("M27")
time.sleep(interval)
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): if(self.p.printing):
print "Print progress: ", 100*float(self.p.queueindex)/len(self.p.mainqueue), "%" 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)
except: except:
print "Done monitoring." print "Done monitoring."
pass pass
......
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