Skip to content

Replacing named tuple #17

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
May 7, 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
92 changes: 57 additions & 35 deletions adafruit_as7341.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@

**Hardware:**

* `Adafruit AS7341 Breakout <https://www.adafruit.com/product/4698>`_
* `Adafruit AS7341 Breakout
<https://www.adafruit.com/product/4698>`_ (Product ID: 4698)

**Software and Dependencies:**

* Adafruit CircuitPython firmware for the supported boards:
https://github.com/adafruit/circuitpython/releases
https://circuitpython.org/downloads

* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
* Adafruit's Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
* Adafruit's Bus Device library:
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

"""
* Adafruit's Register library:
https://github.com/adafruit/Adafruit_CircuitPython_Register

# imports
"""

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_AS7341.git"
from collections import namedtuple

from time import sleep, monotonic
from micropython import const
import adafruit_bus_device.i2c_device as i2c_device
Expand Down Expand Up @@ -165,38 +167,58 @@ class Gain(CV):
)


_SmuxIn = namedtuple(
"_SmuxIn",
[
"NC_F3L",
"F1L_NC",
"NC_NC0",
"NC_F8L",
"F6L_NC",
"F2L_F4L",
"NC_F5L",
"F7L_NC",
"NC_CL",
"NC_F5R",
"F7R_NC",
"NC_NC1",
"NC_F2R",
"F4R_NC",
"F8R_F6R",
"NC_F3R",
"F1R_EXT_GPIO",
"EXT_INT_CR",
"NC_DARK",
"NIR_F",
],
class SMUX_OUT(CV):
"""Options for ``smux_out``"""

pass # pylint: disable=unnecessary-pass


SMUX_OUT.add_values(
(
("DISABLED", 0, 0, None),
("ADC0", 1, 1, None),
("ADC1", 2, 2, None),
("ADC2", 3, 3, None),
("ADC3", 4, 4, None),
("ADC4", 5, 5, None),
("ADC5", 6, 6, None),
)
)
SMUX_IN = _SmuxIn(*list(range(20)))

_SmuxOut = namedtuple("_SmuxOut", "DISABLED ADC0 ADC1 ADC2 ADC3 ADC4 ADC5")
SMUX_OUT = _SmuxOut(*list(range(7)))

class SMUX_IN(CV):
"""Options for ``smux_in``"""

pass # pylint: disable=unnecessary-pass


SMUX_IN.add_values(
(
("NC_F3L", 0, 0, None),
("F1L_NC", 1, 1, None),
("NC_NC0", 2, 2, None),
("NC_F8L", 3, 3, None),
("F6L_NC", 4, 4, None),
("F2L_F4L", 5, 5, None),
("NC_F5L", 6, 6, None),
("F7L_NC", 7, 7, None),
("NC_CL", 8, 8, None),
("NC_F5R", 9, 9, None),
("F7R_NC", 10, 10, None),
("NC_NC1", 11, 11, None),
("NC_F2R", 12, 12, None),
("F4R_NC", 13, 13, None),
("F8R_F6R", 14, 14, None),
("NC_F3R", 15, 15, None),
("F1R_EXT_GPIO", 16, 16, None),
("EXT_INT_CR", 17, 17, None),
("NC_DARK", 18, 18, None),
("NIR_F", 19, 19, None),
)
)


class AS7341: # pylint:disable=too-many-instance-attributes
class AS7341: # pylint:disable=too-many-instance-attributes, no-member
"""Library for the AS7341 Sensor

:param ~busio.I2C i2c_bus: The I2C bus the device is connected to
Expand Down
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

.. automodule:: adafruit_as7341
:members:
:exclude-members: CV, Gain
:exclude-members: CV, Gain, SMUX_IN, SMUX_OUT
2 changes: 1 addition & 1 deletion examples/as7341_led_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import board
import adafruit_as7341

i2c = board.I2C()
i2c = board.I2C() # uses board.SCL and board.SDA
sensor = adafruit_as7341.AS7341(i2c)

print("out of init!")
Expand Down