Skip to main content

gpio for linux

Project description

g4l

Usage

class

  • Gpio(num)
    • parameter
      • num : gpio number

methods

  • Gpio.direction(dir)

    • parameters
      • dir : pin's direction ( Gpio.IN, Gpio.OUT )
  • Gpio.edge(edge)

    • parameters
      • edge : interrupt edge (Gpio.NONE, Gpio.RISING, Gpio.FALLING, Gpio.BOTH)
  • Gpio.input()

    • returns
      • input value
  • Gpio.output(value)

    • parameters
      • value : output value
  • Gpio.setisr(isr)

    • parameters
      • isr : interrupt service routines's callback function

example

input interrupt

from time import sleep
from g4l import Gpio

print('g4l example')
gpio = Gpio(100)
gpio.direction(Gpio.IN)
gpio.edge(Gpio.RISING)
gpio.setisr(lambda:print('gpio isr'))
    
print('loop start - toggle gpio')
cnt = 0
while True:
    print(f'loop {cnt}')
    cnt += 1
    sleep(5)

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

g4l-0.1.4.tar.gz (3.6 kB view hashes)

Uploaded source

Built Distribution

g4l-0.1.4-py3-none-any.whl (3.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page