diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py index 3a7ddf4eb..d3366044d 100644 --- a/klippy/chelper/__init__.py +++ b/klippy/chelper/__init__.py @@ -36,9 +36,10 @@ defs_stepcompress = """ int step_count, interval, add; }; - struct stepcompress *stepcompress_alloc(uint32_t oid, char name[16]); - void stepcompress_fill(struct stepcompress *sc, uint32_t max_error - , int32_t queue_step_msgtag, int32_t set_next_step_dir_msgtag); + struct stepcompress *stepcompress_alloc(char name[16]); + void stepcompress_fill(struct stepcompress *sc, uint32_t oid + , uint32_t max_error, int32_t queue_step_msgtag + , int32_t set_next_step_dir_msgtag); void stepcompress_set_invert_sdir(struct stepcompress *sc , uint32_t invert_sdir); void stepcompress_free(struct stepcompress *sc); diff --git a/klippy/chelper/stepcompress.c b/klippy/chelper/stepcompress.c index ab261d129..1a592173e 100644 --- a/klippy/chelper/stepcompress.c +++ b/klippy/chelper/stepcompress.c @@ -258,13 +258,12 @@ static void sc_thread_free(struct stepcompress *sc); // Allocate a new 'stepcompress' object struct stepcompress * __visible -stepcompress_alloc(uint32_t oid, char name[16]) +stepcompress_alloc(char name[16]) { struct stepcompress *sc = malloc(sizeof(*sc)); memset(sc, 0, sizeof(*sc)); list_init(&sc->msg_queue); list_init(&sc->history_list); - sc->oid = oid; sc->sdir = -1; int ret = sc_thread_alloc(sc, name); @@ -275,9 +274,10 @@ stepcompress_alloc(uint32_t oid, char name[16]) // Fill message id information void __visible -stepcompress_fill(struct stepcompress *sc, uint32_t max_error +stepcompress_fill(struct stepcompress *sc, uint32_t oid, uint32_t max_error , int32_t queue_step_msgtag, int32_t set_next_step_dir_msgtag) { + sc->oid = oid; sc->max_error = max_error; sc->queue_step_msgtag = queue_step_msgtag; sc->set_next_step_dir_msgtag = set_next_step_dir_msgtag; diff --git a/klippy/chelper/stepcompress.h b/klippy/chelper/stepcompress.h index 5ebf8bf08..413446daf 100644 --- a/klippy/chelper/stepcompress.h +++ b/klippy/chelper/stepcompress.h @@ -11,8 +11,8 @@ struct pull_history_steps { int step_count, interval, add; }; -struct stepcompress *stepcompress_alloc(uint32_t oid, char name[16]); -void stepcompress_fill(struct stepcompress *sc, uint32_t max_error +struct stepcompress *stepcompress_alloc(char name[16]); +void stepcompress_fill(struct stepcompress *sc, uint32_t oid, uint32_t max_error , int32_t queue_step_msgtag , int32_t set_next_step_dir_msgtag); void stepcompress_set_invert_sdir(struct stepcompress *sc diff --git a/klippy/extras/motion_queuing.py b/klippy/extras/motion_queuing.py index d981dcb58..8fa562621 100644 --- a/klippy/extras/motion_queuing.py +++ b/klippy/extras/motion_queuing.py @@ -69,10 +69,10 @@ class PrinterMotionQueuing: ffi_main, ffi_lib = chelper.get_ffi() return ffi_lib.trapq_append # C steppersync tracking - def allocate_stepcompress(self, mcu, oid, name): + def allocate_stepcompress(self, mcu, name): name = name.encode("utf-8")[:15] ffi_main, ffi_lib = chelper.get_ffi() - sc = ffi_main.gc(ffi_lib.stepcompress_alloc(oid, name), + sc = ffi_main.gc(ffi_lib.stepcompress_alloc(name), ffi_lib.stepcompress_free) self.stepcompress.append((mcu, sc)) return sc diff --git a/klippy/extras/pwm_tool.py b/klippy/extras/pwm_tool.py index cec7e3791..dfa5c682b 100644 --- a/klippy/extras/pwm_tool.py +++ b/klippy/extras/pwm_tool.py @@ -14,12 +14,11 @@ class MCU_queued_pwm: self._hardware_pwm = False self._cycle_time = 0.100 self._max_duration = 2. - self._oid = oid = mcu.create_oid() + self._oid = mcu.create_oid() printer = mcu.get_printer() sname = config.get_name().split()[-1] self._motion_queuing = printer.load_object(config, 'motion_queuing') - self._stepqueue = self._motion_queuing.allocate_stepcompress( - mcu, oid, sname) + self._stepqueue = self._motion_queuing.allocate_stepcompress(mcu, sname) ffi_main, ffi_lib = chelper.get_ffi() self._stepcompress_queue_mq_msg = ffi_lib.stepcompress_queue_mq_msg mcu.register_config_callback(self._build_config) diff --git a/klippy/stepper.py b/klippy/stepper.py index 046b5280d..deb73769e 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -29,7 +29,7 @@ class MCU_stepper: self._units_in_radians = units_in_radians self._step_dist = rotation_dist / steps_per_rotation self._mcu = mcu = step_pin_params['chip'] - self._oid = oid = mcu.create_oid() + self._oid = mcu.create_oid() mcu.register_config_callback(self._build_config) self._step_pin = step_pin_params['pin'] self._invert_step = step_pin_params['invert'] @@ -45,7 +45,7 @@ class MCU_stepper: self._active_callbacks = [] motion_queuing = printer.load_object(config, 'motion_queuing') sname = self._name.split()[-1] - self._stepqueue = motion_queuing.allocate_stepcompress(mcu, oid, sname) + self._stepqueue = motion_queuing.allocate_stepcompress(mcu, sname) ffi_main, ffi_lib = chelper.get_ffi() ffi_lib.stepcompress_set_invert_sdir(self._stepqueue, self._invert_dir) self._stepper_kinematics = None @@ -123,7 +123,7 @@ class MCU_stepper: max_error = self._mcu.get_max_stepper_error() max_error_ticks = self._mcu.seconds_to_clock(max_error) ffi_main, ffi_lib = chelper.get_ffi() - ffi_lib.stepcompress_fill(self._stepqueue, max_error_ticks, + ffi_lib.stepcompress_fill(self._stepqueue, self._oid, max_error_ticks, step_cmd_tag, dir_cmd_tag) def get_oid(self): return self._oid