]> Repositories - Adafruit_Blinka-hackapet.git/blob - src/adafruit_blinka/microcontroller/generic_linux/libgpiod_pin.py
pullin analogio.py
[Adafruit_Blinka-hackapet.git] / src / adafruit_blinka / microcontroller / generic_linux / libgpiod_pin.py
1 # SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
2 #
3 # SPDX-License-Identifier: MIT
4 """A Pin class for use with libgpiod."""
5 try:
6     import gpiod
7 except ImportError:
8     raise ImportError(
9         "libgpiod Python bindings not found, please install and try again! See "
10         "https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/libgpiod.py"
11     ) from ImportError
12
13 # Versions 1.5.4 and earlier have no __version__ attribute
14 if hasattr(gpiod, "__version__"):
15     version = gpiod.__version__
16 else:
17     version = "1.x"
18
19 if version.startswith("1."):
20     from .libgpiod.libgpiod_pin_1_x import Pin  # pylint: disable=unused-import
21 else:
22     from .libgpiod.libgpiod_pin_2_x import Pin  # pylint: disable=unused-import