From ad6964531c9065446ee0865d30a43ac6d4bf6f92 Mon Sep 17 00:00:00 2001 From: Phil Howard Date: Tue, 23 Apr 2024 16:04:24 +0100 Subject: [PATCH] Handle user supplied LineRequest/offset. Client libraries will use get_pin() to resolve a user-supplied or default pin label to a gpiochip and line offset. If the user decides to supply a LineRequest, offset tuple instead, then simply return it. This avoids having to handle this behaviour in every client library. --- gpiodevice/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gpiodevice/__init__.py b/gpiodevice/__init__.py index a40153c..d982d1f 100644 --- a/gpiodevice/__init__.py +++ b/gpiodevice/__init__.py @@ -148,6 +148,10 @@ def find_chip_by_platform(): def get_pin(pin, label, settings): + # Do nothing if given a user specified LineRequest/offset tuple + if isinstance(pin, tuple): + return pin + chip = find_chip_by_pins(pin) line_offset = chip.line_offset_from_id(pin) consumer = Path(sys.argv[0]).stem