diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-09-13 09:01:13 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-09-13 09:24:27 -0400 |
commit | 14810d7e80e6a691b9d28a21f6cb525ad9fe9855 (patch) | |
tree | af8cc8b2b03b1c4f080c89bda8ab2be9cc3c43d7 | |
parent | 52156d2c418b38576a27e804eb41901b91206825 (diff) | |
download | kutter-14810d7e80e6a691b9d28a21f6cb525ad9fe9855.tar.gz kutter-14810d7e80e6a691b9d28a21f6cb525ad9fe9855.tar.xz kutter-14810d7e80e6a691b9d28a21f6cb525ad9fe9855.zip |
stepcompress: Return number of steps traveled from stepcompress_push()
Return the same information from stepcompress_push() that is returned
from stepcompress_push_const() and stpcompress_push_delta().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r-- | klippy/chelper.py | 2 | ||||
-rw-r--r-- | klippy/mcu.py | 11 | ||||
-rw-r--r-- | klippy/stepcompress.c | 4 |
3 files changed, 7 insertions, 10 deletions
diff --git a/klippy/chelper.py b/klippy/chelper.py index a53304e5..b7dce015 100644 --- a/klippy/chelper.py +++ b/klippy/chelper.py @@ -25,7 +25,7 @@ defs_stepcompress = """ int stepcompress_set_homing(struct stepcompress *sc, uint64_t homing_clock); int stepcompress_queue_msg(struct stepcompress *sc, uint32_t *data, int len); - int stepcompress_push(struct stepcompress *sc, double step_clock + int32_t stepcompress_push(struct stepcompress *sc, double step_clock , int32_t sdir); int32_t stepcompress_push_const(struct stepcompress *sc, double clock_offset , double step_offset, double steps, double start_sv, double accel); diff --git a/klippy/mcu.py b/klippy/mcu.py index 077d6ff8..1fc40302 100644 --- a/klippy/mcu.py +++ b/klippy/mcu.py @@ -108,14 +108,11 @@ class MCU_stepper: if ret: raise error("Internal error in stepcompress") def step(self, mcu_time, sdir): - clock = mcu_time * self._mcu_freq - ret = self._ffi_lib.stepcompress_push(self._stepqueue, clock, sdir) - if ret: + count = self._ffi_lib.stepcompress_push( + self._stepqueue, mcu_time * self._mcu_freq, sdir) + if count == STEPCOMPRESS_ERROR_RET: raise error("Internal error in stepcompress") - if sdir: - self._commanded_pos += 1 - else: - self._commanded_pos -= 1 + self._commanded_pos += count def step_const(self, mcu_time, start_pos, dist, start_v, accel): inv_step_dist = self._inv_step_dist step_offset = self._commanded_pos - start_pos * inv_step_dist diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c index c3f010b2..9c815b3a 100644 --- a/klippy/stepcompress.c +++ b/klippy/stepcompress.c @@ -488,7 +488,7 @@ static inline double safe_sqrt(double v) { } // Schedule a step event at the specified step_clock time -int +int32_t stepcompress_push(struct stepcompress *sc, double step_clock, int32_t sdir) { int ret = set_next_step_dir(sc, !!sdir); @@ -499,7 +499,7 @@ stepcompress_push(struct stepcompress *sc, double step_clock, int32_t sdir) if (ret) return ret; queue_append_finish(qa); - return 0; + return sdir ? 1 : -1; } // Schedule 'steps' number of steps at constant acceleration. If |