This commit is a fairly major piece of work that abstracts all pin
operations (function, state, edge detection, PWM, etc.) into a base
"Pin" class which is then used by input/output/composite devices to
perform all required configuration.
The idea is to pave the way for I2C based IO extenders which can present
additional GPIO ports with similar capabilities to the Pi's "native"
GPIO ports. As a bonus it also abstracts away the reliance on the
RPi.GPIO library to allow alternative pin implementations (e.g. using
RPIO to take advantage of DMA based PWM), or even pure Python
implementations.
The code is running on my Pi and seems to be stable
Have added MCP3301/3302/3304
have implemented the "M" bit to allow Differential mode
Have added an "absVal" for absolute values
Have added a "relVal" for relative val from 0 to 1 (same as "value")
left "value" for backwards compatabilety, but propse to delete it
shifted Rx bits for MCP330x
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
modified: gpiozero/__init__.py
modified: gpiozero/input_devices.py
Untracked files:
ZeroCombo11.py
Date: Mon Jan 18 20:25:36 2016 -0500
This removes the circular dependency introduced in PR#137. This also
fixes up an issue in the base meta-class which meant it wasn't working
in Python 3 (only Python 2), and adds a bit to the meta-class to allow
docstrings to be inherited (taken from the rest-docs branch).
This finishes off implementing values and source for all (current)
classes in gpiozero. I'm afraid things get rather complex in this
commit. For starters, we've now got quite a few "aggregate" classes
which necessarily don't descend from GPIODevice. To implement values and
source on these I could either repeat a helluva lot of code or ... turn
to mixin classes. Yeah, it's multiple inheritance time, baby!
Unfortunately multiple inheritance doesn't work with __slots__ but we
really ought to keep functionality that they provide us (raise
AttributeError when an unknown attribute is set). So I've implemented
this with ... erm ... metaclasses. Sorry!
Permit devices to be explicitly closed and used as context managers.
Also deal with cleanup properly at script end and ensure objects don't
step on the global cleanup function.
The motion sensor queue doesn't shut down properly at script end at the
moment and prevents the interpreter shutting down. This is because it's
a non-daemon thread so `__del__` never gets run and so on.
This is a bit of a major PR - I can split it up if you want. Firstly it
makes a common base class called `GPIODevice` for both `InputDevice` and
`OutputDevice`. This just takes care of the read-only pin stuff. Next it
makes a `GPIOThread` class that ensures its a daemon thread, and which
also ensures proper cleanup on shutdown.
Finally, it fixes `MotionSensor` to use the new `GPIOThread` class
(tested this time! Works nicely) and adds the `blink` method to the
`LED` class (which also works nicely this time).
Small patch to ensure GPIO.cleanup is always called on interpreter
shutdown. This just means the library will "play nice" with whatever
comes afterward.