Commit 17460695 authored by kliment's avatar kliment

Merge pull request #693 from hg42/add-flow-control

add flowrate slider
parents 0193a9db 2eba6caf
...@@ -41,9 +41,9 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode ...@@ -41,9 +41,9 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
if standalone_mode: if standalone_mode:
gauges_base_line = base_line + 10 gauges_base_line = base_line + 10
elif mini_mode and root.display_graph: elif mini_mode and root.display_graph:
gauges_base_line = base_line + 6 gauges_base_line = base_line + 7
else: else:
gauges_base_line = base_line + 5 gauges_base_line = base_line + 6
tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0) tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0)
if mini_mode and root.display_graph: if mini_mode and root.display_graph:
e_base_line = base_line + 3 e_base_line = base_line + 3
...@@ -62,6 +62,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode ...@@ -62,6 +62,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
"ebuttons": (e_base_line + 0, 0), "ebuttons": (e_base_line + 0, 0),
"esettings": (e_base_line + 1, 0), "esettings": (e_base_line + 1, 0),
"speedcontrol": (e_base_line + 2, 0), "speedcontrol": (e_base_line + 2, 0),
"flowcontrol": (e_base_line + 3, 0),
"htemp_gauge": (gauges_base_line + 0, 0), "htemp_gauge": (gauges_base_line + 0, 0),
"btemp_gauge": (gauges_base_line + 1, 0), "btemp_gauge": (gauges_base_line + 1, 0),
"tempdisp": (tempdisp_line, 0), "tempdisp": (tempdisp_line, 0),
...@@ -81,6 +82,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode ...@@ -81,6 +82,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
"ebuttons": (1, 5 if root.display_graph else 6), "ebuttons": (1, 5 if root.display_graph else 6),
"esettings": (1, 5 if root.display_graph else 6), "esettings": (1, 5 if root.display_graph else 6),
"speedcontrol": (1, 5 if root.display_graph else 6), "speedcontrol": (1, 5 if root.display_graph else 6),
"flowcontrol": (1, 5 if root.display_graph else 6),
"htemp_gauge": (1, 5 if mini_mode else 6), "htemp_gauge": (1, 5 if mini_mode else 6),
"btemp_gauge": (1, 5 if mini_mode else 6), "btemp_gauge": (1, 5 if mini_mode else 6),
"tempdisp": (1, 5 if mini_mode else 6), "tempdisp": (1, 5 if mini_mode else 6),
...@@ -218,6 +220,40 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode ...@@ -218,6 +220,40 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
root.speed_spin.SetValue(value) root.speed_spin.SetValue(value)
root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll) root.speed_slider.Bind(wx.EVT_SCROLL, speedslider_scroll)
# Flow control #
flowpanel = root.newPanel(parentpanel)
flowsizer = wx.BoxSizer(wx.HORIZONTAL)
flowsizer.Add(wx.StaticText(flowpanel, -1, _("Print flow:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
root.flow_slider = wx.Slider(flowpanel, -1, 100, 1, 300)
flowsizer.Add(root.flow_slider, 1, flag = wx.EXPAND)
root.flow_spin = FloatSpin(flowpanel, -1, value = 100, min_val = 1, max_val = 300, digits = 0, style = wx.ALIGN_LEFT, size = (60, -1))
flowsizer.Add(root.flow_spin, 0, flag = wx.ALIGN_CENTER_VERTICAL)
root.flow_label = wx.StaticText(flowpanel, -1, _("%"))
flowsizer.Add(root.flow_label, flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
def flowslider_set(event):
root.do_setflow()
root.flow_setbtn.SetBackgroundColour(wx.NullColour)
root.flow_setbtn = make_button(flowpanel, _("Set"), flowslider_set, _("Set print flow factor"), size = (38, -1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.flow_setbtn)
flowsizer.Add(root.flow_setbtn, flag = wx.ALIGN_CENTER)
flowpanel.SetSizer(flowsizer)
add("flowcontrol", flowpanel, flag = wx.EXPAND)
def flowslider_spin(event):
value = root.flow_spin.GetValue()
root.flow_setbtn.SetBackgroundColour("red")
root.flow_slider.SetValue(value)
root.flow_spin.Bind(wx.EVT_SPINCTRL, flowslider_spin)
def flowslider_scroll(event):
value = root.flow_slider.GetValue()
root.flow_setbtn.SetBackgroundColour("red")
root.flow_spin.SetValue(value)
root.flow_slider.Bind(wx.EVT_SCROLL, flowslider_scroll)
# Temperature gauges # # Temperature gauges #
if root.display_gauges: if root.display_gauges:
......
...@@ -438,6 +438,21 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -438,6 +438,21 @@ class PronterWindow(MainWindow, pronsole.pronsole):
except Exception, x: except Exception, x:
self.logError(_("You must enter a speed. (%s)") % (repr(x),)) self.logError(_("You must enter a speed. (%s)") % (repr(x),))
def do_setflow(self, l = ""):
try:
if l.__class__ not in (str, unicode) or not len(l):
l = str(self.flow_slider.GetValue())
else:
l = l.lower()
flow = int(l)
if self.p.online:
self.p.send_now("M221 S" + l)
self.log(_("Setting print flow factor to %d%%.") % flow)
else:
self.logError(_("Printer is not online."))
except Exception, x:
self.logError(_("You must enter a flow. (%s)") % (repr(x),))
def setbedgui(self, f): def setbedgui(self, f):
self.bsetpoint = f self.bsetpoint = f
if self.display_gauges: self.bedtgauge.SetTarget(int(f)) if self.display_gauges: self.bedtgauge.SetTarget(int(f))
......
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