Commit e986b824 authored by Keegi's avatar Keegi

Merge remote branch 'kliment/master'

parents d08bc641 61af573e
...@@ -100,6 +100,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -100,6 +100,12 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def online(self): def online(self):
print "Printer is now online" print "Printer is now online"
self.connectbtn.Disable();
for i in self.printerControls:
i.Enable()
if self.filename:
self.printbtn.Enable()
def sentcb(self,line): def sentcb(self,line):
if("G1" in line): if("G1" in line):
...@@ -216,6 +222,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -216,6 +222,10 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.Close() self.Close()
def popwindow(self): def popwindow(self):
# this list will contain all controls that should be only enabled
# when we're connected to a printer
self.printerControls = []
#sizer layout: topsizer is a column sizer containing two sections #sizer layout: topsizer is a column sizer containing two sections
#upper section contains the mini view buttons #upper section contains the mini view buttons
#lower section contains the rest of the window - manual controls, console, visualizations #lower section contains the rest of the window - manual controls, console, visualizations
...@@ -249,6 +259,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -249,6 +259,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.connectbtn.Bind(wx.EVT_BUTTON,self.connect) self.connectbtn.Bind(wx.EVT_BUTTON,self.connect)
self.disconnectbtn=wx.Button(self.panel,-1,"Disconnect",pos=(470,0)) self.disconnectbtn=wx.Button(self.panel,-1,"Disconnect",pos=(470,0))
self.disconnectbtn.Bind(wx.EVT_BUTTON,self.disconnect) self.disconnectbtn.Bind(wx.EVT_BUTTON,self.disconnect)
self.printerControls.append(self.disconnectbtn)
uts.Add(self.disconnectbtn) uts.Add(self.disconnectbtn)
self.resetbtn=wx.Button(self.panel,-1,"Reset",pos=(560,0)) self.resetbtn=wx.Button(self.panel,-1,"Reset",pos=(560,0))
self.resetbtn.Bind(wx.EVT_BUTTON,self.reset) self.resetbtn.Bind(wx.EVT_BUTTON,self.reset)
...@@ -273,12 +284,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -273,12 +284,15 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
ubs.Add(self.loadbtn) ubs.Add(self.loadbtn)
self.uploadbtn=wx.Button(self.panel,-1,"SD Upload",pos=(90,40)) self.uploadbtn=wx.Button(self.panel,-1,"SD Upload",pos=(90,40))
self.uploadbtn.Bind(wx.EVT_BUTTON,self.upload) self.uploadbtn.Bind(wx.EVT_BUTTON,self.upload)
self.printerControls.append(self.uploadbtn)
ubs.Add(self.uploadbtn) ubs.Add(self.uploadbtn)
self.sdprintbtn=wx.Button(self.panel,-1,"SD Print",pos=(180,40)) self.sdprintbtn=wx.Button(self.panel,-1,"SD Print",pos=(180,40))
self.sdprintbtn.Bind(wx.EVT_BUTTON,self.sdprintfile) self.sdprintbtn.Bind(wx.EVT_BUTTON,self.sdprintfile)
self.printerControls.append(self.sdprintbtn)
ubs.Add(self.sdprintbtn) ubs.Add(self.sdprintbtn)
self.printbtn=wx.Button(self.panel,-1,"Print",pos=(270,40)) self.printbtn=wx.Button(self.panel,-1,"Print",pos=(270,40))
self.printbtn.Bind(wx.EVT_BUTTON,self.printfile) self.printbtn.Bind(wx.EVT_BUTTON,self.printfile)
self.printbtn.Disable()
ubs.Add(self.printbtn) ubs.Add(self.printbtn)
self.pausebtn=wx.Button(self.panel,-1,"Pause",pos=(360,40)) self.pausebtn=wx.Button(self.panel,-1,"Pause",pos=(360,40))
self.pausebtn.Bind(wx.EVT_BUTTON,self.pause) self.pausebtn.Bind(wx.EVT_BUTTON,self.pause)
...@@ -303,9 +317,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -303,9 +317,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lbrs=wx.BoxSizer(wx.HORIZONTAL) lbrs=wx.BoxSizer(wx.HORIZONTAL)
self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER) self.commandbox=wx.TextCtrl(self.panel,size=(250,30),pos=(440,420),style = wx.TE_PROCESS_ENTER)
self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline) self.commandbox.Bind(wx.EVT_TEXT_ENTER,self.sendline)
self.printerControls.append(self.commandbox)
lbrs.Add(self.commandbox) lbrs.Add(self.commandbox)
self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420)) self.sendbtn=wx.Button(self.panel,-1,"Send",pos=(700,420))
self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline) self.sendbtn.Bind(wx.EVT_BUTTON,self.sendline)
self.printerControls.append(self.sendbtn)
lbrs.Add(self.sendbtn) lbrs.Add(self.sendbtn)
lrs.Add(lbrs) lrs.Add(lbrs)
...@@ -328,6 +344,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -328,6 +344,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
btn.properties=i btn.properties=i
btn.Bind(wx.EVT_BUTTON,self.procbutton) btn.Bind(wx.EVT_BUTTON,self.procbutton)
self.btndict[i[1]]=btn self.btndict[i[1]]=btn
self.printerControls.append(btn)
lls.Add(btn,pos=i[2],span=i[4]) lls.Add(btn,pos=i[2],span=i[4])
...@@ -339,6 +356,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -339,6 +356,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(self.htemp,pos=(11,1),span=(1,3)) lls.Add(self.htemp,pos=(11,1),span=(1,3))
self.settbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,335)) self.settbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,335))
self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp) self.settbtn.Bind(wx.EVT_BUTTON,self.do_settemp)
self.printerControls.append(self.settbtn)
lls.Add(self.settbtn,pos=(11,4),span=(1,2)) lls.Add(self.settbtn,pos=(11,4),span=(1,2))
lls.Add(wx.StaticText(self.panel,-1,"Bed:",pos=(0,343)),pos=(12,0),span=(1,1)) lls.Add(wx.StaticText(self.panel,-1,"Bed:",pos=(0,343)),pos=(12,0),span=(1,1))
self.btemp=wx.ComboBox(self.panel, -1, self.btemp=wx.ComboBox(self.panel, -1,
...@@ -348,6 +366,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -348,6 +366,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
lls.Add(self.btemp,pos=(12,1),span=(1,3)) lls.Add(self.btemp,pos=(12,1),span=(1,3))
self.setbbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,365)) self.setbbtn=wx.Button(self.panel,-1,"Set",size=(30,-1),pos=(135,365))
self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp) self.setbbtn.Bind(wx.EVT_BUTTON,self.do_bedtemp)
self.printerControls.append(self.setbbtn)
lls.Add(self.setbbtn,pos=(12,4),span=(1,2)) lls.Add(self.setbbtn,pos=(12,4),span=(1,2))
self.tempdisp=wx.StaticText(self.panel,-1,"") self.tempdisp=wx.StaticText(self.panel,-1,"")
lls.Add(self.tempdisp,pos=(12,6),span=(1,3)) lls.Add(self.tempdisp,pos=(12,6),span=(1,3))
...@@ -409,6 +428,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -409,6 +428,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.topsizer.Layout() self.topsizer.Layout()
self.topsizer.Fit(self) self.topsizer.Fit(self)
# disable all printer controls until we connect to a printer
self.pausebtn.Hide()
for i in self.printerControls:
i.Disable()
#self.panel.Fit() #self.panel.Fit()
#uts.Layout() #uts.Layout()
...@@ -662,6 +686,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -662,6 +686,11 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
self.f=[i.replace("\n","").replace("\r","") for i in open(name)] self.f=[i.replace("\n","").replace("\r","") for i in open(name)]
self.filename=name self.filename=name
self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),)) self.status.SetStatusText("Loaded "+name+", %d lines"%(len(self.f),))
self.printbtn.SetLabel("Print")
self.pausebtn.SetLabel("Pause")
self.pausebtn.Hide()
if self.p.online:
self.printbtn.Enable()
threading.Thread(target=self.loadviz).start() threading.Thread(target=self.loadviz).start()
def loadviz(self): def loadviz(self):
...@@ -676,9 +705,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -676,9 +705,8 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def printfile(self,event): def printfile(self,event):
if self.paused: if self.paused:
self.p.paused=0 self.p.paused=0
self.pausebtn.SetLabel("Pause")
self.printbtn.SetLabel("Print")
self.paused=0 self.paused=0
self.on_startprint()
if self.sdprinting: if self.sdprinting:
self.p.send_now("M26 S0") self.p.send_now("M26 S0")
self.p.send_now("M24") self.p.send_now("M24")
...@@ -690,10 +718,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -690,10 +718,14 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
if not self.p.online: if not self.p.online:
wx.CallAfter(self.status.SetStatusText,"Not connected to printer.") wx.CallAfter(self.status.SetStatusText,"Not connected to printer.")
return return
self.pausebtn.Enable() self.on_startprint()
self.printbtn.SetLabel("Restart")
self.p.startprint(self.f) self.p.startprint(self.f)
def on_startprint(self):
self.pausebtn.SetLabel("Pause")
self.pausebtn.Show()
self.printbtn.SetLabel("Restart")
def endupload(self): def endupload(self):
self.p.send_now("M29 ") self.p.send_now("M29 ")
wx.CallAfter(self.status.SetStatusText,"File upload complete") wx.CallAfter(self.status.SetStatusText,"File upload complete")
...@@ -742,6 +774,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -742,6 +774,7 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def sdprintfile(self,event): def sdprintfile(self,event):
self.on_startprint()
threading.Thread(target=self.getfiles).start() threading.Thread(target=self.getfiles).start()
pass pass
...@@ -778,6 +811,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -778,6 +811,13 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def disconnect(self,event): def disconnect(self,event):
self.p.disconnect() self.p.disconnect()
self.statuscheck=False self.statuscheck=False
self.connectbtn.Enable();
self.printbtn.Disable();
self.pausebtn.Hide();
for i in self.printerControls:
i.Disable()
if self.paused: if self.paused:
self.p.paused=0 self.p.paused=0
self.p.printing=0 self.p.printing=0
......
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