@@ -120,6 +120,33 @@ void Adafruit_TCS34725::enable(void)
120
120
write8 (TCS34725_ENABLE, TCS34725_ENABLE_PON);
121
121
delay (3 );
122
122
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
+ }
123
150
}
124
151
125
152
/* *************************************************************************/
@@ -253,6 +280,21 @@ void Adafruit_TCS34725::getRawData (uint16_t *r, uint16_t *g, uint16_t *b, uint1
253
280
}
254
281
}
255
282
283
+ /* *************************************************************************/
284
+ /* !
285
+ @brief Reads the raw red, green, blue and clear channel values in
286
+ one-shot mode (e.g., wakes from sleep, takes measurement, enters sleep)
287
+ */
288
+ /* *************************************************************************/
289
+ void Adafruit_TCS34725::getRawDataOneShot (uint16_t *r, uint16_t *g, uint16_t *b, uint16_t *c)
290
+ {
291
+ if (!_tcs34725Initialised) begin ();
292
+
293
+ enable ();
294
+ getRawData (r, g, b ,c);
295
+ disable ();
296
+ }
297
+
256
298
/* *************************************************************************/
257
299
/* !
258
300
@brief Converts the raw R/G/B values to color temperature in degrees
0 commit comments