adafruit-circuitpython-mlx90393 2.2.1__py3-none-any.whl → 2.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: adafruit-circuitpython-mlx90393
3
- Version: 2.2.1
3
+ Version: 2.3.1
4
4
  Summary: CircuitPython driver for the MLX90393 3-axis magnetometer.
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -0,0 +1,6 @@
1
+ adafruit_mlx90393.py,sha256=xgMKT0NRfp1sqnzKonL7O5698k08amGzRAgenPspvb0,21413
2
+ adafruit_circuitpython_mlx90393-2.3.1.dist-info/LICENSE,sha256=WeIXVkYWpdba3Boxrax8dB0s5qWg9GTxl7c5uTZQDUI,1105
3
+ adafruit_circuitpython_mlx90393-2.3.1.dist-info/METADATA,sha256=JVORf9E8OG3umEz_NRsA-ii0AaipVOYCQK0brGPaFiM,4084
4
+ adafruit_circuitpython_mlx90393-2.3.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
5
+ adafruit_circuitpython_mlx90393-2.3.1.dist-info/top_level.txt,sha256=5RT_YbHfXFo2Y6zVvz8MXsZLIHm1OxrjFJrzRaCTdNY,18
6
+ adafruit_circuitpython_mlx90393-2.3.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
adafruit_mlx90393.py CHANGED
@@ -43,7 +43,7 @@ try:
43
43
  except ImportError:
44
44
  pass
45
45
 
46
- __version__ = "2.2.1"
46
+ __version__ = "2.3.1"
47
47
  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MLX90393.git"
48
48
 
49
49
  _CMD_SB = const(0b00010000) # Start burst mode
@@ -65,6 +65,9 @@ _CMD_REG_CONF1 = const(0x00) # Gain
65
65
  _CMD_REG_CONF2 = const(0x01) # Burst, comm mode, temperature compensation
66
66
  _CMD_REG_CONF3 = const(0x02) # Oversampling, Filter, Resolution
67
67
  _CMD_REG_CONF4 = const(0x03) # Sensitivity drift
68
+ _CMD_REG_CONF5 = const(0x04) # X-axis Offset Correction
69
+ _CMD_REG_CONF6 = const(0x05) # Y-axis Offset Correction
70
+ _CMD_REG_CONF7 = const(0x06) # Z-axis Offset Correction
68
71
 
69
72
  # Gain settings
70
73
  GAIN_5X = 0x0
@@ -212,6 +215,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
212
215
  filt: int = FILTER_7,
213
216
  oversampling: int = OSR_3,
214
217
  temperature_compensation: bool = False,
218
+ offset: int = 0,
215
219
  debug: bool = False,
216
220
  ) -> None:
217
221
  self.i2c_device = I2CDevice(i2c_bus, address)
@@ -222,6 +226,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
222
226
  self._osr = oversampling
223
227
  self._gain_current = gain
224
228
  self._temperature_compensation = temperature_compensation
229
+ self._off_x = self._off_y = self._off_z = offset
225
230
 
226
231
  # Put the device in a known state to start
227
232
  self.reset()
@@ -241,6 +246,11 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
241
246
  self.gain = self._gain_current
242
247
  self.temperature_compensation = self._temperature_compensation
243
248
 
249
+ # Set offsets to supplied level
250
+ self.offset_x = self._off_x
251
+ self.offset_y = self._off_y
252
+ self.offset_z = self._off_z
253
+
244
254
  def _transceive(self, payload: ReadableBuffer, rxlen: int = 0) -> bytearray:
245
255
  """
246
256
  Writes the specified 'payload' to the sensor
@@ -402,6 +412,48 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
402
412
  self.write_reg(_CMD_REG_CONF2, reg)
403
413
  self._temperature_compensation = temperature_compensation
404
414
 
415
+ @property
416
+ def offset_x(self) -> int:
417
+ """The X axis offset."""
418
+ return self._off_x
419
+
420
+ @offset_x.setter
421
+ def offset_x(self, offset: int) -> None:
422
+ self._set_offset(0, offset)
423
+ self._off_x = offset
424
+
425
+ @property
426
+ def offset_y(self) -> int:
427
+ """The Y axis offset."""
428
+ return self._off_y
429
+
430
+ @offset_y.setter
431
+ def offset_y(self, offset: int) -> None:
432
+ self._set_offset(1, offset)
433
+ self._off_y = offset
434
+
435
+ @property
436
+ def offset_z(self) -> int:
437
+ """The Z axis offset."""
438
+ return self._off_z
439
+
440
+ @offset_z.setter
441
+ def offset_z(self, offset: int) -> None:
442
+ self._set_offset(2, offset)
443
+ self._off_z = offset
444
+
445
+ def _set_offset(self, axis: int, offset: int) -> None:
446
+ if offset < 0x0000 or offset > 0xFFFF:
447
+ raise ValueError("Incorrect offset setting.")
448
+ if axis == 0:
449
+ self.write_reg(_CMD_REG_CONF5, offset)
450
+ elif axis == 1:
451
+ self.write_reg(_CMD_REG_CONF6, offset)
452
+ elif axis == 2:
453
+ self.write_reg(_CMD_REG_CONF7, offset)
454
+ else:
455
+ raise ValueError("Incorrect axis setting.")
456
+
405
457
  def display_status(self) -> None:
406
458
  """
407
459
  Prints out the content of the last status byte in a human-readable
@@ -465,7 +517,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
465
517
  self._transceive(bytes([_CMD_EX]))
466
518
  if self._debug:
467
519
  print("Resetting sensor")
468
- time.sleep(2)
520
+ time.sleep(0.002)
469
521
  self._transceive(bytes([_CMD_RT]))
470
522
  # burn a read post reset
471
523
  try:
@@ -1,6 +0,0 @@
1
- adafruit_mlx90393.py,sha256=TmDYu1ECE5C2HYkQLxZJelnyYg3-LvuRlPRkpWuWK-Q,19835
2
- adafruit_circuitpython_mlx90393-2.2.1.dist-info/LICENSE,sha256=WeIXVkYWpdba3Boxrax8dB0s5qWg9GTxl7c5uTZQDUI,1105
3
- adafruit_circuitpython_mlx90393-2.2.1.dist-info/METADATA,sha256=t_zR-ETTRS-g_dtOYiKIRs_1Ci0puStPRS3F458oUZw,4084
4
- adafruit_circuitpython_mlx90393-2.2.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
5
- adafruit_circuitpython_mlx90393-2.2.1.dist-info/top_level.txt,sha256=5RT_YbHfXFo2Y6zVvz8MXsZLIHm1OxrjFJrzRaCTdNY,18
6
- adafruit_circuitpython_mlx90393-2.2.1.dist-info/RECORD,,