aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/extras/probe.py
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-07-26 09:44:45 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-07-26 09:44:45 -0400
commit273a98d39a88a372c8a2c816622e7df1f777e77d (patch)
tree2e8d4253f901a093d745127d97fd2464098d9266 /klippy/extras/probe.py
parent7a9553b38a39398226d95b7569a0b889b8cdb10a (diff)
downloadkutter-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/probe.py')
-rw-r--r--klippy/extras/probe.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py
index 47ea7d73..3c27e73b 100644
--- a/klippy/extras/probe.py
+++ b/klippy/extras/probe.py
@@ -26,10 +26,11 @@ class PrinterProbe:
self.z_position = pconfig.getfloat('minimum_z_position', 0.)
# Create an "endstop" object to handle the probe pin
ppins = self.printer.lookup_object('pins')
- pin_params = ppins.lookup_pin('endstop', config.get('pin'))
+ pin = config.get('pin')
+ pin_params = ppins.lookup_pin(pin, can_invert=True, can_pullup=True)
mcu = pin_params['chip']
mcu.add_config_object(self)
- self.mcu_probe = mcu.setup_pin(pin_params)
+ self.mcu_probe = mcu.setup_pin('endstop', pin_params)
if (config.get('activate_gcode', None) is not None or
config.get('deactivate_gcode', None) is not None):
self.mcu_probe = ProbeEndstopWrapper(config, self.mcu_probe)
@@ -46,9 +47,8 @@ class PrinterProbe:
kin = self.printer.lookup_object('toolhead').get_kinematics()
for stepper in kin.get_steppers('Z'):
stepper.add_to_endstop(self.mcu_probe)
- def setup_pin(self, pin_params):
- if (pin_params['pin'] != 'z_virtual_endstop'
- or pin_params['type'] != 'endstop'):
+ def setup_pin(self, pin_type, pin_params):
+ if pin_type != 'endstop' or pin_params['pin'] != 'z_virtual_endstop':
raise pins.error("Probe virtual endstop only useful as endstop pin")
if pin_params['invert'] or pin_params['pullup']:
raise pins.error("Can not pullup/invert probe virtual endstop")