Skip to content

add address kwarg #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions adafruit_tlv493d.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@

import struct
import adafruit_bus_device.i2c_device as i2cdevice
from micropython import const

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

_TLV493D_DEFAULT_ADDRESS = const(0x5E)


class TLV493D:
"""Driver for the TLV493D 3-axis Magnetometer.

:param busio.I2C i2c_bus: The I2C bus the TLV493D is connected to.
:param int address: The I2C address of the TLV493D. Defaults to 0x5E.

"""

Expand Down Expand Up @@ -89,8 +93,8 @@ class TLV493D:
"RES3": (3, 0x1F, 0),
}

def __init__(self, i2c_bus):
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, 0x5E)
def __init__(self, i2c_bus, address=_TLV493D_DEFAULT_ADDRESS):
self.i2c_device = i2cdevice.I2CDevice(i2c_bus, address)
self.read_buffer = bytearray(10)
self.write_buffer = bytearray(4)

Expand Down