forked from Klipper3d/klipper
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
17 changed files
with
778 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# BLTouch support | ||
# | ||
# Copyright (C) 2018-2021 Kevin O'Connor <[email protected]> | ||
# Copyright (C) 2018-2024 Kevin O'Connor <[email protected]> | ||
# | ||
# This file may be distributed under the terms of the GNU GPLv3 license. | ||
import logging | ||
|
@@ -23,13 +23,9 @@ | |
} | ||
|
||
# BLTouch "endstop" wrapper | ||
class BLTouchEndstopWrapper: | ||
class BLTouchProbe: | ||
def __init__(self, config): | ||
self.printer = config.get_printer() | ||
self.printer.register_event_handler("klippy:connect", | ||
self.handle_connect) | ||
self.printer.register_event_handler('klippy:mcu_identify', | ||
self.handle_mcu_identify) | ||
self.position_endstop = config.getfloat('z_offset', minval=0.) | ||
self.stow_on_each_sample = config.getboolean('stow_on_each_sample', | ||
True) | ||
|
@@ -44,10 +40,7 @@ def __init__(self, config): | |
self.next_cmd_time = self.action_end_time = 0. | ||
self.finish_home_complete = self.wait_trigger_complete = None | ||
# 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) | ||
mcu = pin_params['chip'] | ||
self.mcu_endstop = mcu.setup_pin('endstop', pin_params) | ||
self.mcu_endstop = ppins.setup_pin('endstop', config.get('sensor_pin')) | ||
# output mode | ||
omodes = {'5V': '5V', 'OD': 'OD', None: None} | ||
self.output_mode = config.getchoice('set_output_mode', omodes, None) | ||
|
@@ -65,19 +58,30 @@ def __init__(self, config): | |
self.get_steppers = self.mcu_endstop.get_steppers | ||
self.home_wait = self.mcu_endstop.home_wait | ||
self.query_endstop = self.mcu_endstop.query_endstop | ||
# multi probes state | ||
self.multi = 'OFF' | ||
# Common probe implementation helpers | ||
self.cmd_helper = probe.ProbeCommandHelper( | ||
config, self, self.mcu_endstop.query_endstop) | ||
self.probe_offsets = probe.ProbeOffsetsHelper(config) | ||
self.probe_session = probe.ProbeSessionHelper(config, self) | ||
# Register BLTOUCH_DEBUG command | ||
self.gcode = self.printer.lookup_object('gcode') | ||
self.gcode.register_command("BLTOUCH_DEBUG", self.cmd_BLTOUCH_DEBUG, | ||
desc=self.cmd_BLTOUCH_DEBUG_help) | ||
self.gcode.register_command("BLTOUCH_STORE", self.cmd_BLTOUCH_STORE, | ||
desc=self.cmd_BLTOUCH_STORE_help) | ||
# multi probes state | ||
self.multi = 'OFF' | ||
def handle_mcu_identify(self): | ||
kin = self.printer.lookup_object('toolhead').get_kinematics() | ||
for stepper in kin.get_steppers(): | ||
if stepper.is_active_axis('z'): | ||
self.add_stepper(stepper) | ||
# Register events | ||
self.printer.register_event_handler("klippy:connect", | ||
self.handle_connect) | ||
def get_probe_params(self, gcmd=None): | ||
return self.probe_session.get_probe_params(gcmd) | ||
def get_offsets(self): | ||
return self.probe_offsets.get_offsets() | ||
def get_status(self, eventtime): | ||
return self.cmd_helper.get_status(eventtime) | ||
def start_probe_session(self, gcmd): | ||
return self.probe_session.start_probe_session(gcmd) | ||
def handle_connect(self): | ||
self.sync_mcu_print_time() | ||
self.next_cmd_time += 0.200 | ||
|
@@ -278,6 +282,6 @@ def cmd_BLTOUCH_STORE(self, gcmd): | |
self.sync_print_time() | ||
|
||
def load_config(config): | ||
blt = BLTouchEndstopWrapper(config) | ||
config.get_printer().add_object('probe', probe.PrinterProbe(config, blt)) | ||
blt = BLTouchProbe(config) | ||
config.get_printer().add_object('probe', blt) | ||
return blt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.