Add possibility to define custom code for cooling (#579)

These changes allow to define custom code to be run when using the cooldown preset.

Here an example in the configuration:
```
[preheat cooldown]
gcode: M107
```
This commit is contained in:
Julien Kohler 2022-04-11 13:25:07 +02:00 committed by GitHub
parent 618c9ac0e8
commit 3ea0b09863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -83,6 +83,7 @@ class TemperaturePanel(ScreenPanel):
def preheat(self): def preheat(self):
self.labels["preheat_grid"] = self._gtk.HomogeneousGrid() self.labels["preheat_grid"] = self._gtk.HomogeneousGrid()
for i, option in enumerate(self.preheat_options): for i, option in enumerate(self.preheat_options):
if option != "cooldown":
self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4)+1)) self.labels[option] = self._gtk.Button(option, "color%d" % ((i % 4)+1))
self.labels[option].connect("clicked", self.set_temperature, option) self.labels[option].connect("clicked", self.set_temperature, option)
self.labels['preheat_grid'].attach(self.labels[option], (i % 2), int(i/2), 1, 1) self.labels['preheat_grid'].attach(self.labels[option], (i % 2), int(i/2), 1, 1)
@ -226,8 +227,7 @@ class TemperaturePanel(ScreenPanel):
self._screen._ws.klippy.set_heater_temp(" ".join(heater.split(" ")[1:]), 0) self._screen._ws.klippy.set_heater_temp(" ".join(heater.split(" ")[1:]), 0)
logging.info("Setting %s to %d" % (heater, 0)) logging.info("Setting %s to %d" % (heater, 0))
self._printer.set_dev_stat(heater, "target", 0) self._printer.set_dev_stat(heater, "target", 0)
return else:
for heater in self.active_heaters: for heater in self.active_heaters:
MAX_TEMP = int(float(self._printer.get_config_section(heater)['max_temp'])) MAX_TEMP = int(float(self._printer.get_config_section(heater)['max_temp']))
if heater.startswith('extruder'): if heater.startswith('extruder'):