Skip to content

Commit

Permalink
Revert "toolhead: Use dict for step generation flush times. (#6303)"
Browse files Browse the repository at this point in the history
This reverts commit 6749985.

A defect was found in the above commit (the input shaper code calls
note_step_generateion_scan_time() for many steppers, so the
input_shaper class can't be used as the index).

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Oct 21, 2023
1 parent 6749985 commit f7567a0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 4 additions & 1 deletion klippy/extras/input_shaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ def _update_input_shaping(self, error=None):
is_sk = self._get_input_shaper_stepper_kinematics(s)
if is_sk is None:
continue
old_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
for shaper in self.shapers:
if shaper in failed_shapers:
continue
if not shaper.set_shaper_kinematics(is_sk):
failed_shapers.append(shaper)
new_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
self.toolhead.note_step_generation_scan_time(self, new_delay)
if old_delay != new_delay:
self.toolhead.note_step_generation_scan_time(new_delay,
old_delay)
if failed_shapers:
error = error or self.printer.command_error
raise error("Failed to configure shaper(s) %s with given parameters"
Expand Down
6 changes: 5 additions & 1 deletion klippy/kinematics/extruder.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ def sync_to_extruder(self, extruder_name):
self.stepper.set_trapq(extruder.get_trapq())
self.motion_queue = extruder_name
def _set_pressure_advance(self, pressure_advance, smooth_time):
old_smooth_time = self.pressure_advance_smooth_time
if not self.pressure_advance:
old_smooth_time = 0.
new_smooth_time = smooth_time
if not pressure_advance:
new_smooth_time = 0.
toolhead = self.printer.lookup_object("toolhead")
toolhead.note_step_generation_scan_time(self, new_smooth_time * .5)
toolhead.note_step_generation_scan_time(new_smooth_time * .5,
old_delay=old_smooth_time * .5)
ffi_main, ffi_lib = chelper.get_ffi()
espa = ffi_lib.extruder_set_pressure_advance
espa(self.sk_extruder, pressure_advance, new_smooth_time)
Expand Down
17 changes: 8 additions & 9 deletions klippy/toolhead.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ def __init__(self, config):
self.drip_completion = None
# Kinematic step generation scan window time tracking
self.kin_flush_delay = SDS_CHECK_TIME
# Map from requester to requested time
self.kin_flush_times = {self: SDS_CHECK_TIME}
self.kin_flush_times = []
self.force_flush_time = self.last_kin_move_time = 0.
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
Expand Down Expand Up @@ -527,15 +526,15 @@ def get_trapq(self):
return self.trapq
def register_step_generator(self, handler):
self.step_generators.append(handler)
def note_step_generation_scan_time(self, requester, delay):
def note_step_generation_scan_time(self, delay, old_delay=0.):
self.flush_step_generation()
if delay == self.kin_flush_times.get(requester, None):
return
cur_delay = self.kin_flush_delay
if old_delay:
self.kin_flush_times.pop(self.kin_flush_times.index(old_delay))
if delay:
self.kin_flush_times[requester] = delay
elif requester in self.kin_flush_times:
del self.kin_flush_times[requester]
self.kin_flush_delay = max(self.kin_flush_times.values())
self.kin_flush_times.append(delay)
new_delay = max(self.kin_flush_times + [SDS_CHECK_TIME])
self.kin_flush_delay = new_delay
def register_lookahead_callback(self, callback):
last_move = self.move_queue.get_last()
if last_move is None:
Expand Down

0 comments on commit f7567a0

Please sign in to comment.