Commit Graph

78 Commits

Author SHA1 Message Date
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
Tim Golden
3d468d764f Fix incorrect variable name 2015-10-24 11:38:01 +01: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
Dave Jones
f6294a5bf4 Fix #76
Makes `value` an alias of `is_active` in the base `GPIODevice`, and
`values` an infinite iterable of this value. Then adds `source` property
to `OutputDevice` allowing simple linkage of devices via iterators.
2015-10-19 11:01:09 +01:00
Ben Nuttall
3230f3ae18 Add PWMLED, close #58 2015-10-17 22:11:59 +01:00
Dave Jones
6583223299 Fix #74
Add more property aliases and do them properly (no more lambdas and
string lookups) which means we can remove `_alias`. This commit also
defines `__slots__` for all classes which should prevent assignation of
invalid attributes with an AttributeError (more friendly than silently
doing the wrong thing). Finally, it cleans up all the property defs to
use Ben's preferred decorator style.
2015-10-17 22:04:52 +01:00
Ben Nuttall
b7cce51497 Update docs for v0.8.0 2015-10-17 12:36:41 +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
7bf0561cb6 Remove relay class, re: #66 2015-10-14 12:17:49 +01:00
Dave Jones
924850ccde Fix #66
This PR adds the `active_high` parameter (defaulted to `True`) to the
`OutputDevice` class. This permits flipping the logic of an output
device in a similar manner to `pull_up` on `InputDevice`.

It also adds a `Relay` class derived from `DigitalOutputDevice` which
uses this parameter to flip the logic (as this is typically required
with relays).
2015-10-14 12:10:36 +01:00
Dave Jones
250ba454d9 Fix #68
Actually, this isn't so much a fix as a re-working of RGBLED. This
renames the `rgb` property to `color` because that's what the property
really represents (combined with `picamera.Color` this lets you do stuff
like `rgb_led.color = Color('red')`), and simplifies the internals of
the class. It also adds the common `close` method and context manager
capabilities.

Finally, it corrects an error I hadn't noticed earlier where
PWMOutputDevice isn't properly cleaning up PWM threads on close.
2015-10-14 12:05:44 +01:00
Dave Jones
53f3a3c69f Fix #64
Make MotionSensor more responsive by effectively removing the averaging
queue. Also add note on how to smooth out "jittery" PIR sensors by
increasing the queue length back up to 5.
2015-10-13 22:00:09 +01:00
Ryan Walmsley
f1771c1f05 Fixed TrafficHat numbering to match promo photos etc. 2015-10-13 13:52:39 +01:00
Dave Jones
bb6523a95b Fix #57
This refactors the GPIOOutputDevice to have an internal `_write` method
similar to the `_read` method used to grab the value of a GPIO device.
This is used for simple 1s and 0s until we get to PWMOutputDevice which
replaces the value with the PWM device's duty cycle level. As a result,
all the DigitalOutputDevice base methods (including blink) "just work".

This commit also, for the moment, removes min_pwm and max_pwm because
I'm not 100% certain how they should interact with the notion of
is_active at the moment. They'll probably get added back in at some
point but I need a bit more time to think about it!
2015-10-12 15:46:48 +01:00
Dave Jones
2d161f560f Fix #50
This isn't a full fix but I can't seem to reproduce the issue in #50 at
the moment. So for now this just ensures that exceptions in the
constructors get cleaned up properly (so they don't block future
construction attempts against the same pin)
2015-10-12 10:15:09 +01:00
Ben Nuttall
3ce4151bb7 Fix faulty PWMOutputDevice value setter 2015-10-12 00:24:46 +01:00
Ben Nuttall
ee36451bed Make Motors PWM devices with optional speed argument on methods 2015-10-07 17:09:28 +01:00
Ben Nuttall
493b4e1cda Change RGBLED interface from 0-100 to 0-255, close #40 2015-10-05 13:26:01 +01:00
Ben Nuttall
c26c279174 Change PWM interface from 0-100 to 0-1, close #45 2015-10-05 12:37:43 +01:00
Ben Nuttall
fd3f66b832 Ensure PWMOutputDevice pin argument not mandatory, close #43 2015-10-05 12:09:35 +01:00
Ben Nuttall
82319ba672 Cleanup 2015-10-05 12:08:55 +01:00
Dave Jones
7429c03117 Docs clean up part 1
Big push on getting the docs cleaned up before 1.0. Proper wrapping of
everything so it's decently viewable from the command line (or as
decently viewable as markdown can be - the tables will never look great
from the command line).

