Skip to main content

Manage RPi.GPIO pin definition and initialization with a config file.

Project description

This utility exposes a class that wraps the [RPi.GPIO]() library so you can define and initialize GPIO pins using a cofiguration file.


### Example Configuration File

A config file `config/pins.yml` is used to define the initial setup for pins that will be accessible to the API. If a pin is not defined here it will not be available to the pin manager. For full documentation about available GPIO input pin configurations see the [documentation](http://sourceforge.net/p/raspberry-gpio-python/wiki/Examples/).

```yaml
18:
mode: OUT
initial: HIGH
23:
mode: OUT
initial: LOW
resistor: PUD_DOWN
24:
mode: IN
event: RISING
bounce: 200
```

* Add a numbered element for each pin to enabled
* `mode` - This controls whether the pin will be used for input or output. Accepted values are: `IN`, `OUT`. (Required)
* `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` - Work in progress... This is used in combination with a pin set to input mode (`mode: IN`). Accepted values are: `RISING`, `FALLING`, `BOTH`.
* `handler` - Work in progress... This is used in combination with an `event` to designate a function to call when the `event` happens. This value should correspond to a function defined in the `handler_file`.
* `bounce` - Work in progress... 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`.


### Example Usage

```python
from pins import PinManager


manager = PinManager(
config_file='path/to/config/file.yml',
handler_file='path/to/event/handlers.py')


# Read a pin
result = manager.read(18)

# Write to a pin
result = manager.write(19, 1)

# Get configuration for a pin
result = manager.get_config(23)
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Pi-Pin-Manager-0.0.2.tar.gz (2.5 kB view details)

Uploaded Source

File details

Details for the file Pi-Pin-Manager-0.0.2.tar.gz.

File metadata

File hashes

Hashes for Pi-Pin-Manager-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2a29f09c7ba6cb116b63d790e7b32706b70f58747d68e0d368daa1b88da5ce45
MD5 c510e5e8f57766bfc5f30a3fa9d0deae
BLAKE2b-256 91c818c9a495f27e7008528d3d320a2f8235c165cd8948c9dac6b59c7a915c04

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page