pins: Remove module level get_printer_pins() and setup_pin() functions
Most callers did a lookup of the pins module via
printer.lookup_object("pins"). Use that as the standard method and
remove these less frequently used methods.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -3,15 +3,14 @@
|
||||
# Copyright (C) 2017,2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import pins
|
||||
|
||||
class ad5206:
|
||||
def __init__(self, config):
|
||||
printer = config.get_printer()
|
||||
enable_pin_params = pins.get_printer_pins(printer).lookup_pin(
|
||||
'digital_out', config.get('enable_pin'))
|
||||
ppins = config.get_printer().lookup_object('pins')
|
||||
enable_pin = config.get('enable_pin')
|
||||
enable_pin_params = ppins.lookup_pin('digital_out', enable_pin)
|
||||
if enable_pin_params['invert']:
|
||||
raise pins.error("ad5206 can not invert pin")
|
||||
raise ppins.error("ad5206 can not invert pin")
|
||||
self.mcu = enable_pin_params['chip']
|
||||
self.pin = enable_pin_params['pin']
|
||||
self.mcu.add_config_object(self)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import pins
|
||||
|
||||
FAN_MIN_TIME = 0.100
|
||||
|
||||
@@ -13,8 +12,8 @@ class PrinterFan:
|
||||
self.last_fan_time = 0.
|
||||
self.max_power = config.getfloat('max_power', 1., above=0., maxval=1.)
|
||||
self.kick_start_time = config.getfloat('kick_start_time', 0.1, minval=0.)
|
||||
printer = config.get_printer()
|
||||
self.mcu_fan = pins.setup_pin(printer, 'pwm', config.get('pin'))
|
||||
ppins = config.get_printer().lookup_object('pins')
|
||||
self.mcu_fan = ppins.setup_pin('pwm', config.get('pin'))
|
||||
self.mcu_fan.setup_max_duration(0.)
|
||||
cycle_time = config.getfloat('cycle_time', 0.010, above=0.)
|
||||
hardware_pwm = config.getboolean('hardware_pwm', False)
|
||||
|
||||
@@ -3,34 +3,34 @@
|
||||
# Copyright (C) 2017,2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import pins
|
||||
|
||||
class PrinterMultiPin:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
ppins = self.printer.lookup_object('pins')
|
||||
try:
|
||||
pins.get_printer_pins(self.printer).register_chip('multi_pin', self)
|
||||
except pins.error:
|
||||
ppins.register_chip('multi_pin', self)
|
||||
except ppins.error:
|
||||
pass
|
||||
self.pin_type = None
|
||||
self.pin_list = [pin.strip() for pin in config.get('pins').split(',')]
|
||||
self.mcu_pins = []
|
||||
def setup_pin(self, pin_params):
|
||||
ppins = self.printer.lookup_object('pins')
|
||||
pin_name = pin_params['pin']
|
||||
pin = self.printer.lookup_object('multi_pin ' + pin_name, None)
|
||||
if pin is not self:
|
||||
if pin is None:
|
||||
raise pins.error("multi_pin %s not configured" % (pin_name,))
|
||||
raise ppins.error("multi_pin %s not configured" % (pin_name,))
|
||||
return pin.setup_pin(pin_params)
|
||||
if self.pin_type is not None:
|
||||
raise pins.error("Can't setup multi_pin %s twice" % (pin_name,))
|
||||
raise ppins.error("Can't setup multi_pin %s twice" % (pin_name,))
|
||||
self.pin_type = pin_params['type']
|
||||
invert = ""
|
||||
if pin_params['invert']:
|
||||
invert = "!"
|
||||
self.mcu_pins = [
|
||||
pins.setup_pin(self.printer, self.pin_type, invert + pin_desc)
|
||||
for pin_desc in self.pin_list]
|
||||
self.mcu_pins = [ppins.setup_pin(self.pin_type, invert + pin_desc)
|
||||
for pin_desc in self.pin_list]
|
||||
return self
|
||||
def get_mcu(self):
|
||||
return self.mcu_pins[0].get_mcu()
|
||||
|
||||
@@ -120,13 +120,14 @@ ReplicapeStepConfig = {
|
||||
class Replicape:
|
||||
def __init__(self, config):
|
||||
printer = config.get_printer()
|
||||
pins.get_printer_pins(printer).register_chip('replicape', self)
|
||||
ppins = printer.lookup_object('pins')
|
||||
ppins.register_chip('replicape', self)
|
||||
revisions = {'B3': 'B3'}
|
||||
config.getchoice('revision', revisions)
|
||||
self.host_mcu = mcu.get_printer_mcu(printer, config.get('host_mcu'))
|
||||
# Setup enable pin
|
||||
self.mcu_pwm_enable = pins.setup_pin(
|
||||
printer, 'digital_out', config.get('enable_pin', '!P9_41'))
|
||||
enable_pin = config.get('enable_pin', '!P9_41')
|
||||
self.mcu_pwm_enable = ppins.setup_pin('digital_out', enable_pin)
|
||||
self.mcu_pwm_enable.setup_max_duration(0.)
|
||||
self.mcu_pwm_start_value = self.mcu_pwm_shutdown_value = False
|
||||
# Setup power pins
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
# Copyright (C) 2017,2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import pins
|
||||
|
||||
SERVO_SIGNAL_PERIOD = 0.020
|
||||
PIN_MIN_TIME = 0.100
|
||||
@@ -11,7 +10,8 @@ PIN_MIN_TIME = 0.100
|
||||
class PrinterServo:
|
||||
def __init__(self, config):
|
||||
self.printer = config.get_printer()
|
||||
self.mcu_servo = pins.setup_pin(self.printer, 'pwm', config.get('pin'))
|
||||
ppins = self.printer.lookup_object('pins')
|
||||
self.mcu_servo = ppins.setup_pin('pwm', config.get('pin'))
|
||||
self.mcu_servo.setup_max_duration(0.)
|
||||
self.mcu_servo.setup_cycle_time(SERVO_SIGNAL_PERIOD)
|
||||
self.min_width = config.getfloat(
|
||||
|
||||
Reference in New Issue
Block a user