diff --git a/docs/api_pins.rst b/docs/api_pins.rst index 340d8b9..e79e020 100644 --- a/docs/api_pins.rst +++ b/docs/api_pins.rst @@ -127,10 +127,10 @@ Like the ``GPIOZERO_PIN_FACTORY`` value, these can be exported from your .. warning:: The astute and mischievous reader may note that it is possible to mix - strictly local pin implementations, e.g. using ``RPiGPIOPin`` for one pin, - and ``NativePin`` for another. This is unsupported, and if it results in - your script crashing, your components failing, or your Raspberry Pi turning - into an actual raspberry pie, you have only yourself to blame. + factories, e.g. using ``RPiGPIOFactory`` for one pin, and ``NativeFactory`` + for another. This is unsupported, and if it results in your script + crashing, your components failing, or your Raspberry Pi turning into an + actual raspberry pie, you have only yourself to blame. Sensible uses of multiple pin factories are given in :doc:`remote_gpio`. diff --git a/gpiozero/pins/native.py b/gpiozero/pins/native.py index b7de08a..cdfd84d 100644 --- a/gpiozero/pins/native.py +++ b/gpiozero/pins/native.py @@ -161,10 +161,11 @@ class NativeFactory(LocalPiFactory): You can construct native pin instances manually like so:: - from gpiozero.pins.native import NativePin + from gpiozero.pins.native import NativeFactory from gpiozero import LED - led = LED(NativePin(12)) + factory = NativeFactory() + led = LED(12, pin_factory=factory) """ def __init__(self): super(NativeFactory, self).__init__() diff --git a/gpiozero/pins/pigpio.py b/gpiozero/pins/pigpio.py index af82597..b1f9f18 100644 --- a/gpiozero/pins/pigpio.py +++ b/gpiozero/pins/pigpio.py @@ -46,20 +46,21 @@ class PiGPIOFactory(PiFactory): You can construct pigpio pins manually like so:: - from gpiozero.pins.pigpio import PiGPIOPin + from gpiozero.pins.pigpio import PiGPIOFactory from gpiozero import LED - led = LED(PiGPIOPin(12)) + factory = PiGPIOFactory() + led = LED(12, pin_factory=factory) This is particularly useful for controlling pins on a remote machine. To accomplish this simply specify the host (and optionally port) when constructing the pin:: - from gpiozero.pins.pigpio import PiGPIOPin + from gpiozero.pins.pigpio import PiGPIOFactory from gpiozero import LED - from signal import pause - led = LED(PiGPIOPin(12, host='192.168.0.2')) + factory = PiGPIOFactory(host='192.168.0.2') + led = LED(12, pin_factory=factory) .. note:: diff --git a/gpiozero/pins/rpigpio.py b/gpiozero/pins/rpigpio.py index 4c43712..332c1c2 100644 --- a/gpiozero/pins/rpigpio.py +++ b/gpiozero/pins/rpigpio.py @@ -40,7 +40,8 @@ class RPiGPIOFactory(LocalPiFactory): from gpiozero.pins.rpigpio import RPiGPIOFactory from gpiozero import LED - led = LED(RPiGPIOPin(12)) + factory = RPiGPIOFactory() + led = LED(12, pin_factory=factory) .. _RPi.GPIO: https://pypi.python.org/pypi/RPi.GPIO """ diff --git a/gpiozero/pins/rpio.py b/gpiozero/pins/rpio.py index 5a51e41..553916b 100644 --- a/gpiozero/pins/rpio.py +++ b/gpiozero/pins/rpio.py @@ -40,10 +40,11 @@ class RPIOFactory(LocalPiFactory): You can construct RPIO pins manually like so:: - from gpiozero.pins.rpio import RPIOPin + from gpiozero.pins.rpio import RPIOFactory from gpiozero import LED - led = LED(RPIOPin(12)) + factory = RPIOFactory() + led = LED(12, pin_factory=factory) .. _RPIO: https://pythonhosted.org/RPIO/ """