Skip to content

improving_docs #22

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 2 commits into from
Apr 25, 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
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ This driver depends on:
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Adafruit OneWire <https://github.com/adafruit/Adafruit_CircuitPython_OneWire>`_

**Note:** This library depends on the OneWire library and will **not** work on the Raspberry Pi

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_.
Expand All @@ -37,6 +35,7 @@ Usage Example
import board
from adafruit_onewire.bus import OneWireBus
from adafruit_ds18x20 import DS18X20

ow_bus = OneWireBus(board.D2)
ds18 = DS18X20(ow_bus, ow_bus.scan()[0])
ds18.temperature
Expand Down
37 changes: 36 additions & 1 deletion adafruit_ds18x20.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
Driver for Dallas 1-Wire temperature sensor.

* Author(s): Carter Nelson

**Software and Dependencies:**

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

"""

__version__ = "0.0.0-auto.0"
Expand All @@ -28,7 +34,36 @@


class DS18X20:
"""Class which provides interface to DS18X20 temperature sensor."""
"""Class which provides interface to DS18X20 temperature sensor
:param bus: The bus the DS18X20 is connected to
:param int address: The device address.

**Quickstart: Importing and using the device**

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

.. code-block:: python

import board
from adafruit_onewire.bus import OneWireBus
from adafruit_ds18x20 import DS18X20

Once this is done you can define your :class:`adafruit_onewire.bus.OneWireBus`
object and define your sensor object

.. code-block:: python

ow_bus = OneWireBus(board.D5)
ds18 = DS18X20(ow_bus, ow_bus.scan()[0])

Now you have access to the :attr:`temperature` attribute

.. code-block:: python

temperature = ds18.temperature

"""

def __init__(self, bus, address):
if address.family_code == 0x10 or address.family_code == 0x28:
Expand Down
8 changes: 7 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@
# Uncomment the below if you use native CircuitPython modules such as
# digitalio, micropython and busio. List the modules you use. Without it, the
# autodoc module docs will fail to generate with a warning.
# autodoc_mock_imports = ["adafruit_onewire", "micropython", "time"]
autodoc_mock_imports = [
"adafruit_onewire",
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
"adafruit_onewire": (
"https://circuitpython.readthedocs.io/projects/onewire/en/latest/",
None,
),
}

# Add any paths that contain templates here, relative to this directory.
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Table of Contents
.. toctree::
:caption: Tutorials

DS18B20 Learning Guide <https://learn.adafruit.com/using-ds18b20-temperature-sensor-with-circuitpython>

.. toctree::
:caption: Related Products

Expand Down