cffi-based Python bindings for FreeBSD GPIO
Project description
Requirements:
Python 2.7 or 3.4
cffi
How to install
Python package on FreeBSD 11 have problem when using python source that needed to compile thing, so the easiest way is to use the binary packages uploaded to pypi:
pip install --only-binary freebsd-11 fbsd_gpio
How to use
The fbsd_gpio module expose two classes, GpioController and GpioPin
Use gpio controller unit 0 (/dev/gpioc0) and list all the pins name:
from fbsd_gpio import GpioController
gpioc = GpioController(0)
for pin in gpioc:
print(pin)
Set pin 127 to output and logical value 1
from fbsd_gpio import GpioController, GPIO_VALUE_HIGH
gpioc = GpioController(0)
gpioc.pin_output(127)
# The two following lines are equivalent
gpioc.pin_set(127, GPIO_VALUE_HIGH)
gpioc.pin_high(127)
Alternativelly you can use the GpioPin class:
from fbsd_gpio import GpioPin, GPIO_VALUE_HIGH
pin = GpioPin(127, unit=0)
pin.ouput = True
# The following lines are equivalent
pin.set(GPIO_VALUE_HIGH)
pin.high()
pin(GPIO_VALUE_HIGH)
Or use the name of the pin directly:
from fbsd_gpio import GpioController, GPIO_VALUE_HIGH
gpioc = GpioController(0)
gpioc.gpioled0.output = True
# The three following lines are equivalent
gpioc.gpioled.set(GPIO_VALUE_HIGH)
gpioc.gpioled0.high()
gpioc.gpioled0(GPIO_VALUE_HIGH)
Get the value of a pin:
from fbsd_gpio import GpioPin
pin = GpioPin(128, unit=0)
if pin.input:
print('Pin is input mode')
else
print('Pin is output mode')
# The two following lines are equivalent
value = pin.get()
value = pin()
Toggle the value of a pin:
from fbsd_gpio import GpioPin
pin = GpioPin(128, unit=0)
pin.toggle()
Change the name of a pin:
from fbsd_gpio import GpioPin
pin = GpioPin(128, unit=0)
pin.name = 'green_led'
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
Built Distributions
File details
Details for the file fbsd_gpio-0.5.0.tar.gz
.
File metadata
- Download URL: fbsd_gpio-0.5.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1842c0bf0f1120d61f9a128419d67f7365e710501e66f8387557bccbc6e00dc8 |
|
MD5 | 79a96aa09d9de122215c66ad872e245e |
|
BLAKE2b-256 | 56f0c08556faee2797eb0dad7d01b43815f7ea319c461ff4ac8c3215a3a3fb51 |
File details
Details for the file fbsd_gpio-0.5.0.freebsd-11.0-CURRENT-arm-py34.tar.gz
.
File metadata
- Download URL: fbsd_gpio-0.5.0.freebsd-11.0-CURRENT-arm-py34.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0749d85cf6ed287d177c9d674dc63b25ff53321faf68faabb2559472260f223 |
|
MD5 | 60f8c5b54691a1d663589df8f9c48831 |
|
BLAKE2b-256 | 2ff9bae77564332854afdef6a27530a53afe3c89b7f0ed7cf0c1f808dd861cb8 |
File details
Details for the file fbsd_gpio-0.5.0.freebsd-11.0-CURRENT-arm-py27.tar.gz
.
File metadata
- Download URL: fbsd_gpio-0.5.0.freebsd-11.0-CURRENT-arm-py27.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 602487371e9fcfb05e7fafebe2b8731f63b20055177244c276f4a12db390f742 |
|
MD5 | d9d99fe7fc64dd858a955ba448cbd109 |
|
BLAKE2b-256 | 5ba0efc00eb75f74afbde525ceae14dfc772335d22f3e5c1b60b583d9ed1087a |