6 #ifndef __SENSORS_TSL2561_h__
7 #define __SENSORS_TSL2561_h__
16 template <
int ADDRESS=TSL2561_ADDR_LOW>
21 Tsl2561 () : _tsl(ADDRESS), _x16(
true) {}
23 if( (_present = _tsl.begin()) ==
true ) {
24 _tsl.setGain(TSL2561_GAIN_16X);
25 _tsl.setTiming(TSL2561_INTEGRATIONTIME_101MS);
26 DPRINT(
"TSL2561 found at 0x");DHEXLN((uint8_t)ADDRESS);
29 DPRINTLN(
"No TSL2561 present");
32 void measure (__attribute__((unused))
bool async=
false) {
33 if( present() ==
true ) {
34 uint16_t b = _tsl.getLuminosity(TSL2561_VISIBLE);
35 if( b > 63000 && _x16 ==
true ) {
37 _tsl.setGain(TSL2561_GAIN_0X);
38 b = _tsl.getLuminosity(TSL2561_VISIBLE);
40 else if ( b < 500 && _x16 ==
false ) {
42 _tsl.setGain(TSL2561_GAIN_16X);
43 b = _tsl.getLuminosity(TSL2561_VISIBLE);
45 DPRINT(
"Brightness: ");DDECLN(b);