Skip to content

Commit acd6433

Browse files
Austin RhodesAustin Rhodes
Austin Rhodes
authored and
Austin Rhodes
committed
Updated enable funtion to have delay after setting PON and AEN.
1 parent a549bdb commit acd6433

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Adafruit_TCS34725.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,33 @@ void Adafruit_TCS34725::enable(void)
120120
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON);
121121
delay(3);
122122
write8(TCS34725_ENABLE, TCS34725_ENABLE_PON | TCS34725_ENABLE_AEN);
123+
/* Set a delay for the integration time.
124+
This is only necessary in the case where enabling and then
125+
immediately trying to read values back. This is because setting
126+
AEN triggers an automatic integration, so if a read RGBC is
127+
performed too quickly, the data is not yet valid and all 0's are
128+
returned */
129+
switch (_tcs34725IntegrationTime)
130+
{
131+
case TCS34725_INTEGRATIONTIME_2_4MS:
132+
delay(3);
133+
break;
134+
case TCS34725_INTEGRATIONTIME_24MS:
135+
delay(24);
136+
break;
137+
case TCS34725_INTEGRATIONTIME_50MS:
138+
delay(50);
139+
break;
140+
case TCS34725_INTEGRATIONTIME_101MS:
141+
delay(101);
142+
break;
143+
case TCS34725_INTEGRATIONTIME_154MS:
144+
delay(154);
145+
break;
146+
case TCS34725_INTEGRATIONTIME_700MS:
147+
delay(700);
148+
break;
149+
}
123150
}
124151

125152
/**************************************************************************/

0 commit comments

Comments
 (0)