Skip to content
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

Init with default values, so they can be changed #26

Merged
merged 2 commits into from
May 6, 2024
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
21 changes: 14 additions & 7 deletions adafruit_lis3mdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,18 +228,25 @@ class LIS3MDL:
_range = RWBits(2, _LIS3MDL_CTRL_REG2, 5)
_reset = RWBit(_LIS3MDL_CTRL_REG2, 2)

def __init__(self, i2c_bus: I2C, address: int = _LIS3MDL_DEFAULT_ADDRESS) -> None:
# pylint: disable=no-member
def __init__(
self,
i2c_bus: I2C,
address: int = _LIS3MDL_DEFAULT_ADDRESS,
performance_mode: PerformanceMode = PerformanceMode.MODE_ULTRA,
data_rate: Rate = Rate.RATE_155_HZ,
range_: Range = Range.RANGE_4_GAUSS,
operation_mode: OperationMode = OperationMode.CONTINUOUS,
) -> None:
# pylint: disable=no-member,too-many-arguments
self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
if self._chip_id != _LIS3MDL_CHIP_ID:
raise RuntimeError("Failed to find LIS3MDL - check your wiring!")

self.reset()
self.performance_mode = PerformanceMode.MODE_ULTRA

self.data_rate = Rate.RATE_155_HZ
self.range = Range.RANGE_4_GAUSS
self.operation_mode = OperationMode.CONTINUOUS
self.performance_mode = performance_mode
self.data_rate = data_rate
self.range = range_
self.operation_mode = operation_mode

sleep(0.010)

Expand Down
Loading