aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepper.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/stepper.py')
-rw-r--r--klippy/stepper.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/klippy/stepper.py b/klippy/stepper.py
index c5f81382..2e6655ef 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -32,6 +32,7 @@ class MCU_stepper:
"Stepper dir pin must be on same mcu as step pin")
self._dir_pin = dir_pin_params['pin']
self._invert_dir = dir_pin_params['invert']
+ self._step_both_edge = self._req_step_both_edge = False
self._mcu_position_offset = 0.
self._reset_cmd_tag = self._get_position_cmd = None
self._active_callbacks = []
@@ -54,6 +55,12 @@ class MCU_stepper:
def units_in_radians(self):
# Returns true if distances are in radians instead of millimeters
return self._units_in_radians
+ def get_pulse_duration(self):
+ return self._step_pulse_duration, self._step_both_edge
+ def setup_default_pulse_duration(self, pulse_duration, step_both_edge):
+ if self._step_pulse_duration is None:
+ self._step_pulse_duration = pulse_duration
+ self._req_step_both_edge = step_both_edge
def setup_itersolve(self, alloc_func, *params):
ffi_main, ffi_lib = chelper.get_ffi()
sk = ffi_main.gc(getattr(ffi_lib, alloc_func)(*params), ffi_lib.free)
@@ -61,11 +68,18 @@ class MCU_stepper:
def _build_config(self):
if self._step_pulse_duration is None:
self._step_pulse_duration = .000002
+ invert_step = self._invert_step
+ sbe = int(self._mcu.get_constants().get('STEPPER_BOTH_EDGE', '0'))
+ if self._req_step_both_edge and sbe:
+ # Enable stepper optimized step on both edges
+ self._step_both_edge = True
+ self._step_pulse_duration = 0.
+ invert_step = -1
step_pulse_ticks = self._mcu.seconds_to_clock(self._step_pulse_duration)
self._mcu.add_config_cmd(
"config_stepper oid=%d step_pin=%s dir_pin=%s invert_step=%d"
" step_pulse_ticks=%u" % (self._oid, self._step_pin, self._dir_pin,
- self._invert_step, step_pulse_ticks))
+ invert_step, step_pulse_ticks))
self._mcu.add_config_cmd("reset_step_clock oid=%d clock=0"
% (self._oid,), on_restart=True)
step_cmd_tag = self._mcu.lookup_command_tag(