Skip to content

Commit

Permalink
Add cleanup method
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hines committed Dec 31, 2014
1 parent eb488d2 commit 01643d2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ v0.0.5, 2014-12-29 -- General clean up
v0.0.6, 2014-12-29 -- Trying to get this README.txt to display correctly
v0.0.7, 2014-12-29 -- Add on/off methods
v0.0.8, 2014-12-30 -- Refactor pin setup method and add test script
v0.0.9, 2014-12-31 -- Add cleanup method and fix some documentation
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML), is used to
* `initial` - This controls the starting value of the pin. Accepted values are: `LOW`, `HIGH`. (Optional - defaults to `LOW`)
* `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)
* `event` - This is used in combination with a pin set to input mode (`mode: IN`). Accepted values are: `RISING`, `FALLING`, `BOTH`.
* `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.
* `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.
* `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`.

**Note:**

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


### Use It (No Events)
### Use It (No Event)

```python
from pi_pin_manager import PinManager
Expand All @@ -61,9 +61,15 @@ pins.off(19)
# Get configuration for a pin
result = pins.get_config(23)
# Cleanup GPIO on single pin
pins.cleanup(18)
# Cleanup GPIO on all pins
pins.cleanup()
```

### Use It (With Events)
### Use It (With Event)

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`.

Expand Down
5 changes: 5 additions & 0 deletions pi_pin_manager/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ def on(self, pin_number):

def off(self, pin_number):
self.write(pin_number, 0)

def cleanup(self, pin_number=None):
if pin_number:
return self._gpio.cleanup(pin_number)
return self._gpio.cleanup()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='Pi-Pin-Manager',
version='0.0.8',
version='0.0.9',
author='Brian Hines',
author_email='[email protected]',
packages=['pi_pin_manager'],
Expand Down

0 comments on commit 01643d2

Please sign in to comment.