A lux sensor library

Dependents:   Adafruit_TSL2561

Committer:
eawendtjr
Date:
Tue Aug 04 17:15:01 2015 +0000
Revision:
1:52b855c13204
Parent:
0:a3cedb66846f
Child:
2:c45d34e9c3f0
Library written but not quite working.

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