FreeBSD gpio device ioctl wrapper
Project description
FreeBSD GPIO ioctl wrapper for Python
This is a simple wrapper around the FreeBSD ioctl
calles for the
GPIO device. It allows very simple access to configuration and I/O facilities
of the GPIO pins.
Installation
pip install pyfbsdgpio-tspspi
Basic usage
For now this section only summarizes the most basic usage of the module (it also supports setting pullup and pulldown resistors and selecting different drive characteristics if the GPIO chipset supports it).
Determining pin count of the GPIO module
One can determine the number of I/O pins available on the GPIO device:
from labdevices.gpio import GpioDirection, GpioDrive, GpioPull
from fbsdgpio import FbsdGPIO
gpio = FbsdGPIO()
print(f"We have {gpio.getIOCount()} I/O ports")
Fetching the current configuration of an I/O port
from labdevices.gpio import GpioDirection, GpioDrive, GpioPull
from fbsdgpio import FbsdGPIO
gpio = FbsdGPIO()
print(f"Current configuration of pin 13: {gpio.getConfig(13)}")
Setting pin as input or output
from labdevices.gpio import GpioDirection, GpioDrive, GpioPull
from fbsdgpio import FbsdGPIO
with FbsdGPIO() as gpio:
gpio.setConfig(13, direction=GpioDirection.Input)
with FbsdGPIO() as gpio:
gpio.setConfig(13, direction=GpioDirection.Output)
Pulse output
# Pulse for 100 microseconds
with FbsdGPIO() as gpio:
gpio.pulse(13, 100)
Also specifying the pulsed (not current) state so the module does not have to query it:
with FbsdGPIO() as gpio:
gpio.pulse(13, 100, False)
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
Close
Hashes for pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1d8eb7c154cb46d1ef3a8ab932e19d1fbe8291dca172099627d2a3b30b7ca3 |
|
MD5 | c41a6842799b0088bf6e103a48d7f8fc |
|
BLAKE2b-256 | df6a007ce921bb4ffbf32f467c1bac72e858a2521ddb0bc8d5ff8498ef1db235 |