X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka.git/blobdiff_plain/66df9c4b8688960e98e67692074a1d8e4ffb6444..2bb509c5e122b4e0538bd5a87364c3c5a524fc0c:/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py diff --git a/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py b/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py index e2cb40f..f4e1b94 100644 --- a/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py +++ b/src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py @@ -21,14 +21,16 @@ 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""" if self.id is None: raise RuntimeError("Can not init a None type pin.") if pull is not None: - raise NotImplementedError("Internal pullups and pulldowns not supported on the MCP2221") + raise NotImplementedError( + "Internal pullups and pulldowns not supported on the MCP2221" + ) if mode in (Pin.IN, Pin.OUT): # All pins can do GPIO pass @@ -53,13 +55,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): @@ -95,4 +92,4 @@ G2 = Pin(2) G3 = Pin(3) SCL = Pin() -SDA = Pin() \ No newline at end of file +SDA = Pin()