circuitpython-adxl36x 0.1.0__tar.gz → 0.2.1__tar.gz
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.
- circuitpython_adxl36x-0.2.1/PKG-INFO +153 -0
- circuitpython_adxl36x-0.2.1/README.md +131 -0
- circuitpython_adxl36x-0.2.1/adxl36x/__init__.py +1287 -0
- {circuitpython_adxl36x-0.1.0 → circuitpython_adxl36x-0.2.1}/pyproject.toml +11 -8
- {circuitpython_adxl36x-0.1.0 → circuitpython_adxl36x-0.2.1}/pyproject.toml.orig +9 -5
- circuitpython_adxl36x-0.1.0/PKG-INFO +0 -75
- circuitpython_adxl36x-0.1.0/README.md +0 -52
- circuitpython_adxl36x-0.1.0/src/adxl36x/__init__.py +0 -747
- {circuitpython_adxl36x-0.1.0 → circuitpython_adxl36x-0.2.1}/LICENSE +0 -0
- {circuitpython_adxl36x-0.1.0/src → circuitpython_adxl36x-0.2.1}/adxl36x/py.typed +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: circuitpython-adxl36x
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: CircuitPython driver for the Analog Devices ADXL366/ADXL367 accelerometers
|
|
5
|
+
Keywords: adxl366,adxl367,accelerometer,blinka,circuitpython,hardware,i2c,micropython,spi
|
|
6
|
+
Author: Mike Mabey
|
|
7
|
+
Author-email: Mike Mabey <email@mikemabey.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
14
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
15
|
+
Classifier: Topic :: System :: Hardware
|
|
16
|
+
Requires-Dist: circuitpython-stubs>=10.2.1
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Project-URL: Homepage, https://github.com/mmabey/circuitpython-adxl36x
|
|
19
|
+
Project-URL: Repository, https://github.com/mmabey/circuitpython-adxl36x
|
|
20
|
+
Project-URL: Issues, https://github.com/mmabey/circuitpython-adxl36x/issues
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# circuitpython-adxl36x
|
|
24
|
+
|
|
25
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
26
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
27
|
+
[](LICENSE)
|
|
28
|
+
[](https://github.com/mmabey/circuitpython-adxl36x/actions/workflows/ci.yml)
|
|
29
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
30
|
+
[](https://github.com/astral-sh/ruff)
|
|
31
|
+
|
|
32
|
+
CircuitPython driver for the Analog Devices [ADXL366](https://www.analog.com/en/products/adxl366.html) and
|
|
33
|
+
[ADXL367](https://www.analog.com/en/products/adxl367.html) ultra-low-power 3-axis MEMS accelerometers.
|
|
34
|
+
|
|
35
|
+
`ADXL367` implements the full shared register map and is the base class. `ADXL366` subclasses it, adding the pedometer,
|
|
36
|
+
Z-axis nonlinearity compensation, and activity/inactivity reference readback - the three features the ADXL367 silicon
|
|
37
|
+
doesn't implement. Both support SPI and I2C.
|
|
38
|
+
|
|
39
|
+
## Relationship to `adafruit_adxl34x`
|
|
40
|
+
|
|
41
|
+
This library's public API deliberately mirrors the shape of [Adafruit's
|
|
42
|
+
`adafruit_adxl34x`](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x) driver for the ADXL34x family
|
|
43
|
+
(`.acceleration`, `.events`, `enable_tap_detection()`, `enable_motion_detection()`, `data_rate`) so that code written
|
|
44
|
+
against a 34x-family chip needs minimal changes to run against a 366/367. The two chip families are **not**
|
|
45
|
+
register-compatible — only the driver's Python API shape is shared. Notable differences:
|
|
46
|
+
|
|
47
|
+
- `range` is named `g_range` here instead — `range` shadows the Python builtin, and compatibility with the ADXL34x API
|
|
48
|
+
takes a back seat to that on this one property.
|
|
49
|
+
- No `enable_freefall_detection()` — the 366/367 has no freefall-detection hardware.
|
|
50
|
+
- `Range` tops out at `RANGE_8_G` — the 366/367 doesn't support ±16g.
|
|
51
|
+
- `DataRate` only has 6 discrete rates (12.5 Hz-400 Hz) vs. the 34x's 16.
|
|
52
|
+
- `.events` includes many more keys (FIFO, pedometer, ADC/temperature thresholds) since the 366/367 exposes far more
|
|
53
|
+
interrupt sources.
|
|
54
|
+
|
|
55
|
+
## Supported features
|
|
56
|
+
|
|
57
|
+
✅ Supported 🚫 Not present on this chip 🚧 Not yet supported by this driver
|
|
58
|
+
|
|
59
|
+
| Feature | ADXL367 | ADXL366 |
|
|
60
|
+
| ----------------------------------------------------- | :-----: | :-----: |
|
|
61
|
+
| Acceleration (raw + scaled `m/s^2`) | ✅ | ✅ |
|
|
62
|
+
| `g_range` / `data_rate` | ✅ | ✅ |
|
|
63
|
+
| Power mode (standby / measurement) | ✅ | ✅ |
|
|
64
|
+
| Wake-up mode (`wakeup_mode`, `wakeup_rate`) | ✅ | ✅ |
|
|
65
|
+
| Linked/looped activity mode (`link_loop_mode`) | ✅ | ✅ |
|
|
66
|
+
| Autosleep (`autosleep`) | ✅ | ✅ |
|
|
67
|
+
| Motion (activity) detection | ✅ | ✅ |
|
|
68
|
+
| Inactivity detection (see note below on free fall) | ✅ | ✅ |
|
|
69
|
+
| Offset trim (`offset`) | ✅ | ✅ |
|
|
70
|
+
| Sensitivity trim (`sens`) | ✅ | ✅ |
|
|
71
|
+
| Axis masking (`tap_axis`, `blocked_axes`) | ✅ | ✅ |
|
|
72
|
+
| Keep-alive timer (`keep_alive_timer`) | ✅ | ✅ |
|
|
73
|
+
| FIFO (oldest-saved / stream / triggered) | ✅ | ✅ |
|
|
74
|
+
| Temperature sensor | ✅ | ✅ |
|
|
75
|
+
| External ADC value (`adc_value`) | ✅ | ✅ |
|
|
76
|
+
| Self-test (`self_test()`) | ✅ | ✅ |
|
|
77
|
+
| Tap detection (single/double) | ✅ | ✅ |
|
|
78
|
+
| Interrupt mapping (`map_interrupt`) / `.events` | ✅ | ✅ |
|
|
79
|
+
| Z-axis nonlinearity compensation | 🚫 | ✅ |
|
|
80
|
+
| Activity/inactivity reference readback | 🚫 | ✅ |
|
|
81
|
+
| Pedometer (`pedometer_enabled`, `steps`) | 🚫 | ✅ |
|
|
82
|
+
| Noise modes (low-noise / ultra-low-noise) | 🚧 | 🚧 |
|
|
83
|
+
| External ADC as activity/inactivity threshold source | 🚧 | 🚧 |
|
|
84
|
+
| External clock | 🚧 | 🚧 |
|
|
85
|
+
| External trigger | 🚧 | 🚧 |
|
|
86
|
+
|
|
87
|
+
**Free fall** isn't a separate feature/method - it's a documented usage pattern of absolute (non-referenced) inactivity
|
|
88
|
+
detection (`enable_inactivity_detection(referenced=False)`), already fully supported.
|
|
89
|
+
|
|
90
|
+
The 🚧 rows are real hardware features (confirmed present on both chips, same register addresses, per each chip's own
|
|
91
|
+
datasheet) that this driver doesn't expose yet - they need either extra wiring/signal sources not on the current
|
|
92
|
+
breadboard (external ADC input, external clock, external trigger) or aren't yet confirmed as needed by any downstream
|
|
93
|
+
project (noise modes). Contributions welcome.
|
|
94
|
+
|
|
95
|
+
## Installation
|
|
96
|
+
|
|
97
|
+
On a CircuitPython board, copy `adxl36x/` into `CIRCUITPY/lib/adxl36x/`. No other bundle libraries are required -
|
|
98
|
+
this driver talks to `busio.I2C`/`busio.SPI` directly.
|
|
99
|
+
|
|
100
|
+
For boards tight on RAM/flash, or if raw source ever fails to compile on-device, each [GitHub
|
|
101
|
+
release](https://github.com/mmabey/circuitpython-adxl36x/releases) also attaches a precompiled `.mpy` bundle
|
|
102
|
+
(`lib/adxl36x/__init__.mpy`) - unzip it and copy `lib/adxl36x/` into `CIRCUITPY/lib/` instead. It's compatible with
|
|
103
|
+
any CircuitPython release sharing the same `.mpy` bytecode version (stable across CircuitPython 9.0.0+ as of this
|
|
104
|
+
writing) - not just the exact version it was built against.
|
|
105
|
+
|
|
106
|
+
For host-side development (type checking, tests) in another project:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv add --editable ~/src/circuitpython-adxl36x
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Hardware validation setup
|
|
113
|
+
|
|
114
|
+
The `examples/hw_*.py` scripts and `examples/hw_checks.py` exercise real silicon and are set up to run against a
|
|
115
|
+
`doit_esp32_devkit_v1` board wired to an [EVAL-ADXL366Z](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/eval-adxl366z.html)
|
|
116
|
+
breakout, over either I2C or SPI:
|
|
117
|
+
|
|
118
|
+
**I2C** (`hw_sanity_check.py` / `hw_interactive_check.py` - edit their `board.I2C()` call to
|
|
119
|
+
`busio.I2C(board.D26, board.D33)` to match these pins):
|
|
120
|
+
|
|
121
|
+
| Signal | GPIO |
|
|
122
|
+
| ------ | ---- |
|
|
123
|
+
| SDA | 33 |
|
|
124
|
+
| SCL | 26 |
|
|
125
|
+
| INT1 | 27 |
|
|
126
|
+
| INT2 | 14 |
|
|
127
|
+
|
|
128
|
+
The EVAL-ADXL366Z has no onboard I2C pull-ups - add external 4.7kOhm pull-ups from SDA and SCL
|
|
129
|
+
to 3.3V.
|
|
130
|
+
|
|
131
|
+
**SPI** (`hw_spi_sanity_check.py` / `hw_spi_interactive_check.py`):
|
|
132
|
+
|
|
133
|
+
| Signal | GPIO |
|
|
134
|
+
| ------ | ---- |
|
|
135
|
+
| SCK | 18 |
|
|
136
|
+
| MOSI | 23 |
|
|
137
|
+
| MISO | 19 |
|
|
138
|
+
| CS | 26 |
|
|
139
|
+
| INT1 | 27 |
|
|
140
|
+
| INT2 | 14 |
|
|
141
|
+
|
|
142
|
+
INT1/INT2 are only needed for the interactive checks (motion/inactivity/tap interrupts, autosleep wake cycle,
|
|
143
|
+
orientation, pedometer) - the non-interactive sanity checks only need the data bus.
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
uv sync
|
|
149
|
+
uv run ruff check --fix
|
|
150
|
+
uv run ruff format
|
|
151
|
+
uv run ty check
|
|
152
|
+
uv run pytest
|
|
153
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# circuitpython-adxl36x
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
4
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://github.com/mmabey/circuitpython-adxl36x/actions/workflows/ci.yml)
|
|
7
|
+
[](https://pypi.org/project/circuitpython-adxl36x/)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
|
|
10
|
+
CircuitPython driver for the Analog Devices [ADXL366](https://www.analog.com/en/products/adxl366.html) and
|
|
11
|
+
[ADXL367](https://www.analog.com/en/products/adxl367.html) ultra-low-power 3-axis MEMS accelerometers.
|
|
12
|
+
|
|
13
|
+
`ADXL367` implements the full shared register map and is the base class. `ADXL366` subclasses it, adding the pedometer,
|
|
14
|
+
Z-axis nonlinearity compensation, and activity/inactivity reference readback - the three features the ADXL367 silicon
|
|
15
|
+
doesn't implement. Both support SPI and I2C.
|
|
16
|
+
|
|
17
|
+
## Relationship to `adafruit_adxl34x`
|
|
18
|
+
|
|
19
|
+
This library's public API deliberately mirrors the shape of [Adafruit's
|
|
20
|
+
`adafruit_adxl34x`](https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x) driver for the ADXL34x family
|
|
21
|
+
(`.acceleration`, `.events`, `enable_tap_detection()`, `enable_motion_detection()`, `data_rate`) so that code written
|
|
22
|
+
against a 34x-family chip needs minimal changes to run against a 366/367. The two chip families are **not**
|
|
23
|
+
register-compatible — only the driver's Python API shape is shared. Notable differences:
|
|
24
|
+
|
|
25
|
+
- `range` is named `g_range` here instead — `range` shadows the Python builtin, and compatibility with the ADXL34x API
|
|
26
|
+
takes a back seat to that on this one property.
|
|
27
|
+
- No `enable_freefall_detection()` — the 366/367 has no freefall-detection hardware.
|
|
28
|
+
- `Range` tops out at `RANGE_8_G` — the 366/367 doesn't support ±16g.
|
|
29
|
+
- `DataRate` only has 6 discrete rates (12.5 Hz-400 Hz) vs. the 34x's 16.
|
|
30
|
+
- `.events` includes many more keys (FIFO, pedometer, ADC/temperature thresholds) since the 366/367 exposes far more
|
|
31
|
+
interrupt sources.
|
|
32
|
+
|
|
33
|
+
## Supported features
|
|
34
|
+
|
|
35
|
+
✅ Supported 🚫 Not present on this chip 🚧 Not yet supported by this driver
|
|
36
|
+
|
|
37
|
+
| Feature | ADXL367 | ADXL366 |
|
|
38
|
+
| ----------------------------------------------------- | :-----: | :-----: |
|
|
39
|
+
| Acceleration (raw + scaled `m/s^2`) | ✅ | ✅ |
|
|
40
|
+
| `g_range` / `data_rate` | ✅ | ✅ |
|
|
41
|
+
| Power mode (standby / measurement) | ✅ | ✅ |
|
|
42
|
+
| Wake-up mode (`wakeup_mode`, `wakeup_rate`) | ✅ | ✅ |
|
|
43
|
+
| Linked/looped activity mode (`link_loop_mode`) | ✅ | ✅ |
|
|
44
|
+
| Autosleep (`autosleep`) | ✅ | ✅ |
|
|
45
|
+
| Motion (activity) detection | ✅ | ✅ |
|
|
46
|
+
| Inactivity detection (see note below on free fall) | ✅ | ✅ |
|
|
47
|
+
| Offset trim (`offset`) | ✅ | ✅ |
|
|
48
|
+
| Sensitivity trim (`sens`) | ✅ | ✅ |
|
|
49
|
+
| Axis masking (`tap_axis`, `blocked_axes`) | ✅ | ✅ |
|
|
50
|
+
| Keep-alive timer (`keep_alive_timer`) | ✅ | ✅ |
|
|
51
|
+
| FIFO (oldest-saved / stream / triggered) | ✅ | ✅ |
|
|
52
|
+
| Temperature sensor | ✅ | ✅ |
|
|
53
|
+
| External ADC value (`adc_value`) | ✅ | ✅ |
|
|
54
|
+
| Self-test (`self_test()`) | ✅ | ✅ |
|
|
55
|
+
| Tap detection (single/double) | ✅ | ✅ |
|
|
56
|
+
| Interrupt mapping (`map_interrupt`) / `.events` | ✅ | ✅ |
|
|
57
|
+
| Z-axis nonlinearity compensation | 🚫 | ✅ |
|
|
58
|
+
| Activity/inactivity reference readback | 🚫 | ✅ |
|
|
59
|
+
| Pedometer (`pedometer_enabled`, `steps`) | 🚫 | ✅ |
|
|
60
|
+
| Noise modes (low-noise / ultra-low-noise) | 🚧 | 🚧 |
|
|
61
|
+
| External ADC as activity/inactivity threshold source | 🚧 | 🚧 |
|
|
62
|
+
| External clock | 🚧 | 🚧 |
|
|
63
|
+
| External trigger | 🚧 | 🚧 |
|
|
64
|
+
|
|
65
|
+
**Free fall** isn't a separate feature/method - it's a documented usage pattern of absolute (non-referenced) inactivity
|
|
66
|
+
detection (`enable_inactivity_detection(referenced=False)`), already fully supported.
|
|
67
|
+
|
|
68
|
+
The 🚧 rows are real hardware features (confirmed present on both chips, same register addresses, per each chip's own
|
|
69
|
+
datasheet) that this driver doesn't expose yet - they need either extra wiring/signal sources not on the current
|
|
70
|
+
breadboard (external ADC input, external clock, external trigger) or aren't yet confirmed as needed by any downstream
|
|
71
|
+
project (noise modes). Contributions welcome.
|
|
72
|
+
|
|
73
|
+
## Installation
|
|
74
|
+
|
|
75
|
+
On a CircuitPython board, copy `adxl36x/` into `CIRCUITPY/lib/adxl36x/`. No other bundle libraries are required -
|
|
76
|
+
this driver talks to `busio.I2C`/`busio.SPI` directly.
|
|
77
|
+
|
|
78
|
+
For boards tight on RAM/flash, or if raw source ever fails to compile on-device, each [GitHub
|
|
79
|
+
release](https://github.com/mmabey/circuitpython-adxl36x/releases) also attaches a precompiled `.mpy` bundle
|
|
80
|
+
(`lib/adxl36x/__init__.mpy`) - unzip it and copy `lib/adxl36x/` into `CIRCUITPY/lib/` instead. It's compatible with
|
|
81
|
+
any CircuitPython release sharing the same `.mpy` bytecode version (stable across CircuitPython 9.0.0+ as of this
|
|
82
|
+
writing) - not just the exact version it was built against.
|
|
83
|
+
|
|
84
|
+
For host-side development (type checking, tests) in another project:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
uv add --editable ~/src/circuitpython-adxl36x
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Hardware validation setup
|
|
91
|
+
|
|
92
|
+
The `examples/hw_*.py` scripts and `examples/hw_checks.py` exercise real silicon and are set up to run against a
|
|
93
|
+
`doit_esp32_devkit_v1` board wired to an [EVAL-ADXL366Z](https://www.analog.com/en/resources/evaluation-hardware-and-software/evaluation-boards-kits/eval-adxl366z.html)
|
|
94
|
+
breakout, over either I2C or SPI:
|
|
95
|
+
|
|
96
|
+
**I2C** (`hw_sanity_check.py` / `hw_interactive_check.py` - edit their `board.I2C()` call to
|
|
97
|
+
`busio.I2C(board.D26, board.D33)` to match these pins):
|
|
98
|
+
|
|
99
|
+
| Signal | GPIO |
|
|
100
|
+
| ------ | ---- |
|
|
101
|
+
| SDA | 33 |
|
|
102
|
+
| SCL | 26 |
|
|
103
|
+
| INT1 | 27 |
|
|
104
|
+
| INT2 | 14 |
|
|
105
|
+
|
|
106
|
+
The EVAL-ADXL366Z has no onboard I2C pull-ups - add external 4.7kOhm pull-ups from SDA and SCL
|
|
107
|
+
to 3.3V.
|
|
108
|
+
|
|
109
|
+
**SPI** (`hw_spi_sanity_check.py` / `hw_spi_interactive_check.py`):
|
|
110
|
+
|
|
111
|
+
| Signal | GPIO |
|
|
112
|
+
| ------ | ---- |
|
|
113
|
+
| SCK | 18 |
|
|
114
|
+
| MOSI | 23 |
|
|
115
|
+
| MISO | 19 |
|
|
116
|
+
| CS | 26 |
|
|
117
|
+
| INT1 | 27 |
|
|
118
|
+
| INT2 | 14 |
|
|
119
|
+
|
|
120
|
+
INT1/INT2 are only needed for the interactive checks (motion/inactivity/tap interrupts, autosleep wake cycle,
|
|
121
|
+
orientation, pedometer) - the non-interactive sanity checks only need the data bus.
|
|
122
|
+
|
|
123
|
+
## Development
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
uv sync
|
|
127
|
+
uv run ruff check --fix
|
|
128
|
+
uv run ruff format
|
|
129
|
+
uv run ty check
|
|
130
|
+
uv run pytest
|
|
131
|
+
```
|