adafruit-circuitpython-mlx90393 2.1.3__tar.gz → 2.3.2__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.readthedocs.yaml +3 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/PKG-INFO +2 -2
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_circuitpython_mlx90393.egg-info/PKG-INFO +2 -2
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_mlx90393.py +98 -10
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/conf.py +0 -1
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/pyproject.toml +1 -1
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.github/workflows/build.yml +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.github/workflows/failure-help-text.yml +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.github/workflows/release_gh.yml +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.github/workflows/release_pypi.yml +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.gitignore +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.pre-commit-config.yaml +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/.pylintrc +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/CODE_OF_CONDUCT.md +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/LICENSE +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/LICENSES/CC-BY-4.0.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/LICENSES/MIT.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/LICENSES/Unlicense.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/README.rst +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/README.rst.license +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_circuitpython_mlx90393.egg-info/SOURCES.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_circuitpython_mlx90393.egg-info/dependency_links.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_circuitpython_mlx90393.egg-info/requires.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_circuitpython_mlx90393.egg-info/top_level.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/_static/favicon.ico +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/_static/favicon.ico.license +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/api.rst +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/api.rst.license +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/examples.rst +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/examples.rst.license +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/index.rst +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/index.rst.license +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/requirements.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/examples/mlx90393_simpletest.py +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/examples/mlx90393_temperature.py +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/optional_requirements.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/requirements.txt +0 -0
- {adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: adafruit-circuitpython-mlx90393
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.3.2
|
4
4
|
Summary: CircuitPython driver for the MLX90393 3-axis magnetometer.
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
6
6
|
License: MIT
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: adafruit-circuitpython-mlx90393
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.3.2
|
4
4
|
Summary: CircuitPython driver for the MLX90393 3-axis magnetometer.
|
5
5
|
Author-email: Adafruit Industries <circuitpython@adafruit.com>
|
6
6
|
License: MIT
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/adafruit_mlx90393.py
RENAMED
@@ -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.3.2"
|
45
47
|
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MLX90393.git"
|
46
48
|
|
47
49
|
_CMD_SB = const(0b00010000) # Start burst mode
|
@@ -60,9 +62,12 @@ _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
|
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
|
66
71
|
|
67
72
|
# Gain settings
|
68
73
|
GAIN_5X = 0x0
|
@@ -209,6 +214,8 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
209
214
|
resolution: int = RESOLUTION_16,
|
210
215
|
filt: int = FILTER_7,
|
211
216
|
oversampling: int = OSR_3,
|
217
|
+
temperature_compensation: bool = False,
|
218
|
+
offset: int = 0,
|
212
219
|
debug: bool = False,
|
213
220
|
) -> None:
|
214
221
|
self.i2c_device = I2CDevice(i2c_bus, address)
|
@@ -218,6 +225,8 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
218
225
|
self._filter = filt
|
219
226
|
self._osr = oversampling
|
220
227
|
self._gain_current = gain
|
228
|
+
self._temperature_compensation = temperature_compensation
|
229
|
+
self._off_x = self._off_y = self._off_z = offset
|
221
230
|
|
222
231
|
# Put the device in a known state to start
|
223
232
|
self.reset()
|
@@ -235,6 +244,12 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
235
244
|
|
236
245
|
# Set gain to the supplied level
|
237
246
|
self.gain = self._gain_current
|
247
|
+
self.temperature_compensation = self._temperature_compensation
|
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
|
238
253
|
|
239
254
|
def _transceive(self, payload: ReadableBuffer, rxlen: int = 0) -> bytearray:
|
240
255
|
"""
|
@@ -383,6 +398,62 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
383
398
|
self.write_reg(_CMD_REG_CONF3, reg)
|
384
399
|
self._osr = level
|
385
400
|
|
401
|
+
@property
|
402
|
+
def temperature_compensation(self) -> bool:
|
403
|
+
"""The temperature compensation setting"""
|
404
|
+
return self._temperature_compensation
|
405
|
+
|
406
|
+
@temperature_compensation.setter
|
407
|
+
def temperature_compensation(self, temperature_compensation: bool) -> None:
|
408
|
+
reg = self.read_reg(_CMD_REG_CONF2)
|
409
|
+
t_cmp_bit = 10
|
410
|
+
reg &= ~(1 << t_cmp_bit)
|
411
|
+
reg |= temperature_compensation << t_cmp_bit
|
412
|
+
self.write_reg(_CMD_REG_CONF2, reg)
|
413
|
+
self._temperature_compensation = temperature_compensation
|
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
|
+
|
386
457
|
def display_status(self) -> None:
|
387
458
|
"""
|
388
459
|
Prints out the content of the last status byte in a human-readable
|
@@ -406,15 +477,12 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
406
477
|
|
407
478
|
:param int reg: The register to read
|
408
479
|
"""
|
409
|
-
#
|
480
|
+
# Read register
|
410
481
|
payload = bytes([_CMD_RR, reg << 2])
|
411
|
-
with self.i2c_device as i2c:
|
412
|
-
i2c.write(payload)
|
413
|
-
|
414
|
-
# Read the response (+1 to account for the mandatory status byte!)
|
415
482
|
data = bytearray(3)
|
416
483
|
with self.i2c_device as i2c:
|
417
|
-
i2c.
|
484
|
+
i2c.write_then_readinto(payload, data)
|
485
|
+
|
418
486
|
# Unpack data (status byte, big-endian 16-bit register value)
|
419
487
|
self._status_last, val = struct.unpack(">BH", data)
|
420
488
|
if self._debug:
|
@@ -446,9 +514,10 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
446
514
|
"""
|
447
515
|
Performs a software reset of the sensor.
|
448
516
|
"""
|
517
|
+
self._transceive(bytes([_CMD_EX]))
|
449
518
|
if self._debug:
|
450
519
|
print("Resetting sensor")
|
451
|
-
time.sleep(
|
520
|
+
time.sleep(0.002)
|
452
521
|
self._transceive(bytes([_CMD_RT]))
|
453
522
|
# burn a read post reset
|
454
523
|
try:
|
@@ -462,6 +531,22 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
462
531
|
"""
|
463
532
|
Reads a single X/Y/Z sample from the magnetometer.
|
464
533
|
"""
|
534
|
+
|
535
|
+
resolutions = {self.resolution_x, self.resolution_y, self.resolution_z}
|
536
|
+
valid_tcomp_resolutions = {RESOLUTION_16, RESOLUTION_17}
|
537
|
+
if self._temperature_compensation and not resolutions.issubset(
|
538
|
+
valid_tcomp_resolutions
|
539
|
+
):
|
540
|
+
resolutions_output = f"""Current Resolutions:
|
541
|
+
\tresolution_x: {self.resolution_x}
|
542
|
+
\tresolution_y: {self.resolution_y}
|
543
|
+
\tresolution_z: {self.resolution_z}"""
|
544
|
+
|
545
|
+
raise ValueError(
|
546
|
+
"All resolutions must be RESOLUTION_16 or RESOLUTION_17"
|
547
|
+
f" if temperature compensation is enabled.\n {resolutions_output}"
|
548
|
+
)
|
549
|
+
|
465
550
|
# Set conversion delay based on filter and oversampling
|
466
551
|
delay = _TCONV_LOOKUP[self._filter][self._osr] / 1000 # per datasheet
|
467
552
|
delay *= 1.1 # plus a little
|
@@ -493,6 +578,9 @@ class MLX90393: # pylint: disable=too-many-instance-attributes
|
|
493
578
|
elif resolution == RESOLUTION_18:
|
494
579
|
(value,) = struct.unpack(">H", data)
|
495
580
|
value -= 0x8000
|
581
|
+
elif self.temperature_compensation:
|
582
|
+
(value,) = struct.unpack(">H", data)
|
583
|
+
value -= 0x8000
|
496
584
|
else:
|
497
585
|
value = struct.unpack(">h", data)[0]
|
498
586
|
return value
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/conf.py
RENAMED
@@ -112,7 +112,6 @@ napoleon_numpy_docstring = False
|
|
112
112
|
import sphinx_rtd_theme
|
113
113
|
|
114
114
|
html_theme = "sphinx_rtd_theme"
|
115
|
-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
|
116
115
|
|
117
116
|
# Add any paths that contain custom static files (such as style sheets) here,
|
118
117
|
# relative to this directory. They are copied after the builtin static files,
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/pyproject.toml
RENAMED
@@ -12,7 +12,7 @@ requires = [
|
|
12
12
|
[project]
|
13
13
|
name = "adafruit-circuitpython-mlx90393"
|
14
14
|
description = "CircuitPython driver for the MLX90393 3-axis magnetometer."
|
15
|
-
version = "2.
|
15
|
+
version = "2.3.2"
|
16
16
|
readme = "README.rst"
|
17
17
|
authors = [
|
18
18
|
{name = "Adafruit Industries", email = "circuitpython@adafruit.com"}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/CODE_OF_CONDUCT.md
RENAMED
File without changes
|
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/LICENSES/MIT.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/README.rst.license
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/api.rst
RENAMED
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/api.rst.license
RENAMED
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/examples.rst
RENAMED
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/docs/index.rst
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{adafruit-circuitpython-mlx90393-2.1.3 → adafruit_circuitpython_mlx90393-2.3.2}/requirements.txt
RENAMED
File without changes
|
File without changes
|