Skip to content

Commit e1a418e

Browse files
author
Brian Hines
committed
Document config with dictionary example
1 parent df6f9a9 commit e1a418e

1 file changed

Lines changed: 27 additions & 3 deletions

File tree

README.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ pip install Pi-Pin-Manager
99

1010
### Configure It
1111

12-
A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML), is used to define the initial pin setup. If a pin is not defined here it will not be available to the `PinManager`. The following snippet shows an example configuration file:
12+
When creating an instance of `pi_pin_manager.PinManager`, there are two ways you can supply pin configuration information: A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML) or a dictionary. If a pin is not defined at this step it will not be available to the `PinManager`.
13+
14+
#### Configure with file
15+
16+
The following snippet shows an example configuration file:
1317

1418
```yaml
1519
18:
@@ -25,6 +29,28 @@ A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML), is used to
2529
bounce: 200
2630
```
2731
32+
#### Configure with dictionary
33+
34+
This snippet shows the same configuration example above as a dictionary:
35+
36+
```python
37+
config = {
38+
18:
39+
'mode': 'OUT'
40+
initial: 'HIGH'
41+
23:
42+
'mode': 'OUT'
43+
initial: 'LOW'
44+
24:
45+
'mode': 'IN'
46+
'event': 'RISING'
47+
'handler': 'do_something'
48+
'bounce': 200
49+
}
50+
```
51+
52+
#### Notes
53+
2854
* Add a numbered element for each pin to enable
2955
* `mode` - This controls whether the pin will be used for input or output. Accepted values are: `IN`, `OUT`. (Required)
3056
* `initial` - This controls the starting value of the pin. Accepted values are: `LOW`, `HIGH`. (Optional - defaults to `LOW`)
@@ -33,8 +59,6 @@ A config file, written in [YAML](http://en.wikipedia.org/wiki/YAML), is used to
3359
* `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.
3460
* `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`.
3561

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

4064

0 commit comments

Comments
 (0)