Skip to content

Commit

Permalink
servo: Asynchronous adjustments of servo position
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dmbutyugin authored and rogerlz committed Aug 31, 2024
1 parent 1ed6a32 commit 1343d8f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions klippy/extras/servo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ def _get_pwm_from_pulse_width(self, width):
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):
Expand Down

0 comments on commit 1343d8f

Please sign in to comment.