Skip to content
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

using _all_channels to update efficiently #34

Merged
merged 2 commits into from
Dec 23, 2023
Merged
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
6 changes: 4 additions & 2 deletions adafruit_as7341.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,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 @@ -465,6 +465,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 @@ -488,6 +489,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