1212
1313Based on drivers by K. Townsend and Tony DiCola
1414
15+
1516Implementation Notes
1617--------------------
1718
1819**Hardware:**
19- https://www.adafruit.com/product/1231
20+
21+ * Adafruit `ADXL345 Digital Accelerometer
22+ <https://www.adafruit.com/product/1231>`_ (Product ID: 1231)
2023
2124**Software and Dependencies:**
2225
2326* Adafruit CircuitPython firmware for the supported boards:
24- https://github.com/adafruit/circuitpython/releases
27+ https://circuitpython.org/downloads
2528
2629* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2730"""
@@ -140,8 +143,32 @@ class Range: # pylint: disable=too-few-public-methods
140143class ADXL345 :
141144 """Driver for the ADXL345 3 axis accelerometer
142145
143- :param ~busio.I2C i2c_bus: The I2C bus the ADXL345 is connected to.
144- :param address: The I2C device address for the sensor. Default is ``0x53``.
146+ :param ~busio.I2C i2c: The I2C bus the ADXL345 is connected to.
147+ :param address: The I2C device address for the sensor. Default is :const:`0x53`.
148+
149+ **Quickstart: Importing and using the device**
150+
151+ Here is an example of using the :class:`ADXL345` class.
152+ First you will need to import the libraries to use the sensor
153+
154+ .. code-block:: python
155+
156+ import board
157+ import adafruit_adxl34x
158+
159+ Once this is done you can define your `board.I2C` object and define your sensor object
160+
161+ .. code-block:: python
162+
163+ i2c = board.I2C() # uses board.SCL and board.SDA
164+ accelerometer = adafruit_adxl34x.ADXL343(i2c)
165+
166+
167+ Now you have access to the :attr:`acceleration` attribute
168+
169+ .. code-block:: python
170+
171+ acceleration = accelerometer.acceleration
145172
146173 """
147174
@@ -158,7 +185,7 @@ def __init__(self, i2c, address=_ADXL345_DEFAULT_ADDRESS):
158185
159186 @property
160187 def acceleration (self ):
161- """The x, y, z acceleration values returned in a 3-tuple in m / s ^ 2. """
188+ """The x, y, z acceleration values returned in a 3-tuple in :math:` m / s ^ 2` """
162189 x , y , z = unpack ("<hhh" , self ._read_register (_REG_DATAX0 , 6 ))
163190 x = x * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
164191 y = y * _ADXL345_MG2G_MULTIPLIER * _STANDARD_GRAVITY
@@ -168,7 +195,8 @@ def acceleration(self):
168195 @property
169196 def events (self ):
170197 """
171- ``events`` will return a dictionary with a key for each event type that has been enabled.
198+ :attr:`events` will return a dictionary with a key for each
199+ event type that has been enabled.
172200 The possible keys are:
173201
174202 +------------+----------------------------------------------------------------------------+
@@ -255,11 +283,13 @@ def enable_freefall_detection(self, *, threshold=10, time=25):
255283 register as dropped. The scale factor is 62.5 mg/LSB.
256284
257285 :param int time: The amount of time that acceleration on all axes must be less than\
258- ``threshhold `` to register as dropped. The scale factor is 5 ms/LSB. Values between 100 ms\
286+ ``threshold `` to register as dropped. The scale factor is 5 ms/LSB. Values between 100 ms\
259287 and 350 ms (20 to 70) are recommended.
260288
261289 If you wish to set them yourself rather than using the defaults,
262- you must use keyword arguments::
290+ you must use keyword arguments:
291+
292+ .. code-block:: python
263293
264294 accelerometer.enable_freefall_detection(time=30)
265295
@@ -294,19 +324,20 @@ def enable_tap_detection(
294324 :param int threshold: A threshold for the tap detection. The scale factor is 62.5 mg/LSB\
295325 The higher the value the less sensitive the detection.
296326
297-
298- :param int duration: This caps the duration of the impulse above ``threshhold``.\
327+ :param int duration: This caps the duration of the impulse above ``threshold``.\
299328 Anything above ``duration`` won't register as a tap. The scale factor is 625 µs/LSB
300329
301- :param int latency(double tap only): The length of time after the initial impulse\
330+ :param int latency: (double tap only) The length of time after the initial impulse\
302331 falls below ``threshold`` to start the window looking for a second impulse.\
303332 The scale factor is 1.25 ms/LSB.
304333
305- :param int window(double tap only): The length of the window in which to look for a\
334+ :param int window: (double tap only) The length of the window in which to look for a\
306335 second tap. The scale factor is 1.25 ms/LSB
307336
308337 If you wish to set them yourself rather than using the defaults,
309- you must use keyword arguments::
338+ you must use keyword arguments:
339+
340+ .. code-block:: python
310341
311342 accelerometer.enable_tap_detection(duration=30, threshold=25)
312343
0 commit comments