A lux sensor library

Dependents:   Adafruit_TSL2561

Committer:
eawendtjr
Date:
Thu Jul 23 21:18:25 2015 +0000
Revision:
0:a3cedb66846f
Child:
1:52b855c13204
LUX sensor library-not working yet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eawendtjr 0:a3cedb66846f 1 // date 7/6/2015
eawendtjr 0:a3cedb66846f 2 // author E wendt
eawendtjr 0:a3cedb66846f 3
eawendtjr 0:a3cedb66846f 4 //TSL2561 light sensor library
eawendtjr 0:a3cedb66846f 5
eawendtjr 0:a3cedb66846f 6 #ifndef _TSL2561_H_
eawendtjr 0:a3cedb66846f 7 #define _TSL2561_H_
eawendtjr 0:a3cedb66846f 8
eawendtjr 0:a3cedb66846f 9 #include "mbed.h"
eawendtjr 0:a3cedb66846f 10 //#define TSL2561_ADDRESS (0x39)
eawendtjr 0:a3cedb66846f 11
eawendtjr 0:a3cedb66846f 12 #define TSL2561_VISIBLE 2 // channel 0 - channel 1
eawendtjr 0:a3cedb66846f 13 #define TSL2561_INFRARED 1 // channel 1
eawendtjr 0:a3cedb66846f 14 #define TSL2561_FULLSPECTRUM 0 // channel 0
eawendtjr 0:a3cedb66846f 15
eawendtjr 0:a3cedb66846f 16 // 3 i2c address options!
eawendtjr 0:a3cedb66846f 17 //#define TSL2561_ADDR_LOW 0x29
eawendtjr 0:a3cedb66846f 18 #define TSL2561_ADDR_FLOAT (0x39<<1)
eawendtjr 0:a3cedb66846f 19 //#define TSL2561_ADDR_HIGH 0x49
eawendtjr 0:a3cedb66846f 20
eawendtjr 0:a3cedb66846f 21 // Lux calculations differ slightly for CS package
eawendtjr 0:a3cedb66846f 22 //#define TSL2561_PACKAGE_CS
eawendtjr 0:a3cedb66846f 23 #define TSL2561_PACKAGE_T_FN_CL
eawendtjr 0:a3cedb66846f 24
eawendtjr 0:a3cedb66846f 25 #define TSL2561_READBIT (0x01)
eawendtjr 0:a3cedb66846f 26
eawendtjr 0:a3cedb66846f 27 #define TSL2561_COMMAND_BIT (0x80) // Must be 1
eawendtjr 0:a3cedb66846f 28 #define TSL2561_CLEAR_BIT (0x40) // Clears any pending interrupt (write 1 to clear)
eawendtjr 0:a3cedb66846f 29 #define TSL2561_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
eawendtjr 0:a3cedb66846f 30 #define TSL2561_BLOCK_BIT (0x10) // 1 = using block read/write
eawendtjr 0:a3cedb66846f 31
eawendtjr 0:a3cedb66846f 32 #define TSL2561_CONTROL_POWERON (0x03)
eawendtjr 0:a3cedb66846f 33 #define TSL2561_CONTROL_POWEROFF (0x00)
eawendtjr 0:a3cedb66846f 34
eawendtjr 0:a3cedb66846f 35 //different timing and gain settings
eawendtjr 0:a3cedb66846f 36 /*#define TSL2561_INTEGRATIONTIME_13MS (0x00) // 13.7ms
eawendtjr 0:a3cedb66846f 37 #define TSL2561_INTEGRATIONTIME_101MS (0x01) // 101ms
eawendtjr 0:a3cedb66846f 38 #define TSL2561_INTEGRATIONTIME_402MS (0x02) // 402ms
eawendtjr 0:a3cedb66846f 39
eawendtjr 0:a3cedb66846f 40 #define TSL2561_GAIN_0X (0x00) //x1
eawendtjr 0:a3cedb66846f 41 #define TSL2561_GAIN_16X (0x10) //x16*/
eawendtjr 0:a3cedb66846f 42
eawendtjr 0:a3cedb66846f 43
eawendtjr 0:a3cedb66846f 44 #define LUX_SCALE 14 // scale by 2^14
eawendtjr 0:a3cedb66846f 45 #define RATIO_SCALE 9 // scale ratio by 2^9
eawendtjr 0:a3cedb66846f 46
eawendtjr 0:a3cedb66846f 47 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 48 // Integration time scaling factors
eawendtjr 0:a3cedb66846f 49 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 50
eawendtjr 0:a3cedb66846f 51 #define CH_SCALE 10 // scale channel values by 2^10
eawendtjr 0:a3cedb66846f 52 #define CHSCALE_TINT0 0x7517 // 322/11 * 2^CH_SCALE
eawendtjr 0:a3cedb66846f 53 #define CHSCALE_TINT1 0x0fe7 // 322/81 * 2^CH_SCALE
eawendtjr 0:a3cedb66846f 54
eawendtjr 0:a3cedb66846f 55 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 56 // T, FN, and CL Package coefficients
eawendtjr 0:a3cedb66846f 57 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 58 // For Ch1/Ch0=0.00 to 0.50
eawendtjr 0:a3cedb66846f 59 // Lux/Ch0=0.0304−0.062*((Ch1/Ch0)^1.4)
eawendtjr 0:a3cedb66846f 60 // piecewise approximation
eawendtjr 0:a3cedb66846f 61 // For Ch1/Ch0=0.00 to 0.125:
eawendtjr 0:a3cedb66846f 62 // Lux/Ch0=0.0304−0.0272*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 63 //
eawendtjr 0:a3cedb66846f 64 // For Ch1/Ch0=0.125 to 0.250:
eawendtjr 0:a3cedb66846f 65 // Lux/Ch0=0.0325−0.0440*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 66 //
eawendtjr 0:a3cedb66846f 67 // For Ch1/Ch0=0.250 to 0.375:
eawendtjr 0:a3cedb66846f 68 // Lux/Ch0=0.0351−0.0544*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 69 //
eawendtjr 0:a3cedb66846f 70 // For Ch1/Ch0=0.375 to 0.50:
eawendtjr 0:a3cedb66846f 71 // Lux/Ch0=0.0381−0.0624*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 72 //
eawendtjr 0:a3cedb66846f 73 // For Ch1/Ch0=0.50 to 0.61:
eawendtjr 0:a3cedb66846f 74 // Lux/Ch0=0.0224−0.031*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 75 //
eawendtjr 0:a3cedb66846f 76 // For Ch1/Ch0=0.61 to 0.80:
eawendtjr 0:a3cedb66846f 77 // Lux/Ch0=0.0128−0.0153*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 78 //
eawendtjr 0:a3cedb66846f 79 // For Ch1/Ch0=0.80 to 1.30:
eawendtjr 0:a3cedb66846f 80 // Lux/Ch0=0.00146−0.00112*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 81 //
eawendtjr 0:a3cedb66846f 82 // For Ch1/Ch0>1.3:
eawendtjr 0:a3cedb66846f 83 // Lux/Ch0=0
eawendtjr 0:a3cedb66846f 84 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 85
eawendtjr 0:a3cedb66846f 86 #define K1T 0x0040 // 0.125 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 87 #define B1T 0x01f2 // 0.0304 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 88 #define M1T 0x01be // 0.0272 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 89
eawendtjr 0:a3cedb66846f 90 #define K2T 0x0080 // 0.250 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 91 #define B2T 0x0214 // 0.0325 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 92 #define M2T 0x02d1 // 0.0440 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 93
eawendtjr 0:a3cedb66846f 94 #define K3T 0x00c0 // 0.375 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 95 #define B3T 0x023f // 0.0351 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 96 #define M3T 0x037b // 0.0544 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 97
eawendtjr 0:a3cedb66846f 98 #define K4T 0x0100 // 0.50 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 99 #define B4T 0x0270 // 0.0381 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 100 #define M4T 0x03fe // 0.0624 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 101
eawendtjr 0:a3cedb66846f 102 #define K5T 0x0138 // 0.61 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 103 #define B5T 0x016f // 0.0224 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 104 #define M5T 0x01fc // 0.0310 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 105
eawendtjr 0:a3cedb66846f 106 #define K6T 0x019a // 0.80 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 107 #define B6T 0x00d2 // 0.0128 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 108 #define M6T 0x00fb // 0.0153 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 109
eawendtjr 0:a3cedb66846f 110 #define K7T 0x029a // 1.3 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 111 #define B7T 0x0018 // 0.00146 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 112 #define M7T 0x0012 // 0.00112 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 113
eawendtjr 0:a3cedb66846f 114 #define K8T 0x029a // 1.3 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 115 #define B8T 0x0000 // 0.000 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 116 #define M8T 0x0000 // 0.000 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 117
eawendtjr 0:a3cedb66846f 118 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 119 // CS package coefficients
eawendtjr 0:a3cedb66846f 120 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 121 // For 0 <= Ch1/Ch0 <= 0.52
eawendtjr 0:a3cedb66846f 122 // Lux/Ch0 = 0.0315−0.0593*((Ch1/Ch0)^1.4)
eawendtjr 0:a3cedb66846f 123 // piecewise approximation
eawendtjr 0:a3cedb66846f 124 // For 0 <= Ch1/Ch0 <= 0.13
eawendtjr 0:a3cedb66846f 125 // Lux/Ch0 = 0.0315−0.0262*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 126 // For 0.13 <= Ch1/Ch0 <= 0.26
eawendtjr 0:a3cedb66846f 127 // Lux/Ch0 = 0.0337−0.0430*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 128 // For 0.26 <= Ch1/Ch0 <= 0.39
eawendtjr 0:a3cedb66846f 129 // Lux/Ch0 = 0.0363−0.0529*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 130 // For 0.39 <= Ch1/Ch0 <= 0.52
eawendtjr 0:a3cedb66846f 131 // Lux/Ch0 = 0.0392−0.0605*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 132 // For 0.52 < Ch1/Ch0 <= 0.65
eawendtjr 0:a3cedb66846f 133 // Lux/Ch0 = 0.0229−0.0291*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 134 // For 0.65 < Ch1/Ch0 <= 0.80
eawendtjr 0:a3cedb66846f 135 // Lux/Ch0 = 0.00157−0.00180*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 136 // For 0.80 < Ch1/Ch0 <= 1.30
eawendtjr 0:a3cedb66846f 137 // Lux/Ch0 = 0.00338−0.00260*(Ch1/Ch0)
eawendtjr 0:a3cedb66846f 138 // For Ch1/Ch0 > 1.30
eawendtjr 0:a3cedb66846f 139 // Lux = 0
eawendtjr 0:a3cedb66846f 140 //−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
eawendtjr 0:a3cedb66846f 141
eawendtjr 0:a3cedb66846f 142 #define K1C 0x0043 // 0.130 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 143 #define B1C 0x0204 // 0.0315 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 144 #define M1C 0x01ad // 0.0262 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 145
eawendtjr 0:a3cedb66846f 146 #define K2C 0x0085 // 0.260 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 147 #define B2C 0x0228 // 0.0337 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 148 #define M2C 0x02c1 // 0.0430 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 149
eawendtjr 0:a3cedb66846f 150 #define K3C 0x00c8 // 0.390 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 151 #define B3C 0x0253 // 0.0363 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 152 #define M3C 0x0363 // 0.0529 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 153
eawendtjr 0:a3cedb66846f 154 #define K4C 0x010a // 0.520 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 155 #define B4C 0x0282 // 0.0392 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 156 #define M4C 0x03df // 0.0605 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 157
eawendtjr 0:a3cedb66846f 158 #define K5C 0x014d // 0.65 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 159 #define B5C 0x0177 // 0.0229 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 160 #define M5C 0x01dd // 0.0291 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 161
eawendtjr 0:a3cedb66846f 162 #define K6C 0x019a // 0.80 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 163 #define B6C 0x0101 // 0.0157 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 164 #define M6C 0x0127 // 0.0180 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 165
eawendtjr 0:a3cedb66846f 166 #define K7C 0x029a // 1.3 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 167 #define B7C 0x0037 // 0.00338 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 168 #define M7C 0x002b // 0.00260 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 169
eawendtjr 0:a3cedb66846f 170 #define K8C 0x029a // 1.3 * 2^RATIO_SCALE
eawendtjr 0:a3cedb66846f 171 #define B8C 0x0000 // 0.000 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 172 #define M8C 0x0000 // 0.000 * 2^LUX_SCALE
eawendtjr 0:a3cedb66846f 173
eawendtjr 0:a3cedb66846f 174 //Enum of all the register addresses as not to put hex numbers in .cpp
eawendtjr 0:a3cedb66846f 175
eawendtjr 0:a3cedb66846f 176 enum
eawendtjr 0:a3cedb66846f 177 {
eawendtjr 0:a3cedb66846f 178 TSL2561_REGISTER_CONTROL = 0x00,
eawendtjr 0:a3cedb66846f 179 TSL2561_REGISTER_TIMING = 0x01,
eawendtjr 0:a3cedb66846f 180 TSL2561_REGISTER_THRESHHOLDL_LOW = 0x02,
eawendtjr 0:a3cedb66846f 181 TSL2561_REGISTER_THRESHHOLDL_HIGH = 0x03,
eawendtjr 0:a3cedb66846f 182 TSL2561_REGISTER_THRESHHOLDH_LOW = 0x04,
eawendtjr 0:a3cedb66846f 183 TSL2561_REGISTER_THRESHHOLDH_HIGH = 0x05,
eawendtjr 0:a3cedb66846f 184 TSL2561_REGISTER_INTERRUPT = 0x06,
eawendtjr 0:a3cedb66846f 185 TSL2561_REGISTER_CRC = 0x08,
eawendtjr 0:a3cedb66846f 186 TSL2561_REGISTER_ID = 0x0A,
eawendtjr 0:a3cedb66846f 187 TSL2561_REGISTER_CHAN0_LOW = 0x0C,
eawendtjr 0:a3cedb66846f 188 TSL2561_REGISTER_CHAN0_HIGH = 0x0D,
eawendtjr 0:a3cedb66846f 189 TSL2561_REGISTER_CHAN1_LOW = 0x0E,
eawendtjr 0:a3cedb66846f 190 TSL2561_REGISTER_CHAN1_HIGH = 0x0F
eawendtjr 0:a3cedb66846f 191 };
eawendtjr 0:a3cedb66846f 192
eawendtjr 0:a3cedb66846f 193 typedef enum
eawendtjr 0:a3cedb66846f 194 {
eawendtjr 0:a3cedb66846f 195 TSL2561_INTEGRATIONTIME_13MS = 0x00, // 13.7ms
eawendtjr 0:a3cedb66846f 196 TSL2561_INTEGRATIONTIME_101MS = 0x01, // 101ms
eawendtjr 0:a3cedb66846f 197 TSL2561_INTEGRATIONTIME_402MS = 0x02 // 402ms
eawendtjr 0:a3cedb66846f 198 }
eawendtjr 0:a3cedb66846f 199 tsl2561IntegrationTime_t;
eawendtjr 0:a3cedb66846f 200
eawendtjr 0:a3cedb66846f 201 typedef enum
eawendtjr 0:a3cedb66846f 202 {
eawendtjr 0:a3cedb66846f 203 TSL2561_GAIN_0X = 0x00, // No gain
eawendtjr 0:a3cedb66846f 204 TSL2561_GAIN_16X = 0x10, // 16x gain
eawendtjr 0:a3cedb66846f 205 }
eawendtjr 0:a3cedb66846f 206 tsl2561Gain_t;
eawendtjr 0:a3cedb66846f 207
eawendtjr 0:a3cedb66846f 208 extern Serial pc;
eawendtjr 0:a3cedb66846f 209
eawendtjr 0:a3cedb66846f 210 class TSL2561
eawendtjr 0:a3cedb66846f 211 {
eawendtjr 0:a3cedb66846f 212 public:
eawendtjr 0:a3cedb66846f 213 //create instances
eawendtjr 0:a3cedb66846f 214 TSL2561(PinName sda, PinName scl, char slave_address = TSL2561_ADDR_FLOAT);
eawendtjr 0:a3cedb66846f 215
eawendtjr 0:a3cedb66846f 216 TSL2561(I2C &i2c_obj, char slave_adr = TSL2561_ADDR_FLOAT);
eawendtjr 0:a3cedb66846f 217
eawendtjr 0:a3cedb66846f 218 //destructor
eawendtjr 0:a3cedb66846f 219 //virtual ~TSL2561()
eawendtjr 0:a3cedb66846f 220
eawendtjr 0:a3cedb66846f 221 /** Begin Initialization SI1145 sensor
eawendtjr 0:a3cedb66846f 222 * Configure sensor setting and read parameters for calibration
eawendtjr 0:a3cedb66846f 223 */
eawendtjr 0:a3cedb66846f 224
eawendtjr 0:a3cedb66846f 225 //check id register before proceeding
eawendtjr 0:a3cedb66846f 226 bool begin(void);
eawendtjr 0:a3cedb66846f 227
eawendtjr 0:a3cedb66846f 228 //Enable sensor using control register
eawendtjr 0:a3cedb66846f 229 void enable(void);
eawendtjr 0:a3cedb66846f 230
eawendtjr 0:a3cedb66846f 231 //Disable sensor using control register
eawendtjr 0:a3cedb66846f 232 void disable(void);
eawendtjr 0:a3cedb66846f 233
eawendtjr 0:a3cedb66846f 234 //set the integration time using command and timing registers
eawendtjr 0:a3cedb66846f 235 void setTiming(tsl2561IntegrationTime_t integration);
eawendtjr 0:a3cedb66846f 236
eawendtjr 0:a3cedb66846f 237 //set the gain using command and timing registers
eawendtjr 0:a3cedb66846f 238 void setGain(tsl2561Gain_t gain);
eawendtjr 0:a3cedb66846f 239
eawendtjr 0:a3cedb66846f 240 //Read data registers than convert to a lux value
eawendtjr 0:a3cedb66846f 241 uint32_t calculateLux(uint16_t ch0, uint16_t ch1);
eawendtjr 0:a3cedb66846f 242
eawendtjr 0:a3cedb66846f 243 //get luminosity from data registers
eawendtjr 0:a3cedb66846f 244 uint32_t getFullLuminosity (void);
eawendtjr 0:a3cedb66846f 245 uint16_t getLuminosity (uint8_t channel);
eawendtjr 0:a3cedb66846f 246
eawendtjr 0:a3cedb66846f 247
eawendtjr 0:a3cedb66846f 248 //function to read data
eawendtjr 0:a3cedb66846f 249 uint16_t get_lux(void);
eawendtjr 0:a3cedb66846f 250
eawendtjr 0:a3cedb66846f 251 private:
eawendtjr 0:a3cedb66846f 252 I2C *i2c_p;
eawendtjr 0:a3cedb66846f 253 I2C &i2c;
eawendtjr 0:a3cedb66846f 254 char address;
eawendtjr 0:a3cedb66846f 255 tsl2561IntegrationTime_t _integration;
eawendtjr 0:a3cedb66846f 256 tsl2561Gain_t _gain;
eawendtjr 0:a3cedb66846f 257 bool _initialized;
eawendtjr 0:a3cedb66846f 258 int32_t t_fine;
eawendtjr 0:a3cedb66846f 259
eawendtjr 0:a3cedb66846f 260
eawendtjr 0:a3cedb66846f 261 };
eawendtjr 0:a3cedb66846f 262 #endif
eawendtjr 0:a3cedb66846f 263 /*class TSL2561 {
eawendtjr 0:a3cedb66846f 264 public:
eawendtjr 0:a3cedb66846f 265 TSL2561(uint8_t addr);
eawendtjr 0:a3cedb66846f 266 boolean begin(void);
eawendtjr 0:a3cedb66846f 267 void enable(void);
eawendtjr 0:a3cedb66846f 268 void disable(void);
eawendtjr 0:a3cedb66846f 269 void write8(uint8_t r, uint8_t v);
eawendtjr 0:a3cedb66846f 270 uint16_t read16(uint8_t reg);
eawendtjr 0:a3cedb66846f 271
eawendtjr 0:a3cedb66846f 272 uint32_t calculateLux(uint16_t ch0, uint16_t ch1);
eawendtjr 0:a3cedb66846f 273 void setTiming(tsl2561IntegrationTime_t integration);
eawendtjr 0:a3cedb66846f 274 void setGain(tsl2561Gain_t gain);
eawendtjr 0:a3cedb66846f 275 uint16_t getLuminosity (uint8_t channel);
eawendtjr 0:a3cedb66846f 276 uint32_t getFullLuminosity ();
eawendtjr 0:a3cedb66846f 277
eawendtjr 0:a3cedb66846f 278 private:
eawendtjr 0:a3cedb66846f 279 int8_t _addr;
eawendtjr 0:a3cedb66846f 280 tsl2561IntegrationTime_t _integration;
eawendtjr 0:a3cedb66846f 281 tsl2561Gain_t _gain;
eawendtjr 0:a3cedb66846f 282
eawendtjr 0:a3cedb66846f 283 boolean _initialized;
eawendtjr 0:a3cedb66846f 284 };*/