2727
2828**Software and Dependencies:** 
2929
30- * Adafruit CircuitPython firmware for the ESP8622 and M0-based  boards: 
31-   https://github.com/adafruit/circuitpython/releases  
30+ * Adafruit CircuitPython firmware for the supported  boards: 
31+   https://circuitpython.org/downloads  
3232* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice 
3333""" 
3434
8585
8686
8787class  LIS3DH :
88-     """Driver base for the LIS3DH accelerometer.""" 
88+     """Driver base for the LIS3DH accelerometer. 
89+ 
90+     :param digitalio.DigitalInOut int1. pin on the sensor that would 
91+     act as an in interrupt 
92+     :param digitalio.DigitalInOut int2. pin on the sensor that would 
93+     act as an in interrupt 
94+ 
95+     """ 
8996
9097    def  __init__ (self , int1 = None , int2 = None ):
9198        # Check device ID. 
@@ -115,10 +122,22 @@ def __init__(self, int1=None, int2=None):
115122
116123    @property  
117124    def  data_rate (self ):
118-         """The data rate of the accelerometer.  Can be DATA_RATE_400_HZ, DATA_RATE_200_HZ, 
119-         DATA_RATE_100_HZ, DATA_RATE_50_HZ, DATA_RATE_25_HZ, DATA_RATE_10_HZ, 
120-         DATA_RATE_1_HZ, DATA_RATE_POWERDOWN, DATA_RATE_LOWPOWER_1K6HZ, or 
121-         DATA_RATE_LOWPOWER_5KHZ.""" 
125+         """The data rate of the accelerometer. 
126+ 
127+         Could have the following values: 
128+ 
129+         * DATA_RATE_400_HZ 
130+         * DATA_RATE_200_HZ 
131+         * DATA_RATE_100_HZ 
132+         * DATA_RATE_50_HZ 
133+         * DATA_RATE_25_HZ 
134+         * DATA_RATE_10_HZ 
135+         * DATA_RATE_1_HZ 
136+         * DATA_RATE_POWERDOWN 
137+         * DATA_RATE_LOWPOWER_1K6HZ 
138+         * DATA_RATE_LOWPOWER_5KHZ. 
139+ 
140+         """ 
122141        ctl1  =  self ._read_register_byte (_REG_CTRL1 )
123142        return  (ctl1  >>  4 ) &  0x0F 
124143
@@ -131,8 +150,16 @@ def data_rate(self, rate):
131150
132151    @property  
133152    def  range (self ):
134-         """The range of the accelerometer.  Can be RANGE_2_G, RANGE_4_G, RANGE_8_G, or 
135-         RANGE_16_G.""" 
153+         """The range of the accelerometer. 
154+ 
155+         Could have the following values: 
156+ 
157+         * RANGE_2_G 
158+         * RANGE_4_G 
159+         * RANGE_8_G 
160+         * RANGE_16_G. 
161+ 
162+         """ 
136163        ctl4  =  self ._read_register_byte (_REG_CTRL4 )
137164        return  (ctl4  >>  4 ) &  0x03 
138165
@@ -145,7 +172,8 @@ def range(self, range_value):
145172
146173    @property  
147174    def  acceleration (self ):
148-         """The x, y, z acceleration values returned in a 3-tuple and are in m / s ^ 2.""" 
175+         """The x, y, z acceleration values returned 
176+         in a 3-tuple and are in :math:`m / s ^ 2`""" 
149177        divider  =  1 
150178        accel_range  =  self .range 
151179        if  accel_range  ==  RANGE_16_G :
@@ -167,21 +195,23 @@ def acceleration(self):
167195        return  AccelerationTuple (x , y , z )
168196
169197    def  shake (self , shake_threshold = 30 , avg_count = 10 , total_delay = 0.1 ):
170-         """ 
171-         Detect when the accelerometer is shaken. Optional parameters: 
198+         """Detect when the accelerometer is shaken. Optional parameters: 
199+ 
200+         :param int shake_threshold: Increase or decrease to change shake sensitivity. 
201+                                     This requires a minimum value of 10. 
202+                                     10 is the total acceleration if the board is not 
203+                                     moving, therefore anything less than 
204+                                     10 will erroneously report a constant shake detected. 
205+                                     Defaults to :const:`30` 
172206
173-         :param shake_threshold: Increase or decrease to change shake sensitivity. This 
174-                                 requires a minimum value of 10. 10 is the total 
175-                                 acceleration if the board is not moving, therefore 
176-                                 anything less than 10 will erroneously report a constant 
177-                                 shake detected. (Default 30) 
207+         :param int avg_count: The number of readings taken and used for the average 
208+                               acceleration. Default to :const:`10` 
178209
179-         :param avg_count : The number of readings taken and used for the average  
180-                           acceleration. (Default 10)  
210+         :param float total_delay : The total time in seconds it takes to obtain avg_count  
211+                                   readings from  acceleration. Defaults to :const:`0.1`  
181212
182-         :param total_delay: The total time in seconds it takes to obtain avg_count 
183-                             readings from acceleration. (Default 0.1) 
184213        """ 
214+ 
185215        shake_accel  =  (0 , 0 , 0 )
186216        for  _  in  range (avg_count ):
187217            # shake_accel creates a list of tuples from acceleration data. 
@@ -198,7 +228,7 @@ def shake(self, shake_threshold=30, avg_count=10, total_delay=0.1):
198228        return  total_accel  >  shake_threshold 
199229
200230    def  read_adc_raw (self , adc ):
201-         """Retrieve the raw analog to digital converter value.   ADC must be a 
231+         """Retrieve the raw analog to digital converter value. ADC must be a 
202232        value 1, 2, or 3. 
203233        """ 
204234        if  adc  <  1  or  adc  >  3 :
@@ -230,18 +260,19 @@ def read_adc_mV(self, adc):  # pylint: disable=invalid-name
230260    def  tapped (self ):
231261        """ 
232262        True if a tap was detected recently. Whether its a single tap or double tap is 
233-         determined by the tap param on `` set_tap``. `` tapped` ` may be True over 
263+         determined by the tap param on :attr:` set_tap`. :attr:` tapped` may be True over 
234264        multiple reads even if only a single tap or single double tap occurred if the 
235265        interrupt (int) pin is not specified. 
236266
237-         The following example uses ``i2c` ` and specifies the interrupt pin: 
267+         The following example uses `board.I2C ` and specifies the interrupt pin: 
238268
239269        .. code-block:: python 
240270
241271            import adafruit_lis3dh 
242272            import digitalio 
273+             import board 
243274
244-             i2c = busio .I2C(board.SCL,  board.SDA)  
275+             i2c = board .I2C()  # uses  board.SCL and  board.SDA 
245276            int1 = digitalio.DigitalInOut(board.D11) # pin connected to interrupt 
246277            lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) 
247278            lis3dh.range = adafruit_lis3dh.RANGE_8_G 
@@ -275,10 +306,11 @@ def set_tap(
275306                              the accelerometer range.  Good values are 5-10 for 16G, 
276307                              10-20 for 8G, 20-40 for 4G, and 40-80 for 2G. 
277308
278-         :param int time_limit: TIME_LIMIT register value (default 10).  
279-         :param int time_latency: TIME_LATENCY register value (default 20).  
280-         :param int time_window: TIME_WINDOW register value (default  255).  
309+         :param int time_limit: TIME_LIMIT register value. Defaults to :const:`10`  
310+         :param int time_latency: TIME_LATENCY register value. Defaults to :const:`20`  
311+         :param int time_window: TIME_WINDOW register value. Defaults to :const:` 255`  
281312        :param int click_cfg: CLICK_CFG register value. 
313+ 
282314        """ 
283315        if  (tap  <  0  or  tap  >  2 ) and  click_cfg  is  None :
284316            raise  ValueError (
@@ -324,7 +356,37 @@ def _write_register_byte(self, register, value):
324356
325357
326358class  LIS3DH_I2C (LIS3DH ):
327-     """Driver for the LIS3DH accelerometer connected over I2C.""" 
359+     """Driver for the LIS3DH accelerometer connected over I2C. 
360+ 
361+     :param ~busio.I2C i2c: The I2C bus the LIS3DH is connected to. 
362+     :param address: The I2C device address. Defaults to :const:`0x18` 
363+ 
364+ 
365+     **Quickstart: Importing and using the device** 
366+ 
367+         Here is an example of using the :class:`LIS3DH_I2C` class. 
368+         First you will need to import the libraries to use the sensor 
369+ 
370+         .. code-block:: python 
371+ 
372+             import board 
373+             import adafruit_lis3dh 
374+ 
375+         Once this is done you can define your `board.I2C` object and define your sensor object 
376+ 
377+         .. code-block:: python 
378+ 
379+             i2c = board.I2C()  # uses board.SCL and board.SDA 
380+             lis3dh = adafruit_lis3dh.LIS3DH_I2C(i2c) 
381+ 
382+         Now you have access to the :attr:`acceleration` attribute 
383+ 
384+         .. code-block:: python 
385+ 
386+             acc_x, acc_y, acc_z = lis3dh.acceleration 
387+ 
388+ 
389+     """ 
328390
329391    def  __init__ (self , i2c , * , address = 0x18 , int1 = None , int2 = None ):
330392        import  adafruit_bus_device .i2c_device  as  i2c_device   # pylint: disable=import-outside-toplevel 
@@ -348,7 +410,36 @@ def _write_register_byte(self, register, value):
348410
349411
350412class  LIS3DH_SPI (LIS3DH ):
351-     """Driver for the LIS3DH accelerometer connected over SPI.""" 
413+     """Driver for the LIS3DH accelerometer connected over SPI. 
414+ 
415+     :param ~busio.I2C i2c: The I2C bus the LIS3DH is connected to. 
416+     :param address: The I2C device address. Defaults to :const:`0x18` 
417+ 
418+ 
419+     **Quickstart: Importing and using the device** 
420+ 
421+         Here is an example of using the :class:`LIS3DH_SPI` class. 
422+         First you will need to import the libraries to use the sensor 
423+ 
424+         .. code-block:: python 
425+ 
426+             import board 
427+             import adafruit_lis3dh 
428+ 
429+         Once this is done you can define your `board.SPI` object and define your sensor object 
430+ 
431+         .. code-block:: python 
432+ 
433+             i2c = board.SPI() 
434+             lis3dh = adafruit_lis3dh.LIS3DH_SPI(spi) 
435+ 
436+         Now you have access to the :attr:`acceleration` attribute 
437+ 
438+         .. code-block:: python 
439+ 
440+             acc_x, acc_y, acc_z = lis3dh.acceleration 
441+ 
442+     """ 
352443
353444    def  __init__ (self , spi , cs , * , baudrate = 100000 , int1 = None , int2 = None ):
354445        import  adafruit_bus_device .spi_device  as  spi_device   # pylint: disable=import-outside-toplevel 
0 commit comments