Skip to content

Commit 32e8ce6

Browse files
authored
Merge pull request #14 from kattni/fix-up
Update version info, README
2 parents 0122361 + 4b8fa77 commit 32e8ce6

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

README.rst

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,52 @@ 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+
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
33+
PyPI <https://pypi.org/project/adafruit-circuitpython-lsm9ds0/>`_. To install for current user:
34+
35+
.. code-block:: shell
36+
37+
pip3 install adafruit-circuitpython-lsm9ds0
38+
39+
To install system-wide (this may be required in some cases):
40+
41+
.. code-block:: shell
42+
43+
sudo pip3 install adafruit-circuitpython-lsm9ds0
44+
45+
To install in a virtual environment in your current project:
46+
47+
.. code-block:: shell
48+
49+
mkdir project-name && cd project-name
50+
python3 -m venv .env
51+
source .env/bin/activate
52+
pip3 install adafruit-circuitpython-lsm9ds0
53+
3054
Usage Example
3155
=============
3256

33-
See examples/lsm9ds0_simpletest.py for a demo of the usage.
57+
.. code-block:: python
58+
59+
import time
60+
import board
61+
import busioimport adafruit_lsm9ds0
62+
63+
i2c = busio.I2C(board.SCL, board.SDA)
64+
sensor = adafruit_lsm9ds0.LSM9DS0_I2C(i2c)
65+
66+
while True:
67+
accel_x, accel_y, accel_z = sensor.acceleration
68+
mag_x, mag_y, mag_z = sensor.magnetic
69+
gyro_x, gyro_y, gyro_z = sensor.gyro
70+
temp = sensor.temperature
71+
print('Acceleration (m/s^2): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(accel_x, accel_y, accel_z))
72+
print('Magnetometer (gauss): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(mag_x, mag_y, mag_z))
73+
print('Gyroscope (degrees/sec): ({0:0.3f},{1:0.3f},{2:0.3f})'.format(gyro_x, gyro_y, gyro_z))
74+
print('Temperature: {0:0.3f}C'.format(temp))
75+
time.sleep(1.0)
3476
3577
Contributing
3678
============
@@ -84,4 +126,4 @@ Now, once you have the virtual environment activated:
84126
85127
This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
86128
view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
87-
locally verify it will pass.
129+
locally verify it will pass.

adafruit_lsm9ds0.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959

6060
from micropython import const
6161

62+
__version__ = "0.0.0-auto.0"
63+
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_LSM9DS0.git"
64+
6265
# Internal constants and register values:
6366
# pylint: disable=bad-whitespace
6467
_LSM9DS0_ADDRESS_ACCELMAG = const(0x1D) # 3B >> 1 = 7bit default

0 commit comments

Comments
 (0)