From 90e32562ea6e8e1f7659c668cc76edfb859fa19d Mon Sep 17 00:00:00 2001 From: Guillaume Seguin Date: Fri, 17 May 2013 16:59:28 +0200 Subject: [PATCH] More work on getting the gauges back --- printrun/gui.py | 38 ++++++++++++++++++++++++-------------- pronterface.py | 34 +++++++++++++++++----------------- 2 files changed, 41 insertions(+), 31 deletions(-) diff --git a/printrun/gui.py b/printrun/gui.py index d3cd10b..28bc1a5 100644 --- a/printrun/gui.py +++ b/printrun/gui.py @@ -26,6 +26,7 @@ from printrun import gviz from printrun.xybuttons import XYButtons from printrun.zbuttons import ZButtons from printrun.graph import Graph +from printrun.pronterface_widgets import TempGauge def make_button(parent, label, callback, tooltip, container = None, size = wx.DefaultSize, style = 0): button = wx.Button(parent, -1, label, style = style, size = size) @@ -144,8 +145,6 @@ class LeftPane(wx.GridBagSizer): if( '(' not in root.htemp.Value): root.htemp.SetValue(root.htemp.Value + ' (user)') - #self.Add(root.btemp, pos = (4, 1), span = (1, 3)) - #self.Add(root.setbbtn, pos = (4, 4), span = (1, 2)) root.tempdisp = wx.StaticText(root.panel,-1, "") root.edist = wx.SpinCtrl(root.panel,-1, "5", min = 0, max = 1000, size = (60,-1)) @@ -165,22 +164,33 @@ class LeftPane(wx.GridBagSizer): root.zfeedc.Bind(wx.EVT_SPINCTRL, root.setfeeds) root.zfeedc.SetBackgroundColour((180, 255, 180)) root.zfeedc.SetForegroundColour("black") - # self.Add((10, 0), pos = (0, 11), span = (1, 1)) - #root.hottgauge = TempGauge(root.panel, size = (200, 24), title = _("Heater:"), maxval = 230) - #self.Add(root.hottgauge, pos = (7, 0), span = (1, 4)) - #root.bedtgauge = TempGauge(root.panel, size = (200, 24), title = _("Bed:"), maxval = 130) - #self.Add(root.bedtgauge, pos = (8, 0), span = (1, 4)) - #def scroll_setpoint(e): - # if e.GetWheelRotation()>0: - # root.do_settemp(str(root.hsetpoint+1)) - # elif e.GetWheelRotation()<0: - # root.do_settemp(str(max(0, root.hsetpoint-1))) - #root.tgauge.Bind(wx.EVT_MOUSEWHEEL, scroll_setpoint) + root.display_gauges = True # FIXME : move to options or CLI options + if root.display_gauges: + root.hottgauge = TempGauge(root.panel, size = (200, 24), title = _("Heater:"), maxval = 300) + self.Add(root.hottgauge, pos = (6, 0), span = (1, 6)) + root.bedtgauge = TempGauge(root.panel, size = (200, 24), title = _("Bed:"), maxval = 150) + self.Add(root.bedtgauge, pos = (7, 0), span = (1, 6)) + def hotendgauge_scroll_setpoint(e): + rot = e.GetWheelRotation() + if rot > 0: + root.do_settemp(str(root.hsetpoint + 1)) + elif rot < 0: + root.do_settemp(str(max(0, root.hsetpoint - 1))) + def bedgauge_scroll_setpoint(e): + rot = e.GetWheelRotation() + if rot > 0: + root.do_settemp(str(root.bsetpoint + 1)) + elif rot < 0: + root.do_settemp(str(max(0, root.bsetpoint - 1))) + root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint) + root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint) + self.Add(root.tempdisp, pos = (8, 0), span = (1, 6)) + else: + self.Add(root.tempdisp, pos = (6, 0), span = (1, 6)) root.graph = Graph(root.panel, wx.ID_ANY) self.Add(root.graph, pos = (4, 5), span = (2, 1)) - self.Add(root.tempdisp, pos = (6, 0), span = (1, 6)) class VizPane(wx.BoxSizer): diff --git a/pronterface.py b/pronterface.py index 744447a..bbcb5e8 100755 --- a/pronterface.py +++ b/pronterface.py @@ -256,7 +256,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): if "S" in line: try: temp = float(line.split("S")[1].split("*")[0]) - #self.hottgauge.SetTarget(temp) + if self.display_gauges: wx.CallAfter(self.hottgauge.SetTarget, temp) wx.CallAfter(self.graph.SetExtruder0TargetTemperature, temp) except: pass @@ -268,7 +268,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): if "S" in line: try: temp = float(line.split("S")[1].split("*")[0]) - #self.bedtgauge.SetTarget(temp) + if self.display_gauges: wx.CallAfter(self.bedtgauge.SetTarget, temp) wx.CallAfter(self.graph.SetBedTargetTemperature, temp) except: pass @@ -295,7 +295,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): def setbedgui(self, f): self.bsetpoint = f - #self.bedtgauge.SetTarget(int(f)) + if self.display_gauges: self.bedtgauge.SetTarget(int(f)) wx.CallAfter(self.graph.SetBedTargetTemperature, int(f)) if f>0: wx.CallAfter(self.btemp.SetValue, str(f)) @@ -315,7 +315,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): def sethotendgui(self, f): self.hsetpoint = f - #self.hottgauge.SetTarget(int(f)) + if self.display_gauges: self.hottgauge.SetTarget(int(f)) wx.CallAfter(self.graph.SetExtruder0TargetTemperature, int(f)) if f > 0: wx.CallAfter(self.htemp.SetValue, str(f)) @@ -1040,17 +1040,22 @@ class PronterWindow(MainWindow, pronsole.pronsole): def clearOutput(self, e): self.logbox.Clear() + def update_tempdisplay(self): + try: + hotend_temp = parse_temperature_report(self.tempreport, "T:") + wx.CallAfter(self.graph.SetExtruder0Temperature, hotend_temp) + if self.display_gauges: wx.CallAfter(self.hottgauge.SetValue, hotend_temp) + bed_temp = parse_temperature_report(self.tempreport, "B:") + wx.CallAfter(self.graph.SetBedTemperature, bed_temp) + if self.display_gauges: wx.CallAfter(self.bedtgauge.SetValue, bed_temp) + except: + traceback.print_exc() + def statuschecker(self): while self.statuscheck: string = "" wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", "")) - try: - #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) - wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) - #self.bedtgauge.SetValue(parse_temperature_report(self.tempreport, "B:")) - wx.CallAfter(self.graph.SetBedTemperature, parse_temperature_report(self.tempreport, "B:")) - except: - pass + self.update_tempdisplay() fractioncomplete = 0.0 if self.sdprinting: fractioncomplete = float(self.percentdone / 100.0) @@ -1111,12 +1116,7 @@ class PronterWindow(MainWindow, pronsole.pronsole): if "T:" in l: self.tempreport = l wx.CallAfter(self.tempdisp.SetLabel, self.tempreport.strip().replace("ok ", "")) - try: - #self.hottgauge.SetValue(parse_temperature_report(self.tempreport, "T:")) - wx.CallAfter(self.graph.SetExtruder0Temperature, parse_temperature_report(self.tempreport, "T:")) - wx.CallAfter(self.graph.SetBedTemperature, parse_temperature_report(self.tempreport, "B:")) - except: - traceback.print_exc() + self.update_tempdisplay() tstring = l.rstrip() #print tstring if (tstring!="ok") and (tstring!="wait") and ("ok T:" not in tstring) and (not self.p.loud):