diff --git a/klippy/extras/gcode_move.py b/klippy/extras/gcode_move.py index 929f7a807..21174a904 100644 --- a/klippy/extras/gcode_move.py +++ b/klippy/extras/gcode_move.py @@ -107,9 +107,9 @@ class GCodeMove: 'extrude_factor': self.extrude_factor, 'absolute_coordinates': self.absolute_coord, 'absolute_extrude': self.absolute_extrude, - 'homing_origin': self.Coord(*self.homing_position[:4]), - 'position': self.Coord(*self.last_position[:4]), - 'gcode_position': self.Coord(*move_position), + 'homing_origin': self.Coord(self.homing_position[:4]), + 'position': self.Coord(self.last_position[:4]), + 'gcode_position': self.Coord(move_position), } def reset_last_position(self): if self.is_printer_ready: diff --git a/klippy/extras/motion_report.py b/klippy/extras/motion_report.py index 9f3a0385b..1c2dc9a6b 100644 --- a/klippy/extras/motion_report.py +++ b/klippy/extras/motion_report.py @@ -151,7 +151,7 @@ class PrinterMotionReport: self.next_status_time = 0. gcode = self.printer.lookup_object('gcode') self.last_status = { - 'live_position': gcode.Coord(0., 0., 0., 0.), + 'live_position': gcode.Coord((0., 0., 0.)), 'live_velocity': 0., 'live_extruder_velocity': 0., 'steppers': [], 'trapq': [], } @@ -236,7 +236,7 @@ class PrinterMotionReport: evelocity = velocity # Report status self.last_status = dict(self.last_status) - self.last_status['live_position'] = toolhead.Coord(*(xyzpos + epos)) + self.last_status['live_position'] = toolhead.Coord(xyzpos + epos) self.last_status['live_velocity'] = xyzvelocity self.last_status['live_extruder_velocity'] = evelocity return self.last_status diff --git a/klippy/gcode.py b/klippy/gcode.py index ca815b4d7..11b57cfab 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -11,10 +11,10 @@ class CommandError(Exception): # Custom "tuple" class for coordinates - add easy access to x, y, z components class Coord(tuple): __slots__ = () - def __new__(cls, x, y, z, e, *args): - return tuple.__new__(cls, (x, y, z, e) + args) - def __getnewargs__(self): - return tuple(self) + def __new__(cls, t): + if len(t) < 4: + t = tuple(t) + (0,) * (4 - len(t)) + return tuple.__new__(cls, t) x = property(operator.itemgetter(0)) y = property(operator.itemgetter(1)) z = property(operator.itemgetter(2)) diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py index edd9c1a04..5362e57d0 100644 --- a/klippy/kinematics/cartesian.py +++ b/klippy/kinematics/cartesian.py @@ -18,8 +18,8 @@ class CartKinematics: for rail, axis in zip(self.rails, 'xyz'): rail.setup_itersolve('cartesian_stepper_alloc', axis.encode()) ranges = [r.get_range() for r in self.rails] - self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) - self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) + self.axes_min = toolhead.Coord([r[0] for r in ranges]) + self.axes_max = toolhead.Coord([r[1] for r in ranges]) self.dc_module = None if config.has_section('dual_carriage'): dc_config = config.getsection('dual_carriage') diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py index f940c57fa..7d074ae63 100644 --- a/klippy/kinematics/corexy.py +++ b/klippy/kinematics/corexy.py @@ -28,8 +28,8 @@ class CoreXYKinematics: 'max_z_accel', max_accel, above=0., maxval=max_accel) self.limits = [(1.0, -1.0)] * 3 ranges = [r.get_range() for r in self.rails] - self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) - self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) + self.axes_min = toolhead.Coord([r[0] for r in ranges]) + self.axes_max = toolhead.Coord([r[1] for r in ranges]) def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] def calc_position(self, stepper_positions): diff --git a/klippy/kinematics/corexz.py b/klippy/kinematics/corexz.py index d4a0eb350..6950dd7b0 100644 --- a/klippy/kinematics/corexz.py +++ b/klippy/kinematics/corexz.py @@ -28,8 +28,8 @@ class CoreXZKinematics: 'max_z_accel', max_accel, above=0., maxval=max_accel) self.limits = [(1.0, -1.0)] * 3 ranges = [r.get_range() for r in self.rails] - self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) - self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) + self.axes_min = toolhead.Coord([r[0] for r in ranges]) + self.axes_max = toolhead.Coord([r[1] for r in ranges]) def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] def calc_position(self, stepper_positions): diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py index 5ec4d54cc..9f4932b09 100644 --- a/klippy/kinematics/delta.py +++ b/klippy/kinematics/delta.py @@ -85,8 +85,8 @@ class DeltaKinematics: " and %.2fmm)" % (max_xy, math.sqrt(self.slow_xy2), math.sqrt(self.very_slow_xy2))) - self.axes_min = toolhead.Coord(-max_xy, -max_xy, self.min_z, 0.) - self.axes_max = toolhead.Coord(max_xy, max_xy, self.max_z, 0.) + self.axes_min = toolhead.Coord((-max_xy, -max_xy, self.min_z)) + self.axes_max = toolhead.Coord((max_xy, max_xy, self.max_z)) self.set_position([0., 0., 0.], "") def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] diff --git a/klippy/kinematics/deltesian.py b/klippy/kinematics/deltesian.py index a62a58bd2..a4fb328b5 100644 --- a/klippy/kinematics/deltesian.py +++ b/klippy/kinematics/deltesian.py @@ -83,8 +83,8 @@ class DeltesianKinematics: above=0., maxval=max_velocity) self.max_z_accel = config.getfloat('max_z_accel', max_accel, above=0., maxval=max_accel) - self.axes_min = toolhead.Coord(*[l[0] for l in self.limits], e=0.) - self.axes_max = toolhead.Coord(*[l[1] for l in self.limits], e=0.) + self.axes_min = toolhead.Coord([l[0] for l in self.limits]) + self.axes_max = toolhead.Coord([l[1] for l in self.limits]) self.homed_axis = [False] * 3 self.set_position([0., 0., 0.], "") def get_steppers(self): diff --git a/klippy/kinematics/generic_cartesian.py b/klippy/kinematics/generic_cartesian.py index 49e16eec3..413cc11ca 100644 --- a/klippy/kinematics/generic_cartesian.py +++ b/klippy/kinematics/generic_cartesian.py @@ -306,8 +306,8 @@ class GenericCartesianKinematics: axes = [a for a, (l, h) in zip("xyz", self.limits) if l <= h] ranges = [c.get_rail().get_range() for c in self.get_primary_carriages()] - axes_min = gcode.Coord(*[r[0] for r in ranges], e=0.) - axes_max = gcode.Coord(*[r[1] for r in ranges], e=0.) + axes_min = gcode.Coord([r[0] for r in ranges]) + axes_max = gcode.Coord([r[1] for r in ranges]) return { 'homed_axes': "".join(axes), 'axis_minimum': axes_min, diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index 22884b93c..bbe7bfa55 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -21,8 +21,8 @@ class HybridCoreXYKinematics: self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y') self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z') ranges = [r.get_range() for r in self.rails] - self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) - self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) + self.axes_min = toolhead.Coord([r[0] for r in ranges]) + self.axes_max = toolhead.Coord([r[1] for r in ranges]) self.dc_module = None if config.has_section('dual_carriage'): dc_config = config.getsection('dual_carriage') diff --git a/klippy/kinematics/hybrid_corexz.py b/klippy/kinematics/hybrid_corexz.py index 1cd646e28..3e2dd4788 100644 --- a/klippy/kinematics/hybrid_corexz.py +++ b/klippy/kinematics/hybrid_corexz.py @@ -21,8 +21,8 @@ class HybridCoreXZKinematics: self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y') self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z') ranges = [r.get_range() for r in self.rails] - self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) - self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) + self.axes_min = toolhead.Coord([r[0] for r in ranges]) + self.axes_max = toolhead.Coord([r[1] for r in ranges]) self.dc_module = None if config.has_section('dual_carriage'): dc_config = config.getsection('dual_carriage') diff --git a/klippy/kinematics/none.py b/klippy/kinematics/none.py index d9f9d21d2..35ebd59ce 100644 --- a/klippy/kinematics/none.py +++ b/klippy/kinematics/none.py @@ -6,7 +6,7 @@ class NoneKinematics: def __init__(self, toolhead, config): - self.axes_minmax = toolhead.Coord(0., 0., 0., 0.) + self.axes_minmax = toolhead.Coord((0., 0., 0.)) def get_steppers(self): return [] def calc_position(self, stepper_positions): diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py index 2e467d50e..422c9981f 100644 --- a/klippy/kinematics/polar.py +++ b/klippy/kinematics/polar.py @@ -31,8 +31,8 @@ class PolarKinematics: self.limit_xy2 = -1. max_xy = self.rails[0].get_range()[1] min_z, max_z = self.rails[1].get_range() - self.axes_min = toolhead.Coord(-max_xy, -max_xy, min_z, 0.) - self.axes_max = toolhead.Coord(max_xy, max_xy, max_z, 0.) + self.axes_min = toolhead.Coord((-max_xy, -max_xy, min_z)) + self.axes_max = toolhead.Coord((max_xy, max_xy, max_z)) def get_steppers(self): return list(self.steppers) def calc_position(self, stepper_positions): diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py index 42b0a706d..2f6d5060b 100644 --- a/klippy/kinematics/rotary_delta.py +++ b/klippy/kinematics/rotary_delta.py @@ -71,8 +71,8 @@ class RotaryDeltaKinematics: "Delta max build height %.2fmm (radius tapered above %.2fmm)" % (self.max_z, self.limit_z)) max_xy = math.sqrt(self.max_xy2) - self.axes_min = toolhead.Coord(-max_xy, -max_xy, self.min_z, 0.) - self.axes_max = toolhead.Coord(max_xy, max_xy, self.max_z, 0.) + self.axes_min = toolhead.Coord((-max_xy, -max_xy, self.min_z)) + self.axes_max = toolhead.Coord((max_xy, max_xy, self.max_z)) self.set_position([0., 0., 0.], "") def get_steppers(self): return [s for rail in self.rails for s in rail.get_steppers()] diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py index 2fa06ef22..77f3cc734 100644 --- a/klippy/kinematics/winch.py +++ b/klippy/kinematics/winch.py @@ -23,8 +23,8 @@ class WinchKinematics: s.set_trapq(toolhead.get_trapq()) # Setup boundary checks acoords = list(zip(*self.anchors)) - self.axes_min = toolhead.Coord(*[min(a) for a in acoords], e=0.) - self.axes_max = toolhead.Coord(*[max(a) for a in acoords], e=0.) + self.axes_min = toolhead.Coord([min(a) for a in acoords]) + self.axes_max = toolhead.Coord([max(a) for a in acoords]) self.set_position([0., 0., 0.], "") def get_steppers(self): return list(self.steppers) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 8f16e75b6..47ca7136c 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -500,7 +500,7 @@ class ToolHead: 'stalls': self.print_stall, 'estimated_print_time': estimated_print_time, 'extruder': extruder.get_name(), - 'position': self.Coord(*self.commanded_pos[:4]), + 'position': self.Coord(self.commanded_pos[:4]), 'max_velocity': self.max_velocity, 'max_accel': self.max_accel, 'minimum_cruise_ratio': self.min_cruise_ratio,