Skip to content

Commit 5772169

Browse files
authored
using _all_channels to update efficiently
When not changing between low and high, the _channel_#_data was not being updated. Also, the clear and nir data is available when _low_channels_configured, so no need to change to high.
1 parent 15c6c2e commit 5772169

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_as7341.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,13 @@ def channel_680nm(self) -> int:
436436
@property
437437
def channel_clear(self) -> int:
438438
"""The current reading for the clear sensor"""
439-
self._configure_f5_f8()
439+
self._all_channels
440440
return self._channel_4_data
441441

442442
@property
443443
def channel_nir(self) -> int:
444444
"""The current reading for the NIR (near-IR) sensor"""
445-
self._configure_f5_f8()
445+
self._all_channels
446446
return self._channel_5_data
447447

448448
def _wait_for_data(self, timeout: float = 1.0) -> None:
@@ -465,6 +465,7 @@ def _configure_f1_f4(self) -> None:
465465
"""Configure the sensor to read from elements F1-F4, Clear, and NIR"""
466466
# disable SP_EN bit while making config changes
467467
if self._low_channels_configured:
468+
self._all_channels
468469
return
469470
self._high_channels_configured = False
470471
self._flicker_detection_1k_configured = False
@@ -488,6 +489,7 @@ def _configure_f5_f8(self) -> None:
488489
"""Configure the sensor to read from elements F5-F8, Clear, and NIR"""
489490
# disable SP_EN bit while making config changes
490491
if self._high_channels_configured:
492+
self._all_channels
491493
return
492494

493495
self._low_channels_configured = False

0 commit comments

Comments
 (0)