2018-04-03 23:01:10 +02:00
|
|
|
# Support for a heated bed
|
|
|
|
#
|
2019-12-17 01:35:49 +01:00
|
|
|
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
|
2018-04-03 23:01:10 +02:00
|
|
|
#
|
|
|
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
|
|
|
|
2019-12-17 01:35:49 +01:00
|
|
|
class PrinterHeaterBed:
|
|
|
|
def __init__(self, config):
|
|
|
|
self.printer = config.get_printer()
|
|
|
|
pheater = self.printer.lookup_object('heater')
|
|
|
|
self.heater = pheater.setup_heater(config, 'B')
|
|
|
|
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)
|
|
|
|
def cmd_M140(self, params, wait=False):
|
|
|
|
# Set Bed Temperature
|
|
|
|
gcode = self.printer.lookup_object('gcode')
|
|
|
|
temp = gcode.get_float('S', params, 0.)
|
|
|
|
toolhead = self.printer.lookup_object('toolhead')
|
|
|
|
print_time = toolhead.get_last_move_time()
|
|
|
|
self.heater.set_temp(print_time, temp)
|
|
|
|
if wait and temp:
|
|
|
|
gcode.wait_for_temperature(self.heater)
|
|
|
|
def cmd_M190(self, params):
|
|
|
|
# Set Bed Temperature and Wait
|
|
|
|
self.cmd_M140(params, wait=True)
|
|
|
|
|
2018-04-03 23:01:10 +02:00
|
|
|
def load_config(config):
|
2019-12-17 01:35:49 +01:00
|
|
|
return PrinterHeaterBed(config)
|