Skip to content

Commit 781a421

Browse files
committed
Set constant for number of samples for averaging
1 parent b687c38 commit 781a421

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Adafruit_TSL2561/Adafruit_TSL2561.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# Added calculateAvgLux
1919
# Changed main method to use calculateAvgLux and looping support added.
2020
# Ported "Extended delays to take into account loose timing with 'delay'" update from CPP code
21+
# Added have so that with autogain every sample goes from 1x to 16x as going from 16x to 1x does not work
2122
#
2223

2324
import sys
@@ -141,6 +142,8 @@ class Adafruit_TSL2651(Adafruit_I2C):
141142

142143
TSL2561_GAIN_1X = 0x00 # No gain
143144
TSL2561_GAIN_16X = 0x10 # 16x gain
145+
146+
TSL2561_NO_OF_AVG_SAMPLES = 25 # How many samples to make an average reading
144147

145148

146149

@@ -489,7 +492,7 @@ def calculateLux(self):
489492
#**************************************************************************/
490493
# Calculates an averaged Lux value over default 30 samples
491494
#**************************************************************************/
492-
def calculateAvgLux(self, testavg=int(30)):
495+
def calculateAvgLux(self, testavg=self.TSL2561_NO_OF_AVG_SAMPLES):
493496
# Set initial vars
494497
count = 0
495498
luxavgtotal = 0

0 commit comments

Comments
 (0)