adafruit-circuitpython-mlx90393 2.1.5__py3-none-any.whl → 2.2.0__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.1.5
3
+ Version: 2.2.0
4
4
  Summary: CircuitPython driver for the MLX90393 3-axis magnetometer.
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License: MIT
@@ -14,7 +14,7 @@ Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Description-Content-Type: text/x-rst
16
16
  License-File: LICENSE
17
- Requires-Dist: Adafruit-Blinka >=7.0.0
17
+ Requires-Dist: Adafruit-Blinka>=7.0.0
18
18
  Requires-Dist: adafruit-circuitpython-busdevice
19
19
  Requires-Dist: adafruit-circuitpython-typing
20
20
  Provides-Extra: optional
@@ -0,0 +1,6 @@
1
+ adafruit_mlx90393.py,sha256=x01r3I_OliE3J9tt3Y_0LQswVOjCqI-mYmqusmwyixY,19835
2
+ adafruit_circuitpython_mlx90393-2.2.0.dist-info/LICENSE,sha256=WeIXVkYWpdba3Boxrax8dB0s5qWg9GTxl7c5uTZQDUI,1105
3
+ adafruit_circuitpython_mlx90393-2.2.0.dist-info/METADATA,sha256=wG-t6WHv4TEbnl3J9sx9iqjMUBCauluWJvauc9HIq8A,4084
4
+ adafruit_circuitpython_mlx90393-2.2.0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
5
+ adafruit_circuitpython_mlx90393-2.2.0.dist-info/top_level.txt,sha256=5RT_YbHfXFo2Y6zVvz8MXsZLIHm1OxrjFJrzRaCTdNY,18
6
+ adafruit_circuitpython_mlx90393-2.2.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (74.1.2)
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.1.5"
46
+ __version__ = "2.2.0"
47
47
  __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MLX90393.git"
48
48
 
49
49
  _CMD_SB = const(0b00010000) # Start burst mode
@@ -62,7 +62,7 @@ _CMD_AXIS_ALL = const(0xE) # X+Y+Z axis bits for commands
62
62
  _CMD_TEMP = const(0x01) # Temperature bit for commands
63
63
 
64
64
  _CMD_REG_CONF1 = const(0x00) # Gain
65
- _CMD_REG_CONF2 = const(0x01) # Burst, comm mode
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
68
 
@@ -211,6 +211,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
211
211
  resolution: int = RESOLUTION_16,
212
212
  filt: int = FILTER_7,
213
213
  oversampling: int = OSR_3,
214
+ temperature_compensation: bool = False,
214
215
  debug: bool = False,
215
216
  ) -> None:
216
217
  self.i2c_device = I2CDevice(i2c_bus, address)
@@ -220,6 +221,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
220
221
  self._filter = filt
221
222
  self._osr = oversampling
222
223
  self._gain_current = gain
224
+ self._temperature_compensation = temperature_compensation
223
225
 
224
226
  # Put the device in a known state to start
225
227
  self.reset()
@@ -237,6 +239,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
237
239
 
238
240
  # Set gain to the supplied level
239
241
  self.gain = self._gain_current
242
+ self.temperature_compensation = self._temperature_compensation
240
243
 
241
244
  def _transceive(self, payload: ReadableBuffer, rxlen: int = 0) -> bytearray:
242
245
  """
@@ -385,6 +388,20 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
385
388
  self.write_reg(_CMD_REG_CONF3, reg)
386
389
  self._osr = level
387
390
 
391
+ @property
392
+ def temperature_compensation(self) -> bool:
393
+ """The temperature compensation setting"""
394
+ return self._temperature_compensation
395
+
396
+ @temperature_compensation.setter
397
+ def temperature_compensation(self, temperature_compensation: bool) -> None:
398
+ reg = self.read_reg(_CMD_REG_CONF2)
399
+ t_cmp_bit = 10
400
+ reg &= ~(1 << t_cmp_bit)
401
+ reg |= temperature_compensation << t_cmp_bit
402
+ self.write_reg(_CMD_REG_CONF2, reg)
403
+ self._temperature_compensation = temperature_compensation
404
+
388
405
  def display_status(self) -> None:
389
406
  """
390
407
  Prints out the content of the last status byte in a human-readable
@@ -462,6 +479,22 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
462
479
  """
463
480
  Reads a single X/Y/Z sample from the magnetometer.
464
481
  """
482
+
483
+ resolutions = {self.resolution_x, self.resolution_y, self.resolution_z}
484
+ valid_tcomp_resolutions = {RESOLUTION_16, RESOLUTION_17}
485
+ if self._temperature_compensation and not resolutions.issubset(
486
+ valid_tcomp_resolutions
487
+ ):
488
+ resolutions_output = f"""Current Resolutions:
489
+ \tresolution_x: {self.resolution_x}
490
+ \tresolution_y: {self.resolution_y}
491
+ \tresolution_z: {self.resolution_z}"""
492
+
493
+ raise ValueError(
494
+ "All resolutions must be RESOLUTION_16 or RESOLUTION_17"
495
+ f" if temperature compensation is enabled.\n {resolutions_output}"
496
+ )
497
+
465
498
  # Set conversion delay based on filter and oversampling
466
499
  delay = _TCONV_LOOKUP[self._filter][self._osr] / 1000 # per datasheet
467
500
  delay *= 1.1 # plus a little
@@ -493,6 +526,9 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
493
526
  elif resolution == RESOLUTION_18:
494
527
  (value,) = struct.unpack(">H", data)
495
528
  value -= 0x8000
529
+ elif self.temperature_compensation:
530
+ (value,) = struct.unpack(">H", data)
531
+ value -= 0x8000
496
532
  else:
497
533
  value = struct.unpack(">h", data)[0]
498
534
  return value
@@ -1,6 +0,0 @@
1
- adafruit_mlx90393.py,sha256=94HFAZMsbNy57SV6Qqu8HqYeUofThg6hT1_PmbHrpzE,18326
2
- adafruit_circuitpython_mlx90393-2.1.5.dist-info/LICENSE,sha256=WeIXVkYWpdba3Boxrax8dB0s5qWg9GTxl7c5uTZQDUI,1105
3
- adafruit_circuitpython_mlx90393-2.1.5.dist-info/METADATA,sha256=2nUZH8DTMICjwDfcj6eP-8cg3Pd6fpHpMP9aljAU4Qk,4085
4
- adafruit_circuitpython_mlx90393-2.1.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
5
- adafruit_circuitpython_mlx90393-2.1.5.dist-info/top_level.txt,sha256=5RT_YbHfXFo2Y6zVvz8MXsZLIHm1OxrjFJrzRaCTdNY,18
6
- adafruit_circuitpython_mlx90393-2.1.5.dist-info/RECORD,,