mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-10-26 15:56:10 +01:00
motion_report: Improve "motion_report/dump_trapq" during homing
Now that trapq_extract_old() can return upcoming moves, it's possible for homing to cause confusing results (as these moves can end early). Avoid this by delaying query responses until after homing completes. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -54,6 +54,8 @@ class PrinterMotionQueuing:
|
|||||||
self.do_kick_flush_timer = True
|
self.do_kick_flush_timer = True
|
||||||
self.last_flush_time = self.last_step_gen_time = 0.
|
self.last_flush_time = self.last_step_gen_time = 0.
|
||||||
self.need_flush_time = self.need_step_gen_time = 0.
|
self.need_flush_time = self.need_step_gen_time = 0.
|
||||||
|
# "Drip" timing (for homing and probing moves)
|
||||||
|
self.drip_start_times = []
|
||||||
# Register handlers
|
# Register handlers
|
||||||
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
printer.register_event_handler("klippy:shutdown", self._handle_shutdown)
|
||||||
# C trapq tracking
|
# C trapq tracking
|
||||||
@@ -245,7 +247,9 @@ class PrinterMotionQueuing:
|
|||||||
if self.do_kick_flush_timer:
|
if self.do_kick_flush_timer:
|
||||||
self.do_kick_flush_timer = False
|
self.do_kick_flush_timer = False
|
||||||
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
|
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
|
||||||
|
# "Drip" timing (for homing and probing moves)
|
||||||
def drip_update_time(self, start_time, end_time, drip_completion):
|
def drip_update_time(self, start_time, end_time, drip_completion):
|
||||||
|
self.drip_start_times.append(start_time)
|
||||||
self._await_flush_time(start_time)
|
self._await_flush_time(start_time)
|
||||||
# Disable background flushing from timer
|
# Disable background flushing from timer
|
||||||
self.reactor.update_timer(self.flush_timer, self.reactor.NEVER)
|
self.reactor.update_timer(self.flush_timer, self.reactor.NEVER)
|
||||||
@@ -269,6 +273,11 @@ class PrinterMotionQueuing:
|
|||||||
# Restore background flushing
|
# Restore background flushing
|
||||||
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
|
self.reactor.update_timer(self.flush_timer, self.reactor.NOW)
|
||||||
self._advance_flush_time(flush_time + self.kin_flush_delay)
|
self._advance_flush_time(flush_time + self.kin_flush_delay)
|
||||||
|
self.drip_start_times.remove(start_time)
|
||||||
|
def check_drip_timing(self):
|
||||||
|
if not self.drip_start_times:
|
||||||
|
return None
|
||||||
|
return min(self.drip_start_times)
|
||||||
|
|
||||||
def load_config(config):
|
def load_config(config):
|
||||||
return PrinterMotionQueuing(config)
|
return PrinterMotionQueuing(config)
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ class DumpTrapQ:
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.trapq = trapq
|
self.trapq = trapq
|
||||||
self.last_batch_msg = (0., 0.)
|
self.last_batch_msg = (0., 0.)
|
||||||
|
self.motion_queuing = printer.lookup_object("motion_queuing")
|
||||||
self.batch_bulk = bulk_sensor.BatchBulkHelper(printer,
|
self.batch_bulk = bulk_sensor.BatchBulkHelper(printer,
|
||||||
self._process_batch)
|
self._process_batch)
|
||||||
api_resp = {'header': ('time', 'duration', 'start_velocity',
|
api_resp = {'header': ('time', 'duration', 'start_velocity',
|
||||||
@@ -121,6 +122,12 @@ class DumpTrapQ:
|
|||||||
d = [(m.print_time, m.move_t, m.start_v, m.accel,
|
d = [(m.print_time, m.move_t, m.start_v, m.accel,
|
||||||
(m.start_x, m.start_y, m.start_z), (m.x_r, m.y_r, m.z_r))
|
(m.start_x, m.start_y, m.start_z), (m.x_r, m.y_r, m.z_r))
|
||||||
for m in data]
|
for m in data]
|
||||||
|
if d:
|
||||||
|
start_drip_time = self.motion_queuing.check_drip_timing()
|
||||||
|
if start_drip_time is not None:
|
||||||
|
# If homing, delay sending trapq entries that may change
|
||||||
|
while d and d[-1][0] + d[-1][1] >= start_drip_time:
|
||||||
|
d.pop()
|
||||||
if d and d[0] == self.last_batch_msg:
|
if d and d[0] == self.last_batch_msg:
|
||||||
d.pop(0)
|
d.pop(0)
|
||||||
if not d:
|
if not d:
|
||||||
|
|||||||
Reference in New Issue
Block a user