Package com.diozero.devices
Class TSL2561
- java.lang.Object
-
- com.diozero.devices.TSL2561
-
- All Implemented Interfaces:
DeviceInterface
,LuminositySensorInterface
,SensorInterface
,AutoCloseable
public class TSL2561 extends Object implements LuminositySensorInterface
Datasheet Pins:+-----------------------------+ | TSL2561 | |-----+-----+-----+-----+-----| | INT | SDA | SCL | GND | VCC | +-----+-----+-----+-----+-----+
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TSL2561.TSL2561Package
-
Constructor Summary
Constructors Constructor Description TSL2561(int controller, TSL2561.TSL2561Package tsl2561Package)
TSL2561(TSL2561.TSL2561Package tsl2561Package)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this devicefloat
getLuminosity()
Converts the raw sensor values to the standard SI lux equivalent.void
setAutoGain(boolean autoGain)
Enables or disables the auto-gain settings when reading data from the sensorvoid
setGain(int gain)
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)
-
-
-
Constructor Detail
-
TSL2561
public TSL2561(TSL2561.TSL2561Package tsl2561Package) throws RuntimeIOException
- Throws:
RuntimeIOException
-
TSL2561
public TSL2561(int controller, TSL2561.TSL2561Package tsl2561Package) throws RuntimeIOException
- Throws:
RuntimeIOException
-
-
Method Detail
-
setAutoGain
public void setAutoGain(boolean autoGain)
Enables or disables the auto-gain settings when reading data from the sensor- Parameters:
autoGain
- enable/disable
-
setGain
public void setGain(int gain) throws RuntimeIOException
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)- Parameters:
gain
- gain value- Throws:
RuntimeIOException
- if an I/O error occurs
-
getLuminosity
public float getLuminosity() throws RuntimeIOException
Converts the raw sensor values to the standard SI lux equivalent. Returns 0 if the sensor is saturated and the values are unreliable.- Specified by:
getLuminosity
in interfaceLuminositySensorInterface
- Throws:
RuntimeIOException
-
close
public void close()
Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
-
-