Skip to content

Commit 01643d2

Browse files
author
Brian Hines
committed
Add cleanup method
1 parent eb488d2 commit 01643d2

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ v0.0.5, 2014-12-29 -- General clean up
44
v0.0.6, 2014-12-29 -- Trying to get this README.txt to display correctly
55
v0.0.7, 2014-12-29 -- Add on/off methods
66
v0.0.8, 2014-12-30 -- Refactor pin setup method and add test script
7+
v0.0.9, 2014-12-31 -- Add cleanup method and fix some documentation

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML), is used to
3030
* `initial` - This controls the starting value of the pin. Accepted values are: `LOW`, `HIGH`. (Optional - defaults to `LOW`)
3131
* `resistor` - This controls the software defined pull up/pull down resistor available in the Broadcom SOC. Accepted values are: `PUD_UP`, `PUD_DOWN`. (Optional - defaults to none)
3232
* `event` - This is used in combination with a pin set to input mode (`mode: IN`). Accepted values are: `RISING`, `FALLING`, `BOTH`.
33-
* `handler` - This is used in combination with an `event` to designate a function to call when an `event` happens. This value should correspond to a function defined in your handler class.
33+
* `handler` - This is used in combination with an `event` to designate a function to call when an `event` happens. This value should correspond to a method defined in your handler class.
3434
* `bounce` - This can be used when an `event` is defined to prevent multiple `handler` calls being fired accidentally. The value is the number of milliseconds to wait before detecting another `event`.
3535

3636
**Note:**
3737

3838
For full documentation about available GPIO input pin configurations see the [documentation](http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/).
3939

4040

41-
### Use It (No Events)
41+
### Use It (No Event)
4242

4343
```python
4444
from pi_pin_manager import PinManager
@@ -61,9 +61,15 @@ pins.off(19)
6161
6262
# Get configuration for a pin
6363
result = pins.get_config(23)
64+
65+
# Cleanup GPIO on single pin
66+
pins.cleanup(18)
67+
68+
# Cleanup GPIO on all pins
69+
pins.cleanup()
6470
```
6571

66-
### Use It (With Events)
72+
### Use It (With Event)
6773

6874
If an `event` and `handler` have been defined for a pin in the config file, then you must also provide a class that contains the callbacks to execute. Each method you add to this class should match the name of a `handler` value. Based on the example code below, `handler: do_something` is expected in the config file `path/to/config/file.yml`.
6975

pi_pin_manager/pins.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ def on(self, pin_number):
7373

7474
def off(self, pin_number):
7575
self.write(pin_number, 0)
76+
77+
def cleanup(self, pin_number=None):
78+
if pin_number:
79+
return self._gpio.cleanup(pin_number)
80+
return self._gpio.cleanup()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='Pi-Pin-Manager',
5-
version='0.0.8',
5+
version='0.0.9',
66
author='Brian Hines',
77
author_email='brian@projectweekend.net',
88
packages=['pi_pin_manager'],

0 commit comments

Comments
 (0)