|
48 | 48 | import adafruit_bus_device.i2c_device as i2c_device
|
49 | 49 | from adafruit_register.i2c_struct import ROUnaryStruct, Struct
|
50 | 50 | from adafruit_register.i2c_bits import RWBits
|
| 51 | +from adafruit_register.i2c_bit import RWBit |
51 | 52 | __version__ = "0.0.0-auto.0"
|
52 | 53 | __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM6DSOX.git"
|
53 | 54 |
|
@@ -164,32 +165,25 @@ class LIS3MDL:
|
164 | 165 | _raw_mag_data = Struct(_LIS3MDL_OUT_X_L, "<hhh")
|
165 | 166 |
|
166 | 167 | _range = RWBits(2, _LIS3MDL_CTRL_REG2, 5)
|
| 168 | + _reset = RWBit(_LIS3MDL_CTRL_REG2, 2) |
167 | 169 |
|
168 | 170 | def __init__(self, i2c_bus, address=_LIS3MDL_DEFAULT_ADDRESS):
|
| 171 | + #pylint: disable=no-member |
169 | 172 | self.i2c_device = i2c_device.I2CDevice(i2c_bus, address)
|
170 | 173 | if self._chip_id != _LIS3MDL_CHIP_ID:
|
171 | 174 | raise RuntimeError("Failed to find LIS3MDL - check your wiring!")
|
172 | 175 | self.reset()
|
173 |
| - # // set high quality performance mode |
174 |
| - # setPerformanceMode(LIS3MDL_ULTRAHIGHMODE); |
175 |
| - self._perf_mode = 0b11 |
176 |
| - self.performance_mode = PerformanceMode.MODE_ULTRA #pylint: disable=no-member |
177 |
| - |
178 |
| - # // 155Hz default rate |
179 |
| - # setDataRate(LIS3MDL_DATARATE_155_HZ); |
180 |
| - |
181 |
| - |
182 |
| - self.range = Range.RANGE_4_GAUSS #pylint: disable=no-member |
| 176 | + self.performance_mode = PerformanceMode.MODE_ULTRA |
183 | 177 |
|
184 |
| - # setOperationMode(LIS3MDL_CONTINUOUSMODE); |
185 |
| - self._operation_mode = 0 # enable, take out of shutdown |
| 178 | + self.data_rate = Rate.RATE_155_HZ |
| 179 | + self.range = Range.RANGE_4_GAUSS |
| 180 | + self._operation_mode = 0 # continuous mode |
186 | 181 | sleep(0.010)
|
| 182 | + |
187 | 183 | def reset(self): #pylint: disable=no-self-use
|
188 | 184 | """Reset the sensor to the default state set by the library"""
|
189 |
| - |
190 |
| - print("called reset") |
191 |
| - # reset |
192 |
| - # sleep(0.010) |
| 185 | + self._reset = True |
| 186 | + sleep(0.010) |
193 | 187 |
|
194 | 188 | @property
|
195 | 189 | def magnetic(self):
|
|
0 commit comments