Skip to main content

No project description provided

Project description

gpiod driver

jumpstarter-driver-gpiod provides functionality for interacting with gpiod GPIO pins for digital input/output operations.

This requires the /dev/gpiochip[0..N] device available on the system, and you can use the gpioinfo gpiod tool to list the available GPIO lines.

Installation

:substitutions:
$ pip3 install --extra-index-url {{index_url}} jumpstarter-driver-gpiod

Configuration

The gpiod driver provides three main driver types:

DigitalOutput Configuration

Example configuration for digital output:

export:
  led_output:
    type: jumpstarter_driver_gpiod.driver.DigitalOutput
    config:
      device: "/dev/gpiochip0"
      line: 18
      drive: "push_pull"
      active_low: false
      bias: "pull_up"
      initial_value: "inactive"

DigitalInput Configuration

Example configuration for digital input:

export:
  button_input:
    type: jumpstarter_driver_gpiod.driver.DigitalInput
    config:
      line: 17
      active_low: false
      bias: "pull_up"

PowerSwitch Configuration

Example configuration for power switching:

export:
  power_switch:
    type: jumpstarter_driver_gpiod.driver.PowerSwitch
    config:
      line: 18
      mode: "push_pull"
      active_low: false
      bias: "pull_up"
      initial_value: "inactive"

Config parameters

Parameter Description Type Required Default Driver Types
device The GPIO device to use (can be integer or string like "/dev/gpiochip0") str no "/dev/gpiochip0" All
line The GPIO line number to use int yes All
drive The drive mode for the GPIO line. Options: "push_pull", "open_drain", "open_source" str no null DigitalOutput, PowerSwitch
active_low Whether the pin is active low (True) or active high (False) bool no False All
bias The bias configuration for the GPIO line. Options: "as_is", "pull_up", "pull_down", "disabled" str no null All
initial_value The initial value for output pins. Options: "active", "inactive", "on", "off", True, False str/bool no "inactive" DigitalOutput, PowerSwitch
mode The mode for PowerSwitch (same as drive parameter) str no "push_pull" PowerSwitch

API Reference

DigitalOutputClient

.. autoclass:: jumpstarter_driver_gpiod.client.DigitalOutputClient()
    :members: on, off, read

DigitalInputClient

.. autoclass:: jumpstarter_driver_gpiod.client.DigitalInputClient()
    :members: wait_for_active, wait_for_inactive, wait_for_edge, read

Examples

Digital Output Examples

Basic LED control:

# Turn LED on
led_output.on()

# Turn LED off
led_output.off()

# Read current state
state = led_output.read()
print(f"LED state: {state}")

Digital Input Examples

Button input with edge detection:

# Read current input state
state = button_input.read()
print(f"Button state: {state}")

# Wait for button press (active state)
button_input.wait_for_active(timeout=10.0)

# Wait for button release (inactive state)
button_input.wait_for_inactive(timeout=10.0)

# Wait for rising edge (button press)
button_input.wait_for_edge("rising", timeout=10.0)

# Wait for falling edge (button release)
button_input.wait_for_edge("falling", timeout=10.0)

Power Switch Examples

Power control for devices:

# Turn power on
power_switch.on()

# Turn power off
power_switch.off()

# Read current power state
state = power_switch.read()
print(f"Power state: {state}")

Pin Configuration Details

Drive Modes

  • push_pull: Standard push-pull output (default)
  • open_drain: Open-drain output (useful for I2C, etc.)
  • open_source: Open-source output

Bias Configuration

  • as_is: No bias (default)
  • pull_up: Internal pull-up resistor
  • pull_down: Internal pull-down resistor
  • disabled: Disable bias

Active Low vs Active High

  • active_low: false (default): Pin is active when HIGH
  • active_low: true: Pin is active when LOW

Initial Values

For output pins, you can set the initial state:

  • "inactive" or "off" or False: Start with pin LOW
  • "active" or "on" or True: Start with pin HIGH

Hardware Requirements

  • gpiod with GPIO access
  • Python gpiod library installed
  • Appropriate permissions to access /dev/gpiochip0

Error Handling

The driver includes comprehensive error handling for:

  • Invalid pin numbers
  • Invalid drive/bias configurations
  • Hardware access errors
  • Timeout conditions for input operations

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

jumpstarter_driver_gpiod-0.7.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

jumpstarter_driver_gpiod-0.7.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file jumpstarter_driver_gpiod-0.7.1.tar.gz.

File metadata

File hashes

Hashes for jumpstarter_driver_gpiod-0.7.1.tar.gz
Algorithm Hash digest
SHA256 85c009d0ae31864a9e19678a1194ea0ea1c65a6238ca8aa13003bc7c6311ccf2
MD5 4d5e6f9aae9bc2d4e176b00298fddb7d
BLAKE2b-256 b216af339aef08c29cf02ebbd648c0b57a25f6b1062ffd472b39cfe73d1bfdf1

See more details on using hashes here.

File details

Details for the file jumpstarter_driver_gpiod-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jumpstarter_driver_gpiod-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 177c5e9b098c821c6d35ad0cdad2c47be8f77fe810b0f30e13d8c3c11bf70cde
MD5 10ef7617ce5881e2355ca1f9a2c3a1e9
BLAKE2b-256 887031273fb754a016338f8e41fee71a80e58edc1245271d08511a3f9a893137

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