I added 2 new functions to read TCS34725 CRGB registry adresses at once. Because I wanted to read data as quickly as possible from sensors on a TCA9548A multiplexer.
CRGB addresses in the TCS34725 are consecutive then it is not necessary to do many write, requestFrom and read. All can be done at once. The I2C bus is also less busy.
Here the different times I measured on a Arduino Uno Rev3:
tcs.read16 x4 (CRGB) : 552us x 4 = 2.208ms
tcs.read16 x3 (RGB) : 552us x 3 = 1.656ms
getFastRawRGBC : 1.150ms
getFastRawRGB : 0.950ms
Then with 8 sensors on a TCA9548A and as I don't need Clear value, I went down to 9.4ms from 19.5ms to get whole RGB data. A tcaSelect function adds 0.231ms per sensor:
(2.208+0.231)8 = 19.5ms
(0.950+0.231)8 = 9.4ms
I don't know if there are some downside to that. Code could be optimized. I didn't exactly understand the TCS34725_COMMAND_BIT. From the Datasheet / Figure 25, I see it does a "Repeated byte protocol". I would have done an "Auto-increment protocol transaction" with a 0b10100000 instead but it seems to change nothing and the 0b10000000 seems OK, then... But I don't like to not understand what I'm doing.
I added 2 new functions to read TCS34725 CRGB registry adresses at once. Because I wanted to read data as quickly as possible from sensors on a TCA9548A multiplexer.
CRGB addresses in the TCS34725 are consecutive then it is not necessary to do many write, requestFrom and read. All can be done at once. The I2C bus is also less busy.
Here the different times I measured on a Arduino Uno Rev3: tcs.read16 x4 (CRGB) : 552us x 4 = 2.208ms tcs.read16 x3 (RGB) : 552us x 3 = 1.656ms getFastRawRGBC : 1.150ms getFastRawRGB : 0.950ms Then with 8 sensors on a TCA9548A and as I don't need Clear value, I went down to 9.4ms from 19.5ms to get whole RGB data. A tcaSelect function adds 0.231ms per sensor: (2.208+0.231)8 = 19.5ms (0.950+0.231)8 = 9.4ms
I don't know if there are some downside to that. Code could be optimized. I didn't exactly understand the TCS34725_COMMAND_BIT. From the Datasheet / Figure 25, I see it does a "Repeated byte protocol". I would have done an "Auto-increment protocol transaction" with a 0b10100000 instead but it seems to change nothing and the 0b10000000 seems OK, then... But I don't like to not understand what I'm doing.