Skip to content

Commit

Permalink
Merge pull request #34 from garyk10/patch-1
Browse files Browse the repository at this point in the history
using _all_channels to update efficiently
  • Loading branch information
FoamyGuy authored Dec 23, 2023
2 parents fcc7bd3 + 0afda19 commit 26697ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions adafruit_as7341.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ def channel_680nm(self) -> int:
@property
def channel_clear(self) -> int:
"""The current reading for the clear sensor"""
self._configure_f5_f8()
_ = self._all_channels
return self._channel_4_data

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

def _wait_for_data(self, timeout: float = 1.0) -> None:
Expand All @@ -463,6 +463,7 @@ def _configure_f1_f4(self) -> None:
"""Configure the sensor to read from elements F1-F4, Clear, and NIR"""
# disable SP_EN bit while making config changes
if self._low_channels_configured:
_ = self._all_channels
return
self._high_channels_configured = False
self._flicker_detection_1k_configured = False
Expand All @@ -486,6 +487,7 @@ def _configure_f5_f8(self) -> None:
"""Configure the sensor to read from elements F5-F8, Clear, and NIR"""
# disable SP_EN bit while making config changes
if self._high_channels_configured:
_ = self._all_channels
return

self._low_channels_configured = False
Expand Down

0 comments on commit 26697ad

Please sign in to comment.