Commit 4ed07aef authored by kliment's avatar kliment

Add log window and fix print from SD command

parent f10c2dce
...@@ -91,9 +91,11 @@ class PronterWindow(wx.Frame): ...@@ -91,9 +91,11 @@ class PronterWindow(wx.Frame):
self.pausebtn.Bind(wx.EVT_BUTTON,self.pause) self.pausebtn.Bind(wx.EVT_BUTTON,self.pause)
self.sdprintbtn=wx.Button(self.panel,-1,"SD Print",pos=(180,75)) self.sdprintbtn=wx.Button(self.panel,-1,"SD Print",pos=(180,75))
self.sdprintbtn.Bind(wx.EVT_BUTTON,self.sdprintfile) self.sdprintbtn.Bind(wx.EVT_BUTTON,self.sdprintfile)
self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(300,75),style = wx.TE_PROCESS_ENTER) self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(400,400),style = wx.TE_PROCESS_ENTER)
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline) self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(560,75)) self.logbox=wx.TextCtrl(self.panel,size=(350,300),pos=(400,75),style = wx.TE_MULTILINE)
self.logbox.Disable()
self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(660,400))
self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline) self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline)
self.monitorbox=wx.CheckBox(self.panel,-1,"Monitor",pos=(10,430)) self.monitorbox=wx.CheckBox(self.panel,-1,"Monitor",pos=(10,430))
self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor) self.monitorbox.Bind(wx.EVT_CHECKBOX,self.setmonitor)
...@@ -113,7 +115,13 @@ class PronterWindow(wx.Frame): ...@@ -113,7 +115,13 @@ class PronterWindow(wx.Frame):
self.monitor=self.monitorbox.GetValue() self.monitor=self.monitorbox.GetValue()
def sendline(self,e): def sendline(self,e):
self.p.send_now(self.commandbox.GetValue()) command=self.commandbox.GetValue()
if not len(command):
return
if(command[0]=="g" or command[0]=="m"):
command=command.upper()
wx.CallAfter(self.logbox.AppendText,">>>"+command+"\n")
self.p.send_now(command)
def statuschecker(self): def statuschecker(self):
try: try:
...@@ -123,7 +131,7 @@ class PronterWindow(wx.Frame): ...@@ -123,7 +131,7 @@ class PronterWindow(wx.Frame):
string+="Printer is online." string+="Printer is online."
string+=(self.tempreport.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ",""))+" " string+=(self.tempreport.replace("\r","").replace("T","Hotend").replace("B","Bed").replace("\n","").replace("ok ",""))+" "
if self.sdprinting: if self.sdprinting:
string+= "SD printing:%04.2f %%",(self.spercentdone,) string+= "SD printing:%04.2f %%"%(self.percentdone,)
if self.p.printing: if self.p.printing:
string+= "printing:%04.2f %%"%(100*float(self.p.queueindex)/len(self.p.mainqueue),) string+= "printing:%04.2f %%"%(100*float(self.p.queueindex)/len(self.p.mainqueue),)
wx.CallAfter(self.status.SetStatusText,string) wx.CallAfter(self.status.SetStatusText,string)
...@@ -157,7 +165,10 @@ class PronterWindow(wx.Frame): ...@@ -157,7 +165,10 @@ class PronterWindow(wx.Frame):
def recvcb(self,l): def recvcb(self,l):
if "T:" in l: if "T:" in l:
self.tempreport=l self.tempreport=l
print l tstring=l.replace("\n","").replace("\r","")
print tstring
if(tstring!="ok"):
wx.CallAfter(self.logbox.AppendText,tstring+"\n")
for i in self.recvlisteners: for i in self.recvlisteners:
i(l) i(l)
...@@ -180,8 +191,8 @@ class PronterWindow(wx.Frame): ...@@ -180,8 +191,8 @@ class PronterWindow(wx.Frame):
wx.CallAfter(self.status.SetStatusText,l) wx.CallAfter(self.status.SetStatusText,l)
if "File selected" in l: if "File selected" in l:
wx.CallAfter(self.status.SetStatusText,"Starting print") wx.CallAfter(self.status.SetStatusText,"Starting print")
self.p.send_now("M24")
self.sdprinting=1 self.sdprinting=1
self.p.send_now("M24")
return return
if "Done printing file" in l: if "Done printing file" in l:
wx.CallAfter(self.status.SetStatusText,l) wx.CallAfter(self.status.SetStatusText,l)
...@@ -201,7 +212,7 @@ class PronterWindow(wx.Frame): ...@@ -201,7 +212,7 @@ class PronterWindow(wx.Frame):
def filesloaded(self): def filesloaded(self):
dlg=wx.SingleChoiceDialog(self, "Select the file to print", "Pick SD file", self.sdfiles) dlg=wx.SingleChoiceDialog(self, "Select the file to print", "Pick SD file", self.sdfiles)
if(dlg.ShowModal==wx.ID_OK): if(dlg.ShowModal()==wx.ID_OK):
target=dlg.GetStringSelection() target=dlg.GetStringSelection()
if len(target): if len(target):
self.recvlisteners+=[self.waitforsdresponse] self.recvlisteners+=[self.waitforsdresponse]
......
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