From b2f57993339bef2cab1ee2125048d66cc300a970 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 12:23:48 -0400 Subject: [PATCH 1/2] improving_docs --- README.rst | 3 +-- adafruit_ds18x20.py | 36 +++++++++++++++++++++++++++++++++++- docs/conf.py | 3 ++- docs/index.rst | 2 ++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 3b9023a..3eca1d7 100644 --- a/README.rst +++ b/README.rst @@ -23,8 +23,6 @@ This driver depends on: * `Adafruit CircuitPython `_ * `Adafruit 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 `_. @@ -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 diff --git a/adafruit_ds18x20.py b/adafruit_ds18x20.py index 4b99a15..8b1f7f8 100644 --- a/adafruit_ds18x20.py +++ b/adafruit_ds18x20.py @@ -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" @@ -28,7 +34,35 @@ 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: diff --git a/docs/conf.py b/docs/conf.py index a63cf77..e7d788c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,11 +23,12 @@ # 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. diff --git a/docs/index.rst b/docs/index.rst index 733410a..6b6f47f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,6 +23,8 @@ Table of Contents .. toctree:: :caption: Tutorials + DS18B20 Learning Guide + .. toctree:: :caption: Related Products From 3fec337c0847205dd492c7dbdf0994b069b09114 Mon Sep 17 00:00:00 2001 From: jposada202020 Date: Sun, 25 Apr 2021 12:31:06 -0400 Subject: [PATCH 2/2] correcting_formating --- adafruit_ds18x20.py | 3 ++- docs/conf.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/adafruit_ds18x20.py b/adafruit_ds18x20.py index 8b1f7f8..03fb28e 100644 --- a/adafruit_ds18x20.py +++ b/adafruit_ds18x20.py @@ -49,7 +49,8 @@ class DS18X20: 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 + Once this is done you can define your :class:`adafruit_onewire.bus.OneWireBus` + object and define your sensor object .. code-block:: python diff --git a/docs/conf.py b/docs/conf.py index e7d788c..1c24e08 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,12 +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",] +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), + "adafruit_onewire": ( + "https://circuitpython.readthedocs.io/projects/onewire/en/latest/", + None, + ), } # Add any paths that contain templates here, relative to this directory.