2018-04-04 00:01:10 +03:00
|
|
|
# Support for a heated bed
|
|
|
|
#
|
2019-12-17 03:35:49 +03:00
|
|
|
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
|
2018-04-04 00:01:10 +03:00
|
|
|
#
|
|
|
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
|
2019-12-17 03:35:49 +03:00
|
|
|
class PrinterHeaterBed:
|
|
|
|
def __init__(self, config):
|
|
|
|
self.printer = config.get_printer()
|
2020-05-05 21:10:30 +03:00
|
|
|
pheaters = self.printer.load_object(config, 'heaters')
|
2020-04-25 20:27:41 +03:00
|
|
|
self.heater = pheaters.setup_heater(config, 'B')
|
2019-12-17 03:35:49 +03:00
|
|
|
self.get_status = self.heater.get_status
|
|
|
|
self.stats = self.heater.stats
|
|
|
|
# Register commands
|
|
|
|
gcode = self.printer.lookup_object('gcode')
|
|
|
|
gcode.register_command("M140", self.cmd_M140)
|
|
|
|
gcode.register_command("M190", self.cmd_M190)
|
2020-04-25 06:18:04 +03:00
|
|
|
def cmd_M140(self, gcmd, wait=False):
|
2019-12-17 03:35:49 +03:00
|
|
|
# Set Bed Temperature
|
2020-04-25 06:18:04 +03:00
|
|
|
temp = gcmd.get_float('S', 0.)
|
2020-01-03 03:17:47 +03:00
|
|
|
self.heater.set_temp(temp)
|
2019-12-17 03:35:49 +03:00
|
|
|
if wait and temp:
|
2020-04-25 20:27:41 +03:00
|
|
|
pheaters = self.printer.lookup_object('heaters')
|
|
|
|
pheaters.wait_for_temperature(self.heater)
|
2020-04-25 06:18:04 +03:00
|
|
|
def cmd_M190(self, gcmd):
|
2019-12-17 03:35:49 +03:00
|
|
|
# Set Bed Temperature and Wait
|
2020-04-25 06:18:04 +03:00
|
|
|
self.cmd_M140(gcmd, wait=True)
|
2019-12-17 03:35:49 +03:00
|
|
|
|
2018-04-04 00:01:10 +03:00
|
|
|
def load_config(config):
|
2019-12-17 03:35:49 +03:00
|
|
|
return PrinterHeaterBed(config)
|