Skip to content

Commit 0577cd5

Browse files
authored
Merge pull request #19 from bjones14/main
Adding Clear and NIR accessors
2 parents 44a07d7 + 5e6302d commit 0577cd5

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ Usage Example
8787
print("F6 - 590nm/Yellow %s" % bar_graph(sensor.channel_590nm))
8888
print("F7 - 630nm/Orange %s" % bar_graph(sensor.channel_630nm))
8989
print("F8 - 680nm/Red %s" % bar_graph(sensor.channel_680nm))
90+
print("Clear %s" % bar_graph(sensor.channel_clear))
91+
print("Near-IR (NIR) %s" % bar_graph(sensor.channel_nir))
9092
print("\n------------------------------------------------")
9193
sleep(1)
9294

adafruit_as7341.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,17 @@ def channel_680nm(self):
376376
self._configure_f5_f8()
377377
return self._channel_3_data
378378

379-
# TODO: Add clear and NIR accessors
379+
@property
380+
def channel_clear(self):
381+
"""The current reading for the clear sensor"""
382+
self._configure_f5_f8()
383+
return self._channel_4_data
384+
385+
@property
386+
def channel_nir(self):
387+
"""The current reading for the NIR (near-IR) sensor"""
388+
self._configure_f5_f8()
389+
return self._channel_5_data
380390

381391
def _wait_for_data(self, timeout=1.0):
382392
"""Wait for sensor data to be ready"""

examples/as7341_simpletest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ def bar_graph(read_value):
2323
print("F6 - 590nm/Yellow %s" % bar_graph(sensor.channel_590nm))
2424
print("F7 - 630nm/Orange %s" % bar_graph(sensor.channel_630nm))
2525
print("F8 - 680nm/Red %s" % bar_graph(sensor.channel_680nm))
26+
print("Clear %s" % bar_graph(sensor.channel_clear))
27+
print("Near-IR (NIR) %s" % bar_graph(sensor.channel_nir))
2628
print("\n------------------------------------------------")
2729
sleep(1)

0 commit comments

Comments
 (0)