Skip to content

Commit 04fbb21

Browse files
authored
Merge pull request #24 from caternuson/iss20
Limit divisors to prevent divide by zero
2 parents 5313110 + 9add0c2 commit 04fbb21

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

adafruit_tcs34725.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,11 @@ def _temperature_and_lux_dn40(self):
308308
# Lux Calculation (DN40 3.2)
309309
G1 = R_Coef * R2 + G_Coef * G2 + B_Coef * B2
310310
CPL = (ATIME_ms * AGAINx) / (GA * DF)
311+
CPL = 0.001 if CPL == 0 else CPL
311312
lux = G1 / CPL
312313

313314
# CT Calculations (DN40 3.4)
315+
R2 = 0.001 if R2 == 0 else R2
314316
CT = CT_Coef * B2 / R2 + CT_Offset
315317

316318
return lux, CT

0 commit comments

Comments
 (0)