TCS34725 Color Detector¶
The TCS34725ColorDetector class controls the color detector on MetaEnviroment boards. The detector is comprised of an array of red-filtered, green-filtered, blue-filtered, and unfiltered photodiodes and uses 4 integrating ADCs to convert the photodiode current into a digital value.
Detecing Color¶
To read color ADC values, call the readColorAdc function. Data is encapsulated in the ColorAdc interface. The adc range, resolution, and sensitivity are influence by the integration time and gain multiplier, configurable with the Tcs34725.ConfigEditor interface.
import com.mbientlab.metawear.module.Tcs34725ColorDetector;
import com.mbientlab.metawear.module.Tcs34725ColorDetector.ColorAdc;
final Tcs34725ColorDetector colorDetectorModule= mwBoard.get(Tcs34725ColorDetector.class);
colorDetectorModule.routeData().fromSensor(false).stream("color_adc").commit()
.onComplete(new CompletionHandler<RouteManager>() {
@Override
public void success(RouteManager result) {
result.subscribe("color_adc", new MessageHandler() {
@Override
public void process(Message msg) {
ColorAdc adc= message.getData(ColorAdc.class);
Log.i("MainActivity", "Color adc: " + adc);
}
});
colorDetectorModule.readColorAdc(false);
}
});