aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorDmitry Butyugin <dmbutyugin@google.com>2024-07-30 20:51:28 +0200
committerKevinOConnor <kevin@koconnor.net>2024-08-03 14:41:30 -0400
commitd7d9092a920b3bd2bede4b570c66ddaa52df3f19 (patch)
treeb1f06de230f6c58eae33ced271150a72fa775232 /klippy
parentba2a149e9ab093a36120226c2e76ba8f3f4e7ed9 (diff)
downloadkutter-d7d9092a920b3bd2bede4b570c66ddaa52df3f19.tar.gz
kutter-d7d9092a920b3bd2bede4b570c66ddaa52df3f19.tar.xz
kutter-d7d9092a920b3bd2bede4b570c66ddaa52df3f19.zip
servo: Asynchronous adjustments of servo position
This change follows the same approach as implemented for fan control. The change removes the move queue flushing when changing servo position, which does not appear to be necessary. This can be beneficial, for example, for WS7040-based cooling on IDEX setups where the servo can be used to control the air flow between the toolheads, with this change eliminating micro-stutters of the toolhead on servo position adjustment. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/extras/servo.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/klippy/extras/servo.py b/klippy/extras/servo.py
index c05c9f81..344d6a31 100644
--- a/klippy/extras/servo.py
+++ b/klippy/extras/servo.py
@@ -58,13 +58,15 @@ class PrinterServo:
return width * self.width_to_value
cmd_SET_SERVO_help = "Set servo angle"
def cmd_SET_SERVO(self, gcmd):
- print_time = self.printer.lookup_object('toolhead').get_last_move_time()
width = gcmd.get_float('WIDTH', None)
if width is not None:
- self._set_pwm(print_time, self._get_pwm_from_pulse_width(width))
+ value = self._get_pwm_from_pulse_width(width)
else:
angle = gcmd.get_float('ANGLE')
- self._set_pwm(print_time, self._get_pwm_from_angle(angle))
+ value = self._get_pwm_from_angle(angle)
+ toolhead = self.printer.lookup_object('toolhead')
+ toolhead.register_lookahead_callback((lambda pt:
+ self._set_pwm(pt, value)))
def load_config_prefix(config):
return PrinterServo(config)