56 #include <Adafruit_Sensor.h>
59 #define TSL2591_VISIBLE (2) // channel 0 - channel 1
60 #define TSL2591_INFRARED (1) // channel 1
61 #define TSL2591_FULLSPECTRUM (0) // channel 0
63 #define TSL2591_ADDR (0x29)
64 #define TSL2591_READBIT (0x01)
66 #define TSL2591_COMMAND_BIT (0xA0) // bits 7 and 5 for 'command normal'
67 #define TSL2591_CLEAR_BIT (0x40) // Clears any pending interrupt (write 1 to clear)
68 #define TSL2591_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
69 #define TSL2591_BLOCK_BIT (0x10) // 1 = using block read/write
71 #define TSL2591_ENABLE_POWERON (0x01)
72 #define TSL2591_ENABLE_POWEROFF (0x00)
73 #define TSL2591_ENABLE_AEN (0x02)
74 #define TSL2591_ENABLE_AIEN (0x10)
76 #define TSL2591_CONTROL_RESET (0x80)
78 #define TSL2591_LUX_DF (408.0F)
79 #define TSL2591_LUX_COEFB (1.64F) // CH0 coefficient
80 #define TSL2591_LUX_COEFC (0.59F) // CH1 coefficient A
81 #define TSL2591_LUX_COEFD (0.86F) // CH2 coefficient B
85 TSL2591_REGISTER_ENABLE = 0x00,
86 TSL2591_REGISTER_CONTROL = 0x01,
87 TSL2591_REGISTER_THRESHHOLDL_LOW = 0x02,
88 TSL2591_REGISTER_THRESHHOLDL_HIGH = 0x03,
89 TSL2591_REGISTER_THRESHHOLDH_LOW = 0x04,
90 TSL2591_REGISTER_THRESHHOLDH_HIGH = 0x05,
91 TSL2591_REGISTER_INTERRUPT = 0x06,
92 TSL2591_REGISTER_CRC = 0x08,
93 TSL2591_REGISTER_ID = 0x0A,
94 TSL2591_REGISTER_CHAN0_LOW = 0x14,
95 TSL2591_REGISTER_CHAN0_HIGH = 0x15,
96 TSL2591_REGISTER_CHAN1_LOW = 0x16,
97 TSL2591_REGISTER_CHAN1_HIGH = 0x17
102 TSL2591_INTEGRATIONTIME_100MS = 0x00,
103 TSL2591_INTEGRATIONTIME_200MS = 0x01,
104 TSL2591_INTEGRATIONTIME_300MS = 0x02,
105 TSL2591_INTEGRATIONTIME_400MS = 0x03,
106 TSL2591_INTEGRATIONTIME_500MS = 0x04,
107 TSL2591_INTEGRATIONTIME_600MS = 0x05,
109 tsl2591IntegrationTime_t;
113 TSL2591_GAIN_LOW = 0x00,
114 TSL2591_GAIN_MED = 0x10,
115 TSL2591_GAIN_HIGH = 0x20,
116 TSL2591_GAIN_MAX = 0x30,
125 boolean begin (
void );
126 void enable (
void );
127 void disable (
void );
128 void write8 ( uint8_t r, uint8_t v );
129 uint16_t read16 ( uint8_t reg );
130 uint8_t read8 ( uint8_t reg );
132 uint32_t calculateLux ( uint16_t ch0, uint16_t ch1 );
133 void setGain ( tsl2591Gain_t gain );
134 void setTiming ( tsl2591IntegrationTime_t integration );
135 uint16_t getLuminosity (uint8_t channel );
136 uint32_t getFullLuminosity ( );
138 tsl2591IntegrationTime_t getTiming();
139 tsl2591Gain_t getGain();
146 tsl2591IntegrationTime_t _integration;
150 boolean _initialized;
void getSensor(sensor_t *)
Gets the sensor_t data.
Definition: Adafruit_TSL2591.cpp:389
Definition: Adafruit_TSL2591.h:120
bool getEvent(sensors_event_t *)
Gets the most recent sensor event.
Definition: Adafruit_TSL2591.cpp:359