From aaeda540b6cc321e04f4466f0fb518eeb93fcaa1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 29 Oct 2017 10:58:04 -0400 Subject: [PATCH] stepper: Calculate the stepper name directly from the config section There is no need to pass the name to the PrinterStepper class as it can determine the name itself. Signed-off-by: Kevin O'Connor --- klippy/cartesian.py | 2 +- klippy/corexy.py | 2 +- klippy/delta.py | 2 +- klippy/extruder.py | 2 +- klippy/stepper.py | 10 ++++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/klippy/cartesian.py b/klippy/cartesian.py index f0d2e258..edd7519b 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -11,7 +11,7 @@ StepList = (0, 1, 2) class CartKinematics: def __init__(self, toolhead, printer, config): self.steppers = [stepper.PrinterHomingStepper( - printer, config.getsection('stepper_' + n), n) + printer, config.getsection('stepper_' + n)) for n in ['x', 'y', 'z']] max_velocity, max_accel = toolhead.get_max_velocity() self.max_z_velocity = config.getfloat( diff --git a/klippy/corexy.py b/klippy/corexy.py index 286811d9..561def5f 100644 --- a/klippy/corexy.py +++ b/klippy/corexy.py @@ -11,7 +11,7 @@ StepList = (0, 1, 2) class CoreXYKinematics: def __init__(self, toolhead, printer, config): self.steppers = [stepper.PrinterHomingStepper( - printer, config.getsection('stepper_' + n), n) + printer, config.getsection('stepper_' + n)) for n in ['x', 'y', 'z']] self.steppers[0].mcu_endstop.add_stepper(self.steppers[1].mcu_stepper) self.steppers[1].mcu_endstop.add_stepper(self.steppers[0].mcu_stepper) diff --git a/klippy/delta.py b/klippy/delta.py index 8eddc3c9..6e04655e 100644 --- a/klippy/delta.py +++ b/klippy/delta.py @@ -14,7 +14,7 @@ SLOW_RATIO = 3. class DeltaKinematics: def __init__(self, toolhead, printer, config): self.steppers = [stepper.PrinterHomingStepper( - printer, config.getsection('stepper_' + n), n) + printer, config.getsection('stepper_' + n)) for n in ['a', 'b', 'c']] self.need_motor_enable = self.need_home = True radius = config.getfloat('delta_radius', above=0.) diff --git a/klippy/extruder.py b/klippy/extruder.py index f86af765..636fed0b 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -12,7 +12,7 @@ class PrinterExtruder: def __init__(self, printer, config): self.config = config self.heater = heater.PrinterHeater(printer, config) - self.stepper = stepper.PrinterStepper(printer, config, 'extruder') + self.stepper = stepper.PrinterStepper(printer, config) self.nozzle_diameter = config.getfloat('nozzle_diameter', above=0.) filament_diameter = config.getfloat( 'filament_diameter', minval=self.nozzle_diameter) diff --git a/klippy/stepper.py b/klippy/stepper.py index 9bcf1e72..7c0e6935 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -7,8 +7,10 @@ import math, logging import homing, pins class PrinterStepper: - def __init__(self, printer, config, name): - self.name = name + def __init__(self, printer, config): + self.name = config.section + if self.name.startswith('stepper_'): + self.name = self.name[8:] self.step_dist = config.getfloat('step_distance', above=0.) self.inv_step_dist = 1. / self.step_dist @@ -47,8 +49,8 @@ class PrinterStepper: self.need_motor_enable = not enable class PrinterHomingStepper(PrinterStepper): - def __init__(self, printer, config, name): - PrinterStepper.__init__(self, printer, config, name) + def __init__(self, printer, config): + PrinterStepper.__init__(self, printer, config) self.mcu_endstop = pins.setup_pin( printer, 'endstop', config.get('endstop_pin'))