Skip to content

Commit 1f79b99

Browse files
authored
Merge pull request #1 from makermelissa/main
Return a boolean value instead of 1 or 0
2 parents 785c377 + cf17ec5 commit 1f79b99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

adafruit_pca9554.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def set_pin_mode(self, pin: int, val: bool) -> None:
9595
# Set as output and turn off the pullup
9696
self.write_gpio(CONFIGPORT, current_value & ~(1 << pin))
9797

98-
def get_pin_mode(self, pin: int) -> None:
98+
def get_pin_mode(self, pin: int) -> bool:
9999
"""Get a single GPIO pin's mode"""
100-
return (self.read_gpio(CONFIGPORT) >> pin) & 0x1
100+
return bool((self.read_gpio(CONFIGPORT) >> pin) & 0x1)
101101

102102
def write_pin(self, pin: int, val: bool) -> None:
103103
"""Set a single GPIO pin high/pulled-up or driven low"""
@@ -111,7 +111,7 @@ def write_pin(self, pin: int, val: bool) -> None:
111111

112112
def read_pin(self, pin: int) -> bool:
113113
"""Read a single GPIO pin as high/pulled-up or driven low"""
114-
return (self.read_gpio(INPUTPORT) >> pin) & 0x1
114+
return bool((self.read_gpio(INPUTPORT) >> pin) & 0x1)
115115

116116

117117
"""

0 commit comments

Comments
 (0)