extruder: Allow dynamic adjustment of pressure advance (#6635)

Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
Dmitry Butyugin 2024-07-11 20:43:21 +02:00 committed by GitHub
parent 248d3dbf8b
commit c84d78f3f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 185 additions and 20 deletions

View file

@ -18,7 +18,7 @@ class ExtruderStepper:
self.stepper = stepper.PrinterStepper(config)
ffi_main, ffi_lib = chelper.get_ffi()
self.sk_extruder = ffi_main.gc(ffi_lib.extruder_stepper_alloc(),
ffi_lib.free)
ffi_lib.extruder_stepper_free)
self.stepper.set_stepper_kinematics(self.sk_extruder)
self.motion_queue = None
# Register commands
@ -71,11 +71,14 @@ class ExtruderStepper:
if not pressure_advance:
new_smooth_time = 0.
toolhead = self.printer.lookup_object("toolhead")
toolhead.note_step_generation_scan_time(new_smooth_time * .5,
old_delay=old_smooth_time * .5)
if new_smooth_time != old_smooth_time:
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)
toolhead.register_lookahead_callback(
lambda print_time: espa(self.sk_extruder, print_time,
pressure_advance, new_smooth_time))
self.pressure_advance = pressure_advance
self.pressure_advance_smooth_time = smooth_time
cmd_SET_PRESSURE_ADVANCE_help = "Set pressure advance parameters"