16
16
17
17
**Hardware:**
18
18
19
- * Adafruit MSA301 Breakout https://www.adafruit.com/product/4344
19
+ * Adafruit `MSA301 Triple Axis Accelerometer
20
+ <https://www.adafruit.com/product/4344>`_
20
21
21
22
**Software and Dependencies:**
22
23
23
24
* Adafruit CircuitPython firmware for the supported boards:
24
- https://github.com/adafruit/circuitpython/releases
25
-
26
- * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27
- * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
25
+ https://circuitpython.org/downloads
26
+ * Adafruit's Bus Device library:
27
+ https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
28
+ * Adafruit's Register library:
29
+ https://github.com/adafruit/Adafruit_CircuitPython_Register
28
30
"""
29
31
30
32
__version__ = "0.0.0-auto.0"
63
65
64
66
class Mode : # pylint: disable=too-few-public-methods
65
67
"""An enum-like class representing the different modes that the MSA301 can
66
- use. The values can be referenced like `` Mode.NORMAL`` or `` Mode.SUSPEND` `
68
+ use. The values can be referenced like :attr:` Mode.NORMAL` or :attr:` Mode.SUSPEND`
67
69
Possible values are
68
70
69
- - ``Mode.NORMAL``
70
- - ``Mode.LOW_POWER``
71
- - ``Mode.SUSPEND``
71
+ - :attr:`Mode.NORMAL`
72
+ - :attr:`Mode.LOW_POWER`
73
+ - :attr:`Mode.SUSPEND`
74
+
72
75
"""
73
76
74
77
# pylint: disable=invalid-name
@@ -78,21 +81,24 @@ class Mode: # pylint: disable=too-few-public-methods
78
81
79
82
80
83
class DataRate : # pylint: disable=too-few-public-methods
81
- """An enum-like class representing the different data rates that the MSA301 can
82
- use. The values can be referenced like ``DataRate.RATE_1_HZ`` or ``DataRate.RATE_1000_HZ``
84
+ """An enum-like class representing the different
85
+ data rates that the MSA301 can
86
+ use. The values can be referenced like
87
+ :attr:`DataRate.RATE_1_HZ` or :attr:`DataRate.RATE_1000_HZ`
83
88
Possible values are
84
89
85
- - ``DataRate.RATE_1_HZ``
86
- - ``DataRate.RATE_1_95_HZ``
87
- - ``DataRate.RATE_3_9_HZ``
88
- - ``DataRate.RATE_7_81_HZ``
89
- - ``DataRate.RATE_15_63_HZ``
90
- - ``DataRate.RATE_31_25_HZ``
91
- - ``DataRate.RATE_62_5_HZ``
92
- - ``DataRate.RATE_125_HZ``
93
- - ``DataRate.RATE_250_HZ``
94
- - ``DataRate.RATE_500_HZ``
95
- - ``DataRate.RATE_1000_HZ``
90
+ - :attr:`DataRate.RATE_1_HZ`
91
+ - :attr:`DataRate.RATE_1_95_HZ`
92
+ - :attr:`DataRate.RATE_3_9_HZ`
93
+ - :attr:`DataRate.RATE_7_81_HZ`
94
+ - :attr:`DataRate.RATE_15_63_HZ`
95
+ - :attr:`DataRate.RATE_31_25_HZ`
96
+ - :attr:`DataRate.RATE_62_5_HZ`
97
+ - :attr:`DataRate.RATE_125_HZ`
98
+ - :attr:`DataRate.RATE_250_HZ`
99
+ - :attr:`DataRate.RATE_500_HZ`
100
+ - :attr:`DataRate.RATE_1000_HZ`
101
+
96
102
"""
97
103
98
104
RATE_1_HZ = 0b0000 # 1 Hz
@@ -109,21 +115,24 @@ class DataRate: # pylint: disable=too-few-public-methods
109
115
110
116
111
117
class BandWidth : # pylint: disable=too-few-public-methods
112
- """An enum-like class representing the different bandwidths that the MSA301 can
113
- use. The values can be referenced like ``BandWidth.WIDTH_1_HZ`` or ``BandWidth.RATE_500_HZ``
118
+ """An enum-like class representing the different
119
+ bandwidths that the MSA301 can
120
+ use. The values can be referenced
121
+ like :attr:`BandWidth.WIDTH_1_HZ` or :attr:`BandWidth.RATE_500_HZ`
114
122
Possible values are
115
123
116
- - ``BandWidth.RATE_1_HZ``
117
- - ``BandWidth.RATE_1_95_HZ``
118
- - ``BandWidth.RATE_3_9_HZ``
119
- - ``BandWidth.RATE_7_81_HZ``
120
- - ``BandWidth.RATE_15_63_HZ``
121
- - ``BandWidth.RATE_31_25_HZ``
122
- - ``BandWidth.RATE_62_5_HZ``
123
- - ``BandWidth.RATE_125_HZ``
124
- - ``BandWidth.RATE_250_HZ``
125
- - ``BandWidth.RATE_500_HZ``
126
- - ``BandWidth.RATE_1000_HZ``
124
+ - :attr:`BandWidth.RATE_1_HZ`
125
+ - :attr:`BandWidth.RATE_1_95_HZ`
126
+ - :attr:`BandWidth.RATE_3_9_HZ`
127
+ - :attr:`BandWidth.RATE_7_81_HZ`
128
+ - :attr:`BandWidth.RATE_15_63_HZ`
129
+ - :attr:`BandWidth.RATE_31_25_HZ`
130
+ - :attr:`BandWidth.RATE_62_5_HZ`
131
+ - :attr:`BandWidth.RATE_125_HZ`
132
+ - :attr:`BandWidth.RATE_250_HZ`
133
+ - :attr:`BandWidth.RATE_500_HZ`
134
+ - :attr:`BandWidth.RATE_1000_HZ`
135
+
127
136
"""
128
137
129
138
WIDTH_1_95_HZ = 0b0000 # 1.95 Hz
@@ -138,14 +147,17 @@ class BandWidth: # pylint: disable=too-few-public-methods
138
147
139
148
140
149
class Range : # pylint: disable=too-few-public-methods
141
- """An enum-like class representing the different acceleration measurement ranges that the
142
- MSA301 can use. The values can be referenced like ``Range.RANGE_2_G`` or ``Range.RANGE_16_G``
150
+ """An enum-like class representing the different
151
+ acceleration measurement ranges that the
152
+ MSA301 can use. The values can be referenced like
153
+ :attr:`Range.RANGE_2_G` or :attr:`Range.RANGE_16_G`
143
154
Possible values are
144
155
145
- - ``Range.RANGE_2_G``
146
- - ``Range.RANGE_4_G``
147
- - ``Range.RANGE_8_G``
148
- - ``Range.RANGE_16_G``
156
+ - :attr:`Range.RANGE_2_G`
157
+ - :attr:`Range.RANGE_4_G`
158
+ - :attr:`Range.RANGE_8_G`
159
+ - :attr:`Range.RANGE_16_G`
160
+
149
161
"""
150
162
151
163
RANGE_2_G = 0b00 # +/- 2g (default value)
@@ -155,14 +167,17 @@ class Range: # pylint: disable=too-few-public-methods
155
167
156
168
157
169
class Resolution : # pylint: disable=too-few-public-methods
158
- """An enum-like class representing the different measurement ranges that the MSA301 can
159
- use. The values can be referenced like ``Range.RANGE_2_G`` or ``Range.RANGE_16_G``
170
+ """An enum-like class representing the different
171
+ measurement ranges that the MSA301 can
172
+ use. The values can be referenced like
173
+ :attr:`Range.RANGE_2_G` or :attr:`Range.RANGE_16_G`
160
174
Possible values are
161
175
162
- - ``Resolution.RESOLUTION_14_BIT``
163
- - ``Resolution.RESOLUTION_12_BIT``
164
- - ``Resolution.RESOLUTION_10_BIT``
165
- - ``Resolution.RESOLUTION_8_BIT``
176
+ - :attr:`Resolution.RESOLUTION_14_BIT`
177
+ - :attr:`Resolution.RESOLUTION_12_BIT`
178
+ - :attr:`Resolution.RESOLUTION_10_BIT`
179
+ - :attr:`Resolution.RESOLUTION_8_BIT`
180
+
166
181
"""
167
182
168
183
RESOLUTION_14_BIT = 0b00
@@ -189,6 +204,31 @@ class MSA301: # pylint: disable=too-many-instance-attributes
189
204
"""Driver for the MSA301 Accelerometer.
190
205
191
206
:param ~busio.I2C i2c_bus: The I2C bus the MSA is connected to.
207
+
208
+
209
+ **Quickstart: Importing and using the device**
210
+
211
+ Here is an example of using the :class:`MSA301` class.
212
+ First you will need to import the libraries to use the sensor
213
+
214
+ .. code-block:: python
215
+
216
+ import board
217
+ import adafruit_msa301
218
+
219
+ Once this is done you can define your `board.I2C` object and define your sensor object
220
+
221
+ .. code-block:: python
222
+
223
+ i2c = board.I2C() # uses board.SCL and board.SDA
224
+ msa = adafruit_msa301.MSA301(i2c)
225
+
226
+ Now you have access to the :attr:`acceleration` attribute
227
+
228
+ .. code-block:: python
229
+
230
+ acc_x, acc_y, acc_z = msa.acceleration
231
+
192
232
"""
193
233
194
234
_part_id = ROUnaryStruct (_MSA301_REG_PARTID , "<B" )
@@ -235,7 +275,8 @@ def __init__(self, i2c_bus):
235
275
236
276
@property
237
277
def acceleration (self ):
238
- """The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2."""
278
+ """The x, y, z acceleration values returned in a
279
+ 3-tuple and are in :math:`m / s ^ 2`"""
239
280
# read the 6 bytes of acceleration data
240
281
241
282
current_range = self .range
@@ -278,13 +319,13 @@ def enable_tap_detection(
278
319
`True` (default) sets the value to 70ms, False to 50ms. Default is `True`
279
320
280
321
:param int long_quiet_window: The length of the "quiet" period after an acceleration\
281
- spike where no more spikes can occour for a tap to be registered.\
322
+ spike where no more spikes can occur for a tap to be registered.\
282
323
`True` (default) sets the value to 30ms, False to 20ms. Default is `True`.
283
324
284
325
:param int double_tap_window: The length of time after an initial tap is registered\
285
326
in which a second tap must be detected to count as a double tap. Setting a lower\
286
327
value will require a faster double tap. The value must be a\
287
- ``TapDuration``. Default is `` TapDuration.DURATION_250_MS` `.
328
+ ``TapDuration``. Default is :attr:` TapDuration.DURATION_250_MS`.
288
329
289
330
If you wish to set them yourself rather than using the defaults,
290
331
you must use keyword arguments::
0 commit comments