From 2a8dd5c51f4097ae1142b681af75f529bb9e37f3 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 5 Dec 2017 21:03:49 -0500 Subject: [PATCH] mcu: Reset the stepper step clock on init - not after each motor on Reset the last step clock during the init phase and after each home - this simplifies the runtime code. Signed-off-by: Kevin O'Connor --- klippy/mcu.py | 21 ++++++++------------- klippy/stepper.py | 2 -- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/klippy/mcu.py b/klippy/mcu.py index 10a14034..6a080429 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -45,6 +45,8 @@ class MCU_stepper: self._oid, self._step_pin, self._dir_pin, self._mcu.seconds_to_clock(min_stop_interval), self._invert_step)) + self._mcu.add_config_cmd( + "reset_step_clock oid=%d clock=0" % (self._oid,), is_init=True) step_cmd = self._mcu.lookup_command( "queue_step oid=%c interval=%u count=%hu add=%hi") dir_cmd = self._mcu.lookup_command( @@ -83,12 +85,15 @@ class MCU_stepper: ret = self._ffi_lib.stepcompress_set_homing(self._stepqueue, 0) if ret: raise error("Internal error in stepcompress") - if not did_trigger: - return ret = self._ffi_lib.stepcompress_reset(self._stepqueue, 0) if ret: raise error("Internal error in stepcompress") - if self._mcu.is_fileoutput(): + data = (self._reset_cmd.msgid, self._oid, 0) + ret = self._ffi_lib.stepcompress_queue_msg( + self._stepqueue, data, len(data)) + if ret: + raise error("Internal error in stepcompress") + if not did_trigger or self._mcu.is_fileoutput(): return cmd = self._get_position_cmd.encode(self._oid) params = self._mcu.send_with_response(cmd, 'stepper_position', self._oid) @@ -96,16 +101,6 @@ class MCU_stepper: if self._invert_dir: pos = -pos self._mcu_position_offset = pos - self._commanded_pos - def reset_step_clock(self, print_time): - clock = self._mcu.print_time_to_clock(print_time) - ret = self._ffi_lib.stepcompress_reset(self._stepqueue, clock) - if ret: - raise error("Internal error in stepcompress") - data = (self._reset_cmd.msgid, self._oid, clock & 0xffffffff) - ret = self._ffi_lib.stepcompress_queue_msg( - self._stepqueue, data, len(data)) - if ret: - raise error("Internal error in stepcompress") def step(self, print_time, sdir): count = self._ffi_lib.stepcompress_push( self._stepqueue, print_time, sdir) diff --git a/klippy/stepper.py b/klippy/stepper.py index d0a6bc80..c532d21a 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -44,8 +44,6 @@ class PrinterStepper: def set_position(self, pos): self.mcu_stepper.set_position(pos) def motor_enable(self, print_time, enable=0): - if enable and self.need_motor_enable: - self.mcu_stepper.reset_step_clock(print_time) if (self.mcu_enable is not None and self.mcu_enable.get_last_setting() != enable): self.mcu_enable.set_digital(print_time, enable)