Skip to content

Commit 64522a6

Browse files
committed
multiple fixes.
1 parent e9370ef commit 64522a6

File tree

7 files changed

+30
-55
lines changed

7 files changed

+30
-55
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ python:
1111
cache:
1212
pip: true
1313

14-
# TODO: if deployment to PyPi is desired, change 'DEPLOY_PYPI' to "true",
15-
# or remove the env block entirely and remove the condition in the
16-
# deploy block.
1714
env:
1815
- DEPLOY_PYPI="false"
1916

@@ -26,8 +23,6 @@ deploy:
2623
overwrite: true
2724
on:
2825
tags: true
29-
# TODO: Use 'travis encrypt --com -r adafruit/<repo slug>' to generate
30-
# the encrypted password for adafruit-travis. Paste result below.
3126
- provider: pypi
3227
user: adafruit-travis
3328
password:

README.rst

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,28 @@ Please ensure all dependencies are available on the CircuitPython filesystem.
2727
This is easily achieved by downloading
2828
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
2929

30-
Installing from PyPI
31-
=====================
32-
.. note:: This library is not available on PyPI yet. Install documentation is included
33-
as a standard element. Stay tuned for PyPI availability!
34-
35-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
36-
If the library is not planned for PyPI, remove the entire 'Installing from PyPI' section.
37-
38-
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
39-
PyPI <https://pypi.org/project/adafruit-circuitpython-lis2dh12/>`_. To install for current user:
40-
41-
.. code-block:: shell
42-
43-
pip3 install adafruit-circuitpython-lis2dh12
44-
45-
To install system-wide (this may be required in some cases):
46-
47-
.. code-block:: shell
48-
49-
sudo pip3 install adafruit-circuitpython-lis2dh12
30+
Usage Example
31+
=============
5032

51-
To install in a virtual environment in your current project:
33+
.. code-block:: python
5234
53-
.. code-block:: shell
35+
import time
36+
import board
37+
import busio
38+
import electronutlabs_lis2dh12
5439
55-
mkdir project-name && cd project-name
56-
python3 -m venv .env
57-
source .env/bin/activate
58-
pip3 install adafruit-circuitpython-lis2dh12
40+
i2c = busio.I2C(board.SCL, board.SDA)
41+
lis2dh12 = electronutlabs_lis2dh12.LIS2DH12_I2C(i2c, address=0x19)
5942
60-
Usage Example
61-
=============
43+
lis2dh12.range = electronutlabs_lis2dh12.RANGE_2_G
6244
63-
.. todo:: Add a quick, simple example. It and other examples should live in the examples folder and be included in docs/examples.rst.
45+
while True:
46+
# Read accelerometer values (in m / s ^ 2). Returns a 3-tuple of x, y,
47+
# z axis values. Divide them by 9.806 to convert to Gs.
48+
x, y, z = [value / electronutlabs_lis2dh12.STANDARD_GRAVITY for value in lis2dh12.acceleration]
49+
print("x = %0.3f G, y = %0.3f G, z = %0.3f G" % (x, y, z))
50+
# Small delay to keep things responsive but give time for interrupt processing.
51+
time.sleep(0.5)
6452
6553
Contributing
6654
============

docs/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
'sphinx.ext.todo',
1717
]
1818

19-
# TODO: Please Read!
2019
# Uncomment the below if you use native CircuitPython modules such as
2120
# digitalio, micropython and busio. List the modules you use. Without it, the
2221
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
22+
autodoc_mock_imports = ["micropython", "busio"]
2423

2524

2625
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
28-
2926
.. toctree::
3027
:caption: Related Products
3128

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
29+
* `ST Microelectronics LIS2DH12 chip <https://www.st.com/en/mems-and-sensors/lis2dh12.html>`_
30+
* `Electronut Labs Blip <https://docs.electronut.in/blip/>`_
3431

3532
.. toctree::
3633
:caption: Other Links

electronutlabs_lis2dh12.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,24 @@
3333
3434
**Hardware:**
3535
36-
.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST
37-
inline format: "* `Link Text <url>`_"
36+
* `ST Microelectronics LIS2DH12 chip
37+
<https://www.st.com/en/mems-and-sensors/lis2dh12.html>`_
38+
* `Electronut Labs Blip <https://docs.electronut.in/blip/>`_
3839
3940
**Software and Dependencies:**
4041
4142
* Adafruit CircuitPython firmware for the supported boards:
4243
https://github.com/adafruit/circuitpython/releases
4344
44-
.. todo:: Uncomment or remove the Bus Device and/or the Register library dependencies based on the library's use of either.
45-
4645
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
47-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
4846
"""
4947

5048
# libray is similar to github.com/adafruit/Adafruit_CircuitPython_LIS3DH
5149

5250
# imports
5351
import time
54-
import math
5552
from collections import namedtuple
5653
import struct
57-
import digitalio
5854

5955
from micropython import const
6056

@@ -100,8 +96,10 @@
10096
# the named tuple returned by the class
10197
AccelerationTuple = namedtuple("acceleration", ("x", "y", "z"))
10298

99+
103100
class LIS2DH12:
104101
"""Driver base for the LIS2DH12 accelerometer."""
102+
105103
def __init__(self):
106104
# Check device ID.
107105
device_id = self._read_register_byte(_REG_WHOAMI)
@@ -163,7 +161,8 @@ def acceleration(self):
163161
elif accel_range == RANGE_2_G:
164162
divider = 16380
165163

166-
x, y, z = struct.unpack('<hhh', self._read_register(_REG_OUT_X_L | 0x80, 6))
164+
x, y, z = struct.unpack(
165+
'<hhh', self._read_register(_REG_OUT_X_L | 0x80, 6))
167166

168167
# convert from Gs to m / s ^ 2 and adjust for the range
169168
x = (x / divider) * STANDARD_GRAVITY
@@ -172,7 +171,6 @@ def acceleration(self):
172171

173172
return AccelerationTuple(x, y, z)
174173

175-
176174
def _read_register_byte(self, register):
177175
# Read a byte register value and return it.
178176
return self._read_register(register, 1)[0]

examples/lis2dh12_simpletest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import time
22
import board
3-
import digitalio
43
import busio
54
import electronutlabs_lis2dh12
65

@@ -12,7 +11,8 @@
1211
while True:
1312
# Read accelerometer values (in m / s ^ 2). Returns a 3-tuple of x, y,
1413
# z axis values. Divide them by 9.806 to convert to Gs.
15-
x, y, z = [value / electronutlabs_lis2dh12.STANDARD_GRAVITY for value in lis2dh12.acceleration]
14+
x, y, z = [
15+
value / electronutlabs_lis2dh12.STANDARD_GRAVITY for value in lis2dh12.acceleration]
1616
print("x = %0.3f G, y = %0.3f G, z = %0.3f G" % (x, y, z))
1717
# Small delay to keep things responsive but give time for interrupt processing.
18-
time.sleep(0.5)
18+
time.sleep(0.5)

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,5 @@
5858

5959
# You can just specify the packages manually here if your project is
6060
# simple. Or you can use find_packages().
61-
# TODO: IF LIBRARY FILES ARE A PACKAGE FOLDER,
62-
# CHANGE `py_modules=['...']` TO `packages=['...']`
6361
py_modules=['electronutlabs_lis2dh12'],
6462
)

0 commit comments

Comments
 (0)