You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,55 @@ watcher.start()
93
93
```
94
94
95
95
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
0 commit comments