diff --git a/adafruit_lis3mdl.py b/adafruit_lis3mdl.py index 1c17e64..d8e8529 100644 --- a/adafruit_lis3mdl.py +++ b/adafruit_lis3mdl.py @@ -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)