motion_queuing: Move flushing logic from toolhead.py to motion_queuing module

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2025-08-12 20:07:08 -04:00
parent a1e3964878
commit 2d489e85de
6 changed files with 149 additions and 135 deletions

View File

@@ -16,8 +16,8 @@ class MCU_queued_pwm:
self._max_duration = 2.
self._oid = oid = mcu.create_oid()
printer = mcu.get_printer()
motion_queuing = printer.load_object(config, 'motion_queuing')
self._stepqueue = motion_queuing.allocate_stepcompress(mcu, oid)
self._motion_queuing = printer.load_object(config, 'motion_queuing')
self._stepqueue = self._motion_queuing.allocate_stepcompress(mcu, oid)
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)
@@ -62,8 +62,8 @@ class MCU_queued_pwm:
if self._duration_ticks >= 1<<31:
raise config_error("PWM pin max duration too large")
if self._duration_ticks:
motion_queuing = printer.lookup_object('motion_queuing')
motion_queuing.register_flush_callback(self._flush_notification)
self._motion_queuing.register_flush_callback(
self._flush_notification)
if self._hardware_pwm:
self._pwm_max = self._mcu.get_constant_float("PWM_MAX")
self._default_value = self._shutdown_value * self._pwm_max
@@ -116,8 +116,8 @@ class MCU_queued_pwm:
# Continue flushing to resend time
wakeclock += self._duration_ticks
wake_print_time = self._mcu.clock_to_print_time(wakeclock)
self._toolhead.note_mcu_movequeue_activity(wake_print_time,
is_step_gen=False)
self._motion_queuing.note_mcu_movequeue_activity(wake_print_time,
is_step_gen=False)
def set_pwm(self, print_time, value):
clock = self._mcu.print_time_to_clock(print_time)
if self._invert: