/ README.rst
README.rst
  1  Introduction
  2  ============
  3  
  4  .. image:: https://readthedocs.org/projects/adafruit-circuitpython-l3gd20/badge/?version=latest
  5      :target: https://circuitpython.readthedocs.io/projects/l3gd20/en/latest/
  6      :alt: Documentation Status
  7  
  8  .. image:: https://img.shields.io/discord/327254708534116352.svg
  9      :target: https://discord.gg/nBQh6qu
 10      :alt: Discord
 11  
 12  .. image:: https://travis-ci.org/adafruit/adafruit_CircuitPython_l3gd20.svg?branch=master
 13      :target: https://travis-ci.org/adafruit/adafruit_CircuitPython_l3gd20
 14      :alt: Build Status
 15  
 16  Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - L3GD20 Driver
 17  
 18  Dependencies
 19  =============
 20  This driver depends on:
 21  
 22  * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
 23  * `Register <https://github.com/adafruit/Adafruit_CircuitPython_Register>`_
 24  
 25  Please ensure all dependencies are available on the CircuitPython filesystem.
 26  This is easily achieved by downloading
 27  `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
 28  
 29  Usage Example
 30  =============
 31  
 32  Of course, you must import the library to use it:
 33  
 34  .. code:: python
 35  
 36      import adafruit_l3gd20
 37  
 38  
 39  This driver takes an instantiated and active I2C object (from the `busio` or
 40  the `bitbangio` library) as an argument to its constructor.  The way to create
 41  an I2C object depends on the board you are using. For boards with labeled SCL
 42  and SDA pins, you can:
 43  
 44  .. code:: python
 45  
 46      from busio import I2C
 47      from board import SDA, SCL
 48  
 49      i2c = I2C(SCL, SDA)
 50  
 51  Once you have the I2C object, you can create the sensor object:
 52  
 53  .. code:: python
 54  
 55      sensor = adafruit_l3gd20.L3GD20_I2C(i2c)
 56  
 57  
 58  And then you can start reading the measurements:
 59  
 60  .. code:: python
 61  
 62      print(sensor.acceleration)
 63  
 64  Contributing
 65  ============
 66  
 67  Contributions are welcome! Please read our `Code of Conduct
 68  <https://github.com/adafruit/adafruit_CircuitPython_l3gd20/blob/master/CODE_OF_CONDUCT.md>`_
 69  before contributing to help this project stay welcoming.
 70  
 71  Building locally
 72  ================
 73  
 74  Zip release files
 75  -----------------
 76  
 77  To build this library locally you'll need to install the
 78  `circuitpython-build-tools <https://github.com/adafruit/circuitpython-build-tools>`_ package.
 79  
 80  .. code-block:: shell
 81  
 82      python3 -m venv .env
 83      source .env/bin/activate
 84      pip install circuitpython-build-tools
 85  
 86  Once installed, make sure you are in the virtual environment:
 87  
 88  .. code-block:: shell
 89  
 90      source .env/bin/activate
 91  
 92  Then run the build:
 93  
 94  .. code-block:: shell
 95  
 96      circuitpython-build-bundles --filename_prefix adafruit-circuitpython-l3gd20 --library_location .
 97  
 98  Sphinx documentation
 99  -----------------------
100  
101  Sphinx is used to build the documentation based on rST files and comments in the code. First,
102  install dependencies (feel free to reuse the virtual environment from above):
103  
104  .. code-block:: shell
105  
106      python3 -m venv .env
107      source .env/bin/activate
108      pip install Sphinx sphinx-rtd-theme
109  
110  Now, once you have the virtual environment activated:
111  
112  .. code-block:: shell
113  
114      cd docs
115      sphinx-build -E -W -b html . _build/html
116  
117  This will output the documentation to ``docs/_build/html``. Open the index.html in your browser to
118  view them. It will also (due to -W) error out on any warning like Travis will. This is a good way to
119  locally verify it will pass.