aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-10-28 22:45:02 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-11-06 15:51:51 -0500
commit7afac2b3afb519e742e33dca62db5d9657f10ee0 (patch)
tree11bf67aeec06b862def14f262944cabe66cf25d7 /klippy
parentf3ef9c18899e06eb66301fe8c994bcc67955905b (diff)
downloadkutter-7afac2b3afb519e742e33dca62db5d9657f10ee0.tar.gz
kutter-7afac2b3afb519e742e33dca62db5d9657f10ee0.tar.xz
kutter-7afac2b3afb519e742e33dca62db5d9657f10ee0.zip
cartesian: Convert step generation to use trapq system
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/chelper/kin_cartesian.c12
-rw-r--r--klippy/kinematics/cartesian.py26
2 files changed, 18 insertions, 20 deletions
diff --git a/klippy/chelper/kin_cartesian.c b/klippy/chelper/kin_cartesian.c
index 4ae89e38..86569d4a 100644
--- a/klippy/chelper/kin_cartesian.c
+++ b/klippy/chelper/kin_cartesian.c
@@ -1,6 +1,6 @@
// Cartesian kinematics stepper pulse time generation
//
-// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -37,11 +37,15 @@ cartesian_stepper_alloc(char axis)
{
struct stepper_kinematics *sk = malloc(sizeof(*sk));
memset(sk, 0, sizeof(*sk));
- if (axis == 'x')
+ if (axis == 'x') {
sk->calc_position_cb = cart_stepper_x_calc_position;
- else if (axis == 'y')
+ sk->active_flags = AF_X;
+ } else if (axis == 'y') {
sk->calc_position_cb = cart_stepper_y_calc_position;
- else if (axis == 'z')
+ sk->active_flags = AF_Y;
+ } else if (axis == 'z') {
sk->calc_position_cb = cart_stepper_z_calc_position;
+ sk->active_flags = AF_Z;
+ }
return sk;
}
diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py
index a08c3770..615f4dbd 100644
--- a/klippy/kinematics/cartesian.py
+++ b/klippy/kinematics/cartesian.py
@@ -1,6 +1,6 @@
# Code for handling the kinematics of cartesian robots
#
-# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
+# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging
@@ -11,16 +11,18 @@ class CartKinematics:
self.printer = config.get_printer()
# Setup axis rails
self.rails = [stepper.LookupMultiRail(config.getsection('stepper_' + n))
- for n in ['x', 'y', 'z']]
+ for n in 'xyz']
for rail, axis in zip(self.rails, 'xyz'):
rail.setup_itersolve('cartesian_stepper_alloc', axis)
+ for s in self.get_steppers():
+ s.set_trapq(toolhead.get_trapq())
+ toolhead.register_move_handler(s.generate_steps)
# Setup boundary checks
max_velocity, max_accel = toolhead.get_max_velocity()
self.max_z_velocity = config.getfloat(
'max_z_velocity', max_velocity, above=0., maxval=max_velocity)
self.max_z_accel = config.getfloat(
'max_z_accel', max_accel, above=0., maxval=max_accel)
- self.need_motor_enable = True
self.limits = [(1.0, -1.0)] * 3
# Setup stepper max halt velocity
max_halt_velocity = toolhead.get_max_axis_halt()
@@ -37,6 +39,8 @@ class CartKinematics:
self.dual_carriage_axis = {'x': 0, 'y': 1}[dc_axis]
dc_rail = stepper.LookupMultiRail(dc_config)
dc_rail.setup_itersolve('cartesian_stepper_alloc', dc_axis)
+ for s in dc_rail.get_steppers():
+ toolhead.register_move_handler(s.generate_steps)
dc_rail.set_max_jerk(max_halt_velocity, max_accel)
self.dual_carriage_rails = [
self.rails[self.dual_carriage_axis], dc_rail]
@@ -86,14 +90,6 @@ class CartKinematics:
rail.motor_enable(print_time, 0)
for rail in self.dual_carriage_rails:
rail.motor_enable(print_time, 0)
- self.need_motor_enable = True
- def _check_motor_enable(self, print_time, move):
- need_motor_enable = False
- for i, rail in enumerate(self.rails):
- if move.axes_d[i]:
- rail.motor_enable(print_time, 1)
- need_motor_enable |= not rail.is_motor_enabled()
- self.need_motor_enable = need_motor_enable
def _check_endstops(self, move):
end_pos = move.end_pos
for i in (0, 1, 2):
@@ -119,11 +115,7 @@ class CartKinematics:
move.limit_speed(
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
def move(self, print_time, move):
- if self.need_motor_enable:
- self._check_motor_enable(print_time, move)
- for i, rail in enumerate(self.rails):
- if move.axes_d[i]:
- rail.step_itersolve(move.cmove)
+ pass
def get_status(self):
return {'homed_axes': "".join([a
for a, (l, h) in zip("XYZ", self.limits) if l <= h])
@@ -134,6 +126,8 @@ class CartKinematics:
toolhead.get_last_move_time()
dc_rail = self.dual_carriage_rails[carriage]
dc_axis = self.dual_carriage_axis
+ self.rails[dc_axis].set_trapq(None)
+ dc_rail.set_trapq(toolhead.get_trapq())
self.rails[dc_axis] = dc_rail
extruder_pos = toolhead.get_position()[3]
toolhead.set_position(self.calc_position() + [extruder_pos])