Skip to content

Commit 26697ad

Browse files
authored
Merge pull request #34 from garyk10/patch-1
using _all_channels to update efficiently
2 parents fcc7bd3 + 0afda19 commit 26697ad

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
@@ -435,13 +435,13 @@ def channel_680nm(self) -> int:
435435
@property
436436
def channel_clear(self) -> int:
437437
"""The current reading for the clear sensor"""
438-
self._configure_f5_f8()
438+
_ = self._all_channels
439439
return self._channel_4_data
440440

441441
@property
442442
def channel_nir(self) -> int:
443443
"""The current reading for the NIR (near-IR) sensor"""
444-
self._configure_f5_f8()
444+
_ = self._all_channels
445445
return self._channel_5_data
446446

447447
def _wait_for_data(self, timeout: float = 1.0) -> None:
@@ -463,6 +463,7 @@ def _configure_f1_f4(self) -> None:
463463
"""Configure the sensor to read from elements F1-F4, Clear, and NIR"""
464464
# disable SP_EN bit while making config changes
465465
if self._low_channels_configured:
466+
_ = self._all_channels
466467
return
467468
self._high_channels_configured = False
468469
self._flicker_detection_1k_configured = False
@@ -486,6 +487,7 @@ def _configure_f5_f8(self) -> None:
486487
"""Configure the sensor to read from elements F5-F8, Clear, and NIR"""
487488
# disable SP_EN bit while making config changes
488489
if self._high_channels_configured:
490+
_ = self._all_channels
489491
return
490492

491493
self._low_channels_configured = False

0 commit comments

Comments
 (0)