diff options
author | FanDjango <51046875+FanDjango@users.noreply.github.com> | 2020-02-24 04:32:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 22:32:07 -0500 |
commit | 16ecf15a912c72cce3d9d6e617828c8aa03f13d8 (patch) | |
tree | 68af5db9976962f7608c1cd2b06b618daeef0d1a /klippy/extras/bltouch.py | |
parent | 245917bf034804acfa3039ac308c7d4308e79e86 (diff) | |
download | kutter-16ecf15a912c72cce3d9d6e617828c8aa03f13d8.tar.gz kutter-16ecf15a912c72cce3d9d6e617828c8aa03f13d8.tar.xz kutter-16ecf15a912c72cce3d9d6e617828c8aa03f13d8.zip |
bltouch: BTLOUCH V3.0/V3.1 Enable 5V/OD mode set commands (#2540)
Signed-off-by: Mike Stiemke <fandjango@gmx.de>
Diffstat (limited to 'klippy/extras/bltouch.py')
-rw-r--r-- | klippy/extras/bltouch.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/klippy/extras/bltouch.py b/klippy/extras/bltouch.py index d5b4becc..8f8dabaa 100644 --- a/klippy/extras/bltouch.py +++ b/klippy/extras/bltouch.py @@ -18,6 +18,8 @@ ENDSTOP_SAMPLE_COUNT = 4 Commands = { None: 0.0, 'pin_down': 0.000650, 'touch_mode': 0.001165, 'pin_up': 0.001475, 'self_test': 0.001780, 'reset': 0.002190, + 'set_5V_output_mode' : 0.001988, 'set_OD_output_mode' : 0.002091, + 'output_mode_store' : 0.001884, } # BLTouch "endstop" wrapper @@ -41,6 +43,10 @@ class BLTouchEndstopWrapper: mcu = pin_params['chip'] mcu.register_config_callback(self._build_config) self.mcu_endstop = mcu.setup_pin('endstop', pin_params) + # output mode + self.output_mode = config.getchoice('set_output_mode', + {'5V': '5V', 'OD': 'OD', + None: None}, None) # Setup for sensor test self.next_test_time = 0. self.pin_up_not_triggered = config.getboolean( @@ -61,6 +67,8 @@ class BLTouchEndstopWrapper: 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 _build_config(self): @@ -69,6 +77,7 @@ class BLTouchEndstopWrapper: if stepper.is_active_axis('z'): self.add_stepper(stepper) def handle_connect(self): + self.set_output_mode(self.output_mode) try: self.raise_probe() except homing.CommandError as e: @@ -178,6 +187,44 @@ class BLTouchEndstopWrapper: sample_count, rest_time) def get_position_endstop(self): return self.position_endstop + def set_output_mode(self, mode): + # If this is inadvertently/purposely issued for a + # BLTOUCH pre V3.0 and clones: + # No reaction at all. + # BLTOUCH V3.0 and V3.1: + # This will set the mode. + if mode is None: + return + logging.info("BLTouch set output mode: %s", mode) + self.sync_mcu_print_time() + if mode == '5V': + self.send_cmd('set_5V_output_mode') + if mode == 'OD': + self.send_cmd('set_OD_output_mode') + def store_output_mode(self, mode): + # If this command is inadvertently/purposely issued for a + # BLTOUCH pre V3.0 and clones: + # No reaction at all to this sequence apart from a pin-down/pin-up + # BLTOUCH V3.0: + # This will set the mode (twice) and sadly, a pin-up is needed at + # the end, because of the pin-down + # BLTOUCH V3.1: + # This will set the mode and store it in the eeprom. + # The pin-up is not needed but does not hurt + logging.info("BLTouch store output mode: %s", mode) + self.sync_print_time() + self.send_cmd('pin_down') + if mode == '5V': + self.send_cmd('set_5V_output_mode') + else: + self.send_cmd('set_OD_output_mode') + self.send_cmd('output_mode_store') + if mode == '5V': + self.send_cmd('set_5V_output_mode') + else: + self.send_cmd('set_OD_output_mode') + self.send_cmd('pin_up') + self.send_cmd(None) cmd_BLTOUCH_DEBUG_help = "Send a command to the bltouch for debugging" def cmd_BLTOUCH_DEBUG(self, params): cmd = self.gcode.get_str('COMMAND', params, None) @@ -190,6 +237,16 @@ class BLTouchEndstopWrapper: self.send_cmd(cmd, duration=self.pin_move_time) self.send_cmd(None) self.sync_print_time() + cmd_BLTOUCH_STORE_help = "Store an output mode in the BLTouch EEPROM" + def cmd_BLTOUCH_STORE(self, params): + cmd = self.gcode.get_str('MODE', params, None) + if cmd is None or cmd not in ['5V', 'OD']: + self.gcode.respond_info("BLTouch output modes: 5V, OD") + return + self.gcode.respond_info("Storing BLTouch output mode: %s" % (cmd,)) + self.sync_print_time() + self.store_output_mode(cmd) + self.sync_print_time() def load_config(config): blt = BLTouchEndstopWrapper(config) |