Skip to content

Commit 4956807

Browse files
author
Brian Hines
committed
Some documentation
1 parent d24d453 commit 4956807

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,55 @@ watcher.start()
9393
```
9494

9595

96+
### Multiple Pin Watcher
97+
98+
The `MultiplePinWatcher` can simultaneously watch multiple pins, and fire off custom actions when events are detected. It takes two parameters:
99+
* A config file or dictionary as outlined above.
100+
* An event handler class. The class contstructor must take one parameter. An instance of the GPIO module will be passed into the constructor when it is called. This class must also have method names that match the `handler` names used in the config file. The methods you define for this must accept a single parameter. The number of the pin will be passed in automatically into the method when it is called.
101+
102+
**Example Config File:**
103+
```yaml
104+
18:
105+
mode: IN
106+
initial: HIGH
107+
resistor: PUD_UP
108+
event: FALLING
109+
bounce: 200
110+
handler: do_something
111+
112+
23:
113+
mode: IN
114+
initial: HIGH
115+
resistor: PUD_UP
116+
event: BOTH
117+
bounce: 200
118+
handler: do_something_else
119+
```
120+
121+
122+
```python
123+
from pi_pin_manager import MultiplePinWatcher
124+
125+
126+
class MyHandler(object):
127+
128+
def __init__(self, gpio):
129+
self._gpio = gpio
130+
131+
def do_something(self, pin):
132+
# Whatever you want to happen when an event is detected goes here
133+
print("PIN {0}!!!".format(pin))
134+
135+
def do_something_else(self, pin):
136+
# Whatever you want to happen when an event is detected goes here
137+
print("PIN {0}!!!".format(pin))
138+
139+
watcher = MultiplePinWatcher(config='path/to/config/file.yml', event_handler=MyHandler)
140+
141+
watcher.start()
142+
```
143+
144+
96145
### Pin Manager (no event)
97146

98147
```python

0 commit comments

Comments
 (0)