Skip to content

Commit

Permalink
测试使用do_move()函数, 也不行,会中断打印.
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoGeTiertime committed Feb 8, 2024
1 parent eccb414 commit 460e028
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion klippy/extras/gcode_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down Expand Up @@ -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"}
Expand Down
1 change: 1 addition & 0 deletions klippy/extras/manual_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 460e028

Please sign in to comment.