mirror of https://github.com/Desuuuu/klipper.git
stepper: Add support for providing a list of pins to enable
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7702f0a027
commit
a2e550d1cd
|
@ -30,7 +30,8 @@ dir_pin: ar55
|
|||
# parameter must be provided.
|
||||
enable_pin: !ar38
|
||||
# Enable pin (default is enable high; use ! to indicate enable
|
||||
# low). If this parameter is not provided then the stepper motor
|
||||
# low). Alternatively, this may be a comma separated list of pins to
|
||||
# enable. If this parameter is not provided then the stepper motor
|
||||
# driver must always be enabled.
|
||||
step_distance: .0225
|
||||
# Distance in mm that each step causes the axis to travel. This
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Printer stepper support
|
||||
#
|
||||
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
# Copyright (C) 2016-2019 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import math, logging, collections
|
||||
|
@ -26,9 +26,18 @@ class StepperEnablePin:
|
|||
if not self.enable_count:
|
||||
self.mcu_enable.set_digital(print_time, 0)
|
||||
|
||||
def lookup_enable_pin(ppins, pin):
|
||||
if pin is None:
|
||||
class StepperMultiEnablePin:
|
||||
def __init__(self, enable_list):
|
||||
self.enable_list = enable_list
|
||||
def set_enable(self, print_time, enable):
|
||||
for en in self.enable_list:
|
||||
en.set_enable(print_time, enable)
|
||||
|
||||
def lookup_enable_pin(ppins, pin_list):
|
||||
if pin_list is None:
|
||||
return StepperEnablePin(None, 9999)
|
||||
enable_list = []
|
||||
for pin in pin_list.split(','):
|
||||
pin_params = ppins.lookup_pin(pin, can_invert=True,
|
||||
share_type='stepper_enable')
|
||||
enable = pin_params.get('class')
|
||||
|
@ -36,7 +45,10 @@ def lookup_enable_pin(ppins, pin):
|
|||
mcu_enable = pin_params['chip'].setup_pin('digital_out', pin_params)
|
||||
mcu_enable.setup_max_duration(0.)
|
||||
pin_params['class'] = enable = StepperEnablePin(mcu_enable)
|
||||
return enable
|
||||
enable_list.append(enable)
|
||||
if len(enable_list) == 1:
|
||||
return enable_list[0]
|
||||
return StepperMultiEnablePin(enable_list)
|
||||
|
||||
|
||||
######################################################################
|
||||
|
|
Loading…
Reference in New Issue