mirror of https://github.com/Desuuuu/klipper.git
klippy: Rename lookup_module_objects() to lookup_objects()
Rename the method and support returning all known objects. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
50196c7141
commit
18b04ffe68
|
@ -164,11 +164,14 @@ class Printer:
|
||||||
if default is ConfigWrapper.sentinel:
|
if default is ConfigWrapper.sentinel:
|
||||||
raise self.config_error("Unknown config object '%s'" % (name,))
|
raise self.config_error("Unknown config object '%s'" % (name,))
|
||||||
return default
|
return default
|
||||||
def lookup_module_objects(self, module_name):
|
def lookup_objects(self, module=None):
|
||||||
prefix = module_name + ' '
|
if module is None:
|
||||||
objs = [self.objects[n] for n in self.objects if n.startswith(prefix)]
|
return list(self.objects.items())
|
||||||
if module_name in self.objects:
|
prefix = module + ' '
|
||||||
return [self.objects[module_name]] + objs
|
objs = [(n, self.objects[n])
|
||||||
|
for n in self.objects if n.startswith(prefix)]
|
||||||
|
if module in self.objects:
|
||||||
|
return [(module, self.objects[module])] + objs
|
||||||
return objs
|
return objs
|
||||||
def set_rollover_info(self, name, info):
|
def set_rollover_info(self, name, info):
|
||||||
logging.info(info)
|
logging.info(info)
|
||||||
|
@ -280,7 +283,7 @@ class Printer:
|
||||||
try:
|
try:
|
||||||
self._stats(self.reactor.monotonic(), force_output=True)
|
self._stats(self.reactor.monotonic(), force_output=True)
|
||||||
if run_result == 'firmware_restart':
|
if run_result == 'firmware_restart':
|
||||||
for m in self.lookup_module_objects('mcu'):
|
for n, m in self.lookup_objects(module='mcu'):
|
||||||
m.microcontroller_restart()
|
m.microcontroller_restart()
|
||||||
for cb in self.state_cb:
|
for cb in self.state_cb:
|
||||||
cb('disconnect')
|
cb('disconnect')
|
||||||
|
|
|
@ -196,7 +196,8 @@ class ToolHead:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
self.reactor = self.printer.get_reactor()
|
self.reactor = self.printer.get_reactor()
|
||||||
self.all_mcus = self.printer.lookup_module_objects('mcu')
|
self.all_mcus = [
|
||||||
|
m for n, m in self.printer.lookup_objects(module='mcu')]
|
||||||
self.mcu = self.all_mcus[0]
|
self.mcu = self.all_mcus[0]
|
||||||
self.move_queue = MoveQueue()
|
self.move_queue = MoveQueue()
|
||||||
self.commanded_pos = [0., 0., 0., 0.]
|
self.commanded_pos = [0., 0., 0., 0.]
|
||||||
|
|
Loading…
Reference in New Issue