diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-07-26 09:44:45 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-07-26 09:44:45 -0400 |
commit | 273a98d39a88a372c8a2c816622e7df1f777e77d (patch) | |
tree | 2e8d4253f901a093d745127d97fd2464098d9266 /klippy/extras/replicape.py | |
parent | 7a9553b38a39398226d95b7569a0b889b8cdb10a (diff) | |
download | kutter-273a98d39a88a372c8a2c816622e7df1f777e77d.tar.gz kutter-273a98d39a88a372c8a2c816622e7df1f777e77d.tar.xz kutter-273a98d39a88a372c8a2c816622e7df1f777e77d.zip |
pins: Explicitly pass can_invert and can_pullup to lookup_pin()
Don't pass pin_type to lookup_pin() - instead, if a pin can be
inverted or can have a pullup, then the caller must explicitly specify
that when calling lookup_pin(). This simplifies the code for the
cases where it is not valid to invert or pullup.
Explicitly pass the pin_type to setup_pin() and have ppins.setup_pin()
apply default pullup and invert flags.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/extras/replicape.py')
-rw-r--r-- | klippy/extras/replicape.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/klippy/extras/replicape.py b/klippy/extras/replicape.py index 5bc851e9..91e75550 100644 --- a/klippy/extras/replicape.py +++ b/klippy/extras/replicape.py @@ -14,10 +14,10 @@ REPLICAPE_PCA9685_CYCLE_TIME = .001 PIN_MIN_TIME = 0.100 class pca9685_pwm: - def __init__(self, replicape, channel, pin_params): + def __init__(self, replicape, channel, pin_type, pin_params): self._replicape = replicape self._channel = channel - if pin_params['type'] not in ['digital_out', 'pwm']: + if pin_type not in ['digital_out', 'pwm']: raise pins.error("Pin type not supported on replicape") self._mcu = replicape.host_mcu self._mcu.add_config_object(self) @@ -90,14 +90,14 @@ class pca9685_pwm: self.set_pwm(print_time, 0.) class ReplicapeDACEnable: - def __init__(self, replicape, channel, pin_params): - if pin_params['type'] != 'digital_out': + def __init__(self, replicape, channel, pin_type, pin_params): + if pin_type != 'digital_out': raise pins.error("Replicape virtual enable pin must be digital_out") if pin_params['invert']: raise pins.error("Replicape virtual enable pin can not be inverted") self.mcu = replicape.host_mcu self.value = replicape.stepper_dacs[channel] - self.pwm = pca9685_pwm(replicape, channel, pin_params) + self.pwm = pca9685_pwm(replicape, channel, pin_type, pin_params) def get_mcu(self): return self.mcu def setup_max_duration(self, max_duration): @@ -221,12 +221,12 @@ class Replicape: clock = self.host_mcu.print_time_to_clock(print_time) # XXX - the spi_send message should be scheduled self.spi_send_cmd.send([self.sr_oid, sr], minclock=clock, reqclock=clock) - def setup_pin(self, pin_params): + def setup_pin(self, pin_type, pin_params): pin = pin_params['pin'] if pin not in self.pins: raise pins.error("Unknown replicape pin %s" % (pin,)) pclass, channel = self.pins[pin] - return pclass(self, channel, pin_params) + return pclass(self, channel, pin_type, pin_params) def load_config(config): return Replicape(config) |