From: brentru Date: Fri, 29 Mar 2024 13:57:40 +0000 (-0400) Subject: toggle X-Git-Tag: 8.39.0^2~13 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/45c6059e81fcdc21409153ffa553700874ed7634 toggle --- diff --git a/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py b/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py index e2cb40f..27a1c56 100644 --- a/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py +++ b/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py @@ -21,7 +21,7 @@ class Pin: def __init__(self, pin_id=None): self.id = pin_id self._mode = None - self._prv_val = None + self._prv_val = False def init(self, mode=IN, pull=None): """Initialize the Pin""" @@ -53,13 +53,8 @@ class Pin: if self._mode in (Pin.IN, Pin.OUT): # digital read if val is None: - # The value returned will toggle between True and False - # and will be True on the first digital read - # TODO: Behavior needs to be tested - if self._prv_val == None or False: - self._prv_val = True - else: - self._prv_val = False + # The returned value toggles between True and false + self._prv_val = not self._prv_val return self._prv_val # digital write if val in (Pin.LOW, Pin.HIGH):