Skip to content

Commit 4923344

Browse files
brentrubrentru
brentru
authored and
brentru
committed
checking in digitalio, ready
1 parent 6a0c036 commit 4923344

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

adafruit_esp32spi/digitalio.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ def value(self, val=None):
9494
def __repr__(self):
9595
return str(self.pin_id)
9696

97-
@staticmethod
97+
# pylint: disable = too-few-public-methods
9898
class DriveMode():
9999
"""DriveMode Enum."""
100100
PUSH_PULL = None
101101
OPEN_DRAIN = None
102102
DriveMode.PUSH_PULL = DriveMode()
103103
DriveMode.OPEN_DRAIN = DriveMode()
104104

105-
@staticmethod
105+
106106
class Direction():
107107
"""DriveMode Enum."""
108108
INPUT = None
@@ -118,6 +118,7 @@ class DigitalInOut():
118118
:param int pin: Valid ESP32 GPIO Pin, predefined in ESP32_GPIO_PINS.
119119
"""
120120
_pin = None
121+
#pylint: disable = attribute-defined-outside-init
121122
def __init__(self, esp, pin):
122123
self._esp = esp
123124
self._pin = Pin(pin, self._esp)
@@ -138,9 +139,9 @@ def switch_to_output(self, value=False, drive_mode=DriveMode.PUSH_PULL):
138139
:param bool value: Default mode to set upon switching.
139140
:param DriveMode drive_mode: Drive mode for the output.
140141
"""
141-
self.direction = Direction.OUTPUT
142-
self.value = value
142+
self._direction = Direction.OUTPUT
143143
self._drive_mode = drive_mode
144+
self.value = value
144145

145146
def switch_to_input(self, pull=None):
146147
"""Sets the pull and then switch to read in digital values.
@@ -189,7 +190,7 @@ def value(self, val):
189190
def drive_mode(self):
190191
"""Returns pin drive mode."""
191192
if self.direction is Direction.OUTPUT:
192-
return self.__drive_mode
193+
return self._drive_mode
193194
raise AttributeError("Not an output")
194195

195196
@drive_mode.setter
@@ -200,6 +201,6 @@ def drive_mode(self, mode):
200201
"""
201202
self.__drive_mode = mode
202203
if mode is DriveMode.OPEN_DRAIN:
203-
self._pin.init(mode=Pin.OPEN_DRAIN)
204+
raise NotImplementedError('Drive mode %s not implemented in ESP32SPI.'%mode)
204205
elif mode is DriveMode.PUSH_PULL:
205206
self._pin.init(mode=Pin.OUT)

0 commit comments

Comments
 (0)