aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-12 22:02:32 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-13 00:38:17 -0400
commitbe91c1229fdc8aae5f18549c6f565f33b32b4719 (patch)
tree403f4680e54124b94d5f8135b06a0293d2872c40
parent168cb95bd5b269b8d00aac47cf821f805338b364 (diff)
downloadkutter-be91c1229fdc8aae5f18549c6f565f33b32b4719.tar.gz
kutter-be91c1229fdc8aae5f18549c6f565f33b32b4719.tar.xz
kutter-be91c1229fdc8aae5f18549c6f565f33b32b4719.zip
gcode: Eliminate build_config() method
Lookup the printer components during the set_printer_ready() callback. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/gcode.py7
-rw-r--r--klippy/klippy.py3
2 files changed, 5 insertions, 5 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py
index e0bf6aa9..56a5f746 100644
--- a/klippy/gcode.py
+++ b/klippy/gcode.py
@@ -34,15 +34,16 @@ class GCodeParser:
self.homing_add = [0.0, 0.0, 0.0, 0.0]
self.axis2pos = {'X': 0, 'Y': 1, 'Z': 2, 'E': 3}
self.build_handlers()
- def build_config(self):
- self.toolhead = self.printer.objects['toolhead']
+ def build_handlers(self):
+ # Lookup printer components
+ self.toolhead = self.printer.objects.get('toolhead')
self.heater_nozzle = None
extruder = self.printer.objects.get('extruder')
if extruder:
self.heater_nozzle = extruder.heater
self.heater_bed = self.printer.objects.get('heater_bed')
self.fan = self.printer.objects.get('fan')
- def build_handlers(self):
+ # Map command handlers
handlers = ['G1', 'G4', 'G20', 'G21', 'G28', 'G90', 'G91', 'G92',
'M18', 'M82', 'M83', 'M105', 'M110', 'M112', 'M114', 'M115',
'M206', 'M400',
diff --git a/klippy/klippy.py b/klippy/klippy.py
index 412477ad..9b366a3b 100644
--- a/klippy/klippy.py
+++ b/klippy/klippy.py
@@ -100,6 +100,7 @@ class Printer:
self.startup_state = startup_state
self.software_version = version
self.reactor = reactor.Reactor()
+ self.objects = {}
self.gcode = gcode.GCodeParser(self, input_fd, is_fileinput)
self.stats_timer = self.reactor.register_timer(self.stats)
self.connect_timer = self.reactor.register_timer(
@@ -111,7 +112,6 @@ class Printer:
self.run_result = None
self.fileconfig = None
self.mcu = None
- self.objects = {}
def set_fileoutput(self, debugoutput, dictionary):
self.debugoutput = debugoutput
self.dictionary = dictionary
@@ -152,7 +152,6 @@ class Printer:
def build_config(self):
for oname in sorted(self.objects.keys()):
self.objects[oname].build_config()
- self.gcode.build_config()
self.mcu.build_config()
def validate_config(self):
valid_sections = dict([(s, 1) for s, o in self.all_config_options])