Skip to content

Commit

Permalink
bltouch: No need to pause the toolhead for PWM off commands
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Mar 30, 2020
1 parent 2f5d2a3 commit 5271f35
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions klippy/extras/bltouch.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, config):
self.mcu_pwm = ppins.setup_pin('pwm', config.get('control_pin'))
self.mcu_pwm.setup_max_duration(0.)
self.mcu_pwm.setup_cycle_time(SIGNAL_PERIOD)
self.next_cmd_time = 0.
self.next_cmd_time = self.action_end_time = 0.
# Create an "endstop" object to handle the sensor pin
pin = config.get('sensor_pin')
pin_params = ppins.lookup_pin(pin, can_invert=True, can_pullup=True)
Expand Down Expand Up @@ -89,17 +89,19 @@ def sync_mcu_print_time(self):
def sync_print_time(self):
toolhead = self.printer.lookup_object('toolhead')
print_time = toolhead.get_last_move_time()
if self.next_cmd_time > print_time:
toolhead.dwell(self.next_cmd_time - print_time)
else:
if print_time > self.next_cmd_time:
self.next_cmd_time = print_time
elif self.action_end_time > print_time:
toolhead.dwell(self.action_end_time - print_time)
def send_cmd(self, cmd, duration=MIN_CMD_TIME):
self.mcu_pwm.set_pwm(self.next_cmd_time, Commands[cmd] / SIGNAL_PERIOD)
# Translate duration to ticks to avoid any secondary mcu clock skew
mcu = self.mcu_pwm.get_mcu()
cmd_clock = mcu.print_time_to_clock(self.next_cmd_time)
cmd_clock += mcu.seconds_to_clock(max(duration, MIN_CMD_TIME))
self.next_cmd_time = mcu.clock_to_print_time(cmd_clock)
if cmd is not None:
self.action_end_time = self.next_cmd_time
return self.next_cmd_time
def verify_state(self, check_start_time, check_end_time, triggered):
# Perform endstop check to verify bltouch reports desired state
Expand Down

0 comments on commit 5271f35

Please sign in to comment.