Skip to content

Adding Clear and NIR accessors #19

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 6 commits into from
Sep 9, 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
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Usage Example
print("F6 - 590nm/Yellow %s" % bar_graph(sensor.channel_590nm))
print("F7 - 630nm/Orange %s" % bar_graph(sensor.channel_630nm))
print("F8 - 680nm/Red %s" % bar_graph(sensor.channel_680nm))
print("Clear %s" % bar_graph(sensor.channel_clear))
print("Near-IR (NIR) %s" % bar_graph(sensor.channel_nir))
print("\n------------------------------------------------")
sleep(1)

Expand Down
12 changes: 11 additions & 1 deletion adafruit_as7341.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,17 @@ def channel_680nm(self):
self._configure_f5_f8()
return self._channel_3_data

# TODO: Add clear and NIR accessors
@property
def channel_clear(self):
"""The current reading for the clear sensor"""
self._configure_f5_f8()
return self._channel_4_data

@property
def channel_nir(self):
"""The current reading for the NIR (near-IR) sensor"""
self._configure_f5_f8()
return self._channel_5_data

def _wait_for_data(self, timeout=1.0):
"""Wait for sensor data to be ready"""
Expand Down
2 changes: 2 additions & 0 deletions examples/as7341_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ def bar_graph(read_value):
print("F6 - 590nm/Yellow %s" % bar_graph(sensor.channel_590nm))
print("F7 - 630nm/Orange %s" % bar_graph(sensor.channel_630nm))
print("F8 - 680nm/Red %s" % bar_graph(sensor.channel_680nm))
print("Clear %s" % bar_graph(sensor.channel_clear))
print("Near-IR (NIR) %s" % bar_graph(sensor.channel_nir))
print("\n------------------------------------------------")
sleep(1)