Allow the creation of remote pins easily with PiGPIOPin. Also changes
DefaultPin to a pin_factory callable which accepts the input pin number.
This commit is contained in:
Dave Jones
2016-04-16 00:21:51 +01:00
parent 8426c68040
commit 79a0fd2a27
5 changed files with 75 additions and 67 deletions

View File

@@ -36,18 +36,18 @@ from .exc import (
from .pins import _pins_shutdown
try:
from .pins.rpigpio import RPiGPIOPin
DefaultPin = RPiGPIOPin
pin_factory = RPiGPIOPin
except ImportError:
try:
from .pins.rpio import RPIOPin
DefaultPin = RPIOPin
pin_factory = RPIOPin
except ImportError:
try:
from .pins.pigipod import PiGPIOPin
DefaultPin = PiGPIOPin
pin_factory = PiGPIOPin
except ImportError:
from .pins.native import NativePin
DefaultPin = NativePin
pin_factory = NativePin
_PINS = set()
@@ -365,7 +365,7 @@ class GPIODevice(Device):
if pin is None:
raise GPIOPinMissing('No pin given')
if isinstance(pin, int):
pin = DefaultPin(pin)
pin = pin_factory(pin)
with _PINS_LOCK:
if pin in _PINS:
raise GPIOPinInUse(