Bla bla blaaaaaaa...
Dependencies: mbed
Fork of Main_V1_1 by
Diff: TSL2561.h
- Revision:
- 3:534235b99bc6
- Parent:
- 2:17591031447b
diff -r 17591031447b -r 534235b99bc6 TSL2561.h --- a/TSL2561.h Wed Aug 23 09:27:52 2017 +0000 +++ b/TSL2561.h Mon Oct 02 12:47:09 2017 +0000 @@ -16,18 +16,18 @@ * http://www.adafruit.com/products/439 * http://akizukidenshi.com/catalog/g/gM-08219/ */ - + #ifndef TSL2561_H #define TSL2561_H - + #include "mbed.h" - + // Luminosity sensor, TSL2561 // Address b7=0,b6=1,b5=1,b4=1,b3=0,b2=0,b1=1, b0=R/W #define TSL2561_ADDRESS_GND (0x29 << 1) #define TSL2561_ADDRESS_FLOAT (0x39 << 1) #define TSL2561_ADDRESS_VDD (0x49 << 1) - + ////////////// Registers ////////////////////////////////// // Register definition #define TSL2561_CONTROL 0x00 @@ -41,7 +41,7 @@ #define TSL2561_DATA0HIGH 0x0D #define TSL2561_DATA1LOW 0x0E #define TSL2561_DATA1HIGH 0x0F - + ////////////// TIMING PARAMETER /////////////////////////// #define TIMING_GAIN_1 (0UL << 4) #define TIMING_GAIN_16 (1UL << 4) @@ -50,11 +50,11 @@ #define TIMING_TIME_402 (0x2) #define TIMING_TIME_MANU (0x3) #define TIMING_DEFAULT (TIMING_GAIN_1 + TIMING_TIME_402) - + ////////////// ID ///////////////////////////////////////// #define I_AM_TSL2561 0x50 #define REG_NO_MASK 0x0F - + ////////////// COMMAND //////////////////////////////////// #define CMD_CMDMODE (1UL << 7) #define CMD_CLEAR (1UL << 6) @@ -62,7 +62,7 @@ #define CMD_BLOCK (1UL << 4) #define CMD_SINGLE (CMD_CMDMODE) #define CMD_MULTI (CMD_CMDMODE + CMD_WORD) - + /** Interface for Luminosity sensor, TSL2561 * @code * #include "mbed.h" @@ -83,7 +83,7 @@ * } * @endcode */ - + class TSL2561 { public: @@ -92,63 +92,63 @@ */ TSL2561(PinName p_sda, PinName p_scl); TSL2561(PinName p_sda, PinName p_scl, uint8_t addr); - + /** Configure data pin (with other devices on I2C line) * @param I2C previous definition */ TSL2561(I2C& p_i2c); TSL2561(I2C& p_i2c, uint8_t addr); - + /** Get approximates the human eye response * in the commonly used Illuminance unit of Lux * @param none * @return Lux */ float lux(void); - + /** Set timing register * @param timing parameter * @return timing read data */ uint8_t set_timing_reg(uint8_t parameter); - + /** Read timing register * @param timing parameter * @return timing read data */ uint8_t read_timing_reg(void); - + /** Set I2C clock frequency * @param freq. * @return none */ void frequency(int hz); - + /** check Device ID number * @param none * @return TSL2561 = 1, others 0 */ uint8_t who_am_i(void); - + /** Read ID and Revision Number * @param none * @return ID + REVNO */ uint16_t read_ID(void); - + /** Power Up/Down * @param none * @return none */ void power_up(void); void power_down(void); - + protected: I2C *_i2c_p; I2C &_i2c; - + void init(void); - + private: uint8_t TSL2561_addr; uint8_t dt[4]; @@ -158,5 +158,5 @@ uint8_t id_number; double integ_time; }; - -#endif // TSL2561_H + +#endif // TSL2561_H \ No newline at end of file