Skip to content

Commit b92ff60

Browse files
Merge pull request #2 from jposada202020/improving_docs
improving_docs
2 parents 2824171 + 595148f commit b92ff60

File tree

5 files changed

+39
-31
lines changed

5 files changed

+39
-31
lines changed

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ To install in a virtual environment in your current project:
6060
Usage Example
6161
=============
6262

63-
.. code-block:: python
63+
.. code-block:: python3
6464
6565
import time
6666
import board
67-
import busio
6867
import adafruit_bh1750
6968
70-
i2c = busio.I2C(board.SCL, board.SDA)
71-
69+
i2c = board.I2C()
7270
sensor = adafruit_bh1750.BH1750(i2c)
7371
7472
while True:

adafruit_bh1750.py

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
1717
**Hardware:**
1818
19-
* `Adafruit BH1750 Breakout <https://www.adafruit.com/products/46XX>`_
19+
* Adafruit `BH1750 Light Sensor
20+
<https://www.adafruit.com/product/4681>`_ (Product ID: 4681)
2021
2122
**Software and Dependencies:**
2223
2324
* Adafruit CircuitPython firmware for the supported boards:
24-
https://github.com/adafruit/circuitpython/releases
25+
https://circuitpython.org/downloads
2526
26-
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
27+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
2728
"""
2829

2930
# imports
@@ -89,7 +90,7 @@ class RWBitfields:
8990
gets and sets the full byte value from the ``_settings`` attribute of the calling
9091
object.
9192
92-
Values are `int` between 0 and ``2**num_bits - 1``
93+
Values are `int` between 0 and :math:`2^num_bits - 1`
9394
9495
:param int num_bits: The number of bits in the field.
9596
:param type lowest_bit: The lowest bits index within the byte at ``register_address``
@@ -148,10 +149,33 @@ class Resolution(CV):
148149
class BH1750: # pylint:disable=too-many-instance-attributes
149150
"""Library for the BH1750 Sensor
150151
152+
:param ~busio.I2C i2c_bus: The I2C bus the BH1750 is connected to.
153+
:param int address: The I2C device address. Defaults to :const:`0x23`.Can be
154+
set to :const:`0x5C` by pulling the address pin high.
151155
152-
:param ~busio.I2C i2c_bus: The I2C bus the BH1750 is connected to.
153-
:param address: The I2C slave address of the sensor. Defaults to ``0x23``. \
154-
Can be set to ``0x5C`` by pulling the address pin high.
156+
157+
**Quickstart: Importing and using the BH1750**
158+
159+
Here is an example of using the :class:`BH1750` class.
160+
First you will need to import the libraries to use the sensor
161+
162+
.. code-block:: python
163+
164+
import board
165+
import adafruit_bh1750
166+
167+
Once this is done you can define your `board.I2C` object and define your sensor object
168+
169+
.. code-block:: python
170+
171+
i2c = board.I2C() # uses board.SCL and board.SDA
172+
sensor = adafruit_bh1750.BH1750(i2c)
173+
174+
Now you have access to the :attr:`lux` value in lux
175+
176+
.. code-block:: python
177+
178+
lux = sensor.lux
155179
156180
"""
157181

@@ -194,25 +218,7 @@ def _raw_reading(self):
194218

195219
@property
196220
def lux(self):
197-
"""Light value in lux.
198-
199-
This example prints the light data in lux. Cover the sensor to see the values change.
200-
201-
.. code-block:: python
202-
203-
import time
204-
import board
205-
import busio
206-
import adafruit_bh1750
207-
208-
i2c = busio.I2C(board.SCL, board.SDA)
209-
sensor = adafruit_bh1750.BH1750(i2c)
210-
211-
while True:
212-
print("Lux:", sensor.lux)
213-
time.sleep(0.1)
214-
215-
"""
221+
"""Light value in lux."""
216222
raw_lux = self._raw_reading
217223

218224
return self._convert_to_lux(raw_lux)

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_bh1750
88
:members:
9+
:exclude-members: CV, Resolution, Mode, RWBitfields

docs/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26+
Adafruit BH1750 Light Sensor Breakout Learning Guide <https://learn.adafruit.com/adafruit-bh1750-ambient-light-sensor>
27+
2628
.. toctree::
2729
:caption: Related Products
2830

31+
Adafruit BH1750 Light Sensor Breakout <https://www.adafruit.com/products/4681>
32+
2933
.. toctree::
3034
:caption: Other Links
3135

examples/bh1750_simpletest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import adafruit_bh1750
77

88
i2c = board.I2C()
9-
109
sensor = adafruit_bh1750.BH1750(i2c)
1110

1211
while True:

0 commit comments

Comments
 (0)