Add temperature fans to heaters (#325)

* Add temperature fans to heaters

* Make code prettier

* Indentation
This commit is contained in:
Julian Schill
2021-11-17 03:03:14 +01:00
committed by GitHub
parent 29e9bad1aa
commit 51d26a3a29
4 changed files with 24 additions and 1 deletions

View File

@@ -44,6 +44,10 @@ class KlippyGcodes:
def set_heater_temp(heater, temp):
return 'SET_HEATER_TEMPERATURE heater="%s" target=%s' % (heater, str(temp))
@staticmethod
def set_temp_fan_temp(temp_fan, temp):
return 'SET_TEMPERATURE_FAN_TARGET temperature_fan="%s" target=%s' % (temp_fan, str(temp))
@staticmethod
def set_fan_speed(speed):
speed = str(int(float(int(speed) % 101)/100*255))

View File

@@ -337,6 +337,17 @@ class MoonrakerApi:
*args
)
def set_temp_fan_temp(self, temp_fan, target, callback=None, *args):
logging.debug("Sending temperature fan %s to temp: %s", temp_fan, target)
return self._ws.send_method(
"printer.gcode.script",
{
"script": KlippyGcodes.set_temp_fan_temp(temp_fan, target)
},
callback,
*args
)
def set_tool_temp(self, tool, target, callback=None, *args):
logging.debug("Sending set_tool_temp: %s", KlippyGcodes.set_ext_temp(target, tool))
return self._ws.send_method(

View File

@@ -55,7 +55,8 @@ class Printer:
if "shared_heater" in self.config[x]:
continue
self.extrudercount += 1
if x == 'heater_bed' or x.startswith('heater_generic ') or x.startswith('temperature_sensor '):
if x == 'heater_bed' or x.startswith('heater_generic ') or x.startswith('temperature_sensor ') \
or x.startswith('temperature_fan '):
self.devices[x] = {
"temperature": 0,
"target": 0
@@ -200,6 +201,8 @@ class Printer:
heaters.append(h)
for h in self.get_config_section_list("temperature_sensor "):
heaters.append(h)
for h in self.get_config_section_list("temperature_fan "):
heaters.append(h)
return heaters
def get_printer_status_data(self):

View File

@@ -224,6 +224,8 @@ class TemperaturePanel(ScreenPanel):
self._screen._ws.klippy.set_heater_temp(" ".join(self.active_heater.split(" ")[1:]), target)
elif self.active_heater == "heater_bed":
self._screen._ws.klippy.set_bed_temp(target)
elif self.active_heater.startswith("temperature_fan "):
self._screen._ws.klippy.set_temp_fan_temp(" ".join(self.active_heater.split(" ")[1:]), target)
else:
self._screen._ws.klippy.set_tool_temp(self._printer.get_tool_number(self.active_heater), target)
@@ -241,6 +243,9 @@ class TemperaturePanel(ScreenPanel):
temp = int(text)
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_BED_TEMP else temp
self._screen._ws.klippy.set_bed_temp(temp)
elif self.active_heater.startswith("temperature_fan "):
temp = int(text)
self._screen._ws.klippy.set_temp_fan_temp(" ".join(self.active_heater.split(" ")[1:]), temp)
else:
temp = int(text)
temp = 0 if temp < 0 or temp > KlippyGcodes.MAX_EXT_TEMP else temp