X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/blobdiff_plain/22e03b686ec9ff0eb7bd11985d55cb33b525672f..3d15d80420f6f61a17bf7e9c00a97863b4d96bb3:/src/adafruit_blinka/microcontroller/generic_agnostic_board/pin.py diff --git a/src/adafruit_blinka/microcontroller/generic_agnostic_board/pin.py b/src/adafruit_blinka/microcontroller/generic_agnostic_board/pin.py index 3ff957d..47d9754 100644 --- a/src/adafruit_blinka/microcontroller/generic_agnostic_board/pin.py +++ b/src/adafruit_blinka/microcontroller/generic_agnostic_board/pin.py @@ -71,6 +71,8 @@ class Pin: PULL_UP = 1 PULL_DOWN = 2 + # pylint: disable=no-self-use + def return_toggle(self): """Returns the pin's expected value, toggling between True and False""" toggle_state = not self.previous_value @@ -125,8 +127,8 @@ class Pin: 4: self.return_true, # Dx_OUTPUT 7: self.return_random_int, # Ax_INPUT_RAND_INT 8: self.return_fixed_int_pi, # Ax_INPUT_FIXED_INT_PI - 9: self.return_sine_wave, # Ax_OUTPUT_WAVE_SINE - 10: self.return_sawtooth_wave, # Ax_OUTPUT_WAVE_SAW + 9: self.return_sine_wave, # Ax_INPUT_WAVE_SINE + 10: self.return_sawtooth_wave, # Ax_INPUT_WAVE_SAW 11: self.return_toggle, # Dx_INPUT_TOGGLE } @@ -150,10 +152,10 @@ class Pin: self.current_value = self.pin_behavior.get(self.id)() # is pin a pull up and pin is LOW? - if self._pull == Pin.PULL_UP and self.current_value == False: + if self._pull == Pin.PULL_UP and self.current_value is False: self.current_value = False # is pin a pull down and pin is HIGH? - if self._pull == Pin.PULL_DOWN and self.current_value == True: + if self._pull == Pin.PULL_DOWN and self.current_value is True: self.current_value = False return self.current_value @@ -178,8 +180,8 @@ class Pin: # Analog Out if self._mode == Pin.DAC: if val is None: - # write only - raise AttributeError("unreadable attribute") + self.previous_value = self.current_value + return self.current_value self.write(val) return None raise RuntimeError( @@ -200,6 +202,7 @@ A0 = Pin(7) A1 = Pin(8) A2 = Pin(9) A3 = Pin(10) +A4 = Pin(12) D7 = Pin(11)