aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/toolhead.py')
-rw-r--r--klippy/toolhead.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 6b0058d3..d9b26ef8 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -3,8 +3,8 @@
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
-import math, logging
-import mcu, homing, cartesian, corexy, delta, extruder
+import math, logging, importlib
+import mcu, homing, kinematics.extruder
# Common suffixes: _d is distance (in mm), _v is velocity (in
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
@@ -227,12 +227,16 @@ class ToolHead:
self.motor_off_timer = self.reactor.register_timer(
self._motor_off_handler, self.reactor.NOW)
# Create kinematics class
- self.extruder = extruder.DummyExtruder()
+ self.extruder = kinematics.extruder.DummyExtruder()
self.move_queue.set_extruder(self.extruder)
- kintypes = {'cartesian': cartesian.CartKinematics,
- 'corexy': corexy.CoreXYKinematics,
- 'delta': delta.DeltaKinematics}
- self.kin = config.getchoice('kinematics', kintypes)(self, config)
+ kin_name = config.get('kinematics')
+ try:
+ mod = importlib.import_module('kinematics.' + kin_name)
+ self.kin = mod.load_kinematics(self, config)
+ except:
+ msg = "Error loading kinematics '%s'" % (kin_name,)
+ logging.exception(msg)
+ raise config.error(msg)
# SET_VELOCITY_LIMIT command
gcode = self.printer.lookup_object('gcode')
gcode.register_command('SET_VELOCITY_LIMIT', self.cmd_SET_VELOCITY_LIMIT,
@@ -353,7 +357,7 @@ class ToolHead:
self.dwell(STALL_TIME)
last_move_time = self.get_last_move_time()
self.kin.motor_off(last_move_time)
- for ext in extruder.get_printer_extruders(self.printer):
+ for ext in kinematics.extruder.get_printer_extruders(self.printer):
ext.motor_off(last_move_time)
self.dwell(STALL_TIME)
self.need_motor_off = False
@@ -444,3 +448,4 @@ class ToolHead:
def add_printer_objects(config):
config.get_printer().add_object('toolhead', ToolHead(config))
+ kinematics.extruder.add_printer_objects(config)