grove_digital_light
Embed:
(wiki syntax)
Show/hide line numbers
grove_digital_light.h
00001 00002 00003 00004 #ifndef __GROVE_DIGITAL_LIGHT_H__ 00005 #define __GROVE_DIGITAL_LIGHT_H__ 00006 00007 #include "suli2.h" 00008 00009 #define TSL2561_Address (0x29<<1) //device address 00010 00011 #define TSL2561_Control 0x80 00012 #define TSL2561_Timing 0x81 00013 #define TSL2561_Interrupt 0x86 00014 #define TSL2561_Channal0L 0x8C 00015 #define TSL2561_Channal0H 0x8D 00016 #define TSL2561_Channal1L 0x8E 00017 #define TSL2561_Channal1H 0x8F 00018 00019 #define LUX_SCALE 14 // scale by 2^14 00020 #define RATIO_SCALE 9 // scale ratio by 2^9 00021 #define CH_SCALE 10 // scale channel values by 2^10 00022 #define CHSCALE_TINT0 0x7517 // 322/11 * 2^CH_SCALE 00023 #define CHSCALE_TINT1 0x0fe7 // 322/81 * 2^CH_SCALE 00024 00025 #define K1T 0x0040 // 0.125 * 2^RATIO_SCALE 00026 #define B1T 0x01f2 // 0.0304 * 2^LUX_SCALE 00027 #define M1T 0x01be // 0.0272 * 2^LUX_SCALE 00028 #define K2T 0x0080 // 0.250 * 2^RATIO_SCA 00029 #define B2T 0x0214 // 0.0325 * 2^LUX_SCALE 00030 #define M2T 0x02d1 // 0.0440 * 2^LUX_SCALE 00031 #define K3T 0x00c0 // 0.375 * 2^RATIO_SCALE 00032 #define B3T 0x023f // 0.0351 * 2^LUX_SCALE 00033 #define M3T 0x037b // 0.0544 * 2^LUX_SCALE 00034 #define K4T 0x0100 // 0.50 * 2^RATIO_SCALE 00035 #define B4T 0x0270 // 0.0381 * 2^LUX_SCALE 00036 #define M4T 0x03fe // 0.0624 * 2^LUX_SCALE 00037 #define K5T 0x0138 // 0.61 * 2^RATIO_SCALE 00038 #define B5T 0x016f // 0.0224 * 2^LUX_SCALE 00039 #define M5T 0x01fc // 0.0310 * 2^LUX_SCALE 00040 #define K6T 0x019a // 0.80 * 2^RATIO_SCALE 00041 #define B6T 0x00d2 // 0.0128 * 2^LUX_SCALE 00042 #define M6T 0x00fb // 0.0153 * 2^LUX_SCALE 00043 #define K7T 0x029a // 1.3 * 2^RATIO_SCALE 00044 #define B7T 0x0018 // 0.00146 * 2^LUX_SCALE 00045 #define M7T 0x0012 // 0.00112 * 2^LUX_SCALE 00046 #define K8T 0x029a // 1.3 * 2^RATIO_SCALE 00047 #define B8T 0x0000 // 0.000 * 2^LUX_SCALE 00048 #define M8T 0x0000 // 0.000 * 2^LUX_SCALE 00049 00050 #define K1C 0x0043 // 0.130 * 2^RATIO_SCALE 00051 #define B1C 0x0204 // 0.0315 * 2^LUX_SCALE 00052 #define M1C 0x01ad // 0.0262 * 2^LUX_SCALE 00053 #define K2C 0x0085 // 0.260 * 2^RATIO_SCALE 00054 #define B2C 0x0228 // 0.0337 * 2^LUX_SCALE 00055 #define M2C 0x02c1 // 0.0430 * 2^LUX_SCALE 00056 #define K3C 0x00c8 // 0.390 * 2^RATIO_SCALE 00057 #define B3C 0x0253 // 0.0363 * 2^LUX_SCALE 00058 #define M3C 0x0363 // 0.0529 * 2^LUX_SCALE 00059 #define K4C 0x010a // 0.520 * 2^RATIO_SCALE 00060 #define B4C 0x0282 // 0.0392 * 2^LUX_SCALE 00061 #define M4C 0x03df // 0.0605 * 2^LUX_SCALE 00062 #define K5C 0x014d // 0.65 * 2^RATIO_SCALE 00063 #define B5C 0x0177 // 0.0229 * 2^LUX_SCALE 00064 #define M5C 0x01dd // 0.0291 * 2^LUX_SCALE 00065 #define K6C 0x019a // 0.80 * 2^RATIO_SCALE 00066 #define B6C 0x0101 // 0.0157 * 2^LUX_SCALE 00067 #define M6C 0x0127 // 0.0180 * 2^LUX_SCALE 00068 #define K7C 0x029a // 1.3 * 2^RATIO_SCALE 00069 #define B7C 0x0037 // 0.00338 * 2^LUX_SCALE 00070 #define M7C 0x002b // 0.00260 * 2^LUX_SCALE 00071 #define K8C 0x029a // 1.3 * 2^RATIO_SCALE 00072 #define B8C 0x0000 // 0.000 * 2^LUX_SCALE 00073 #define M8C 0x0000 // 0.000 * 2^LUX_SCALE 00074 00075 void grove_digital_light_init(I2C_T *i2c, int pinsda, int pinscl); 00076 bool grove_digital_light_write_setup(I2C_T *i2c); 00077 bool grove_digital_light_readvisiblelux(I2C_T *i2c, uint32_t *lux); 00078 00079 #endif
Generated on Tue Jul 12 2022 21:35:27 by 1.7.2