Skip to content

Commit 1fbea7a

Browse files
Merge pull request #8 from jposada202020/improving_docs
improving_docs
2 parents 707f48d + cd3be8c commit 1fbea7a

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,9 @@ Usage Example
6060
6161
import time
6262
import board
63-
import busio
6463
import adafruit_hts221
6564
66-
i2c = busio.I2C(board.SCL, board.SDA)
65+
i2c = board.I2C()
6766
hts = adafruit_hts221.HTS221(i2c)
6867
while True:
6968
print("Relative Humidity: %.2f percent rH" % hts.relative_humidity)

adafruit_hts221.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
1616
**Hardware:**
1717
18-
* `HTS221 Breakout <https://www.adafruit.com/products/4535>`_
18+
* `Adafruit HTS221 - Temperature & Humidity
19+
Sensor Breakout Board <https://www.adafruit.com/products/4535>`_
1920
2021
**Software and Dependencies:**
2122
* Adafruit CircuitPython firmware for the supported boards:
@@ -65,7 +66,7 @@ class CV:
6566

6667
@classmethod
6768
def add_values(cls, value_tuples):
68-
"creates CV entires"
69+
"""creates CV entries"""
6970
cls.string = {}
7071
cls.lsb = {}
7172

@@ -77,12 +78,12 @@ def add_values(cls, value_tuples):
7778

7879
@classmethod
7980
def is_valid(cls, value):
80-
"Returns true if the given value is a member of the CV"
81+
"""Returns true if the given value is a member of the CV"""
8182
return value in cls.string
8283

8384

8485
class Rate(CV):
85-
"""Options for ``data_rate``
86+
"""Options for :attr:`data_rate`
8687
8788
+-----------------------+------------------------------------------------------------------+
8889
| Rate | Description |
@@ -115,7 +116,32 @@ class Rate(CV):
115116
class HTS221: # pylint: disable=too-many-instance-attributes
116117
"""Library for the ST HTS221 Humidity and Temperature Sensor
117118
118-
:param ~busio.I2C i2c_bus: The I2C bus the HTS221HB is connected to.
119+
:param ~busio.I2C i2c_bus: The I2C bus the HTS221 is connected to
120+
121+
122+
**Quickstart: Importing and using the HTS221**
123+
124+
Here is an example of using the :class:`HTS221` class.
125+
First you will need to import the libraries to use the sensor
126+
127+
.. code-block:: python
128+
129+
import board
130+
import adafruit_hts221
131+
132+
Once this is done you can define your `board.I2C` object and define your sensor object
133+
134+
.. code-block:: python
135+
136+
i2c = board.I2C() # uses board.SCL and board.SDA
137+
hts = adafruit_hts221.HTS221(i2c)
138+
139+
Now you have access to the :attr:`temperature` and :attr:`relative_humidity` attributes
140+
141+
.. code-block:: python
142+
143+
temperature = hts.temperature
144+
relative_humidity = hts.relative_humidity
119145
120146
"""
121147

@@ -203,7 +229,7 @@ def relative_humidity(self):
203229

204230
@property
205231
def temperature(self):
206-
"""The current temperature measurement in degrees C"""
232+
"""The current temperature measurement in degrees Celsius"""
207233

208234
calibrated_value_delta = self.calibrated_value_1 - self.calib_temp_value_0
209235
calibrated_measurement_delta = self.calib_temp_meas_1 - self.calib_temp_meas_0
@@ -222,10 +248,11 @@ def temperature(self):
222248

223249
@property
224250
def data_rate(self):
225-
"""The rate at which the sensor measures ``relative_humidity`` and ``temperature``.
226-
``data_rate`` should be set to one of the values of ``adafruit_hts221.Rate``. Note that
227-
setting ``data_rate`` to ``Rate.ONE_SHOT`` will cause ``relative_humidity`` and
228-
``temperature`` measurements to only update when ``take_measurements`` is called."""
251+
"""The rate at which the sensor measures :attr:`relative_humidity` and :attr:`temperature`.
252+
:attr:`data_rate` should be set to one of the values of :class:`adafruit_hts221.Rate`.
253+
Note that setting :attr:`data_rate` to ``Rate.ONE_SHOT`` will cause
254+
:attr:`relative_humidity` and :attr:`temperature` measurements to only
255+
update when :meth:`take_measurements` is called."""
229256
return self._data_rate
230257

231258
@data_rate.setter
@@ -246,8 +273,8 @@ def temperature_data_ready(self):
246273
return self._temperature_status_bit
247274

248275
def take_measurements(self):
249-
"""Update the value of ``relative_humidity`` and ``temperature`` by taking a single
250-
measurement. Only meaningful if ``data_rate`` is set to ``ONE_SHOT``"""
276+
"""Update the value of :attr:`relative_humidity` and :attr:`temperature` by taking a single
277+
measurement. Only meaningful if :attr:`data_rate` is set to ``ONE_SHOT``"""
251278
self._one_shot_bit = True
252279
while self._one_shot_bit:
253280
pass

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
77
.. automodule:: adafruit_hts221
88
:members:
9+
:exclude-members: CV

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit HTS221 - Temperature & Humidity Sensor Learning Guide <https://learn.adafruit.com/adafruit-hts221-temperature-humidity-sensor>
2627

2728
.. toctree::
2829
:caption: Related Products
2930

30-
* `HTS221 Breakout <https://www.adafruit.com/products/4535>`_
31+
Adafruit HTS221 - Temperature & Humidity Sensor Breakout Board <https://www.adafruit.com/products/4535>
3132

3233
.. toctree::
3334
:caption: Other Links

examples/hts221_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
import time
55
import board
6-
import busio
76
import adafruit_hts221
87

9-
i2c = busio.I2C(board.SCL, board.SDA)
8+
i2c = board.I2C()
109
hts = adafruit_hts221.HTS221(i2c)
10+
1111
while True:
1212
print("Relative Humidity: %.2f %% rH" % hts.relative_humidity)
1313
print("Temperature: %.2f C" % hts.temperature)

0 commit comments

Comments
 (0)