An access layer for the Pineworks Labs RP2040 GPIO board
Project description
Pineworks Labs Breakout Interface
Installation
pip install pineworkslabs
RP2040 GPIO Standalone
The RP2040 GPIO is a standalone module which uses the telemetrix library to interface over serial.
Importing
To import this package, run:
import pineworkslabs.GPIO as GPIO
Connecting to the GPIO
When the package is imported on a connected PC, the setup code will find a compatible GPIO board on a connected COM port.
Example: blink an LED
import pineworkslabs.GPIO as GPIO
import time
GPIO.setmode(GPIO.PINEWORKS)
pin = 20
while True:
try:
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.HIGH)
time.sleep(0.25)
GPIO.output(pin, GPIO.LOW)
time.sleep(0.25)
except KeyboardInterrupt:
GPIO.cleanup()
Raspberry Pi 4 / LePotato
Pineworks Labs legacy GPIO boards are a breakout module to be used with a Raspberry Pi 4+ or a Libre Computer Board (LePotato AML-905X-CC-V1.0-A).
Importing
To import this package on the RPi or LePotato, run:
import pineworkslabs.RPi as GPIO
Setting the mode
The relevant difference between the Raspberry Pi and the LePotato for this package is the GPIO pinout. Use the following command to set the appropriate pinout lookup table:
setmode(RASPBERRY_PI_LOOKUP)
or
setmode(LE_POTATO_LOOKUP)
Not all pins are available for output, depending on the mode.
Reading and writing pins
To read a pin, first set it up using the IN flag, then read it with input.
pin: int | str = 20
setup(pin, IN)
print(input(pin))
Similarly, to write a pin, set it up using the OUT flag, then write to it with output.
pin: int | str = 20
setup(pin, OUT)
output(pin, HIGH)
Cleaning up
To reset all pins to LOW, run:
cleanup()
Example: blink an LED (LePotato)
import pineworkslabs.RPi as GPIO
import time
GPIO.setmode(GPIO.LE_POTATO_LOOKUP)
pin = 20
while True:
try:
GPIO.setup(pin, GPIO.OUT)
GPIO.output(pin, GPIO.HIGH)
time.sleep(0.25)
GPIO.output(pin, GPIO.LOW)
time.sleep(0.25)
except KeyboardInterrupt:
GPIO.cleanup()
Acknowledgements
We are indebted to the work of the telemetrix team for serial connectivity between the PC and the GPIO board, and the gpiod team for the interface between the Raspberry Pi/LePotato and the GPIO.
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 pineworkslabs-0.2.0.tar.gz.
File metadata
- Download URL: pineworkslabs-0.2.0.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
942e14765475fc87c2b65a8b6c6547a9d2ab12a5d2dc21975a707ae3c8bac0a6
|
|
| MD5 |
5a62514dce025108a71ffac36e7bfc43
|
|
| BLAKE2b-256 |
be545b69ab8a8f13bd6cea4e9b852cea4cd95b02893e424ced42a9592714333a
|
File details
Details for the file pineworkslabs-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pineworkslabs-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67db1063e7b4aa1c4c7d2ecec43322c3a8f14a8ff658248440d2694e779ec1c4
|
|
| MD5 |
f67b8891fb35401d36673f031e7c59ce
|
|
| BLAKE2b-256 |
6de1044db404b079c06e8ffc971f1f0540ddff7e81e3b566da219696ac3b8039
|