Skip to content

Commit a032f92

Browse files
committed
allow optional reset adafruit#79
1 parent f6e2f6b commit a032f92

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

adafruit_seesaw/seesaw.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,25 +127,22 @@ class Seesaw:
127127
128128
:param ~busio.I2C i2c_bus: Bus the SeeSaw is connected to
129129
:param int addr: I2C address of the SeeSaw device
130-
:param ~digitalio.DigitalInOut drdy: Pin connected to SeeSaw's 'ready' output"""
130+
:param ~digitalio.DigitalInOut drdy: Pin connected to SeeSaw's 'ready' output
131+
:param bool reset: Whether to do a software reset on init"""
131132

132133
INPUT = const(0x00)
133134
OUTPUT = const(0x01)
134135
INPUT_PULLUP = const(0x02)
135136
INPUT_PULLDOWN = const(0x03)
136137

137-
def __init__(self, i2c_bus, addr=0x49, drdy=None):
138+
def __init__(self, i2c_bus, addr=0x49, drdy=None, reset=True):
138139
self._drdy = drdy
139140
if drdy is not None:
140141
drdy.switch_to_input()
141142

142143
self.i2c_device = I2CDevice(i2c_bus, addr)
143-
self.sw_reset()
144-
145-
def sw_reset(self):
146-
"""Trigger a software reset of the SeeSaw chip"""
147-
self.write8(_STATUS_BASE, _STATUS_SWRST, 0xFF)
148-
time.sleep(0.500)
144+
if reset:
145+
self.sw_reset()
149146

150147
self.chip_id = self.read8(_STATUS_BASE, _STATUS_HW_ID)
151148

@@ -175,6 +172,12 @@ def sw_reset(self):
175172
self.pin_mapping = ATtiny8x7_Pinmap
176173
# pylint: enable=import-outside-toplevel
177174

175+
def sw_reset(self):
176+
"""Trigger a software reset of the SeeSaw chip"""
177+
self.write8(_STATUS_BASE, _STATUS_SWRST, 0xFF)
178+
time.sleep(0.500)
179+
180+
178181
def get_options(self):
179182
"""Retrieve the 'options' word from the SeeSaw board"""
180183
buf = bytearray(4)

0 commit comments

Comments
 (0)