output_pin: Improve GCodeRequestQueue timing on duplicate requests

If there is a duplicate request it is not necessary to add a 100ms
delay to the next update.  Rework the callback signaling to better
report these duplicate updates.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2024-09-15 00:03:58 -04:00
parent 0532a41c75
commit 69e0d866c0
2 changed files with 23 additions and 17 deletions

View file

@ -45,10 +45,10 @@ class PrinterServo:
def get_status(self, eventtime):
return {'value': self.last_value}
def _set_pwm(self, print_time, value):
if value != self.last_value:
self.last_value = value
self.mcu_servo.set_pwm(print_time, value)
return (True, 0.)
if value == self.last_value:
return "discard", 0.
self.last_value = value
self.mcu_servo.set_pwm(print_time, value)
def _get_pwm_from_angle(self, angle):
angle = max(0., min(self.max_angle, angle))
width = self.min_width + angle * self.angle_to_width