vitiral / gpio

python gpio module for linux using the sysfs file access (/sys/class/gpio). Mimics similar Raspberry Pi IO libraries
MIT License
76 stars 46 forks source link

Linux sysfs gpio access

This library provides gpio access via the standard linux sysfs interface

It is intended to mimick RPIO as much as possible for all features, while also supporting additional (and better named) functionality to the same methods.

Supported Features

Examples

RPi.GPIO Drop-in

Good for up to 130KHz pin toggle on a Pi 400.

import time

import gpio as GPIO

GPIO.setup(14, GPIO.OUT)

while True:
    GPIO.output(14, GPIO.HIGH)
    time.sleep(1.0)
    GPIO.output(14, GPIO.LOW)
    time.sleep(1.0)

Use GPIOPin directly

Good for up to 160KHz pin toggle on a Pi 400.

This gives you a class instance you can manipulate directly, eliminating the lookup:

import gpio

pin = gpio.GPIOPin(14, gpio.OUT)

while True:
    pin.write(14, GPIO.HIGH)
    time.sleep(1.0)
    pin.write(14, GPIO.LOW)
    time.sleep(1.0)