From 5ffea76efea34661887d0d670c1523ca0c5a8c12 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 3 Jan 2025 13:13:36 -0600 Subject: [PATCH 1/2] return bool from read_pin() --- adafruit_pcf8574.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pcf8574.py b/adafruit_pcf8574.py index da6f703..cbd70df 100644 --- a/adafruit_pcf8574.py +++ b/adafruit_pcf8574.py @@ -90,7 +90,7 @@ def write_pin(self, pin: int, val: bool) -> None: def read_pin(self, pin: int) -> bool: """Read a single GPIO pin as high/pulled-up or driven low""" - return (self.read_gpio() >> pin) & 0x1 + return bool((self.read_gpio() >> pin) & 0x1) """ From 82f8da98346a95390944257f5ed637ff2cc410e9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Mon, 6 Jan 2025 16:54:58 -0600 Subject: [PATCH 2/2] comparison instead of bool function Co-authored-by: Scott Shawcroft --- adafruit_pcf8574.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_pcf8574.py b/adafruit_pcf8574.py index cbd70df..2f28fb3 100644 --- a/adafruit_pcf8574.py +++ b/adafruit_pcf8574.py @@ -90,7 +90,7 @@ def write_pin(self, pin: int, val: bool) -> None: def read_pin(self, pin: int) -> bool: """Read a single GPIO pin as high/pulled-up or driven low""" - return bool((self.read_gpio() >> pin) & 0x1) + return ((self.read_gpio() >> pin) & 0x1) == 1 """