Skip to main content

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)

Metadata

Release files for pyfbsdgpio-tspspi 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyfbsdgpio-tspspi 0.0.1
File Size Uploaded
pyfbsdgpio-tspspi-0.0.1.tar.gz 2.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyfbsdgpio-tspspi 0.0.1
File Interpreter ABI Platform
pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.6 kB

Release files / pyfbsdgpio-tspspi-0.0.1.tar.gz

Download URL pyfbsdgpio-tspspi-0.0.1.tar.gz
Size 2.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cf0e7397cab68e9331169a902aa06ba63cf216bfe794b2ad933b946a0f3b7b82
BLAKE2b-256 checksum
How to use checksums
35ba7f0fd61f5e0cdd070ed278daaa0ce0751baf4636e3b9aadaaa12d6e6e633
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release files / pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl

Download URL pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c1d8eb7c154cb46d1ef3a8ab932e19d1fbe8291dca172099627d2a3b30b7ca3
BLAKE2b-256 checksum
How to use checksums
df6a007ce921bb4ffbf32f467c1bac72e858a2521ddb0bc8d5ff8498ef1db235
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page