mirror of https://github.com/Desuuuu/klipper.git
klippy: No need to pass printer reference to add_printer_objects()
The config reference already stores a reference to the printer object. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
5cdba1fda8
commit
7d897d84d7
|
@ -231,7 +231,8 @@ class DummyExtruder:
|
|||
def lookahead(self, moves, flush_count, lazy):
|
||||
return flush_count
|
||||
|
||||
def add_printer_objects(printer, config):
|
||||
def add_printer_objects(config):
|
||||
printer = config.get_printer()
|
||||
for i in range(99):
|
||||
section = 'extruder%d' % (i,)
|
||||
if not config.has_section(section):
|
||||
|
|
|
@ -216,8 +216,8 @@ class ControlPID:
|
|||
######################################################################
|
||||
|
||||
class PrinterHeaters:
|
||||
def __init__(self, printer, config):
|
||||
self.printer = printer
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
self.sensors = {}
|
||||
self.heaters = {}
|
||||
def add_sensor(self, sensor_type, sensor_factory):
|
||||
|
@ -249,5 +249,5 @@ class PrinterHeaters:
|
|||
sensor_type,))
|
||||
return self.sensors[sensor_type](config)
|
||||
|
||||
def add_printer_objects(printer, config):
|
||||
printer.add_object('heater', PrinterHeaters(printer, config))
|
||||
def add_printer_objects(config):
|
||||
config.get_printer().add_object('heater', PrinterHeaters(config))
|
||||
|
|
|
@ -213,11 +213,11 @@ class Printer:
|
|||
# Create printer components
|
||||
config = ConfigWrapper(self, fileconfig, 'printer')
|
||||
for m in [pins, heater, mcu]:
|
||||
m.add_printer_objects(self, config)
|
||||
m.add_printer_objects(config)
|
||||
for section in fileconfig.sections():
|
||||
self.try_load_module(config, section)
|
||||
for m in [toolhead, extruder]:
|
||||
m.add_printer_objects(self, config)
|
||||
m.add_printer_objects(config)
|
||||
# Validate that there are no undefined parameters in the config file
|
||||
valid_sections = { s: 1 for s, o in self.all_config_options }
|
||||
for section_name in fileconfig.sections():
|
||||
|
|
|
@ -399,10 +399,10 @@ class MCU_adc:
|
|||
|
||||
class MCU:
|
||||
error = error
|
||||
def __init__(self, printer, config, clocksync):
|
||||
self._printer = printer
|
||||
def __init__(self, config, clocksync):
|
||||
self._printer = config.get_printer()
|
||||
self._clocksync = clocksync
|
||||
self._reactor = printer.get_reactor()
|
||||
self._reactor = self._printer.get_reactor()
|
||||
self._name = config.get_name()
|
||||
if self._name.startswith('mcu '):
|
||||
self._name = self._name[4:]
|
||||
|
@ -425,7 +425,7 @@ class MCU:
|
|||
self._is_shutdown = self._is_timeout = False
|
||||
self._shutdown_msg = ""
|
||||
# Config building
|
||||
printer.lookup_object('pins').register_chip(self._name, self)
|
||||
self._printer.lookup_object('pins').register_chip(self._name, self)
|
||||
self._oid_count = 0
|
||||
self._config_objects = []
|
||||
self._init_cmds = []
|
||||
|
@ -775,13 +775,14 @@ def error_help(msg):
|
|||
return help_msg
|
||||
return ""
|
||||
|
||||
def add_printer_objects(printer, config):
|
||||
def add_printer_objects(config):
|
||||
printer = config.get_printer()
|
||||
reactor = printer.get_reactor()
|
||||
mainsync = clocksync.ClockSync(reactor)
|
||||
printer.add_object('mcu', MCU(printer, config.getsection('mcu'), mainsync))
|
||||
printer.add_object('mcu', MCU(config.getsection('mcu'), mainsync))
|
||||
for s in config.get_prefix_sections('mcu '):
|
||||
printer.add_object(s.section, MCU(
|
||||
printer, s, clocksync.SecondarySync(reactor, mainsync)))
|
||||
s, clocksync.SecondarySync(reactor, mainsync)))
|
||||
|
||||
def get_printer_mcu(printer, name):
|
||||
if name == 'mcu':
|
||||
|
|
|
@ -247,5 +247,5 @@ class PrinterPins:
|
|||
raise error("Duplicate chip name '%s'" % (chip_name,))
|
||||
self.chips[chip_name] = chip
|
||||
|
||||
def add_printer_objects(printer, config):
|
||||
printer.add_object('pins', PrinterPins())
|
||||
def add_printer_objects(config):
|
||||
config.get_printer().add_object('pins', PrinterPins())
|
||||
|
|
|
@ -442,5 +442,5 @@ class ToolHead:
|
|||
accel = gcode.get_float('S', params, above=0.)
|
||||
self.max_accel = min(accel, self.config_max_accel)
|
||||
|
||||
def add_printer_objects(printer, config):
|
||||
printer.add_object('toolhead', ToolHead(config))
|
||||
def add_printer_objects(config):
|
||||
config.get_printer().add_object('toolhead', ToolHead(config))
|
||||
|
|
Loading…
Reference in New Issue