Only one code change in this PR: rename bouncetime to bounce_time
(everything else is PEP-8, so this probably should be too) and change
its units to seconds from milliseconds (again, all other durations in
the library are in seconds, so it feels inconsistent that this one
isn't; for the sake of those who won't read the docs - which is most
people - I figure consistency helps with guessing!).
2015-10-03 16:24:12 +01:00
Ben Nuttall
3a4d3d4deb Add documentation for Motor, Robot and RyanteckRobot 2015-10-02 18:08:59 +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
b2a36bba47 Resolve merge conflict 2015-09-28 11:38:09 +01:00
Ben Nuttall
3f960f6da3 Update docstrings and add initial set of documentation 2015-09-28 11:11:00 +01:00
Dave Jones
c35dd1698b Fix #27 2015-09-27 17:29:21 +01:00
Dave Jones
980e4e7144 Fix #32 2015-09-24 16:45:55 +01:00
Ben Nuttall
7811ed67c9 Ensure args are passed to flash() 2015-09-24 12:23:09 +01:00
Ben Nuttall
cfed671972 Add docstrings, close #26 2015-09-24 11:39:50 +01:00
Ben Nuttall
c619aab630 Expose LEDBoard 2015-09-23 17:47:49 +01:00
Ben Nuttall
d47aff9f69 Make TrafficLights extend LEDBoard 2015-09-23 17:30:17 +01:00
Ben Nuttall
12800db25f Refactor PiLiter into generic LEDBoard class 2015-09-23 16:32:00 +01:00
Ben Nuttall
b97e97909c Add flash method to output devices and boards, close #22 2015-09-23 15:31:06 +01:00
Ben Nuttall
931571b85d Add toggle to boards 2015-09-23 14:44:41 +01:00
Ben Nuttall
3a19d8f5ab Merge branch 'master' of github.com:rpi-distro/python-gpiozero 2015-09-23 14:18:44 +01:00
Ben Nuttall
5e0a56b11c Make buzzer blink, close #19 2015-09-23 14:18:40 +01:00
Dave Jones
6b7a3c8851 Fix #25
Add a nice __repr__ to the GPIODevice base class.

This isn't much but generally I think `__repr__` implementations should
be deliberately simple: firstly, they're frequently used for debugging
so if they're at all complex you risk making a debugging tool buggy
(very annoying!). Secondly, if you pour too much info into them you risk
making the debugging output cluttered, so I tend to prefer keeping it to
straight-forward simple to retrieve/calculate info without excessive
detail (if the user wants more, they can always query it directly).

There is one refinement here: in SmoothedInputDevice, `__repr__` is
tweaked to ensure that when partial is False (the default), and the
queue isn't filled, `__repr__` doesn't block (because it should *never*
block).
2015-09-23 14:07:17 +01:00
Dave Jones
4e33052703 Fix #28
Re-order the test bindings to prefer using no parameters if possible
2015-09-23 13:47:32 +01:00
Dave Jones
7c647ec616 Fix #23
Add OutputDevice.toggle method with locking for correct threaded
operation
2015-09-23 13:38:37 +01:00
Ben Nuttall
e805eedd13 Add properties for leds and all on boards 2015-09-23 11:42:06 +01:00
Ben Nuttall
4a7d60f6a3 Release v0.4.0 2015-09-23 11:20:43 +01:00
Ben Nuttall
bb33b9aff3 Fix PiTraffic and TrafficHat 2015-09-23 11:16:42 +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
5c12d8c2e0 Flexible events
Permit event callbacks to accept no parameters, or a single parameter
providing the source input object
2015-09-22 23:20:29 +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