mirror of
https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git
synced 2026-10-25 12:39:18 +03:00
Replace tool examples with use case examples drawn from the tools. Signed-off-by: Kent Gibson <warthog618@gmail.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
24 lines
647 B
Python
Executable File
24 lines
647 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# SPDX-FileCopyrightText: 2023 Kent Gibson <warthog618@gmail.com>
|
|
|
|
"""Minimal example of watching for info changes on particular lines."""
|
|
|
|
import gpiod
|
|
|
|
|
|
def watch_line_info(chip_path, line_offsets):
|
|
with gpiod.Chip(chip_path) as chip:
|
|
for offset in line_offsets:
|
|
chip.watch_line_info(offset)
|
|
|
|
while True:
|
|
print(chip.read_info_event())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
watch_line_info("/dev/gpiochip0", [5, 3, 7])
|
|
except OSError as ex:
|
|
print(ex, "\nCustomise the example configuration to suit your situation")
|