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):
|
def lookahead(self, moves, flush_count, lazy):
|
||||||
return flush_count
|
return flush_count
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(config):
|
||||||
|
printer = config.get_printer()
|
||||||
for i in range(99):
|
for i in range(99):
|
||||||
section = 'extruder%d' % (i,)
|
section = 'extruder%d' % (i,)
|
||||||
if not config.has_section(section):
|
if not config.has_section(section):
|
||||||
|
|
|
@ -216,8 +216,8 @@ class ControlPID:
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
class PrinterHeaters:
|
class PrinterHeaters:
|
||||||
def __init__(self, printer, config):
|
def __init__(self, config):
|
||||||
self.printer = printer
|
self.printer = config.get_printer()
|
||||||
self.sensors = {}
|
self.sensors = {}
|
||||||
self.heaters = {}
|
self.heaters = {}
|
||||||
def add_sensor(self, sensor_type, sensor_factory):
|
def add_sensor(self, sensor_type, sensor_factory):
|
||||||
|
@ -249,5 +249,5 @@ class PrinterHeaters:
|
||||||
sensor_type,))
|
sensor_type,))
|
||||||
return self.sensors[sensor_type](config)
|
return self.sensors[sensor_type](config)
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(config):
|
||||||
printer.add_object('heater', PrinterHeaters(printer, config))
|
config.get_printer().add_object('heater', PrinterHeaters(config))
|
||||||
|
|
|
@ -213,11 +213,11 @@ class Printer:
|
||||||
# Create printer components
|
# Create printer components
|
||||||
config = ConfigWrapper(self, fileconfig, 'printer')
|
config = ConfigWrapper(self, fileconfig, 'printer')
|
||||||
for m in [pins, heater, mcu]:
|
for m in [pins, heater, mcu]:
|
||||||
m.add_printer_objects(self, config)
|
m.add_printer_objects(config)
|
||||||
for section in fileconfig.sections():
|
for section in fileconfig.sections():
|
||||||
self.try_load_module(config, section)
|
self.try_load_module(config, section)
|
||||||
for m in [toolhead, extruder]:
|
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
|
# Validate that there are no undefined parameters in the config file
|
||||||
valid_sections = { s: 1 for s, o in self.all_config_options }
|
valid_sections = { s: 1 for s, o in self.all_config_options }
|
||||||
for section_name in fileconfig.sections():
|
for section_name in fileconfig.sections():
|
||||||
|
|
|
@ -399,10 +399,10 @@ class MCU_adc:
|
||||||
|
|
||||||
class MCU:
|
class MCU:
|
||||||
error = error
|
error = error
|
||||||
def __init__(self, printer, config, clocksync):
|
def __init__(self, config, clocksync):
|
||||||
self._printer = printer
|
self._printer = config.get_printer()
|
||||||
self._clocksync = clocksync
|
self._clocksync = clocksync
|
||||||
self._reactor = printer.get_reactor()
|
self._reactor = self._printer.get_reactor()
|
||||||
self._name = config.get_name()
|
self._name = config.get_name()
|
||||||
if self._name.startswith('mcu '):
|
if self._name.startswith('mcu '):
|
||||||
self._name = self._name[4:]
|
self._name = self._name[4:]
|
||||||
|
@ -425,7 +425,7 @@ class MCU:
|
||||||
self._is_shutdown = self._is_timeout = False
|
self._is_shutdown = self._is_timeout = False
|
||||||
self._shutdown_msg = ""
|
self._shutdown_msg = ""
|
||||||
# Config building
|
# 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._oid_count = 0
|
||||||
self._config_objects = []
|
self._config_objects = []
|
||||||
self._init_cmds = []
|
self._init_cmds = []
|
||||||
|
@ -775,13 +775,14 @@ def error_help(msg):
|
||||||
return help_msg
|
return help_msg
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(config):
|
||||||
|
printer = config.get_printer()
|
||||||
reactor = printer.get_reactor()
|
reactor = printer.get_reactor()
|
||||||
mainsync = clocksync.ClockSync(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 '):
|
for s in config.get_prefix_sections('mcu '):
|
||||||
printer.add_object(s.section, MCU(
|
printer.add_object(s.section, MCU(
|
||||||
printer, s, clocksync.SecondarySync(reactor, mainsync)))
|
s, clocksync.SecondarySync(reactor, mainsync)))
|
||||||
|
|
||||||
def get_printer_mcu(printer, name):
|
def get_printer_mcu(printer, name):
|
||||||
if name == 'mcu':
|
if name == 'mcu':
|
||||||
|
|
|
@ -247,5 +247,5 @@ class PrinterPins:
|
||||||
raise error("Duplicate chip name '%s'" % (chip_name,))
|
raise error("Duplicate chip name '%s'" % (chip_name,))
|
||||||
self.chips[chip_name] = chip
|
self.chips[chip_name] = chip
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(config):
|
||||||
printer.add_object('pins', PrinterPins())
|
config.get_printer().add_object('pins', PrinterPins())
|
||||||
|
|
|
@ -442,5 +442,5 @@ class ToolHead:
|
||||||
accel = gcode.get_float('S', params, above=0.)
|
accel = gcode.get_float('S', params, above=0.)
|
||||||
self.max_accel = min(accel, self.config_max_accel)
|
self.max_accel = min(accel, self.config_max_accel)
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(config):
|
||||||
printer.add_object('toolhead', ToolHead(config))
|
config.get_printer().add_object('toolhead', ToolHead(config))
|
||||||
|
|
Loading…
Reference in New Issue