Skip to content

Commit 3ae8e96

Browse files
committed
fix docs build
1 parent 05a32c7 commit 3ae8e96

File tree

4 files changed

+46
-31
lines changed

4 files changed

+46
-31
lines changed

README.rst

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,10 @@ This is easily achieved by downloading
3838
or individual libraries can be installed using
3939
`circup <https://github.com/adafruit/circup>`_.
4040

41-
42-
43-
.. todo:: Describe the Adafruit product this library works with. For PCBs, you can also add the
44-
image from the assets folder in the PCB's GitHub repo.
45-
46-
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/6335>`_
41+
`Adafruit OPT4048 Tri-Stimulus XYZ Color and Lux Sensor <http://www.adafruit.com/products/6335>`_
4742

4843
Installing from PyPI
4944
=====================
50-
.. note:: This library is not available on PyPI yet. Install documentation is included
51-
as a standard element. Stay tuned for PyPI availability!
52-
53-
.. todo:: Remove the above note if PyPI version is/will be available at time of release.
5445

5546
On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
5647
PyPI <https://pypi.org/project/adafruit-circuitpython-opt4048/>`_.
@@ -101,8 +92,28 @@ Or the following command to update an existing version:
10192
Usage Example
10293
=============
10394

104-
.. todo:: Add a quick, simple example. It and other examples should live in the
105-
examples folder and be included in docs/examples.rst.
95+
.. code-block:: python
96+
97+
import time
98+
from time import sleep
99+
100+
import board
101+
102+
from adafruit_opt4048 import OPT4048, ConversionTime, Mode, Range
103+
104+
i2c = board.I2C() # uses board.SCL and board.SDA
105+
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
106+
sensor = OPT4048(i2c)
107+
108+
sensor.range = Range.AUTO
109+
sensor.conversion_time = ConversionTime.TIME_100MS
110+
sensor.mode = Mode.CONTINUOUS
111+
while True:
112+
x, y, lux = sensor.get_cie()
113+
print(f"CIE x:{x}, y:{y}, lux: {lux}", end=" ")
114+
print(f"K: {sensor.calculate_color_temperature(x,y)}")
115+
time.sleep(1)
116+
106117
107118
Documentation
108119
=============

adafruit_opt4048.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
2323
* Adafruit CircuitPython firmware for the supported boards:
2424
https://circuitpython.org/downloads
25-
# * Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26-
# * Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
25+
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
26+
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
27+
2728
"""
2829

2930
# imports
@@ -56,18 +57,6 @@
5657
class CV:
5758
"""Constant value class helper for enums."""
5859

59-
# @classmethod
60-
# def add_values(cls, value_tuples: Tuple[str, int, str, Optional[float]]) -> None:
61-
# """Add CV values to the class"""
62-
# cls.string = {}
63-
# cls.lsb = {}
64-
#
65-
# for value_tuple in value_tuples:
66-
# name, value, string, lsb = value_tuple
67-
# setattr(cls, name, value)
68-
# cls.string[value] = string
69-
# cls.lsb[value] = lsb
70-
7160
@classmethod
7261
def is_valid(cls, value: int) -> bool:
7362
"""Validate that a given value is a member"""
@@ -78,6 +67,7 @@ def is_valid(cls, value: int) -> bool:
7867

7968
@classmethod
8069
def get_name(cls, value) -> str:
70+
"""Get the name for a given value"""
8171
name_dict = {}
8272
for _key, _value in cls.__dict__.items():
8373
name_dict[_value] = _key

docs/examples.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,21 @@ Ensure your device works with this simple test.
66
.. literalinclude:: ../examples/opt4048_simpletest.py
77
:caption: examples/opt4048_simpletest.py
88
:linenos:
9+
10+
Webserial example
11+
-----------------
12+
13+
Output color data over serial for use with webserial page
14+
15+
.. literalinclude:: ../examples/opt4048_webserial.py
16+
:caption: examples/opt4048_webserial.py
17+
:linenos:
18+
19+
Full test
20+
---------
21+
22+
Comprehensive test of features
23+
24+
.. literalinclude:: ../examples/opt4048_fulltest.py
25+
:caption: examples/opt4048_fulltest.py
26+
:linenos:

docs/index.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ Table of Contents
2424
.. toctree::
2525
:caption: Tutorials
2626

27-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
28-
the toctree above for use later.
29-
3027
.. toctree::
3128
:caption: Related Products
3229

33-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
34-
the toctree above for use later.
30+
Adafruit OPT4048 Tri-Stimulus XYZ Color and Lux Sensor <http://www.adafruit.com/products/6335>
3531

3632
.. toctree::
3733
:caption: Other Links

0 commit comments

Comments
 (0)