aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2024-09-13 15:13:09 -0400
committerKevin O'Connor <kevin@koconnor.net>2024-09-16 13:31:14 -0400
commitf323a4fcc7d688240b745fd8ce5bcf1025f4ad6e (patch)
tree45e44d32c9e5674e12838754a0bed7609e4242c0
parent69e0d866c02a93072ea6aeaaec230b6939ba7604 (diff)
downloadkutter-f323a4fcc7d688240b745fd8ce5bcf1025f4ad6e.tar.gz
kutter-f323a4fcc7d688240b745fd8ce5bcf1025f4ad6e.tar.xz
kutter-f323a4fcc7d688240b745fd8ce5bcf1025f4ad6e.zip
output_pin: Add send_async_request() support to GCodeRequestQueue
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/output_pin.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/klippy/extras/output_pin.py b/klippy/extras/output_pin.py
index 2c5cae9c..5e03b423 100644
--- a/klippy/extras/output_pin.py
+++ b/klippy/extras/output_pin.py
@@ -46,12 +46,26 @@ class GCodeRequestQueue:
self.next_min_flush_time = next_time + max(min_wait, PIN_MIN_TIME)
# Ensure following queue items are flushed
self.toolhead.note_mcu_movequeue_activity(self.next_min_flush_time)
- def queue_request(self, print_time, value):
+ def _queue_request(self, print_time, value):
self.rqueue.append((print_time, value))
self.toolhead.note_mcu_movequeue_activity(print_time)
def queue_gcode_request(self, value):
self.toolhead.register_lookahead_callback(
- (lambda pt: self.queue_request(pt, value)))
+ (lambda pt: self._queue_request(pt, value)))
+ def send_async_request(self, print_time, value):
+ while 1:
+ next_time = max(print_time, self.next_min_flush_time)
+ # Invoke callback for the request
+ action, min_wait = "normal", 0.
+ ret = self.callback(next_time, value)
+ if ret is not None:
+ # Handle special cases
+ action, min_wait = ret
+ if action == "discard":
+ break
+ self.next_min_flush_time = next_time + max(min_wait, PIN_MIN_TIME)
+ if action != "delay":
+ break
class PrinterOutputPin:
def __init__(self, config):