Skip to content

Commit 1594054

Browse files
authored
Merge pull request #6 from danaliv/address_kwarg
add address kwarg
2 parents e0fc1d7 + ce4afa6 commit 1594054

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

adafruit_tlv493d.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,19 @@
4646

4747
import struct
4848
import adafruit_bus_device.i2c_device as i2cdevice
49+
from micropython import const
4950

5051
__version__ = "0.0.0-auto.0"
5152
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_TLV493D.git"
5253

54+
_TLV493D_DEFAULT_ADDRESS = const(0x5E)
55+
5356

5457
class TLV493D:
5558
"""Driver for the TLV493D 3-axis Magnetometer.
5659
5760
:param busio.I2C i2c_bus: The I2C bus the TLV493D is connected to.
61+
:param int address: The I2C address of the TLV493D. Defaults to 0x5E.
5862
5963
"""
6064

@@ -89,8 +93,8 @@ class TLV493D:
8993
"RES3": (3, 0x1F, 0),
9094
}
9195

92-
def __init__(self, i2c_bus):
93-
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, 0x5E)
96+
def __init__(self, i2c_bus, address=_TLV493D_DEFAULT_ADDRESS):
97+
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
9498
self.read_buffer = bytearray(10)
9599
self.write_buffer = bytearray(4)
96100

0 commit comments

Comments
 (0)