Skip to main content

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


Download files

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

Source Distribution

pyfbsdgpio-tspspi-0.0.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file pyfbsdgpio-tspspi-0.0.1.tar.gz.

File metadata

  • Download URL: pyfbsdgpio-tspspi-0.0.1.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for pyfbsdgpio-tspspi-0.0.1.tar.gz
Algorithm Hash digest
SHA256 cf0e7397cab68e9331169a902aa06ba63cf216bfe794b2ad933b946a0f3b7b82
MD5 58d7aae1878bd86eff1618b24c54d8af
BLAKE2b-256 35ba7f0fd61f5e0cdd070ed278daaa0ce0751baf4636e3b9aadaaa12d6e6e633

See more details on using hashes here.

File details

Details for the file pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfbsdgpio_tspspi-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c1d8eb7c154cb46d1ef3a8ab932e19d1fbe8291dca172099627d2a3b30b7ca3
MD5 c41a6842799b0088bf6e103a48d7f8fc
BLAKE2b-256 df6a007ce921bb4ffbf32f467c1bac72e858a2521ddb0bc8d5ff8498ef1db235

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