toolhead: Use dict for step generation flush times. (#6303)
Makes the API to extruder and input shaper more robust, avoiding the need to track the old delay. Signed-off-by: Viesturs Zariņš <viesturz@gmail.com>
This commit is contained in:
parent
0c521b601d
commit
6749985302
|
@ -135,16 +135,13 @@ class InputShaper:
|
||||||
is_sk = self._get_input_shaper_stepper_kinematics(s)
|
is_sk = self._get_input_shaper_stepper_kinematics(s)
|
||||||
if is_sk is None:
|
if is_sk is None:
|
||||||
continue
|
continue
|
||||||
old_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
|
|
||||||
for shaper in self.shapers:
|
for shaper in self.shapers:
|
||||||
if shaper in failed_shapers:
|
if shaper in failed_shapers:
|
||||||
continue
|
continue
|
||||||
if not shaper.set_shaper_kinematics(is_sk):
|
if not shaper.set_shaper_kinematics(is_sk):
|
||||||
failed_shapers.append(shaper)
|
failed_shapers.append(shaper)
|
||||||
new_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
|
new_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
|
||||||
if old_delay != new_delay:
|
self.toolhead.note_step_generation_scan_time(self, new_delay)
|
||||||
self.toolhead.note_step_generation_scan_time(new_delay,
|
|
||||||
old_delay)
|
|
||||||
if failed_shapers:
|
if failed_shapers:
|
||||||
error = error or self.printer.command_error
|
error = error or self.printer.command_error
|
||||||
raise error("Failed to configure shaper(s) %s with given parameters"
|
raise error("Failed to configure shaper(s) %s with given parameters"
|
||||||
|
|
|
@ -70,15 +70,11 @@ class ExtruderStepper:
|
||||||
self.stepper.set_trapq(extruder.get_trapq())
|
self.stepper.set_trapq(extruder.get_trapq())
|
||||||
self.motion_queue = extruder_name
|
self.motion_queue = extruder_name
|
||||||
def _set_pressure_advance(self, pressure_advance, smooth_time):
|
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
|
new_smooth_time = smooth_time
|
||||||
if not pressure_advance:
|
if not pressure_advance:
|
||||||
new_smooth_time = 0.
|
new_smooth_time = 0.
|
||||||
toolhead = self.printer.lookup_object("toolhead")
|
toolhead = self.printer.lookup_object("toolhead")
|
||||||
toolhead.note_step_generation_scan_time(new_smooth_time * .5,
|
toolhead.note_step_generation_scan_time(self, new_smooth_time * .5)
|
||||||
old_delay=old_smooth_time * .5)
|
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
ffi_main, ffi_lib = chelper.get_ffi()
|
||||||
espa = ffi_lib.extruder_set_pressure_advance
|
espa = ffi_lib.extruder_set_pressure_advance
|
||||||
espa(self.sk_extruder, pressure_advance, new_smooth_time)
|
espa(self.sk_extruder, pressure_advance, new_smooth_time)
|
||||||
|
|
|
@ -239,7 +239,8 @@ class ToolHead:
|
||||||
self.drip_completion = None
|
self.drip_completion = None
|
||||||
# Kinematic step generation scan window time tracking
|
# Kinematic step generation scan window time tracking
|
||||||
self.kin_flush_delay = SDS_CHECK_TIME
|
self.kin_flush_delay = SDS_CHECK_TIME
|
||||||
self.kin_flush_times = []
|
# Map from requester to requested time
|
||||||
|
self.kin_flush_times = {self: SDS_CHECK_TIME}
|
||||||
self.force_flush_time = self.last_kin_move_time = 0.
|
self.force_flush_time = self.last_kin_move_time = 0.
|
||||||
# Setup iterative solver
|
# Setup iterative solver
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
ffi_main, ffi_lib = chelper.get_ffi()
|
||||||
|
@ -526,15 +527,15 @@ class ToolHead:
|
||||||
return self.trapq
|
return self.trapq
|
||||||
def register_step_generator(self, handler):
|
def register_step_generator(self, handler):
|
||||||
self.step_generators.append(handler)
|
self.step_generators.append(handler)
|
||||||
def note_step_generation_scan_time(self, delay, old_delay=0.):
|
def note_step_generation_scan_time(self, requester, delay):
|
||||||
self.flush_step_generation()
|
self.flush_step_generation()
|
||||||
cur_delay = self.kin_flush_delay
|
if delay == self.kin_flush_times.get(requester, None):
|
||||||
if old_delay:
|
return
|
||||||
self.kin_flush_times.pop(self.kin_flush_times.index(old_delay))
|
|
||||||
if delay:
|
if delay:
|
||||||
self.kin_flush_times.append(delay)
|
self.kin_flush_times[requester] = delay
|
||||||
new_delay = max(self.kin_flush_times + [SDS_CHECK_TIME])
|
elif requester in self.kin_flush_times:
|
||||||
self.kin_flush_delay = new_delay
|
del self.kin_flush_times[requester]
|
||||||
|
self.kin_flush_delay = max(self.kin_flush_times.values())
|
||||||
def register_lookahead_callback(self, callback):
|
def register_lookahead_callback(self, callback):
|
||||||
last_move = self.move_queue.get_last()
|
last_move = self.move_queue.get_last()
|
||||||
if last_move is None:
|
if last_move is None:
|
||||||
|
|
Loading…
Reference in New Issue