Skip to content

Commit 3240680

Browse files
committed
fixing smuxing issue and excessive waits for data
1 parent baaf1dd commit 3240680

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

adafruit_as7341.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,9 @@ def all_channels(self):
290290
"""The current readings for all six ADC channels"""
291291

292292
self._configure_f1_f4()
293-
self._wait_for_data()
294293
low_channel_reads = self._all_channels
295294

296295
self._configure_f5_f8()
297-
self._wait_for_data()
298296
high_channel_reads = self._all_channels
299297

300298
return low_channel_reads + high_channel_reads
@@ -303,56 +301,48 @@ def all_channels(self):
303301
def channel_415nm(self):
304302
"""The current reading for the 415nm band"""
305303
self._configure_f1_f4()
306-
self._wait_for_data()
307304
return self._channel_0_data
308305

309306
@property
310307
def channel_445nm(self):
311308
"""The current reading for the 445nm band"""
312309
self._configure_f1_f4()
313-
self._wait_for_data()
314310
return self._channel_1_data
315311

316312
@property
317313
def channel_480nm(self):
318314
"""The current reading for the 480nm band"""
319315
self._configure_f1_f4()
320-
self._wait_for_data()
321316
return self._channel_2_data
322317

323318
@property
324319
def channel_515nm(self):
325320
"""The current reading for the 515nm band"""
326321
self._configure_f1_f4()
327-
self._wait_for_data()
328322
return self._channel_3_data
329323

330324
@property
331325
def channel_555nm(self):
332326
"""The current reading for the 555nm band"""
333327
self._configure_f5_f8()
334-
self._wait_for_data()
335328
return self._channel_0_data
336329

337330
@property
338331
def channel_590nm(self):
339332
"""The current reading for the 590nm band"""
340333
self._configure_f5_f8()
341-
self._wait_for_data()
342334
return self._channel_1_data
343335

344336
@property
345337
def channel_630nm(self):
346338
"""The current reading for the 630nm band"""
347339
self._configure_f5_f8()
348-
self._wait_for_data()
349340
return self._channel_2_data
350341

351342
@property
352343
def channel_680nm(self):
353344
"""The current reading for the 680nm band"""
354345
self._configure_f5_f8()
355-
self._wait_for_data()
356346
return self._channel_3_data
357347

358348
def _wait_for_data(self, timeout=1.0):
@@ -392,6 +382,7 @@ def _configure_f1_f4(self):
392382
# Enable SP_EN bit
393383
self._color_meas_enabled = True
394384
self._low_channels_configured = True
385+
self._wait_for_data()
395386

396387
def _configure_f5_f8(self):
397388
"""Configure the sensor to read from elements F5-F8, Clear, and NIR"""
@@ -414,7 +405,8 @@ def _configure_f5_f8(self):
414405

415406
# Enable SP_EN bit
416407
self._color_meas_enabled = True
417-
self._high_channels_configured = False
408+
self._high_channels_configured = True
409+
self._wait_for_data()
418410

419411
@property
420412
def flicker_detected(self):
@@ -448,7 +440,6 @@ def flicker_detection_enabled(self, flicker_enable):
448440

449441
def _f1f4_clear_nir(self):
450442
"""Configure SMUX for sensors F1-F4, Clear and NIR"""
451-
452443
self.set_smux(SMUX_IN.NC_F3L, SMUX_OUT.DISABLED, SMUX_OUT.ADC2)
453444
self.set_smux(SMUX_IN.F1L_NC, SMUX_OUT.ADC0, SMUX_OUT.DISABLED)
454445
self.set_smux(SMUX_IN.NC_NC0, SMUX_OUT.DISABLED, SMUX_OUT.DISABLED)

0 commit comments

Comments
 (0)