Library which provides functions to control a TAOS TSL2561 Light-To-Digital Converter via I2C.
Fork of TSL2561_I2C by
TCS3472_I2C.h
- Committer:
- karlmaxwell67
- Date:
- 2014-03-20
- Revision:
- 3:6a89ac4a1979
- Parent:
- 2:38d5187a4e7b
- Child:
- 4:5d1f8d7d81ff
File content as of revision 3:6a89ac4a1979:
#ifndef TCS3472_I2C_H #define TCS3472_I2C_H #include "mbed.h" //Defines #define SLAVE_ADDRESS 0x29 #define ENABLE 0x00 #define ATIME 0x01 #define WTIME 0x03 #define AILTL 0x04 #define AIHTL 0x06 #define PERS 0x0C #define CONFIG 0x0D #define CONTROL 0x0F #define ID 0x12 #define STATUS 0x13 #define CDATA 0x14 #define RDATA 0x16 #define GDATA 0x18 #define BDATA 0x1A class TCS3472_I2C { public: TCS3472_I2C( PinName sda, PinName scl ); int getAllColours( int* readings ); int getClearData(); int getRedData(); int getGreenData(); int getBlueData(); int enablePower(); int disablePower(); int enableRGBC(); int disableRGBC(); int enablePowerAndRGBC(); int disablePowerAndRGBC(); int enableWait(); int disableWait(); int enableInterrupt(); int disableInterrupt(); int setWaitTime( const float wtime ); // wtime (in ms) should be in the range 2.4 - 7400ms. int setIntegrationTime( const float itime ); // itime (in ms) should be in the range 2.4 - 614.4ms. char readEnableRegister(); int readLowInterruptThreshold(); int readHighInterruptThreshold(); int setLowInterruptThreshold( const int threshold ); int setHighInterruptThreshold( const int threshold ); int readInterruptPersistence(); int setInterruptPersistence( const int persistence ); // persistence must be 0, 1, 2, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55 or 60 int clearInterrupt(); int readRGBCGain(); int setRGBCGain( const int gain ); // gain must be 1, 4, 16 or 60 char getDeviceID(); char readStatusRegister(); private: I2C i2c; int writeSingleRegister( char address, char data ); int writeMultipleRegisters( char address, char* data, int quantity ); char readSingleRegister( char address ); int readMultipleRegisters( char address, char* output, int quantity ); }; #endif