Skip to content

Commit

Permalink
Add fan power (0-255) to temperature graph
Browse files Browse the repository at this point in the history
  • Loading branch information
kliment committed Feb 12, 2016
1 parent 72063a1 commit ace6637
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
23 changes: 22 additions & 1 deletion printrun/gui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,21 @@ def __init__(self, parent, id, root, pos = wx.DefaultPosition,
self.extruder1targettemps = parent_graph.extruder1targettemps
self.bedtemps = parent_graph.bedtemps
self.bedtargettemps = parent_graph.bedtargettemps
self.fanpowers=parent_graph.fanpowers
else:
self.extruder0temps = [0]
self.extruder0targettemps = [0]
self.extruder1temps = [0]
self.extruder1targettemps = [0]
self.bedtemps = [0]
self.bedtargettemps = [0]
self.fanpowers= [0]

self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.updateTemperatures, self.timer)

self.minyvalue = 0
self.maxyvalue = 250
self.maxyvalue = 260
self.rescaley = True # should the Y axis be rescaled dynamically?
if self.rescaley:
self._ybounds = Graph._YBounds(self)
Expand Down Expand Up @@ -94,6 +96,7 @@ def updateTemperatures(self, event):
self.AddExtruder0TargetTemperature(self.extruder0targettemps[-1])
self.AddExtruder1Temperature(self.extruder1temps[-1])
self.AddExtruder1TargetTemperature(self.extruder1targettemps[-1])
self.AddFanPower(self.fanpowers[-1])
if self.rescaley:
self._ybounds.update()
self.Refresh()
Expand Down Expand Up @@ -216,6 +219,10 @@ def drawtemperature(self, dc, gc, temperature_list,
x_pos - x_add - (font.GetPointSize() * text_size),
lastyvalue - (font.GetPointSize() / 2))

def drawfanpower(self, dc, gc):
self.drawtemperature(dc, gc, self.fanpowers,
"Fan", 1, 0, 0, 0, 128)

def drawbedtemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtemps,
"Bed", 2, 255, 0, 0, 128)
Expand All @@ -240,6 +247,15 @@ def drawextruder1targettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder1targettemps,
"Ex1 Target", 2, 55, 55, 0, 128)

def SetFanPower(self, value):
self.fanpowers.pop()
self.fanpowers.append(value)

def AddFanPower(self, value):
self.fanpowers.append(value)
if float(len(self.fanpowers) - 1) / self.xsteps > 1:
self.fanpowers.pop(0)

def SetBedTemperature(self, value):
self.bedtemps.pop()
self.bedtemps.append(value)
Expand Down Expand Up @@ -313,6 +329,7 @@ def draw(self, dc, w, h):
self.drawgrid(dc, gc)
self.drawbedtargettemp(dc, gc)
self.drawbedtemp(dc, gc)
self.drawfanpower(dc, gc)
self.drawextruder0targettemp(dc, gc)
self.drawextruder0temp(dc, gc)
self.drawextruder1targettemp(dc, gc)
Expand Down Expand Up @@ -385,6 +402,8 @@ def getBounds(self):
if bed_target > 0 or bed_max > 5: # use HBP
miny = min(miny, bed_min, bed_target)
maxy = max(maxy, bed_max, bed_target)
miny=min(0,miny);
maxy=max(260,maxy);

padding = (maxy - miny) * self.buffer / (1.0 - 2 * self.buffer)
miny -= padding
Expand Down Expand Up @@ -417,6 +436,8 @@ def getBoundsQuick(self):
if bed_target > 0 or bed_max > 5: # use HBP
miny = min(miny, bed_min, bed_target)
maxy = max(maxy, bed_max, bed_target)
miny=min(0,miny);
maxy=max(260,maxy);

# We have to rescale, so add padding
bufratio = self.buffer / (1.0 - self.buffer)
Expand Down
8 changes: 8 additions & 0 deletions printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,14 @@ def sentcb(self, line, gline):
temp = gline_s
if self.display_gauges: wx.CallAfter(self.bedtgauge.SetTarget, temp)
if self.display_graph: wx.CallAfter(self.graph.SetBedTargetTemperature, temp)
elif gline.command in ["M106"]:
gline_s=gcoder.S(gline)
fanpow=255
if gline_s is not None:
fanpow=gline_s
if self.display_graph: wx.CallAfter(self.graph.SetFanPower, fanpow)
elif gline.command in ["M107"]:
if self.display_graph: wx.CallAfter(self.graph.SetFanPower, 0)
elif gline.command.startswith("T"):
tool = gline.command[1:]
if hasattr(self, "extrudersel"): wx.CallAfter(self.extrudersel.SetValue, tool)
Expand Down

0 comments on commit ace6637

Please sign in to comment.