Commit Graph

39 Commits

Author SHA1 Message Date
Dave Jones
3acf8a0d3a More work on the tests... 2016-04-05 13:22:40 +01:00
Dave Jones
6c39e7716f Merge pull request #246 from waveform80/pin-database
Add pins database
2016-04-05 00:51:27 +01:00
Dave Jones
50946b417c Add pins database
Related to @lurch's comments on #148, this PR contains a database of
pins for each Pi revision, along with various other bits of miscellany
(I might've gotten a bit carried away here...).

Any corrections/extensions welcome!
2016-04-05 00:44:19 +01:00
Dave Jones
69dd8a439a The source/values toolkit
Me and my big mouth. No sooner do I declare the base classes "relatively
stable" than I go and mess around with it all again. Anyway, this is the
long promised set of utilities to make source/values more interesting.
It includes a few interesting little utility functions, a whole bunch of
examples and introduces the notion of "pseudo" devices with no (obvious)
hardware representation like a time-of-day device.

This necessitated making the event system a little more generic (it's
not exclusive the GPIO devices after all; no reason we can't use it on
composite devices in future) and by this point the mixins have gotten
large enough to justify their own module.

The pseudo-devices are a bit spartan and basic at the moment but I'm
sure there'll be plenty of future ideas...
2016-04-04 23:59:05 +01:00
Dave Jones
7826e60c3d Fix #193
Changed pin.function so that it's always read-write, which in turn
permits InputDevice to force pin.function to "input" rather than
checking that it's not "input" first. This ensures internal state in
RPi.GPIO and RPIO reflects the reality of each pin's function (see
discussion under the ticket for more detail).
2016-04-03 15:45:28 +01:00
Dave Jones
d6af02933a Fix #130, fix #131, fix #189
This PR implements SnowPi, adds the ability for LEDBoard's to own other
LEDBoards as well as LEDs, and enhances blink so that manually
controlling a LED automatically stops it from blinking (no matter
whether it's blinking itself or a LEDBoard is blinking it).

It also fixes up RGBLED and Motor which I managed to break with the last
PR ...
2016-04-01 17:32:46 +01:00
Dave Jones
759a6a58e6 Fix #140, fix #69, fix #185
This PR adds a software SPI implementation. Firstly this removes the
absolute necessity for spidev (#140), which also means when it's not
present things still work (effectively fixes #185), and also enables any
four pins to be used for SPI devices (which don't require the hardware
implementation).

The software implementation is simplistic but still supports clock
polarity and phase, select-high, and variable bits per word. However it
doesn't allow precise speeds to be implemented because it just wibbles
the clock as fast as it can (which being pure Python isn't actually that
fast).

Finally, because this PR involves creating a framework for "shared"
devices (like SPI devices with multiple channels), it made sense to bung
Energenie (#69) in as wells as this is a really simple shared device.
2016-04-01 12:57:17 +01:00
Ben Nuttall
72afe2250a Expose all MCP* classes added in #162 2016-02-14 13:23:29 +00:00
Dave Jones
83fb6ae8b4 Fix #114 - ultrasonic sensors
Implements support for the HC-SR04 ultrasonic sensor as an input device
class named DistanceSensor
2016-02-12 19:27:24 +00:00
Dave Jones
1f2140a9f5 Work on #87
Implement a test suite, including Travis-CI integration
2016-02-11 21:11:22 +00:00
Dave Jones
8e0c6e243b Refactor low level implementation
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.
2016-02-08 14:54:18 +00:00
Dave Jones
55e99f379a Merge-clean update of PR #126
This is an updated cherry-pick of Martin O'Hanlon's LEDBarGraph class.
2016-02-08 12:54:55 +00:00
Dave Jones
0bc62aee73 Generic docs need reST
Conversion of all docs to reST so that the generic docs can link easily
with the rest of the docs.
2016-01-30 23:40:12 +00:00
pcopa
38bc27b546 Have made a simpler structure for MCP3008/3004 and MCP3208/3204.
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
2016-01-29 22:03:13 -05:00
Dave Jones
59ba7154c5 Move exceptions to their own sub-module
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).
2016-01-07 11:01:49 +00:00
Ben Nuttall
f1d4ca0c05 Add LineSensor 2015-11-23 08:36:14 +00:00
Ben Nuttall
cfe200af35 Add CamJamKitRobot interface 2015-11-22 18:35:11 +00:00
Ben Nuttall
492f311cc4 Remove incomplete TemperatureSensor for 1.0 release, close #93 2015-11-15 13:00:06 +00:00
Dave Jones
b87e2a4d53 Fix #81
Fix up the FishDish hierarchy so that all LEDS can be addressed as
`lights` directly.
2015-10-25 10:45:34 +00:00
Dave Jones
fa0a1b3cdd Fix #76, fix #79
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!
2015-10-22 21:44:42 +01:00
Ben Nuttall
3230f3ae18 Add PWMLED, close #58 2015-10-17 22:11:59 +01:00
Dave Jones
a347a2ca4e Fix #41
Add `AnalogInputDevice` base class and extend `MCP3008` (and `MCP3004`)
classes from it.
2015-10-15 10:18:28 +01:00
Ben Nuttall
dc34cf3ccf Implement Motor, Robot and RyanteckRobot 2015-10-02 15:27:55 +01:00
Ben Nuttall
fbede611df Add MCP3008 and potentiometer example 2015-09-30 19:02:12 +01:00
Dave Jones
034b88b478 Add close method and context manager
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.
2015-09-29 19:10:01 +01:00
Ben Nuttall
8fc8e3444e Add RGBLED using new PWMOutputDevice 2015-09-28 19:34:55 +01:00
Ben Nuttall
c619aab630 Expose LEDBoard 2015-09-23 17:47:49 +01:00
Ben Nuttall
4a7d60f6a3 Release v0.4.0 2015-09-23 11:20:43 +01:00
Ben Nuttall
2d999f82ab Merge branch 'master' of github.com:rpi-distro/python-gpiozero 2015-09-23 11:15:17 +01:00
Dave Jones
b81d9ed875 Fix missing comma in __init__ 2015-09-22 22:08:06 +01:00
Ben Nuttall
8fe2a9d8ca Add missing comma 2015-09-22 18:23:56 +01:00
Ben Nuttall
65d363b7ed Tidy up 2015-09-22 17:52:19 +01:00
Ben Nuttall
1bc5a5fa92 Release v0.3.0 2015-09-22 16:34:25 +01:00
Philip Howard
9019452973 Update __init__.py
Added rogue missing comma!
2015-09-21 17:00:09 +01:00
Ben Nuttall
5669a98b42 Expose add-on board classes to the module 2015-09-21 15:29:54 +01:00
Ben Nuttall
a07f89c561 Release v0.2.0 2015-09-21 11:20:21 +01:00
Dave Jones
e2ddad6fea Shut down GPIO threads nicely
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).
2015-09-18 12:45:30 +01:00
Dave Jones
481193497a Ensure GPIO.cleanup is called
Small patch to ensure GPIO.cleanup is always called on interpreter
shutdown. This just means the library will "play nice" with whatever
comes afterward.
2015-09-17 18:51:56 +01:00
Ben Nuttall
abdc215175 Rename to gpiozero and tidy up 2015-09-15 17:53:08 +01:00