Skip to content

Commit b687c38

Browse files
committed
Moved the set gain to 1X at the beginning of every sample when using autogain as hack for fixing 16X to 1X not working.
1 parent b6a4f09 commit b687c38

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Adafruit_TSL2561/Adafruit_TSL2561.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ def setGain(self, gain):
313313
# the TSL2561, adjusting gain if auto-gain is enabled
314314
#**************************************************************************/
315315
def getLuminosity (self):
316+
# This is a hack to ensure that when looping with autogain the gain can go up and down as without
317+
# setting the gain to 1X before every reading it doesn't seem able to go from 16X
318+
# back to 1X again. Going from 1X to 16X works fine. - IC
319+
if (self._tsl2561AutoGain):
320+
self.setGain(self.TSL2561_GAIN_1X)
321+
316322
if (self._debug == True): print "getLuminosity"
317323
valid = False
318324

@@ -484,7 +490,6 @@ def calculateLux(self):
484490
# Calculates an averaged Lux value over default 30 samples
485491
#**************************************************************************/
486492
def calculateAvgLux(self, testavg=int(30)):
487-
self.setGain(self.TSL2561_GAIN_1X)
488493
# Set initial vars
489494
count = 0
490495
luxavgtotal = 0

0 commit comments

Comments
 (0)