Skip to content

Commit

Permalink
Fix reset order
Browse files Browse the repository at this point in the history
  • Loading branch information
georgeharker committed Oct 4, 2024
1 parent ac4004d commit 69a090a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions adafruit_seesaw/seesaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,14 @@ def __init__(self, i2c_bus, addr=0x49, drdy=None, rd_delay=0.008, wr_delay=0.008
self.i2c_device = I2CDevice(i2c_bus, addr)
self.sw_reset()

def sw_reset(self):
def sw_reset(self, new_address = None):
"""Trigger a software reset of the SeeSaw chip"""
self.write8(_STATUS_BASE, _STATUS_SWRST, 0xFF)
time.sleep(0.010)

if new_address != None:
self.i2c_device.device_address = addr

chip_id = self.read8(_STATUS_BASE, _STATUS_HW_ID)

if chip_id != _HW_ID_CODE:
Expand Down Expand Up @@ -395,8 +398,7 @@ def set_i2c_addr(self, addr):
"""Store a new address in the device's EEPROM and reboot it."""
self.eeprom_write8(_EEPROM_I2C_ADDR, addr)
time.sleep(0.250)
self.i2c_device.device_address = addr
self.sw_reset()
self.sw_reset(addr)

def get_i2c_addr(self):
"""Return the device's I2C address stored in its EEPROM"""
Expand Down

0 comments on commit 69a090a

Please sign in to comment.