Merge pull request #192 from waveform80/pigpiod

Fix #180 - Add support for pigpio
This commit is contained in:
Dave Jones
2016-02-12 20:15:25 +00:00
7 changed files with 312 additions and 13 deletions

View File

@@ -20,10 +20,12 @@ integer number instead, it uses one of the following classes to provide the
2. :class:`gpiozero.pins.rpio.RPIOPin`
3. :class:`gpiozero.pins.native.NativePin`
3. :class:`gpiozero.pins.pigpiod.PiGPIOPin`
4. :class:`gpiozero.pins.native.NativePin`
You can change the default pin implementation by over-writing the
``DefaultPin`` global in devices like so::
``DefaultPin`` global in the ``devices`` module like so::
from gpiozero.pins.native import NativePin
import gpiozero.devices
@@ -35,8 +37,24 @@ You can change the default pin implementation by over-writing the
# This will now use NativePin instead of RPiGPIOPin
led = LED(16)
In future, this separation should allow the library to utilize pins that are
part of IO extender chips. For example::
Alternatively, instead of passing an integer to the device constructor, you
can pass a :class:`Pin` object itself::
from gpiozero.pins.native import NativePin
from gpiozero import LED
led = LED(NativePin(16))
This is particularly useful with implementations that can take extra parameters
such as :class:`PiGPIOPin` which can address pins on remote machines::
from gpiozero.pins.pigpiod import PiGPIOPin
from gpiozero import LED
led = LED(PiGPIOPin(16, host='my_other_pi'))
In future, this separation of pins and devices should also permit the library
to utilize pins that are part of IO extender chips. For example::
from gpiozero import IOExtender, LED
@@ -52,13 +70,6 @@ part of IO extender chips. For example::
comments from testers!
Abstract Pin
============
.. autoclass:: Pin
:members:
RPiGPIOPin
==========
@@ -75,6 +86,14 @@ RPIOPin
.. autoclass:: RPIOPin
PiGPIOPin
=========
.. currentmodule:: gpiozero.pins.pigpiod
.. autoclass:: PiGPIOPin
NativePin
=========
@@ -82,3 +101,10 @@ NativePin
.. autoclass:: NativePin
Abstract Pin
============
.. autoclass:: Pin
:members:

View File

@@ -39,6 +39,7 @@ sys.modules['RPi'] = Mock()
sys.modules['RPi.GPIO'] = sys.modules['RPi'].GPIO
sys.modules['RPIO'] = Mock()
sys.modules['RPIO.PWM'] = sys.modules['RPIO'].PWM
sys.modules['pigpio'] = Mock()
sys.modules['w1thermsensor'] = Mock()
sys.modules['spidev'] = Mock()