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