adafruit-circuitpython-mlx90393 2.1.4__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.
- {adafruit_circuitpython_mlx90393-2.1.4.dist-info → adafruit_circuitpython_mlx90393-2.2.0.dist-info}/METADATA +2 -2
- adafruit_circuitpython_mlx90393-2.2.0.dist-info/RECORD +6 -0
- {adafruit_circuitpython_mlx90393-2.1.4.dist-info → adafruit_circuitpython_mlx90393-2.2.0.dist-info}/WHEEL +1 -1
- adafruit_mlx90393.py +42 -3
- adafruit_circuitpython_mlx90393-2.1.4.dist-info/RECORD +0 -6
- {adafruit_circuitpython_mlx90393-2.1.4.dist-info → adafruit_circuitpython_mlx90393-2.2.0.dist-info}/LICENSE +0 -0
- {adafruit_circuitpython_mlx90393-2.1.4.dist-info → adafruit_circuitpython_mlx90393-2.2.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: adafruit-circuitpython-mlx90393
|
3
|
-
Version: 2.
|
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
|
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,,
|
adafruit_mlx90393.py
CHANGED
@@ -28,6 +28,7 @@ Implementation Notes
|
|
28
28
|
https://github.com/adafruit/Adafruit_CircuitPython_Register
|
29
29
|
|
30
30
|
"""
|
31
|
+
|
31
32
|
import struct
|
32
33
|
import time
|
33
34
|
|
@@ -36,12 +37,13 @@ from micropython import const
|
|
36
37
|
|
37
38
|
try:
|
38
39
|
from typing import Tuple
|
39
|
-
|
40
|
+
|
40
41
|
from busio import I2C
|
42
|
+
from circuitpython_typing import ReadableBuffer
|
41
43
|
except ImportError:
|
42
44
|
pass
|
43
45
|
|
44
|
-
__version__ = "2.
|
46
|
+
__version__ = "2.2.0"
|
45
47
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MLX90393.git"
|
46
48
|
|
47
49
|
_CMD_SB = const(0b00010000) # Start burst mode
|
@@ -60,7 +62,7 @@ _CMD_AXIS_ALL = const(0xE) # X+Y+Z axis bits for commands
|
|
60
62
|
_CMD_TEMP = const(0x01) # Temperature bit for commands
|
61
63
|
|
62
64
|
_CMD_REG_CONF1 = const(0x00) # Gain
|
63
|
-
_CMD_REG_CONF2 = const(0x01) # Burst, comm mode
|
65
|
+
_CMD_REG_CONF2 = const(0x01) # Burst, comm mode, temperature compensation
|
64
66
|
_CMD_REG_CONF3 = const(0x02) # Oversampling, Filter, Resolution
|
65
67
|
_CMD_REG_CONF4 = const(0x03) # Sensitivity drift
|
66
68
|
|
@@ -209,6 +211,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
209
211
|
resolution: int = RESOLUTION_16,
|
210
212
|
filt: int = FILTER_7,
|
211
213
|
oversampling: int = OSR_3,
|
214
|
+
temperature_compensation: bool = False,
|
212
215
|
debug: bool = False,
|
213
216
|
) -> None:
|
214
217
|
self.i2c_device = I2CDevice(i2c_bus, address)
|
@@ -218,6 +221,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
218
221
|
self._filter = filt
|
219
222
|
self._osr = oversampling
|
220
223
|
self._gain_current = gain
|
224
|
+
self._temperature_compensation = temperature_compensation
|
221
225
|
|
222
226
|
# Put the device in a known state to start
|
223
227
|
self.reset()
|
@@ -235,6 +239,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
235
239
|
|
236
240
|
# Set gain to the supplied level
|
237
241
|
self.gain = self._gain_current
|
242
|
+
self.temperature_compensation = self._temperature_compensation
|
238
243
|
|
239
244
|
def _transceive(self, payload: ReadableBuffer, rxlen: int = 0) -> bytearray:
|
240
245
|
"""
|
@@ -383,6 +388,20 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
383
388
|
self.write_reg(_CMD_REG_CONF3, reg)
|
384
389
|
self._osr = level
|
385
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
|
+
|
386
405
|
def display_status(self) -> None:
|
387
406
|
"""
|
388
407
|
Prints out the content of the last status byte in a human-readable
|
@@ -443,6 +462,7 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
443
462
|
"""
|
444
463
|
Performs a software reset of the sensor.
|
445
464
|
"""
|
465
|
+
self._transceive(bytes([_CMD_EX]))
|
446
466
|
if self._debug:
|
447
467
|
print("Resetting sensor")
|
448
468
|
time.sleep(2)
|
@@ -459,6 +479,22 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
459
479
|
"""
|
460
480
|
Reads a single X/Y/Z sample from the magnetometer.
|
461
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
|
+
|
462
498
|
# Set conversion delay based on filter and oversampling
|
463
499
|
delay = _TCONV_LOOKUP[self._filter][self._osr] / 1000 # per datasheet
|
464
500
|
delay *= 1.1 # plus a little
|
@@ -490,6 +526,9 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
490
526
|
elif resolution == RESOLUTION_18:
|
491
527
|
(value,) = struct.unpack(">H", data)
|
492
528
|
value -= 0x8000
|
529
|
+
elif self.temperature_compensation:
|
530
|
+
(value,) = struct.unpack(">H", data)
|
531
|
+
value -= 0x8000
|
493
532
|
else:
|
494
533
|
value = struct.unpack(">h", data)[0]
|
495
534
|
return value
|
@@ -1,6 +0,0 @@
|
|
1
|
-
adafruit_mlx90393.py,sha256=Eq_i3wioTBwNsQfr-Z-aeSkW5mvAx7GEWdXgK1c6VIc,18281
|
2
|
-
adafruit_circuitpython_mlx90393-2.1.4.dist-info/LICENSE,sha256=WeIXVkYWpdba3Boxrax8dB0s5qWg9GTxl7c5uTZQDUI,1105
|
3
|
-
adafruit_circuitpython_mlx90393-2.1.4.dist-info/METADATA,sha256=ES262PDC-d8JY8vvSwB8Wxp1Pvl9g9Fda3RJ2ksSbdw,4085
|
4
|
-
adafruit_circuitpython_mlx90393-2.1.4.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
5
|
-
adafruit_circuitpython_mlx90393-2.1.4.dist-info/top_level.txt,sha256=5RT_YbHfXFo2Y6zVvz8MXsZLIHm1OxrjFJrzRaCTdNY,18
|
6
|
-
adafruit_circuitpython_mlx90393-2.1.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|