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
-
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
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 Details
-
TSL2561
- Throws:
RuntimeIOException
-
TSL2561
- Throws:
RuntimeIOException
-
-
Method Details
-
setAutoGain
public void setAutoGain(boolean autoGain)Enables or disables the auto-gain settings when reading data from the sensor- Parameters:
autoGain
- enable/disable
-
setGain
Adjusts the gain on the TSL2561 (adjusts the sensitivity to light)- Parameters:
gain
- gain value- Throws:
RuntimeIOException
- if an I/O error occurs
-
getLuminosity
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
-