.. highlight:: java TSL2671 Proximity Detector ========================== The `Tsl2671Proximity `_ class controls the proximity detector on MetaDetector boards. The detector uses photodiodes responsive to both visible and infared light and integrating ADCs to convert the photodiode currents into a digital value. Sensor Configuration -------------------- Configuring the TSL2671 detector is done with the `Tsl2671Proximity.ConfigEditor `_ interface. There are 4 options to configure: These settings control the sensitivity and distance at which the sensor can detect proximity. It is recommended that you use the channel 1 receiver diode, and, if your board is powered by the CR2032 battery, keep the driver current at 25mA or lower. :: import com.mbientlab.metawear.module.Tsl2671Proximity; final Tsl2671Proximity proximity= mwBoard.getModule(Tsl2671Proximity.class); proximity.configure() .setReceiverDiode(Tsl2671Proximity.ReceiverDiode.CHANNEL_1) .setTransmitterDriver(Tsl2671Proximity.TransmitterDrive.CURRENT_12_5MA) .commit(); Detecting Proximity ------------------- To detect proximity from the board, call the `readProximity `_ method. The distance between the detector and the object is given as an ADC ratio where a higher value corresponds to a closer distance. :: proximity.routeData().fromSensor(false).stream("proximity").commit() .onComplete(new CompletionHandler() { @Override public void success(RouteManager result) { result.subscribe("proximity", new RouteManager.MessageHandler() { @Override public void process(Message msg) { Log.i("test", msg.getData(Integer.class).toString()); } }); proximity.readProximity(false); } });