359 Commits

Author SHA1 Message Date
Dave Jones
e9a970ae5c Experiment with LightSensor
Remove wait_for_input, add_callback and remove_callback from the base
InputDevice class and add specific things for LightSensor:
wait_for_light and wait_for_dark to wait on those events occurring, and
when_light and when_dark which can be set to callbacks to call on those
events occurring.
2015-09-21 11:57:50 +01:00
Ben Nuttall
a07f89c561 Release v0.2.0 2015-09-21 11:20:21 +01:00
Ben Nuttall
6c98086bff Remove callback before adding a new one 2015-09-21 11:19:21 +01:00
Dave Jones
0d7c7e28fc Lots of fixes
* Move `is_active` to `GPIODevice`; it's equally applicable to inputs
  and outputs so there's no point having it just in inputs
* Flip the pull-up status for `MotionSensor` (it was backwards leading
  to reversed readings from the sensor)
* Add a `threshold` to `MotionSensor` (optional), and `value` (similar
  to `LightSensor`)
* Also expose `pull_up` as a simple bool property
* Rejig `LightSensor` so it also derives from `InputDevice` (it inherits
  enough to make it worthwhile) and so that its API is similar to
  `MotionSensor` (a `value` property with a `*_detected` property, and a
  background threaded queue which constantly monitors values)
2015-09-20 19:41:19 +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
Dave Jones
1219d99ded Fix #8
Make the pin property a read-only property
2015-09-17 10:50:23 +01:00
Ben Nuttall
df1eb2dffd Merge branch 'motion-queue' of git://github.com/waveform80/gpio-zero into waveform80-motion-queue 2015-09-15 17:57:43 +01:00
Ben Nuttall
abdc215175 Rename to gpiozero and tidy up 2015-09-15 17:53:08 +01:00