Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cooler support #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions printrun/gcoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def find_specific_code(line, code):
def S(line):
return find_specific_code(line, "S")

def C(line):
return " C " in line.raw

def P(line):
return find_specific_code(line, "P")

Expand Down
64 changes: 55 additions & 9 deletions printrun/gui/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
gauges_base_line = base_line + 7
else:
gauges_base_line = base_line + 6
tempdisp_line = gauges_base_line + (2 if root.display_gauges else 0)
tempdisp_line = gauges_base_line + (4 if root.display_gauges else 0)
if mini_mode and root.display_graph:
e_base_line = base_line + 3
else:
Expand All @@ -59,13 +59,18 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
"btemp_off": (base_line + 1, 2),
"btemp_val": (base_line + 1, 3),
"btemp_set": (base_line + 1, 4),
"ebuttons": (e_base_line + 0, 0),
"esettings": (e_base_line + 1, 0),
"speedcontrol": (e_base_line + 2, 0),
"flowcontrol": (e_base_line + 3, 0),
"htemp_gauge": (gauges_base_line + 0, 0),
"btemp_gauge": (gauges_base_line + 1, 0),
"tempdisp": (tempdisp_line, 0),
"ctemp_label": (base_line + 2, 0),
"ctemp_off": (base_line + 2, 2),
"ctemp_val": (base_line + 2, 3),
"ctemp_set": (base_line + 2, 4),
"ebuttons": (e_base_line + 1, 0),
"esettings": (e_base_line + 2, 0),
"speedcontrol": (e_base_line + 3, 0),
"flowcontrol": (e_base_line + 4, 0),
"htemp_gauge": (gauges_base_line + 1, 0),
"btemp_gauge": (gauges_base_line + 2, 0),
"ctemp_gauge": (gauges_base_line + 3, 0),
"tempdisp": (tempdisp_line, 3),
"extrude": (3, 0),
"reverse": (3, 2),
}
Expand All @@ -79,12 +84,17 @@ def add_extra_controls(self, root, parentpanel, extra_buttons = None, mini_mode
"btemp_off": (1, 1),
"btemp_val": (1, 1),
"btemp_set": (1, 1 if root.display_graph else 2),
"ctemp_label": (1, 2),
"ctemp_off": (1, 1),
"ctemp_val": (1, 1),
"ctemp_set": (1, 1 if root.display_graph else 2),
"ebuttons": (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),
"flowcontrol": (1, 5 if root.display_graph else 6),
"htemp_gauge": (1, 5 if mini_mode else 6),
"btemp_gauge": (1, 5 if mini_mode else 6),
"ctemp_gauge": (1, 5 if mini_mode else 6),
"tempdisp": (1, 5 if mini_mode else 6),
"extrude": (1, 2),
"reverse": (1, 3),
Expand Down Expand Up @@ -167,20 +177,46 @@ def add(name, widget, *args, **kwargs):
root.printerControls.append(root.setbbtn)
add("btemp_set", root.setbbtn, flag = wx.EXPAND)

# Cooler temp // NEXTIME
add("ctemp_label", wx.StaticText(parentpanel, -1, _("Cooler:")), flag = wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT)
ctemp_choices = [root.coolertemps[i] + " (" + i + ")" for i in sorted(root.coolertemps.keys(), key = lambda x:root.temps[x])]

root.setcoff = make_button(parentpanel, _("Off"), lambda e: root.do_coolertemp("off"), _("Switch Cooler Off"), size = (38, -1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.setcoff)
add("ctemp_off", root.setcoff)

if root.settings.last_cooler_temperature not in map(float, root.coolertemps.values()):
ctemp_choices = [str(root.settings.last_cooler_temperature)] + ctemp_choices
root.ctemp = wx.ComboBox(parentpanel, -1, choices = ctemp_choices,
style = wx.CB_DROPDOWN, size = (80, -1))
root.ctemp.SetToolTip(wx.ToolTip(_("Select Temperature for Cooler")))
root.ctemp.Bind(wx.EVT_COMBOBOX, root.ctemp_change)
add("ctemp_val", root.ctemp)

root.setcbtn = make_button(parentpanel, _("Set"), root.do_coolertemp, _("Switch Cooler"), size = (38, -1), style = wx.BU_EXACTFIT)
root.printerControls.append(root.setcbtn)
add("ctemp_set", root.setcbtn, flag = wx.EXPAND)

root.ctemp.SetValue(str(root.settings.last_cooler_temperature))
root.btemp.SetValue(str(root.settings.last_bed_temperature))
root.htemp.SetValue(str(root.settings.last_temperature))


# added for an error where only the bed would get (pla) or (abs).
# This ensures, if last temp is a default pla or abs, it will be marked so.
# if it is not, then a (user) remark is added. This denotes a manual entry

for i in ctemp_choices:
if i.split()[0] == str(root.settings.last_cooler_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_cooler_temperature):
root.ctemp.SetValue(i)
for i in btemp_choices:
if i.split()[0] == str(root.settings.last_bed_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_bed_temperature):
root.btemp.SetValue(i)
for i in htemp_choices:
if i.split()[0] == str(root.settings.last_temperature).split('.')[0] or i.split()[0] == str(root.settings.last_temperature):
root.htemp.SetValue(i)

if '(' not in root.ctemp.Value:
root.ctemp.SetValue(root.ctemp.Value + ' (user)')
if '(' not in root.btemp.Value:
root.btemp.SetValue(root.btemp.Value + ' (user)')
if '(' not in root.htemp.Value:
Expand Down Expand Up @@ -261,6 +297,8 @@ def flowslider_scroll(event):
add("htemp_gauge", root.hottgauge, flag = wx.EXPAND)
root.bedtgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Bed:"), maxval = 150, bgcolor = root.bgcolor)
add("btemp_gauge", root.bedtgauge, flag = wx.EXPAND)
root.coolertgauge = TempGauge(parentpanel, size = (-1, 24), title = _("Cooler:"), maxval = 50, bgcolor = root.bgcolor)
add("ctemp_gauge", root.coolertgauge, flag = wx.EXPAND)

def hotendgauge_scroll_setpoint(e):
rot = e.GetWheelRotation()
Expand All @@ -275,8 +313,16 @@ def bedgauge_scroll_setpoint(e):
root.do_settemp(str(root.bsetpoint + 1))
elif rot < 0:
root.do_settemp(str(max(0, root.bsetpoint - 1)))
def coolergauge_scroll_setpoint(e):
rot = e.GetWheelRotation()
if rot > 0:
root.do_settemp(str(root.csetpoint + 1))
elif rot < 0:
root.do_settemp(str(max(0, root.csetpoint - 1)))

root.hottgauge.Bind(wx.EVT_MOUSEWHEEL, hotendgauge_scroll_setpoint)
root.bedtgauge.Bind(wx.EVT_MOUSEWHEEL, bedgauge_scroll_setpoint)
root.coolertgauge.Bind(wx.EVT_MOUSEWHEEL, coolergauge_scroll_setpoint)

# Temperature (M105) feedback display #
root.tempdisp = wx.StaticText(parentpanel, -1, "", style = wx.ST_NO_AUTORESIZE)
Expand Down
51 changes: 50 additions & 1 deletion printrun/gui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ def __init__(self, parent, id, root, pos = wx.DefaultPosition,
self.extruder1temps = parent_graph.extruder1temps
self.extruder1targettemps = parent_graph.extruder1targettemps
self.bedtemps = parent_graph.bedtemps
self.coolertemps = parent_graph.coolertemps
self.bedtargettemps = parent_graph.bedtargettemps
self.coolertargettemps = parent_graph.coolertargettemps
self.fanpowers=parent_graph.fanpowers
else:
self.extruder0temps = [0]
self.extruder0targettemps = [0]
self.extruder1temps = [0]
self.extruder1targettemps = [0]
self.coolertemps = [0]
self.coolertargettemps = [0]
self.bedtemps = [0]
self.bedtargettemps = [0]
self.fanpowers= [0]
Expand Down Expand Up @@ -92,6 +96,8 @@ def __del__(self):
def updateTemperatures(self, event):
self.AddBedTemperature(self.bedtemps[-1])
self.AddBedTargetTemperature(self.bedtargettemps[-1])
self.AddCoolerTemperature(self.coolertemps[-1])
self.AddCoolerTargetTemperature(self.coolertargettemps[-1])
self.AddExtruder0Temperature(self.extruder0temps[-1])
self.AddExtruder0TargetTemperature(self.extruder0targettemps[-1])
self.AddExtruder1Temperature(self.extruder1temps[-1])
Expand Down Expand Up @@ -230,6 +236,14 @@ def drawbedtemp(self, dc, gc):
def drawbedtargettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.bedtargettemps,
"Bed Target", 2, 255, 120, 0, 128)
def drawcoolertemp(self, dc, gc):
self.drawtemperature(dc, gc, self.coolertemps,
"Cooler", 2, 255, 0, 0, 128)

def drawcoolertargettemp(self, dc, gc):
self.drawtemperature(dc, gc, self.coolertargettemps,
"Cooler Target", 2, 255, 120, 0, 128)


def drawextruder0temp(self, dc, gc):
self.drawtemperature(dc, gc, self.extruder0temps,
Expand Down Expand Up @@ -259,21 +273,40 @@ def AddFanPower(self, value):
def SetBedTemperature(self, value):
self.bedtemps.pop()
self.bedtemps.append(value)
def SetCoolerTemperature(self, value):
self.coolertemps.pop()
self.coolertemps.append(value)

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

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


def SetBedTargetTemperature(self, value):
self.bedtargettemps.pop()
self.bedtargettemps.append(value)

def SetCoolerTargetTemperature(self, value):
self.coolertargettemps.pop()
self.coolertargettemps.append(value)

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

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


def SetExtruder0Temperature(self, value):
self.extruder0temps.pop()
self.extruder0temps.append(value)
Expand Down Expand Up @@ -329,6 +362,8 @@ def draw(self, dc, w, h):
self.drawgrid(dc, gc)
self.drawbedtargettemp(dc, gc)
self.drawbedtemp(dc, gc)
self.drawcoolertargettemp(dc, gc)
self.drawcoolertemp(dc, gc)
self.drawfanpower(dc, gc)
self.drawextruder0targettemp(dc, gc)
self.drawextruder0temp(dc, gc)
Expand Down Expand Up @@ -393,6 +428,10 @@ def getBounds(self):
bed_min = min(self.graph.bedtemps)
bed_max = max(self.graph.bedtemps)
bed_target = self.graph.bedtargettemps[-1]
cooler_min = min(self.graph.coolertemps)
cooler_max = max(self.graph.coolertemps)
cooler_target = self.graph.coolertargettemps[-1]


miny = min(extruder0_min, extruder0_target)
maxy = max(extruder0_max, extruder0_target)
Expand All @@ -402,6 +441,10 @@ 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)
if cooler_target > 0 or cooler_max > 5: # use HBP
miny = min(miny, cooler_min, cooler_target)
maxy = max(maxy, cooler_max, cooler_target)

miny=min(0,miny);
maxy=max(260,maxy);

Expand All @@ -427,7 +470,9 @@ def getBoundsQuick(self):
bed_min = self.graph.bedtemps[-1]
bed_max = self.graph.bedtemps[-1]
bed_target = self.graph.bedtargettemps[-1]

cooler_min = self.graph.coolertemps[-1]
cooler_max = self.graph.coolertemps[-1]
cooler_target = self.graph.coolertargettemps[-1]
miny = min(extruder0_min, extruder0_target)
maxy = max(extruder0_max, extruder0_target)
if extruder1_target > 0 or extruder1_max > 5: # use extruder1
Expand All @@ -436,6 +481,10 @@ 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)
if cooler_target > 0 or cooler_max > 5: # use HBP
miny = min(miny, cooler_min, cooler_target)
maxy = max(maxy, cooler_max, cooler_target)

miny=min(0,miny);
maxy=max(260,maxy);

Expand Down