Commit Graph

55 Commits

Author SHA1 Message Date
Dave Jones
1f2140a9f5 Work on #87
Implement a test suite, including Travis-CI integration
2016-02-11 21:11:22 +00:00
Dave Jones
b4a8273472 Bump version and update changelog for 1.1
Includes some last minute changes too
2016-02-08 23:37:13 +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
006c10cce0 Miscellaneous minor changes for 1.1 2016-02-08 12:01:42 +00:00
Dave Jones
9871ac3dca Fix #135 2016-02-08 00:33:05 +00:00
Dave Jones
19c19f6ff5 Merge pull request #173 from waveform80/blink-device-not-led
Fix #167
2016-02-07 22:52:49 +00:00
Dave Jones
f0ea1627f7 Fix #167 2016-02-07 22:51:41 +00:00
Andrew Scheller
29ca48d2a7 Minor tweak to PWMOutputDevice.is_active
...so that its implementation is more consistent with the other is_active methods
2016-02-03 03:34:12 +00:00
Dave Jones
e52ad37200 Fix prototypes in docs
The prototypes in the docs are rigged to make out the first parameter as
mandatory (as it effectively is); however this does mean you've got to
remember to update the prototype when you modify it in the code! :)
2016-01-31 20:07:34 +00:00
Dave Jones
8b21599257 Fix #118
... and fix up active_high values while we're at it ...
2016-01-31 17:50:02 +00:00
Dave Jones
d5226d1fee Minor changes 2016-01-31 16:25:35 +00:00
Dave Jones
de5dff3c1d Fix #143
Add active_high parameter to PWMOutputDevice (there's no reason PWM
devices can't be wired active low after all)
2016-01-31 16:17:43 +00:00
Dave Jones
cf18fb971e Fix #121
Change parent of PWMOutputDevice to OutputDevice and implement blink to
maintain compatibility. The version of blink implemented here is
slightly extended to include functionality like Explorer HAT's "pulse".
The parameter defaults behave identically to OutputDevice's blink but
can be adjusted to have the device smoothly fade in and out.
2016-01-31 13:47:11 +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
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
ef9e5802dc Merge pull request #108 from waveform80/motor-pins
Fix #107
2015-11-15 18:22:01 +00:00
Dave Jones
c929b9a53b Fix #107
Add forward_device and backward_device to Motor, left_motor and
right_motor to Robot, and ensure all CompositeDevice descendents have a
proper close() method and closed property. Also, add a few more
_check_open calls around the place to make sure GPIODeviceClosed is
properly raised in response to read and writing values.
2015-11-15 18:19:15 +00:00
Ben Nuttall
4975e9c8fb Update docs: add PWMLED and include value, values and source properties 2015-11-15 17:18:10 +00:00
Ben Nuttall
492f311cc4 Remove incomplete TemperatureSensor for 1.0 release, close #93 2015-11-15 13:00:06 +00:00
Dave Jones
f69b6195ca Fix #75
Alias blink to beep for Buzzer
2015-11-15 11:48:53 +00:00
Dave Jones
2a1ed11535 Fix #91
Override toggle() in PWMOutputDevice, and add reverse() to Motor and
Robot
2015-10-26 21:23:03 +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
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
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
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
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
b97e97909c Add flash method to output devices and boards, close #22 2015-09-23 15:31:06 +01:00
Ben Nuttall
5e0a56b11c Make buzzer blink, close #19 2015-09-23 14:18:40 +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