Skip to content

improving_docs #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,31 @@ Usage Notes

Of course, you must import the library to use it:

.. code:: python
.. code:: python3

import adafruit_bno055


This driver takes an instantiated and active I2C object (from the `busio` or
the `bitbangio` library) as an argument to its constructor. The way to create
an I2C object depends on the board you are using. For boards with labeled SCL
and SDA pins, you can:
This driver takes an instantiated and active I2C object as an argument to its
constructor. The way to create an I2C object depends on the board you are
using. For boards with labeled SCL and SDA pins, you can:

.. code:: python
.. code:: python3

from busio import I2C
from board import SDA, SCL
import board

i2c = I2C(SCL, SDA)
i2c = board.I2C()

Once you have the I2C object, you can create the sensor object:

.. code:: python
.. code:: python3

sensor = adafruit_bno055.BNO055_I2C(i2c)


And then you can start reading the measurements:

.. code:: python
.. code:: python3

print(sensor.temperature)
print(sensor.euler)
Expand Down
50 changes: 46 additions & 4 deletions adafruit_bno055.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,30 @@
# SPDX-License-Identifier: MIT

"""
``adafruit_bno055`` - Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055
`adafruit_bno055`
=======================================================================================

This is a CircuitPython driver for the Bosch BNO055 nine degree of freedom
inertial measurement unit module with sensor fusion.

* Author(s): Radomir Dopieralski


**Hardware:**

* Adafruit `9-DOF Absolute Orientation IMU Fusion Breakout - BNO055
<https://www.adafruit.com/product/4646>`_ (Product ID: 4646)


**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://circuitpython.org/downloads

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register

"""
import time
import struct
Expand Down Expand Up @@ -164,6 +181,31 @@ def __set__(self, obj, value):
class BNO055: # pylint: disable=too-many-public-methods
"""
Base class for the BNO055 9DOF IMU sensor.

**Quickstart: Importing and using the device**

Here is an example of using the :class:`BNO055` class.
First you will need to import the libraries to use the sensor

.. code-block:: python

import board
import adafruit_bno055

Once this is done you can define your `board.I2C` object and define your sensor object

.. code-block:: python

i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_bno055.BNO055_I2C(i2c)


Now you have access to the :attr:`acceleration` attribute among others

.. code-block:: python

sensor = accelerometer.acceleration

"""

def __init__(self):
Expand Down Expand Up @@ -227,11 +269,11 @@ def mode(self):
| NDOF_MODE | X | X | X | X | - |
+------------------+-------+---------+------+----------+----------+

The default mode is ``NDOF_MODE``.
The default mode is :const:`NDOF_MODE`.

| You can set the mode using the line below:
| ``sensor.mode = adafruit_bno055.ACCONLY_MODE``
| replacing ``ACCONLY_MODE`` with the mode you want to use
| replacing :const:`ACCONLY_MODE` with the mode you want to use

.. data:: CONFIG_MODE

Expand Down Expand Up @@ -662,7 +704,7 @@ def axis_remap(self):

@axis_remap.setter
def axis_remap(self, remap):
"""Pass a tuple coinsidting of x, y, z, x_sign, y-sign, and z_sign.
"""Pass a tuple consisting of x, y, z, x_sign, y-sign, and z_sign.

Set axis remap for each axis. The x, y, z parameter values should
be set to one of AXIS_REMAP_X (0x00), AXIS_REMAP_Y (0x01), or
Expand Down
12 changes: 12 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ Ensure your device works with this simple test.
.. literalinclude:: ../examples/bno055_simpletest.py
:caption: examples/bno055_simpletest.py
:linenos:


Raspberry PI I2C GPIO Simpletest
--------------------------------

This example demonstrates how to instantiate the
Adafruit BNO055 Sensor using this library and just
the I2C bus number.

.. literalinclude:: ../examples/bno055_i2c-gpio_simpletest.py
:caption: examples/bno055_i2c-gpio_simpletest.py
:linenos:
4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ Table of Contents
.. toctree::
:caption: Tutorials

Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 Learning Guide <https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/overview>

.. toctree::
:caption: Related Products

Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 <https://www.adafruit.com/product/2472>
Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 <https://www.adafruit.com/product/4646>

.. toctree::
:caption: Other Links
Expand Down
9 changes: 4 additions & 5 deletions examples/bno055_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

import time
import board
import busio
import adafruit_bno055

# Use these lines for I2C
i2c = busio.I2C(board.SCL, board.SDA)

i2c = board.I2C()
sensor = adafruit_bno055.BNO055_I2C(i2c)

# User these lines for UART
# uart = busio.UART(board.TX, board.RX)
# If you are going to use UART uncomment these lines
# uart = board.UART()
# sensor = adafruit_bno055.BNO055_UART(uart)

last_val = 0xFFFF
Expand Down