Python API for Numato GPIO Expanders
Project description
Python API for Numato GPIO Expanders
This Python API can be used to control Numato 32 Port USB GPIO expanders.
- Configure ports as input or output port
- Write to output ports
- Read from input ports
- Read integer values from ADC input ports (1 - 7)
- Register a callback for input port events (edge detection)
Usage
Install latest development version:
pip install --user git+https://github.com/clssn/numato-gpio.git
Install latest release:
pip install --user numato-gpio
Once installed, the API can be used like:
import numato_gpio as gpio
my_device_id = 0
gpio.discover()
dev = gpio.devices[my_device_id]
# configure port 4 as output and set it to high
dev.setup(4, gpio.OUT)
dev.write(4, 1)
# configure port 27 as input and print its logic level
dev.setup(27, gpio.IN)
print(dev.read(27))
# configure port 2 as input and print its ADC value
dev.setup(2, gpio.IN)
print(dev.adc_read(2))
# configure port 14 as input and setup notification on logic level changes
dev.setup(14, gpio.IN)
def callback(port, level):
print("{edge:7s} edge detected on port {port} "
"-> new logic level is {level}".format(
edge="Rising" if level else "Falling",
port=port,
level="high" if level else "low")
)
dev.add_event_detect(14, callback, gpio.BOTH)
dev.notify(True)
Known Issues
Though the code works well in a Home Assistant integration since 2018, there are quite some aspects to improve. The following issues are only the ones the author is aware of:
- No unit tests
- Some docstrings are hard to understand
- Device discovery/registry as module-global dict is sub-optimal
- Only
/dev/ACMxdevices are scanned which were mapped on the author's Linux
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numato-gpio-0.2.0.tar.gz.
File metadata
- Download URL: numato-gpio-0.2.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99752d07a03a69c4f67160f216c7433f8158abd5d6176da6cf5195e500e6d732
|
|
| MD5 |
46b637a70a1c5b9c05d8e1684dfc81df
|
|
| BLAKE2b-256 |
3910f38908558ff668c7497ed16bc7b4dabed6678c37d90e82b1117397883af7
|
File details
Details for the file numato_gpio-0.2.0-py3-none-any.whl.
File metadata
- Download URL: numato_gpio-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
270ee7037b86ca1fd04b8b388f94839d88adf6a17f08a81d99dae64d1a231e09
|
|
| MD5 |
8f5f8daef176ceed9773d073259f3672
|
|
| BLAKE2b-256 |
2710671feeea81ba393c948e3179a95407233ef538e56923b5cc83eac83c60f2
|