From 460e02871b1622ad19dd6b004077859a1f75fe72 Mon Sep 17 00:00:00 2001 From: guoge Date: Thu, 8 Feb 2024 11:35:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BD=BF=E7=94=A8do=5Fmove()?= =?UTF-8?q?=E5=87=BD=E6=95=B0,=20=E4=B9=9F=E4=B8=8D=E8=A1=8C,=E4=BC=9A?= =?UTF-8?q?=E4=B8=AD=E6=96=AD=E6=89=93=E5=8D=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- klippy/extras/gcode_button.py | 10 +++++++++- klippy/extras/manual_stepper.py | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/klippy/extras/gcode_button.py b/klippy/extras/gcode_button.py index 669edfb404b2..eb53370d2e97 100644 --- a/klippy/extras/gcode_button.py +++ b/klippy/extras/gcode_button.py @@ -13,7 +13,7 @@ def __init__(self, config): self.last_state = 0 buttons = self.printer.load_object(config, "buttons") if config.get('analog_range', None) is None: - buttons.register_buttons([self.pin], self.button_callback) + buttons.register_buttons([self.pin], self.button_callback_feed) else: amin, amax = config.getfloatlist('analog_range', count=2) pullup = config.getfloat('analog_pullup_resistor', 4700., above=0.) @@ -42,6 +42,14 @@ def button_callback(self, eventtime, state): except: logging.exception("Script running error") + def button_callback_feed(self, eventtime, state): + self.last_state = state + stepper = self.printer.lookup_object('feeder_step_0') + if not state: + stepper.do_move(100, 10, 1000) + else: + stepper.do_move(10, 10, 1000) + def get_status(self, eventtime=None): if self.last_state: return {'state': "PRESSED"} diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py index 223e13f1d00f..c7cf9d5658f5 100644 --- a/klippy/extras/manual_stepper.py +++ b/klippy/extras/manual_stepper.py @@ -34,6 +34,7 @@ def __init__(self, config): gcode.register_mux_command('MANUAL_STEPPER', "STEPPER", stepper_name, self.cmd_MANUAL_STEPPER, desc=self.cmd_MANUAL_STEPPER_help) + self.printer.add_object(stepper_name, self) def sync_print_time(self): toolhead = self.printer.lookup_object('toolhead') print_time = toolhead.get_last_move_time()